mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
invert if: preserve parenthesis when not safe to delete (IDEA-107783)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// "Invert If Condition" "true"
|
||||
class A {
|
||||
public boolean foo(boolean a, boolean b, boolean c, boolean d) {
|
||||
|
||||
if ((a || b) && !c && !d) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Invert If Condition" "true"
|
||||
class A {
|
||||
public boolean foo(boolean a, boolean b, boolean c, boolean d) {
|
||||
|
||||
if (!(a |<caret>| b) || c || d)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,11 @@ public class CodeInsightServicesUtil {
|
||||
if (expression.getOperationTokenType() == JavaTokenType.EXCL) {
|
||||
PsiExpression operand = expression.getOperand();
|
||||
if (operand instanceof PsiParenthesizedExpression) {
|
||||
operand = ((PsiParenthesizedExpression)operand).getExpression();
|
||||
final PsiElement parent = booleanExpression.getParent();
|
||||
if (parent instanceof PsiPolyadicExpression &&
|
||||
((PsiPolyadicExpression)parent).getOperationTokenType() == JavaTokenType.ANDAND) {
|
||||
operand = ((PsiParenthesizedExpression)operand).getExpression();
|
||||
}
|
||||
}
|
||||
return operand;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user