generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lexer): add support for multiple front matter variables #16
Added support for multiple front matter variables in the lexer. This includes changes to the lexer's state management and whitespace handling. Also added a new test case to verify the functionality.
- Loading branch information
Showing
4 changed files
with
292 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
shirelang/src/test/testData/parser/MultipleFMVariable.shire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
variables: | ||
"extContext": /build\.gradle\.kts/ { cat | grep("org.springframework.boot:spring-boot-starter-jdbc") | print("This project use Spring Framework")} | ||
"testTemplate": /\(.*\).java/ { | ||
case "$1" { | ||
"Controller" { cat(".shire/templates/ControllerTest.java") } | ||
"Service" { cat(".shire/templates/ServiceTest.java") } | ||
default { cat(".shire/templates/DefaultTest.java") } | ||
} | ||
} | ||
"allController": { | ||
from { | ||
PsiClass clazz /* sample */ | ||
} | ||
where { | ||
clazz.getAnAnnotation() == "org.springframework.web.bind.annotation.RequestMapping" | ||
} | ||
select { | ||
clazz.id, clazz.name, "code" | ||
} | ||
} | ||
--- |
228 changes: 228 additions & 0 deletions
228
shirelang/src/test/testData/parser/MultipleFMVariable.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
ShireFile | ||
ShireFrontMatterHeaderImpl(FRONT_MATTER_HEADER) | ||
PsiElement(ShireTokenType.FRONTMATTER_START)('---') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
ShireFrontMatterEntriesImpl(FRONT_MATTER_ENTRIES) | ||
ShireFrontMatterEntryImpl(FRONT_MATTER_ENTRY) | ||
ShireFrontMatterKeyImpl(FRONT_MATTER_KEY) | ||
ShireFrontMatterIdImpl(FRONT_MATTER_ID) | ||
PsiElement(ShireTokenType.IDENTIFIER)('variables') | ||
PsiElement(ShireTokenType.COLON)(':') | ||
ShireFrontMatterValueImpl(FRONT_MATTER_VALUE) | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
ShireObjectKeyValueImpl(OBJECT_KEY_VALUE) | ||
PsiElement(ShireTokenType.INDENT)(' ') | ||
ShireKeyValueImpl(KEY_VALUE) | ||
ShireFrontMatterEntryImpl(FRONT_MATTER_ENTRY) | ||
ShireFrontMatterKeyImpl(FRONT_MATTER_KEY) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"extContext"') | ||
PsiElement(ShireTokenType.COLON)(':') | ||
PsiWhiteSpace(' ') | ||
ShirePatternActionImpl(PATTERN_ACTION) | ||
PatternElement(PATTERN) | ||
PsiElement(ShireTokenType.PATTERN_EXPR)('/build\.gradle\.kts/') | ||
PsiWhiteSpace(' ') | ||
ShireActionBlockImpl(ACTION_BLOCK) | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiWhiteSpace(' ') | ||
ShireActionBodyImpl(ACTION_BODY) | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireFuncCallImpl(FUNC_CALL) | ||
ShireFuncNameImpl(FUNC_NAME) | ||
PsiElement(ShireTokenType.IDENTIFIER)('cat') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.|)('|') | ||
PsiWhiteSpace(' ') | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireFuncCallImpl(FUNC_CALL) | ||
ShireFuncNameImpl(FUNC_NAME) | ||
PsiElement(ShireTokenType.IDENTIFIER)('grep') | ||
PsiElement(ShireTokenType.()('(') | ||
ShirePipelineArgsImpl(PIPELINE_ARGS) | ||
ShirePipelineArgImpl(PIPELINE_ARG) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"org.springframework.boot:spring-boot-starter-jdbc"') | ||
PsiElement(ShireTokenType.))(')') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.|)('|') | ||
PsiWhiteSpace(' ') | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireFuncCallImpl(FUNC_CALL) | ||
ShireFuncNameImpl(FUNC_NAME) | ||
PsiElement(ShireTokenType.IDENTIFIER)('print') | ||
PsiElement(ShireTokenType.()('(') | ||
ShirePipelineArgsImpl(PIPELINE_ARGS) | ||
ShirePipelineArgImpl(PIPELINE_ARG) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"This project use Spring Framework"') | ||
PsiElement(ShireTokenType.))(')') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireFrontMatterEntryImpl(FRONT_MATTER_ENTRY) | ||
ShireFrontMatterKeyImpl(FRONT_MATTER_KEY) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"testTemplate"') | ||
PsiElement(ShireTokenType.COLON)(':') | ||
PsiWhiteSpace(' ') | ||
ShirePatternActionImpl(PATTERN_ACTION) | ||
PatternElement(PATTERN) | ||
PsiElement(ShireTokenType.PATTERN_EXPR)('/\(.*\).java/') | ||
PsiWhiteSpace(' ') | ||
ShireActionBlockImpl(ACTION_BLOCK) | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireActionBodyImpl(ACTION_BODY) | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireCaseBodyImpl(CASE_BODY) | ||
PsiElement(ShireTokenType.case)('case') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"$1"') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireCasePatternActionImpl(CASE_PATTERN_ACTION) | ||
ShireCaseConditionImpl(CASE_CONDITION) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"Controller"') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiWhiteSpace(' ') | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireFuncCallImpl(FUNC_CALL) | ||
ShireFuncNameImpl(FUNC_NAME) | ||
PsiElement(ShireTokenType.IDENTIFIER)('cat') | ||
PsiElement(ShireTokenType.()('(') | ||
ShirePipelineArgsImpl(PIPELINE_ARGS) | ||
ShirePipelineArgImpl(PIPELINE_ARG) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('".shire/templates/ControllerTest.java"') | ||
PsiElement(ShireTokenType.))(')') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireCasePatternActionImpl(CASE_PATTERN_ACTION) | ||
ShireCaseConditionImpl(CASE_CONDITION) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"Service"') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiWhiteSpace(' ') | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireFuncCallImpl(FUNC_CALL) | ||
ShireFuncNameImpl(FUNC_NAME) | ||
PsiElement(ShireTokenType.IDENTIFIER)('cat') | ||
PsiElement(ShireTokenType.()('(') | ||
ShirePipelineArgsImpl(PIPELINE_ARGS) | ||
ShirePipelineArgImpl(PIPELINE_ARG) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('".shire/templates/ServiceTest.java"') | ||
PsiElement(ShireTokenType.))(')') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireCasePatternActionImpl(CASE_PATTERN_ACTION) | ||
ShireCaseConditionImpl(CASE_CONDITION) | ||
PsiElement(ShireTokenType.default)('default') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiWhiteSpace(' ') | ||
ShireActionExprImpl(ACTION_EXPR) | ||
ShireFuncCallImpl(FUNC_CALL) | ||
ShireFuncNameImpl(FUNC_NAME) | ||
PsiElement(ShireTokenType.IDENTIFIER)('cat') | ||
PsiElement(ShireTokenType.()('(') | ||
ShirePipelineArgsImpl(PIPELINE_ARGS) | ||
ShirePipelineArgImpl(PIPELINE_ARG) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('".shire/templates/DefaultTest.java"') | ||
PsiElement(ShireTokenType.))(')') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireFrontMatterEntryImpl(FRONT_MATTER_ENTRY) | ||
ShireFrontMatterKeyImpl(FRONT_MATTER_KEY) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"allController"') | ||
PsiElement(ShireTokenType.COLON)(':') | ||
PsiWhiteSpace(' ') | ||
ShireQueryStatementImpl(QUERY_STATEMENT) | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireFromClauseImpl(FROM_CLAUSE) | ||
PsiElement(ShireTokenType.from)('from') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShirePsiElementDeclImpl(PSI_ELEMENT_DECL) | ||
ShireVariableDeclImpl(VARIABLE_DECL) | ||
ShirePsiTypeImpl(PSI_TYPE) | ||
PsiElement(ShireTokenType.IDENTIFIER)('PsiClass') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.IDENTIFIER)('clazz') | ||
PsiWhiteSpace(' ') | ||
PsiComment(ShireTokenType.BLOCK_COMMENT)('/* sample */') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireWhereClauseImpl(WHERE_CLAUSE) | ||
PsiElement(ShireTokenType.where)('where') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireEqComparisonExprImpl(EQ_COMPARISON_EXPR) | ||
ShireCallExprImpl(CALL_EXPR) | ||
ShireRefExprImpl(REF_EXPR) | ||
ShireRefExprImpl(REF_EXPR) | ||
PsiElement(ShireTokenType.IDENTIFIER)('clazz') | ||
PsiElement(ShireTokenType..)('.') | ||
PsiElement(ShireTokenType.IDENTIFIER)('getAnAnnotation') | ||
PsiElement(ShireTokenType.()('(') | ||
PsiElement(ShireTokenType.))(')') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.==)('==') | ||
PsiWhiteSpace(' ') | ||
ShireLiteralExprImpl(LITERAL_EXPR) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"org.springframework.web.bind.annotation.RequestMapping"') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireSelectClauseImpl(SELECT_CLAUSE) | ||
PsiElement(ShireTokenType.select)('select') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.{)('{') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
ShireRefExprImpl(REF_EXPR) | ||
ShireRefExprImpl(REF_EXPR) | ||
PsiElement(ShireTokenType.IDENTIFIER)('clazz') | ||
PsiElement(ShireTokenType..)('.') | ||
PsiElement(ShireTokenType.IDENTIFIER)('id') | ||
PsiElement(ShireTokenType.,)(',') | ||
PsiWhiteSpace(' ') | ||
ShireRefExprImpl(REF_EXPR) | ||
ShireRefExprImpl(REF_EXPR) | ||
PsiElement(ShireTokenType.IDENTIFIER)('clazz') | ||
PsiElement(ShireTokenType..)('.') | ||
PsiElement(ShireTokenType.IDENTIFIER)('name') | ||
PsiElement(ShireTokenType.,)(',') | ||
PsiWhiteSpace(' ') | ||
ShireLiteralExprImpl(LITERAL_EXPR) | ||
PsiElement(ShireTokenType.QUOTE_STRING)('"code"') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiWhiteSpace(' ') | ||
PsiElement(ShireTokenType.})('}') | ||
PsiElement(ShireTokenType.NEWLINE)('\n') | ||
PsiElement(ShireTokenType.FRONTMATTER_END)('---') |