mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
keep comments on split declaration inside for loop
This commit is contained in:
@@ -31,6 +31,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -171,7 +172,7 @@ public class SplitDeclarationAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
final PsiElement parent = block.getParent();
|
||||
PsiExpressionStatement replaced = (PsiExpressionStatement)decl.replace(statement);
|
||||
PsiExpressionStatement replaced = (PsiExpressionStatement)new CommentTracker().replaceAndRestoreComments(decl, statement);
|
||||
if (!(parent instanceof PsiCodeBlock)) {
|
||||
final PsiBlockStatement blockStatement =
|
||||
(PsiBlockStatement)JavaPsiFacade.getElementFactory(project).createStatementFromText("{}", block);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// "Split into declaration and assignment" "true"
|
||||
class Test {
|
||||
{
|
||||
//c1
|
||||
int i;
|
||||
for (i = 0; i<10; i++) {
|
||||
System.out.println();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// "Split into declaration and assignment" "true"
|
||||
class Test {
|
||||
{
|
||||
for (int i<caret>=0; i<10; i++) {
|
||||
for (int i<caret>//c1
|
||||
=0; i<10; i++) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user