Rename: Replace name identifiers via AST to prevent unwanted reformatting
#KT-8563 Fixed
This commit is contained in:
@@ -92,7 +92,7 @@ abstract class KtNamedDeclarationStub<T extends KotlinStubWithFqName<?>> extends
|
||||
|
||||
PsiElement newIdentifier = KtPsiFactory(this).createNameIdentifierIfPossible(name);
|
||||
if (newIdentifier != null) {
|
||||
identifier.replace(newIdentifier);
|
||||
KtPsiUtilKt.astReplace(identifier, newIdentifier);
|
||||
}
|
||||
else {
|
||||
identifier.delete();
|
||||
|
||||
@@ -568,4 +568,6 @@ fun KtExpression.getLabeledParent(labelName: String): KtLabeledExpression? {
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun PsiElement.astReplace(newElement: PsiElement) = parent.node.replaceChild(node, newElement.node)
|
||||
Reference in New Issue
Block a user