mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DataFlowInspection: unwrap parentheses when checking if redundant assignment is inside class initializer
This commit is contained in:
+1
@@ -306,6 +306,7 @@ public class DataFlowInspectionBase extends AbstractBaseJavaLocalInspectionTool
|
||||
HashSet<PsiElement> reportedAnchors,
|
||||
DataFlowInstructionVisitor visitor) {
|
||||
visitor.sameValueAssignments().forEach(expr -> {
|
||||
expr = PsiUtil.skipParenthesizedExprDown(expr);
|
||||
if(!reportedAnchors.add(expr)) return;
|
||||
PsiAssignmentExpression assignment = PsiTreeUtil.getParentOfType(expr, PsiAssignmentExpression.class);
|
||||
PsiElement context = PsiTreeUtil.getParentOfType(expr, PsiForStatement.class, PsiClassInitializer.class);
|
||||
|
||||
@@ -39,4 +39,14 @@ public class RedundantAssignment {
|
||||
<warning descr="Variable is already assigned to this value">a</warning> = b;
|
||||
}
|
||||
}
|
||||
|
||||
class X {
|
||||
int a;
|
||||
int b;
|
||||
|
||||
{
|
||||
a = 0;
|
||||
((b)) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user