mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
split if: skip comments inside (IDEA-95297)
they should be restored though
This commit is contained in:
@@ -125,8 +125,7 @@ public class SplitIfAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
private static PsiExpression getROperands(PsiPolyadicExpression expression, PsiJavaToken separator) throws IncorrectOperationException {
|
||||
PsiElement next = separator.getNextSibling();
|
||||
if (next instanceof PsiWhiteSpace) next = next.getNextSibling();
|
||||
PsiElement next = PsiTreeUtil.skipSiblingsForward(separator.getNextSibling(), PsiWhiteSpace.class, PsiComment.class);
|
||||
if (next == null) {
|
||||
throw new IncorrectOperationException("Unable to split '"+expression.getText()+"' at '"+separator+"' (offset "+separator.getStartOffsetInParent()+")");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a) {
|
||||
call();
|
||||
} else if (b) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a |<caret>| //comment
|
||||
b) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,12 @@ public class SplitIfActionTest extends LightCodeInsightTestCase {
|
||||
checkResultByFile("/codeInsight/splitIfAction/afterOrParenthesis.java");
|
||||
}
|
||||
|
||||
public void testComment() throws Exception {
|
||||
configureByFile("/codeInsight/splitIfAction/beforeComment.java");
|
||||
perform();
|
||||
checkResultByFile("/codeInsight/splitIfAction/afterComment.java");
|
||||
}
|
||||
|
||||
public void test8() throws Exception {
|
||||
configureByFile("/codeInsight/splitIfAction/beforeOrAndMixed.java");
|
||||
SplitIfAction action = new SplitIfAction();
|
||||
|
||||
Reference in New Issue
Block a user