mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-120799 (Quick-fix for "Unnecessary parentheses" changes expression semantics)
This commit is contained in:
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -505,15 +505,16 @@ public class ParenthesesUtils {
|
||||
}
|
||||
}
|
||||
final IElementType parentOperator = parentPolyadicExpression.getOperationTokenType();
|
||||
final IElementType childOperator = childPolyadicExpression.getOperationTokenType();
|
||||
if (ignoreClarifyingParentheses) {
|
||||
final IElementType childOperator = childPolyadicExpression.getOperationTokenType();
|
||||
if (!childOperator.equals(parentOperator)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final PsiExpression[] parentOperands = parentPolyadicExpression.getOperands();
|
||||
if (!PsiTreeUtil.isAncestor(parentOperands[0], expression, false)) {
|
||||
if (!isCommutativeOperator(parentOperator)) {
|
||||
if (!isAssociativeOperation(parentPolyadicExpression) ||
|
||||
JavaTokenType.DIV == childOperator || JavaTokenType.PERC == childOperator) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -112,4 +112,12 @@ public class UnnecessaryParenthesesInspection
|
||||
Object info = new Object[]{"abc"};
|
||||
String s = (String)((Object[])info)[0];
|
||||
}
|
||||
|
||||
void zz() {
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
|
||||
final int i = a * ((b + 2) / 3); // no warn
|
||||
final int j = a * ((b + 2) % 3); // no warn
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user