diff --git a/src/main/grammars/FeakinParser.bnf b/src/main/grammars/FeakinParser.bnf index e7a79ae..0e5a896 100644 --- a/src/main/grammars/FeakinParser.bnf +++ b/src/main/grammars/FeakinParser.bnf @@ -200,10 +200,13 @@ flowDeclaration ::= FLOW_KEYWORD flowBody flowBody ::= LBRACE stepDeclaration* RBRACE -private stepDeclaration ::= viaMethodDeclaration - | viaMessageDeclaration +private stepDeclaration ::= VIA_KEYWORD objectName ((DOUBLE_COLON | DOT) viaMethodName parameters?)? (viaMethodDeclaration | viaMessageDeclaration) -viaMethodDeclaration ::= VIA_KEYWORD objectName ((DOUBLE_COLON | DOT) viaMethodName parameters?)? (RECEIVE_KEYWORD receiveObject)? SEMICOLON? +viaMethodDeclaration ::= RECEIVE_KEYWORD receiveObject SEMICOLON? + +viaMessageDeclaration ::= SEND_KEYWORD passObject TO_KEYWORD topic SEMICOLON? + +private passObject ::= objectName parameters ::= LPAREN (parameter (COMMA parameter)*)? RPAREN @@ -213,10 +216,6 @@ paramType ::= IDENTIFIER ('<' IDENTIFIER '>')?; private receiveObject ::= objectName (COLON viaMethodName)? -viaMessageDeclaration ::= VIA_KEYWORD objectName ((DOUBLE_COLON | DOT) viaMethodName parameters?)? SEND_KEYWORD passObject TO_KEYWORD topic SEMICOLON? - -private passObject ::= objectName - layeredDeclaration ::= LAYERED_KEYWORD IDENTIFIER layeredBody layeredBody ::= LBRACE dependency? layerDeclaration* RBRACE diff --git a/src/main/kotlin/com/feakin/intellij/linemarkers/FkLayeredLineMarkerContributor.kt b/src/main/kotlin/com/feakin/intellij/linemarkers/FkLayeredLineMarkerContributor.kt new file mode 100644 index 0000000..62c4140 --- /dev/null +++ b/src/main/kotlin/com/feakin/intellij/linemarkers/FkLayeredLineMarkerContributor.kt @@ -0,0 +1,25 @@ +package com.feakin.intellij.linemarkers + +import com.feakin.intellij.FkIcons +import com.feakin.intellij.psi.FkLayeredDeclaration +import com.intellij.codeInsight.daemon.LineMarkerInfo +import com.intellij.codeInsight.daemon.LineMarkerProvider +import com.intellij.openapi.editor.markup.GutterIconRenderer +import com.intellij.psi.PsiElement +import java.awt.event.MouseEvent + +class FkLayeredLineMarkerContributor : LineMarkerProvider { + override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo? { + if (element !is FkLayeredDeclaration) return null + + return LineMarkerInfo( + element, + element.textRange, + FkIcons.FILE, + { "Layered Line Marker" }, + { _: MouseEvent?, _: PsiElement? -> run {} }, + GutterIconRenderer.Alignment.LEFT, + { "Message Queue" } + ) + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0801e19..e18c4bc 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -57,6 +57,8 @@ implementationClass="com.feakin.intellij.linemarkers.FkImplMessageProvider"/> + diff --git a/src/test/testData/parser/ImplFlow.txt b/src/test/testData/parser/ImplFlow.txt index b7c5814..bce163c 100644 --- a/src/test/testData/parser/ImplFlow.txt +++ b/src/test/testData/parser/ImplFlow.txt @@ -53,15 +53,15 @@ Feakin PsiWhiteSpace('\n ') PsiComment(FeakinTokenType.COMMENT)('//') PsiWhiteSpace('\n ') + PsiElement(FeakinTokenType.via)('via') + PsiWhiteSpace(' ') + FkObjectNameImpl(OBJECT_NAME) + PsiElement(FeakinTokenType.IDENTIFIER)('UserRepository') + PsiElement(FeakinTokenType.::)('::') + FkViaMethodNameImpl(VIA_METHOD_NAME) + PsiElement(FeakinTokenType.IDENTIFIER)('getUserById') + PsiWhiteSpace(' ') FkViaMethodDeclarationImpl(VIA_METHOD_DECLARATION) - PsiElement(FeakinTokenType.via)('via') - PsiWhiteSpace(' ') - FkObjectNameImpl(OBJECT_NAME) - PsiElement(FeakinTokenType.IDENTIFIER)('UserRepository') - PsiElement(FeakinTokenType.::)('::') - FkViaMethodNameImpl(VIA_METHOD_NAME) - PsiElement(FeakinTokenType.IDENTIFIER)('getUserById') - PsiWhiteSpace(' ') PsiElement(FeakinTokenType.receive)('receive') PsiWhiteSpace(' ') FkObjectNameImpl(OBJECT_NAME) @@ -73,24 +73,24 @@ Feakin PsiWhiteSpace('\n ') PsiComment(FeakinTokenType.COMMENT)('//') PsiWhiteSpace('\n ') + PsiElement(FeakinTokenType.via)('via') + PsiWhiteSpace(' ') + FkObjectNameImpl(OBJECT_NAME) + PsiElement(FeakinTokenType.IDENTIFIER)('UserRepository') + PsiElement(FeakinTokenType.::)('::') + FkViaMethodNameImpl(VIA_METHOD_NAME) + PsiElement(FeakinTokenType.IDENTIFIER)('save') + FkParametersImpl(PARAMETERS) + PsiElement(FeakinTokenType.()('(') + FkParameterImpl(PARAMETER) + PsiElement(FeakinTokenType.IDENTIFIER)('user') + PsiElement(FeakinTokenType.:)(':') + PsiWhiteSpace(' ') + FkParamTypeImpl(PARAM_TYPE) + PsiElement(FeakinTokenType.IDENTIFIER)('User') + PsiElement(FeakinTokenType.))(')') + PsiWhiteSpace(' ') FkViaMethodDeclarationImpl(VIA_METHOD_DECLARATION) - PsiElement(FeakinTokenType.via)('via') - PsiWhiteSpace(' ') - FkObjectNameImpl(OBJECT_NAME) - PsiElement(FeakinTokenType.IDENTIFIER)('UserRepository') - PsiElement(FeakinTokenType.::)('::') - FkViaMethodNameImpl(VIA_METHOD_NAME) - PsiElement(FeakinTokenType.IDENTIFIER)('save') - FkParametersImpl(PARAMETERS) - PsiElement(FeakinTokenType.()('(') - FkParameterImpl(PARAMETER) - PsiElement(FeakinTokenType.IDENTIFIER)('user') - PsiElement(FeakinTokenType.:)(':') - PsiWhiteSpace(' ') - FkParamTypeImpl(PARAM_TYPE) - PsiElement(FeakinTokenType.IDENTIFIER)('User') - PsiElement(FeakinTokenType.))(')') - PsiWhiteSpace(' ') PsiElement(FeakinTokenType.receive)('receive') PsiWhiteSpace(' ') FkObjectNameImpl(OBJECT_NAME) @@ -103,12 +103,12 @@ Feakin PsiWhiteSpace('\n ') PsiComment(FeakinTokenType.COMMENT)('//') PsiWhiteSpace('\n ') + PsiElement(FeakinTokenType.via)('via') + PsiWhiteSpace(' ') + FkObjectNameImpl(OBJECT_NAME) + PsiElement(FeakinTokenType.IDENTIFIER)('MessageQueue') + PsiWhiteSpace(' ') FkViaMessageDeclarationImpl(VIA_MESSAGE_DECLARATION) - PsiElement(FeakinTokenType.via)('via') - PsiWhiteSpace(' ') - FkObjectNameImpl(OBJECT_NAME) - PsiElement(FeakinTokenType.IDENTIFIER)('MessageQueue') - PsiWhiteSpace(' ') PsiElement(FeakinTokenType.send)('send') PsiWhiteSpace(' ') FkObjectNameImpl(OBJECT_NAME)