Skip to content

Commit

Permalink
feat: add line marker for layered
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Oct 11, 2022
1 parent d816fb4 commit a2a1fc7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 37 deletions.
13 changes: 6 additions & 7 deletions src/main/grammars/FeakinParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PsiElement>? {
if (element !is FkLayeredDeclaration) return null

return LineMarkerInfo(
element,
element.textRange,
FkIcons.FILE,
{ "Layered Line Marker" },
{ _: MouseEvent?, _: PsiElement? -> run {} },
GutterIconRenderer.Alignment.LEFT,
{ "Message Queue" }
)
}
}
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
implementationClass="com.feakin.intellij.linemarkers.FkImplMessageProvider"/>
<codeInsight.lineMarkerProvider language="Feakin"
implementationClass="com.feakin.intellij.linemarkers.FkImplMethodProvider"/>
<codeInsight.lineMarkerProvider language="Feakin"
implementationClass="com.feakin.intellij.linemarkers.FkLayeredLineMarkerContributor"/>

<runLineMarkerContributor language="Feakin"
implementationClass="com.feakin.intellij.linemarkers.FkImplLineMarkerContributor"/>
Expand Down
60 changes: 30 additions & 30 deletions src/test/testData/parser/ImplFlow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit a2a1fc7

Please sign in to comment.