PsiExpressionStatement (PsiAssignmentExpression assignment, PsiExpressionStatement statement, @InspectionMessage String message) { if (!assignment.getOperationTokenType().equals(JavaTokenType.EQ)) return statement; var arrayAccessExpression = tryCast(assignment.getLExpression(), PsiArrayAccessExpression.class); if (arrayAccessExpression == null) return statement; PsiExpression qualifier = PsiUtil.skipParenthesizedExprDown(arrayAccessExpression.getArrayExpression()); PsiExpression arg = arrayAccessExpression.getIndexExpression(); Object key = getKey(arg); if (key == null) return statement; if (qualifier == null) return statement; PsiVariable qualifierVar = qualifier instanceof PsiReferenceExpression ? tryCast(((PsiReferenceExpression)qualifier).resolve(), PsiVariable.class) : null; if (qualifierVar != null && VariableAccessUtils.variableIsUsed(qualifierVar, assignment.getRExpression())) return statement; Map<Object, List<PsiExpression>> map = new HashMap<>(); map.computeIfAbsent(key, k -> new ArrayList<>()).add(arg); while (true) { PsiExpressionStatement nextStatement = findNextStatement(statement); if (nextStatement == null) break; PsiAssignmentExpression nextExpression = tryCast(nextStatement.getExpression(), PsiAssignmentExpression.class); if (nextExpression == null || !nextExpression.getOperationTokenType().equals(JavaTokenType.EQ)) break; var nextArrayAccess = tryCast(nextExpression.getLExpression(), PsiArrayAccessExpression.class); if (nextArrayAccess == null) break; PsiExpression nextQualifier = PsiUtil.skipParenthesizedExprDown(nextArrayAccess.getArrayExpression()); if (nextQualifier == null || !PsiEquivalenceUtil.areElementsEquivalent(qualifier, nextQualifier)) break; if (qualifierVar != null && VariableAccessUtils.variableIsUsed(qualifierVar, nextExpression.getRExpression())) break; PsiExpression nextArg = nextArrayAccess.getIndexExpression(); Object nextKey = getKey(nextArg); if (nextKey != null) { map.computeIfAbsent(nextKey, k -> new ArrayList<>()).add(nextArg); } statement = nextStatement; } registerDuplicates(message, map); return statement; }