Skip to content

Commit 50f599e

Browse files
committed
feat(devin-lang): add CodeBlockElement class #101
This commit introduces a new class `CodeBlockElement` to the DevInLanguage parser, providing a wrapper for code block elements within text. The class is designed to handle injection host functionality, including updating text and creating literal text escapers. This addition will improve the parsing capabilities of the DevInLanguage plugin, allowing for more accurate and comprehensive processing of code blocks within user input.
1 parent b487200 commit 50f599e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cc.unitmesh.language.parser
2+
3+
import com.intellij.extapi.psi.ASTWrapperPsiElement
4+
import com.intellij.lang.ASTNode
5+
import com.intellij.psi.LiteralTextEscaper
6+
import com.intellij.psi.PsiLanguageInjectionHost
7+
import com.intellij.psi.impl.source.tree.injected.InjectionBackgroundSuppressor
8+
9+
class CodeBlockElement(node: ASTNode) : ASTWrapperPsiElement(node), PsiLanguageInjectionHost,
10+
InjectionBackgroundSuppressor {
11+
override fun isValidHost(): Boolean {
12+
TODO("Not yet implemented")
13+
}
14+
15+
override fun updateText(text: String): PsiLanguageInjectionHost {
16+
TODO("Not yet implemented")
17+
}
18+
19+
override fun createLiteralTextEscaper(): LiteralTextEscaper<out PsiLanguageInjectionHost> {
20+
TODO("Not yet implemented")
21+
}
22+
23+
}

exts/devin-lang/src/main/kotlin/cc/unitmesh/language/parser/DevInParserDefinition.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cc.unitmesh.language.parser
22

33
import cc.unitmesh.language.DevInLanguage
44
import cc.unitmesh.language.lexer.DevInLexerAdapter
5-
import cc.unitmesh.language.parser.DevInParser
65
import cc.unitmesh.language.psi.DevInFile
76
import cc.unitmesh.language.psi.DevInTypes
87
import com.intellij.lang.ASTNode
@@ -47,6 +46,10 @@ internal class DevInParserDefinition : ParserDefinition {
4746

4847
@NotNull
4948
override fun createElement(node: ASTNode?): PsiElement {
49+
// val elementType = node!!.elementType
50+
// if (elementType == DevInTypes.CODE_BLOCK) {
51+
// return CodeBlockElement(node)
52+
// }
5053
return DevInTypes.Factory.createElement(node)
5154
}
5255

0 commit comments

Comments
 (0)