generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 297
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): introduce support for agent commands and variables #…
…101 The commit introduces a new lexical and syntactic model for the DevInLanguage, including the support for agent commands and variables. The changes include the addition of new token types, grammar rules, and completion logic, as well as the modification of the lexer and syntax highlighting to accommodate these new features.
- Loading branch information
Showing
7 changed files
with
41 additions
and
14 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
14 changes: 12 additions & 2 deletions
14
exts/devin-lang/src/main/kotlin/cc/unitmesh/language/DevInCompletionContributor.kt
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 |
---|---|---|
@@ -1,17 +1,27 @@ | ||
package cc.unitmesh.language | ||
|
||
import cc.unitmesh.language.completion.VariableProvider | ||
import cc.unitmesh.language.psi.DevInFile | ||
import cc.unitmesh.language.psi.DevInTypes | ||
import com.intellij.codeInsight.completion.CompletionContributor | ||
import com.intellij.codeInsight.completion.CompletionInitializationContext | ||
import com.intellij.codeInsight.completion.CompletionType | ||
import com.intellij.patterns.PlatformPatterns.psiElement | ||
import cc.unitmesh.language.completion.VariableProvider | ||
|
||
class DevInCompletionContributor : CompletionContributor() { | ||
private val INPUT_DUMMY_IDENTIFIER = "AutoDevDummy" | ||
|
||
init { | ||
extend( | ||
CompletionType.BASIC, | ||
psiElement(DevInTypes.REF_BLOCK), | ||
psiElement(DevInTypes.VARIABLE_START), | ||
VariableProvider() | ||
) | ||
} | ||
|
||
override fun beforeCompletion(context: CompletionInitializationContext) { | ||
if ((context.file is DevInFile) && context.dummyIdentifier === INPUT_DUMMY_IDENTIFIER) { | ||
context.dummyIdentifier = INPUT_DUMMY_IDENTIFIER | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
FILE | ||
DevInFile | ||
PsiElement(DevInTokenType.TEXT_SEGMENT)('你好 ') | ||
PsiElement(DevInTokenType.REF_BLOCK)('@hello-world') | ||
DevInUsedImpl(USED) | ||
PsiElement(DevInTokenType.AGENT_START)('@') | ||
DevInAgentIdImpl(AGENT_ID) | ||
PsiElement(DevInTokenType.IDENTIFIER)('hello-world') | ||
PsiElement(DevInTokenType.TEXT_SEGMENT)(' sm') |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
FILE | ||
DevInFile | ||
PsiElement(DevInTokenType.TEXT_SEGMENT)('```java\npublic class Main {\n public static void main(String[] args) {\n System.out.println("Hello, world!");\n }\n}\n```') |