Skip to content

Commit

Permalink
#437 | Added Type System related code completion and reference supp…
Browse files Browse the repository at this point in the history
…ort for `Type` column
  • Loading branch information
mlytvyn authored May 26, 2023
1 parent 00328ab commit fbc10ea
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 101 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;

public interface ImpexUserRightsEnd extends ImpexUserRightsAwarePsiElement {
public interface ImpexUserRightsEnd extends PsiElement {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImpexUserRightsHeaderParameter> getUserRightsHeaderParameterList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;

public interface ImpexUserRightsStart extends ImpexUserRightsAwarePsiElement {
public interface ImpexUserRightsStart extends PsiElement {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 8 additions & 12 deletions gen/com/intellij/idea/plugin/hybris/impex/psi/ImpexVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions src/com/intellij/idea/plugin/hybris/impex/Impex.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/com/intellij/idea/plugin/hybris/impex/psi/ImpexPsiUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -167,7 +167,7 @@ fun getHeaderParameter(element: ImpexUserRightsValue): ImpexUserRightsHeaderPara
parent
.columnNumber
?.let {
element.getUserRights()
getUserRights(element)
?.userRightsHeaderLine
?.getHeaderParameter(it)

Expand All @@ -188,6 +188,9 @@ fun getColumnNumber(element: ImpexUserRightsHeaderParameter): Int? = element

fun getValueGroups(element: ImpexUserRightsHeaderParameter): Collection<ImpexUserRightsValueGroup> {
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<ImpexUserRights>()

This file was deleted.

This file was deleted.

Loading

0 comments on commit fbc10ea

Please sign in to comment.