mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
create local from usage: preserve comments
found by property testing GitOrigin-RevId: 2b4aabe7f5cc3e87d8cbbb9959f778aa241fa377
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c5e8fb5b98
commit
356697425a
+2
-9
@@ -22,6 +22,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -106,15 +107,7 @@ public class CreateLocalFromUsageFix extends CreateVarFromUsageFix {
|
||||
TypeExpression expression = new TypeExpression(project, expectedTypes);
|
||||
|
||||
if (isInline) {
|
||||
final PsiExpression expr = ((PsiExpressionStatement)anchor).getExpression();
|
||||
final PsiElement semicolon = expr.getNextSibling();
|
||||
if (semicolon != null) {
|
||||
final PsiElement nextSibling = semicolon.getNextSibling();
|
||||
if (nextSibling != null) {
|
||||
decl.addRange(nextSibling, anchor.getLastChild());
|
||||
}
|
||||
}
|
||||
decl = (PsiDeclarationStatement)anchor.replace(decl);
|
||||
decl = (PsiDeclarationStatement)new CommentTracker().replaceAndRestoreComments(anchor, decl);
|
||||
}
|
||||
else {
|
||||
decl = (PsiDeclarationStatement)anchor.getParent().addBefore(decl, anchor);
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
public class A {
|
||||
void foo() {
|
||||
String[] split = null;
|
||||
//c1
|
||||
String zeit = split[1]; // 2011-04-13
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
public class A {
|
||||
void foo() {
|
||||
String[] split = null;
|
||||
ze<caret>it = split[1]; // 2011-04-13
|
||||
ze<caret>it//c1
|
||||
= split[1]; // 2011-04-13
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user