Skip to content

Commit c3a7b94

Browse files
committed
feat(devin-lang): add support for DevInAstFactory and DevInTypedHandler. #101
The commit introduces a new file `DevInAstFactory.kt` that extends `ASTFactory`, providing a custom factory for the DevIn language. This class is responsible for creating Abstract Syntax Trees (ASTs) for the DevIn language. Another new file `DevInTypedHandler.kt` is added, which extends `TypedHandlerDelegate`. This class handles keyboard input within the DevIn language file, providing support for auto-completion and other editor actions. The `cc.unitmesh.language.xml` file is modified to register the newly created `DevInAstFactory` and `DevInTypedHandler` with the IntelliJ platform. This ensures that the custom functionality is integrated into the IDE's features for the DevIn language.
1 parent f12af8d commit c3a7b94

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cc.unitmesh.language
2+
3+
import com.intellij.lang.ASTFactory
4+
5+
class DevInAstFactory : ASTFactory()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package cc.unitmesh.language
2+
3+
import cc.unitmesh.language.psi.DevInFile
4+
import com.intellij.codeInsight.editorActions.TypedHandlerDelegate
5+
import com.intellij.openapi.editor.Editor
6+
import com.intellij.openapi.project.Project
7+
import com.intellij.psi.PsiFile
8+
9+
class DevInTypedHandler : TypedHandlerDelegate() {
10+
11+
override fun checkAutoPopup(charTyped: Char, project: Project, editor: Editor, file: PsiFile): Result {
12+
if (file !is DevInFile) {
13+
return Result.CONTINUE
14+
}
15+
16+
return when (charTyped) {
17+
'@' -> {
18+
Result.STOP
19+
}
20+
21+
'/' -> {
22+
Result.STOP
23+
}
24+
25+
'$' -> {
26+
Result.STOP
27+
}
28+
29+
else -> {
30+
Result.CONTINUE
31+
}
32+
}
33+
}
34+
}

exts/devin-lang/src/main/resources/cc.unitmesh.language.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
<lang.parserDefinition language="DevIn" implementationClass="cc.unitmesh.language.DevInParserDefinition"/>
88
<lang.syntaxHighlighterFactory language="DevIn"
99
implementationClass="cc.unitmesh.language.DevInSyntaxHighlighterFactory"/>
10+
11+
<lang.ast.factory language="DevIn"
12+
implementationClass="cc.unitmesh.language.DevInAstFactory"/>
13+
14+
<typedHandler implementation="cc.unitmesh.language.DevInTypedHandler"/>
1015
</extensions>
1116
</idea-plugin>

0 commit comments

Comments
 (0)