java create local from usage: do not duplicate comments inside variable initializer (IDEA-256107)

GitOrigin-RevId: 3f9298e0d38ca0840a57922a7b9eb23c27277668
This commit is contained in:
Anna Kozlova
2020-11-26 12:11:11 +00:00
committed by intellij-monorepo-bot
parent 91029bab3c
commit 3a646d1f0c
3 changed files with 7 additions and 3 deletions
@@ -110,7 +110,9 @@ public class CreateLocalFromUsageFix extends CreateVarFromUsageFix {
TypeExpression expression = new TypeExpression(project, expectedTypes);
if (isInline) {
decl = (PsiDeclarationStatement)new CommentTracker().replaceAndRestoreComments(anchor, decl);
CommentTracker tracker = new CommentTracker();
tracker.markUnchanged(initializer);
decl = (PsiDeclarationStatement)tracker.replaceAndRestoreComments(anchor, decl);
}
else {
decl = (PsiDeclarationStatement)anchor.getParent().addBefore(decl, anchor);
@@ -3,7 +3,8 @@ public class A {
void foo() {
String[] split = null;
//c1
String zeit = split[1]; // 2011-04-13
String zeit = split//c2
[1]; // 2011-04-13
}
}
@@ -3,7 +3,8 @@ public class A {
void foo() {
String[] split = null;
ze<caret>it//c1
= split[1]; // 2011-04-13
= split//c2
[1]; // 2011-04-13
}
}