PsiExpressionStatement (PsiMethodCallExpression call, PsiExpressionStatement statement, CallMatcher myMatcher, @InspectionMessage String message) { PsiExpression arg = call.getArgumentList().getExpressions()[0]; PsiExpression qualifier = PsiUtil.skipParenthesizedExprDown(ExpressionUtils.getEffectiveQualifier(call.getMethodExpression())); 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, call.getArgumentList())) 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; PsiMethodCallExpression nextCall = tryCast(nextStatement.getExpression(), PsiMethodCallExpression.class); if (!myMatcher.test(nextCall)) break; PsiExpression nextQualifier = PsiUtil.skipParenthesizedExprDown(ExpressionUtils.getEffectiveQualifier(nextCall.getMethodExpression())); if (nextQualifier == null || !PsiEquivalenceUtil.areElementsEquivalent(qualifier, nextQualifier)) break; if (qualifierVar != null && VariableAccessUtils.variableIsUsed(qualifierVar, nextCall.getArgumentList())) break; PsiExpression nextArg = ArrayUtil.getFirstElement(nextCall.getArgumentList().getExpressions()); Object nextKey = getKey(nextArg); if (nextKey != null) { map.computeIfAbsent(nextKey, k -> new ArrayList<>()).add(nextArg); } statement = nextStatement; } registerDuplicates(message, map); return statement; }