mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
preserve comments: invert if with comment after then branch
This commit is contained in:
+2
-2
@@ -248,8 +248,8 @@ public class InvertIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
|
||||
if (element instanceof PsiReturnStatement) {
|
||||
PsiReturnStatement returnStatement = (PsiReturnStatement) element;
|
||||
ifStatement = addAfterWithinCodeBlock(ifStatement, ct.markUnchanged(thenBranch));
|
||||
ct.replaceAndRestoreComments(Objects.requireNonNull(ifStatement.getThenBranch()), returnStatement.copy());
|
||||
ifStatement = addAfterWithinCodeBlock(ifStatement, thenBranch);
|
||||
ct.replaceAndRestoreComments(Objects.requireNonNull(ifStatement.getThenBranch()), ct.markUnchanged(returnStatement).copy());
|
||||
|
||||
ControlFlow flow2 = buildControlFlow(findCodeBlock(ifStatement));
|
||||
if (!ControlFlowUtil.isInstructionReachable(flow2, flow2.getStartOffset(returnStatement), 0)) returnStatement.delete();
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
public class C {
|
||||
public boolean isAcceptable(Object element) {
|
||||
if (element == null) {
|
||||
return false;//c1
|
||||
}
|
||||
System.out.println();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
public class C {
|
||||
public boolean isAcceptable(Object element) {
|
||||
i<caret>f (element != null) {
|
||||
System.out.println();
|
||||
}//c1
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user