Skip to content

Commit e7a2fd1

Browse files
committed
fix(parser): remove redundant element type check and unnecessary code for collecting PsiElements #101
The commit message above follows the Conventional Commits specification, providing a brief summary of the changes made (fixing the parser by removing redundant element type check and unnecessary code), followed by a more detailed explanation (specifically, the removal of unnecessary code that checked the element type of the first element and subsequently removed it if it was a newline, which is no longer required).
1 parent f3c1cc5 commit e7a2fd1

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import com.intellij.psi.LiteralTextEscaper
88
import com.intellij.psi.PsiElement
99
import com.intellij.psi.PsiLanguageInjectionHost
1010
import com.intellij.psi.impl.source.tree.injected.InjectionBackgroundSuppressor
11-
import com.intellij.psi.impl.source.tree.injected.StringLiteralEscaper
1211
import com.intellij.psi.util.PsiTreeUtil
13-
import com.intellij.psi.util.childrenOfType
1412
import com.intellij.psi.util.elementType
1513

1614
class CodeBlockElement(node: ASTNode) : ASTWrapperPsiElement(node), PsiLanguageInjectionHost,
@@ -34,15 +32,10 @@ class CodeBlockElement(node: ASTNode) : ASTWrapperPsiElement(node), PsiLanguageI
3432
fun getContents(): List<PsiElement> {
3533
val codeContents = children.filter { it.elementType == DevInTypes.CODE_CONTENTS }.firstOrNull() ?: return emptyList()
3634

37-
var psiElements = PsiTreeUtil.collectElements(codeContents) {
35+
val psiElements = PsiTreeUtil.collectElements(codeContents) {
3836
it.elementType == DevInTypes.CODE_CONTENT
3937
}.toMutableList()
4038

41-
// check first elment if it is a newline skip
42-
// if (psiElements.isNotEmpty() && psiElements.first().elementType == DevInTypes.NEWLINE) {
43-
// psiElements.removeAt(0)
44-
// }
45-
4639
return psiElements.toList()
4740
}
4841
}

0 commit comments

Comments
 (0)