Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ImpEx unique value inspection to support multi-line \ separator #681

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
### Fixes
- Fixed preview of the inlay hint for Dynamic attributes [#668](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/668)
- Enable custom action toolbars only for SAP Commerce projects [#669](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/669)
- Fixed `ImpEx` unique value inspection to support multi-line ` \ ` separator [#681](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/681)

### Other
- Added VCS issue navigation for IntelliJ [#665](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/665)
Expand Down
10 changes: 5 additions & 5 deletions gen/com/intellij/idea/plugin/hybris/impex/ImpexParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ static boolean value_dec(PsiBuilder b, int l) {
}

/* ********************************************************** */
// FIELD_VALUE_SEPARATOR MULTILINE_SEPARATOR? value?
// FIELD_VALUE_SEPARATOR value? MULTILINE_SEPARATOR?
public static boolean value_group(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "value_group")) return false;
if (!nextTokenIs(b, FIELD_VALUE_SEPARATOR)) return false;
Expand All @@ -1617,17 +1617,17 @@ public static boolean value_group(PsiBuilder b, int l) {
return r || p;
}

// MULTILINE_SEPARATOR?
// value?
private static boolean value_group_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "value_group_1")) return false;
consumeToken(b, MULTILINE_SEPARATOR);
value(b, l + 1);
return true;
}

// value?
// MULTILINE_SEPARATOR?
private static boolean value_group_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "value_group_2")) return false;
value(b, l + 1);
consumeToken(b, MULTILINE_SEPARATOR);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.idea.plugin.hybris.impex.inspection.analyzer.*
import com.intellij.idea.plugin.hybris.impex.psi.ImpexHeaderLine
import com.intellij.idea.plugin.hybris.impex.psi.ImpexValueGroup
import com.intellij.idea.plugin.hybris.impex.utils.ImpexPsiUtils
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.PsiFile
import com.intellij.psi.util.PsiTreeUtil
Expand All @@ -51,12 +51,13 @@ private class NoUniqueValueVisitor(private val problemsHolder: ProblemsHolder) :

val keyAttrsGroupedByName = fullParametersList.filter { keyAttrPredicate(it) }.groupBy { it.anyHeaderParameterName.text }

val dataMap = mutableMapOf<String, List<PsiElement>>()
keyAttrsGroupedByName.forEach { (name, attrs) ->
dataMap[name] = attrs
.flatMap { ImpexPsiUtils.getColumnForHeader(it) }
.map { it.lastChild }
}
val dataMap =keyAttrsGroupedByName.entries
.associate { (name, attrs) ->
name to attrs
.flatMap { ImpexPsiUtils.getColumnForHeader(it) }
.filterIsInstance<ImpexValueGroup>()
.mapNotNull { it.value }
}

if (distinctCommonAttrsNames.isEmpty()) {
val attrsNames = fullParametersList
Expand Down
2 changes: 1 addition & 1 deletion src/com/intellij/idea/plugin/hybris/impex/Impex.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ value_line ::= (sub_type_name value_group*) | (value_group+) {
methods=[getHeaderLine getValueGroup]
}

value_group ::= FIELD_VALUE_SEPARATOR MULTILINE_SEPARATOR? value?
value_group ::= FIELD_VALUE_SEPARATOR value? MULTILINE_SEPARATOR?
{
pin=1
methods=[getFullHeaderParameter getColumnNumber getValueLine computeValue]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fun keyAttrPredicate(param: ImpexFullHeaderParameter) = param.modifiersList

fun intersection(a: ByteArray, b: ByteArray) = a.filterIndexed { index, i -> b[index] != 0.toByte() && b[index] == i }.isNotEmpty()

fun createDataTable(dataMap: MutableMap<String, List<PsiElement>>, distinctCommonAttrsNames: List<String>, notKeyAttrsList: List<ImpexFullHeaderParameter>): DataTable {
fun createDataTable(dataMap: Map<String, List<PsiElement>>, distinctCommonAttrsNames: List<String>, notKeyAttrsList: List<ImpexFullHeaderParameter>): DataTable {
val countKeyAttrs = dataMap.entries.size
val countRows = dataMap.values.first().size

Expand All @@ -32,7 +32,7 @@ fun createDataTable(dataMap: MutableMap<String, List<PsiElement>>, distinctCommo
return DataTable(keyRows, distinctCommonAttrsNames, notKeyAttrsList)
}

fun createRows(countRows: Int, countKeyAttrs: Int, dataMap: MutableMap<String, List<PsiElement>>): MutableList<Key> {
fun createRows(countRows: Int, countKeyAttrs: Int, dataMap: Map<String, List<PsiElement>>): MutableList<Key> {
val keyRows = mutableListOf<Key>()
for (i in 0 until countRows) {
val k = mutableListOf<PsiElement>()
Expand Down