Return correct parent element for destructuring declaration initializer
This commit is contained in:
@@ -91,6 +91,11 @@ fun doConvertParent(element: UElement, parent: PsiElement?): UElement? {
|
||||
return result.body
|
||||
}
|
||||
|
||||
if (result is KotlinUDestructuringDeclarationExpression &&
|
||||
element.psi == (parent as KtDestructuringDeclaration).initializer) {
|
||||
return result.tempVarAssignment
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ internal object KotlinConverter {
|
||||
}
|
||||
}
|
||||
is KtDestructuringDeclaration -> expr<UDeclarationsExpression> {
|
||||
val declarationsExpression = KotlinUDeclarationsExpression(givenParent)
|
||||
val declarationsExpression = KotlinUDestructuringDeclarationExpression(givenParent, expression)
|
||||
declarationsExpression.apply {
|
||||
val tempAssignment = KotlinULocalVariable(UastKotlinPsiVariable.create(expression, declarationsExpression), declarationsExpression)
|
||||
val destructuringAssignments = expression.entries.mapIndexed { i, entry ->
|
||||
|
||||
+10
-2
@@ -19,7 +19,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
||||
import org.jetbrains.uast.kotlin.doConvertParent
|
||||
|
||||
class KotlinUDeclarationsExpression(
|
||||
open class KotlinUDeclarationsExpression(
|
||||
override val psi: PsiElement?,
|
||||
givenParent: UElement?,
|
||||
val psiAnchor: PsiElement? = null
|
||||
@@ -32,4 +32,12 @@ class KotlinUDeclarationsExpression(
|
||||
|
||||
override lateinit var declarations: List<UDeclaration>
|
||||
internal set
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinUDestructuringDeclarationExpression(
|
||||
givenParent: UElement?,
|
||||
psiAnchor: PsiElement
|
||||
) : KotlinUDeclarationsExpression(null, givenParent, psiAnchor) {
|
||||
|
||||
val tempVarAssignment get() = declarations.first()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user