FIR: fix PsiElementFinderByType
Current implementation would return the input node if the type matches. This is clear wrong since the method is supposed to return children.
This commit is contained in:
committed by
teamcityserver
parent
93561a1a55
commit
f51b108821
+6
-4
@@ -22,11 +22,13 @@ class LighterTreeElementFinderByType(
|
||||
}
|
||||
|
||||
private fun visitNode(node: LighterASTNode, currentDepth: Int): LighterASTNode? {
|
||||
if (node.tokenType in types) {
|
||||
if (index == 0) {
|
||||
return node
|
||||
if (currentDepth != 0) {
|
||||
if (node.tokenType in types) {
|
||||
if (index == 0) {
|
||||
return node
|
||||
}
|
||||
index--
|
||||
}
|
||||
index--
|
||||
}
|
||||
|
||||
if (currentDepth == depth) return null
|
||||
|
||||
+6
-4
@@ -19,11 +19,13 @@ class PsiElementFinderByType(
|
||||
}
|
||||
|
||||
private fun visitElement(element: PsiElement, currentDepth: Int): PsiElement? {
|
||||
if (element.node.elementType in types) {
|
||||
if (index == 0) {
|
||||
return element
|
||||
if (currentDepth != 0) {
|
||||
if (element.node.elementType in types) {
|
||||
if (index == 0) {
|
||||
return element
|
||||
}
|
||||
index--
|
||||
}
|
||||
index--
|
||||
}
|
||||
|
||||
if (currentDepth == depth) return null
|
||||
|
||||
Reference in New Issue
Block a user