mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Clarification comment about relational precedence
Review ID: IDEA-CR-32780
This commit is contained in:
+7
-4
@@ -89,12 +89,15 @@ public class SimplifiableConditionalExpressionInspection extends BaseInspection
|
||||
assert thenExpression != null;
|
||||
assert elseExpression != null;
|
||||
if (BoolUtils.areExpressionsOpposite(thenExpression, elseExpression)) {
|
||||
// EQUALITY_PRECEDENCE is technically enough here, but it may produces quite confusing code like "a == b > c"
|
||||
// so we add (formally redundant) parentheses in this case: "a == (b > c)"
|
||||
final int precedence = PsiPrecedenceUtil.RELATIONAL_PRECEDENCE;
|
||||
if (BoolUtils.isNegation(thenExpression)) {
|
||||
return ParenthesesUtils.getText(tracker.markUnchanged(condition), PsiPrecedenceUtil.RELATIONAL_PRECEDENCE) + " != " +
|
||||
ParenthesesUtils.getText(tracker.markUnchanged(elseExpression), PsiPrecedenceUtil.RELATIONAL_PRECEDENCE);
|
||||
return ParenthesesUtils.getText(tracker.markUnchanged(condition), precedence) + " != " +
|
||||
ParenthesesUtils.getText(tracker.markUnchanged(elseExpression), precedence);
|
||||
} else {
|
||||
return ParenthesesUtils.getText(tracker.markUnchanged(condition), PsiPrecedenceUtil.RELATIONAL_PRECEDENCE) + " == " +
|
||||
ParenthesesUtils.getText(tracker.markUnchanged(thenExpression), PsiPrecedenceUtil.RELATIONAL_PRECEDENCE);
|
||||
return ParenthesesUtils.getText(tracker.markUnchanged(condition), precedence) + " == " +
|
||||
ParenthesesUtils.getText(tracker.markUnchanged(thenExpression), precedence);
|
||||
}
|
||||
}
|
||||
if (BoolUtils.isTrue(thenExpression)) {
|
||||
|
||||
Reference in New Issue
Block a user