generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devin-lang): improve code fence parsing to support embedded lang…
…uages #101 The commit introduces a new feature to the DevInLexer.flex file, enhancing the code fence parsing functionality to recognize and handle embedded languages within code blocks. This change enables the lexer to correctly interpret content inside code fences, which is crucial for the correct parsing and processing of code samples in the DevInLang language. The modification includes the addition of a new state, `CODE_BLOCK`, to distinguish between normal text segments and code blocks. The lexer now checks for the start of a code block with a leading `@`, `/`, or `$` character, and only transitions to the corresponding block type (e.g., `AGENT_BLOCK`, `COMMAND_BLOCK`, or `VARIABLE_BLOCK`) if the current input is not within a code block. Furthermore, a new test case is added to `DevInParsingTest.kt` to validate the parsing of Java annotations within code blocks, ensuring the robustness of the lexer's new behavior.
- Loading branch information
Showing
6 changed files
with
36 additions
and
6 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
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
7 changes: 7 additions & 0 deletions
7
exts/devin-lang/src/test/testData/parser/JavaAnnotation.devin
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,7 @@ | ||
```java | ||
@Target({ElementType.TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ExampleAnnotation { | ||
String value() default ""; | ||
} | ||
``` |
18 changes: 18 additions & 0 deletions
18
exts/devin-lang/src/test/testData/parser/JavaAnnotation.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,18 @@ | ||
DevInFile | ||
CodeBlockElement(CODE) | ||
PsiElement(DevInTokenType.CODE_BLOCK_START)('```') | ||
PsiElement(DevInTokenType.LANGUAGE_ID)('java') | ||
PsiElement(DevInTokenType.NEWLINE)('\n') | ||
ASTWrapperPsiElement(CODE_CONTENTS) | ||
PsiElement(DevInTokenType.CODE_CONTENT)('@Target({ElementType.TYPE})') | ||
PsiElement(DevInTokenType.NEWLINE)('\n') | ||
PsiElement(DevInTokenType.CODE_CONTENT)('@Retention(RetentionPolicy.RUNTIME)') | ||
PsiElement(DevInTokenType.NEWLINE)('\n') | ||
PsiElement(DevInTokenType.CODE_CONTENT)('public ') | ||
PsiElement(DevInTokenType.CODE_CONTENT)('@interface ExampleAnnotation {') | ||
PsiElement(DevInTokenType.NEWLINE)('\n') | ||
PsiElement(DevInTokenType.CODE_CONTENT)(' String value() default "";') | ||
PsiElement(DevInTokenType.NEWLINE)('\n') | ||
PsiElement(DevInTokenType.CODE_CONTENT)('}') | ||
PsiElement(DevInTokenType.NEWLINE)('\n') | ||
PsiElement(DevInTokenType.CODE_BLOCK_END)('```') |
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