From fbc10ea08b4f5722e15a3399c818b446f309f9dc Mon Sep 17 00:00:00 2001 From: Mykhailo Lytvyn Date: Fri, 26 May 2023 11:49:47 +0200 Subject: [PATCH] #437 | Added `Type System` related code completion and reference support for `Type` column --- CHANGELOG.md | 1 + .../hybris/impex/psi/ImpexUserRightsEnd.java | 2 +- .../psi/ImpexUserRightsFirstValueGroup.java | 2 +- .../impex/psi/ImpexUserRightsHeaderLine.java | 2 +- .../psi/ImpexUserRightsHeaderParameter.java | 2 +- .../impex/psi/ImpexUserRightsStart.java | 2 +- .../impex/psi/ImpexUserRightsValue.java | 2 +- .../impex/psi/ImpexUserRightsValueGroup.java | 2 +- .../impex/psi/ImpexUserRightsValueLine.java | 2 +- .../plugin/hybris/impex/psi/ImpexVisitor.java | 20 +++----- .../psi/impl/ImpexUserRightsEndImpl.java | 3 +- .../ImpexUserRightsFirstValueGroupImpl.java | 3 +- .../impl/ImpexUserRightsHeaderLineImpl.java | 3 +- .../ImpexUserRightsHeaderParameterImpl.java | 3 +- .../psi/impl/ImpexUserRightsStartImpl.java | 3 +- .../impl/ImpexUserRightsValueGroupImpl.java | 3 +- .../psi/impl/ImpexUserRightsValueImpl.java | 2 +- .../impl/ImpexUserRightsValueLineImpl.java | 3 +- .../idea/plugin/hybris/impex/Impex.bnf | 9 ++-- .../plugin/hybris/impex/psi/ImpexPsiUtil.kt | 11 ++-- .../psi/ImpexUserRightsAwarePsiElement.kt | 26 ---------- .../ImpexUserRightsAwarePsiElementImpl.kt | 36 ------------- .../psi/impl/ImpexUserRightsValueMixin.kt | 51 +++++++++++++++++++ .../psi/references/ImpexTSItemReference.kt | 11 +++- 24 files changed, 103 insertions(+), 101 deletions(-) delete mode 100644 src/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsAwarePsiElement.kt delete mode 100644 src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsAwarePsiElementImpl.kt create mode 100644 src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueMixin.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d75e4a6f..ad84481a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - SAP Help Portal - [User Rights](https://help.sap.com/docs/SAP_COMMERCE/50c996852b32456c96d3161a95544cdb/e472718cafe840c39fbb5ceb00002e52.html?locale=en-US) - Re-implemented from the scratch Lexer and Parser for `User Rights` block [#435](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/435) - Brand-new formatting model for `User Rights` block [#436](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/436) +- Added `Type System` related code completion and reference support for `Type` column [#437](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/437) ### `FlexibleSearch` enhancements - Added possibility to copy FlexibleSearch from the Java 15 text block `"""SELECT * FROM {Product}"""` [#428](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/428) diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsEnd.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsEnd.java index 2842d8d44..7e8a9e31a 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsEnd.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsEnd.java @@ -25,6 +25,6 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsEnd extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsEnd extends PsiElement { } diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsFirstValueGroup.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsFirstValueGroup.java index a9ec7538b..30cec05c8 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsFirstValueGroup.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsFirstValueGroup.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsFirstValueGroup extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsFirstValueGroup extends PsiElement { @NotNull ImpexUserRightsValue getUserRightsValue(); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderLine.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderLine.java index 4344a139a..a68752366 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderLine.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderLine.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsHeaderLine extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsHeaderLine extends PsiElement { @NotNull List getUserRightsHeaderParameterList(); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderParameter.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderParameter.java index 29e36fa83..7154fda07 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderParameter.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsHeaderParameter.java @@ -26,7 +26,7 @@ import com.intellij.psi.PsiElement; import java.util.Collection; -public interface ImpexUserRightsHeaderParameter extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsHeaderParameter extends PsiElement { @Nullable ImpexUserRightsHeaderLine getHeaderLine(); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsStart.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsStart.java index b7ced4fb9..c542a2b93 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsStart.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsStart.java @@ -25,6 +25,6 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsStart extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsStart extends PsiElement { } diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValue.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValue.java index f4f12bb95..aa87be3ed 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValue.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValue.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsValue extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsValue extends PsiElement { @Nullable ImpexUserRightsHeaderParameter getHeaderParameter(); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueGroup.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueGroup.java index 10926d37a..6ed7538c0 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueGroup.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueGroup.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsValueGroup extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsValueGroup extends PsiElement { @Nullable ImpexUserRightsValue getUserRightsValue(); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueLine.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueLine.java index f0b87c4d8..bc4c568cc 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueLine.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsValueLine.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -public interface ImpexUserRightsValueLine extends ImpexUserRightsAwarePsiElement { +public interface ImpexUserRightsValueLine extends PsiElement { @Nullable ImpexUserRightsFirstValueGroup getUserRightsFirstValueGroup(); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexVisitor.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexVisitor.java index a3477f770..0dcf00b40 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexVisitor.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexVisitor.java @@ -120,35 +120,35 @@ public void visitUserRights(@NotNull ImpexUserRights o) { } public void visitUserRightsEnd(@NotNull ImpexUserRightsEnd o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsFirstValueGroup(@NotNull ImpexUserRightsFirstValueGroup o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsHeaderLine(@NotNull ImpexUserRightsHeaderLine o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsHeaderParameter(@NotNull ImpexUserRightsHeaderParameter o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsStart(@NotNull ImpexUserRightsStart o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsValue(@NotNull ImpexUserRightsValue o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsValueGroup(@NotNull ImpexUserRightsValueGroup o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitUserRightsValueLine(@NotNull ImpexUserRightsValueLine o) { - visitUserRightsAwarePsiElement(o); + visitPsiElement(o); } public void visitValue(@NotNull ImpexValue o) { @@ -167,10 +167,6 @@ public void visitPsiNamedElement(@NotNull ImpexPsiNamedElement o) { visitPsiElement(o); } - public void visitUserRightsAwarePsiElement(@NotNull ImpexUserRightsAwarePsiElement o) { - visitPsiElement(o); - } - public void visitPsiElement(@NotNull PsiElement o) { visitElement(o); } diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsEndImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsEndImpl.java index 9e175d380..1306ffd63 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsEndImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsEndImpl.java @@ -28,9 +28,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsEndImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsEnd { +public class ImpexUserRightsEndImpl extends ASTWrapperPsiElement implements ImpexUserRightsEnd { public ImpexUserRightsEndImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsFirstValueGroupImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsFirstValueGroupImpl.java index 386e94bd8..b4c1fc2b2 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsFirstValueGroupImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsFirstValueGroupImpl.java @@ -28,9 +28,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsFirstValueGroupImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsFirstValueGroup { +public class ImpexUserRightsFirstValueGroupImpl extends ASTWrapperPsiElement implements ImpexUserRightsFirstValueGroup { public ImpexUserRightsFirstValueGroupImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderLineImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderLineImpl.java index f818f8f34..6c567c5ad 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderLineImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderLineImpl.java @@ -28,9 +28,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsHeaderLineImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsHeaderLine { +public class ImpexUserRightsHeaderLineImpl extends ASTWrapperPsiElement implements ImpexUserRightsHeaderLine { public ImpexUserRightsHeaderLineImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderParameterImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderParameterImpl.java index 45cbc1d0b..22dd8e29b 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderParameterImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsHeaderParameterImpl.java @@ -28,10 +28,11 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; import java.util.Collection; -public class ImpexUserRightsHeaderParameterImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsHeaderParameter { +public class ImpexUserRightsHeaderParameterImpl extends ASTWrapperPsiElement implements ImpexUserRightsHeaderParameter { public ImpexUserRightsHeaderParameterImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsStartImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsStartImpl.java index 9b74b4d7a..9d48bbcc7 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsStartImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsStartImpl.java @@ -28,9 +28,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsStartImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsStart { +public class ImpexUserRightsStartImpl extends ASTWrapperPsiElement implements ImpexUserRightsStart { public ImpexUserRightsStartImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueGroupImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueGroupImpl.java index bd1bc9d5b..59bcd1f61 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueGroupImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueGroupImpl.java @@ -28,9 +28,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsValueGroupImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsValueGroup { +public class ImpexUserRightsValueGroupImpl extends ASTWrapperPsiElement implements ImpexUserRightsValueGroup { public ImpexUserRightsValueGroupImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueImpl.java index 0c290d68a..7cea18410 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueImpl.java @@ -30,7 +30,7 @@ import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsValueImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsValue { +public class ImpexUserRightsValueImpl extends ImpexUserRightsValueMixin implements ImpexUserRightsValue { public ImpexUserRightsValueImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueLineImpl.java b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueLineImpl.java index 88a4c255e..0788f3918 100644 --- a/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueLineImpl.java +++ b/gen/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueLineImpl.java @@ -28,9 +28,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.idea.plugin.hybris.impex.psi.*; -public class ImpexUserRightsValueLineImpl extends ImpexUserRightsAwarePsiElementImpl implements ImpexUserRightsValueLine { +public class ImpexUserRightsValueLineImpl extends ASTWrapperPsiElement implements ImpexUserRightsValueLine { public ImpexUserRightsValueLineImpl(@NotNull ASTNode node) { super(node); diff --git a/src/com/intellij/idea/plugin/hybris/impex/Impex.bnf b/src/com/intellij/idea/plugin/hybris/impex/Impex.bnf index c580a92a9..fd7542387 100644 --- a/src/com/intellij/idea/plugin/hybris/impex/Impex.bnf +++ b/src/com/intellij/idea/plugin/hybris/impex/Impex.bnf @@ -33,8 +33,6 @@ tokenTypeClass="com.intellij.idea.plugin.hybris.impex.psi.ImpexTokenType" classHeader="generatedFilesHeader.txt" - implements("user_rights_.*")="com.intellij.idea.plugin.hybris.impex.psi.ImpexUserRightsAwarePsiElement" - extends("user_rights_.*")="com.intellij.idea.plugin.hybris.impex.psi.impl.ImpexUserRightsAwarePsiElementImpl" generate=[java='17'] } @@ -124,21 +122,22 @@ user_rights_value_line ::= user_rights_first_value_group? user_rights_value_grou } user_rights_first_value_group ::= user_rights_value { - methods=[getValueLine] recoverWhile=user_rights_value_group_recover + methods=[getValueLine] } user_rights_value_group ::= FIELD_VALUE_SEPARATOR user_rights_value? { pin=1 - methods=[getValueLine getColumnNumber getHeaderParameter] recoverWhile=user_rights_value_group_recover + methods=[getValueLine getColumnNumber getHeaderParameter] } user_rights_value ::= PERMISSION_DENIED | PERMISSION_ALLOWED | user_rights_type_attribute | FIELD_VALUE (COMMA FIELD_VALUE)* { - methods=[getHeaderParameter] + mixin="com.intellij.idea.plugin.hybris.impex.psi.impl.ImpexUserRightsValueMixin" recoverWhile=user_rights_value_dec_recover + methods=[getHeaderParameter] } private user_rights_type_attribute ::= FIELD_VALUE DOT FIELD_VALUE { pin=2 diff --git a/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexPsiUtil.kt b/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexPsiUtil.kt index be812e428..f6f1a48e5 100644 --- a/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexPsiUtil.kt +++ b/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexPsiUtil.kt @@ -151,14 +151,14 @@ fun getColumnNumber(element: ImpexUserRightsValueGroup): Int? = element fun getHeaderParameter(element: ImpexUserRightsValueGroup): ImpexUserRightsHeaderParameter? = element .columnNumber ?.let { - element.getUserRights() + getUserRights(element) ?.userRightsHeaderLine ?.getHeaderParameter(it) } fun getHeaderParameter(element: ImpexUserRightsValue): ImpexUserRightsHeaderParameter? = when (val parent = element.parent) { is ImpexUserRightsFirstValueGroup -> { - parent.getUserRights() + getUserRights(parent) ?.userRightsHeaderLine ?.getHeaderParameter(0) } @@ -167,7 +167,7 @@ fun getHeaderParameter(element: ImpexUserRightsValue): ImpexUserRightsHeaderPara parent .columnNumber ?.let { - element.getUserRights() + getUserRights(element) ?.userRightsHeaderLine ?.getHeaderParameter(it) @@ -188,6 +188,9 @@ fun getColumnNumber(element: ImpexUserRightsHeaderParameter): Int? = element fun getValueGroups(element: ImpexUserRightsHeaderParameter): Collection { val columnNumber = element.columnNumber ?: return emptyList() - val userRights = element.getUserRights() ?: return emptyList() + val userRights = getUserRights(element) ?: return emptyList() return userRights.getValueGroups(columnNumber) } + +fun getUserRights(element: PsiElement): ImpexUserRights? = element + .parentOfType() diff --git a/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsAwarePsiElement.kt b/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsAwarePsiElement.kt deleted file mode 100644 index 095e42f38..000000000 --- a/src/com/intellij/idea/plugin/hybris/impex/psi/ImpexUserRightsAwarePsiElement.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. - * Copyright (C) 2019 EPAM Systems - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.intellij.idea.plugin.hybris.impex.psi - -import com.intellij.psi.PsiElement - -interface ImpexUserRightsAwarePsiElement : PsiElement { - - fun getUserRights(): ImpexUserRights? -} \ No newline at end of file diff --git a/src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsAwarePsiElementImpl.kt b/src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsAwarePsiElementImpl.kt deleted file mode 100644 index 7d7a4c2b7..000000000 --- a/src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsAwarePsiElementImpl.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. - * Copyright (C) 2019 EPAM Systems - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.intellij.idea.plugin.hybris.impex.psi.impl - -import com.intellij.extapi.psi.ASTWrapperPsiElement -import com.intellij.idea.plugin.hybris.impex.psi.ImpexUserRights -import com.intellij.idea.plugin.hybris.impex.psi.ImpexUserRightsAwarePsiElement -import com.intellij.lang.ASTNode -import com.intellij.psi.util.parentOfType -import java.io.Serial - -abstract class ImpexUserRightsAwarePsiElementImpl(node: ASTNode) : ASTWrapperPsiElement(node), ImpexUserRightsAwarePsiElement { - - override fun getUserRights() = parentOfType() - - companion object { - @Serial - private const val serialVersionUID: Long = 8027432712695405735L - } -} \ No newline at end of file diff --git a/src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueMixin.kt b/src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueMixin.kt new file mode 100644 index 000000000..038673b50 --- /dev/null +++ b/src/com/intellij/idea/plugin/hybris/impex/psi/impl/ImpexUserRightsValueMixin.kt @@ -0,0 +1,51 @@ +/* + * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. + * Copyright (C) 2019 EPAM Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.intellij.idea.plugin.hybris.impex.psi.impl + +import com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes +import com.intellij.idea.plugin.hybris.impex.psi.ImpexUserRightsValue +import com.intellij.idea.plugin.hybris.impex.psi.references.ImpexTSItemReference +import com.intellij.idea.plugin.hybris.psi.impl.ASTWrapperReferencePsiElement +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReferenceBase +import com.intellij.psi.util.elementType +import java.io.Serial + +abstract class ImpexUserRightsValueMixin(astNode: ASTNode) : ASTWrapperReferencePsiElement(astNode), ImpexUserRightsValue { + + override fun createReference(): PsiReferenceBase? { + val headerParameter = this.headerParameter ?: return null + + return when (headerParameter.firstChild.elementType) { + ImpexTypes.TYPE -> ImpexTSItemReference(this) +// ImpexTypes.TARGET -> with(PsiTreeUtilExt.getLeafsOfElementType(it, ImpexTypes.FIELD_VALUE)) { +// getOrNull(0)?.let { highlight(ImpexTypes.HEADER_TYPE, holder, it) } +// getOrNull(1)?.let { highlight(ImpexTypes.HEADER_PARAMETER_NAME, holder, it) } +// } + else -> null + } + } + + companion object { + @Serial + private const val serialVersionUID: Long = -1657911985932608306L + } + +} diff --git a/src/com/intellij/idea/plugin/hybris/impex/psi/references/ImpexTSItemReference.kt b/src/com/intellij/idea/plugin/hybris/impex/psi/references/ImpexTSItemReference.kt index 56aa270d4..5df942873 100644 --- a/src/com/intellij/idea/plugin/hybris/impex/psi/references/ImpexTSItemReference.kt +++ b/src/com/intellij/idea/plugin/hybris/impex/psi/references/ImpexTSItemReference.kt @@ -17,22 +17,29 @@ */ package com.intellij.idea.plugin.hybris.impex.psi.references -import com.intellij.idea.plugin.hybris.impex.psi.ImpexHeaderTypeName +import com.intellij.codeInsight.lookup.LookupElementBuilder import com.intellij.idea.plugin.hybris.psi.reference.TSReferenceBase import com.intellij.idea.plugin.hybris.psi.util.PsiUtils +import com.intellij.idea.plugin.hybris.system.type.codeInsight.completion.TSCompletionService import com.intellij.idea.plugin.hybris.system.type.meta.TSMetaModelAccess +import com.intellij.idea.plugin.hybris.system.type.meta.model.TSMetaType import com.intellij.idea.plugin.hybris.system.type.psi.reference.result.EnumResolveResult import com.intellij.idea.plugin.hybris.system.type.psi.reference.result.ItemResolveResult import com.intellij.idea.plugin.hybris.system.type.psi.reference.result.RelationResolveResult import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.util.Key +import com.intellij.psi.PsiElement import com.intellij.psi.ResolveResult import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.ParameterizedCachedValue import com.intellij.psi.util.ParameterizedCachedValueProvider -class ImpexTSItemReference(owner: ImpexHeaderTypeName) : TSReferenceBase(owner) { +class ImpexTSItemReference(owner: PsiElement) : TSReferenceBase(owner) { + + override fun getVariants(): Array = TSCompletionService.getInstance(element.project) + .getCompletions(TSMetaType.META_ITEM, TSMetaType.META_ENUM, TSMetaType.META_RELATION) + .toTypedArray() override fun multiResolve(incompleteCode: Boolean): Array { val indicator = ProgressManager.getInstance().progressIndicator