Commit 6d2fcadd authored by Dmitry Gridin's avatar Dmitry Gridin Committed by intellij-monorepo-bot
Browse files

[kotlin] ReplaceWithImportAliasInspection: fix psi-tree structure

^KTIJ-20184

GitOrigin-RevId: 5c849164240829b0ed48fffc278ee1f6cd52f6aa
parent ff05ef18
Branches unavailable Tags unavailable
No related merge requests found
Showing with 8 additions and 1 deletion
+8 -1
......@@ -50,7 +50,14 @@ class ReplaceWithImportAliasInspection : AbstractKotlinInspection() {
val expression = descriptor.psiElement as? KtNameReferenceExpression ?: return
val aliasNameIdentifier = aliasNameIdentifierPointer.element ?: return
expression.getIdentifier()?.replace(aliasNameIdentifier.copy())
expression.getQualifiedElement().replace(expression.parent.safeAs<KtCallExpression>() ?: expression)
expression.getQualifiedElement().let { element ->
if (element is KtUserType) {
element.referenceExpression?.replace(expression)
element.deleteQualifier()
} else {
element.replace(expression.parent.safeAs<KtCallExpression>() ?: expression)
}
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment