void (PsiExpression reference) { PsiMethodCallExpression qualifiedCall = ExpressionUtils.getCallForQualifier(reference); if (qualifiedCall != null) { processQualifiedCall(qualifiedCall); return; } PsiElement parent = reference.getParent(); PsiElement grandParent = skipAssigmentExprUp(parent); if (parent instanceof PsiExpressionList || (parent instanceof PsiAssignmentExpression && grandParent instanceof PsiExpressionList)) { PsiExpressionList args = (PsiExpressionList)(parent instanceof PsiExpressionList ? parent : grandParent); PsiCallExpression surroundingCall = ObjectUtils.tryCast(args.getParent(), PsiCallExpression.class); if (surroundingCall != null) { if (surroundingCall instanceof PsiMethodCallExpression && processCollectionMethods((PsiMethodCallExpression)surroundingCall, reference)) { return; } makeQueried(); if (!isQueryMethod(surroundingCall) && !COLLECTION_SAFE_ARGUMENT_METHODS.matches(surroundingCall)) { makeUpdated(); } return; } } if (parent instanceof PsiMethodReferenceExpression) { processQualifiedMethodReference(((PsiMethodReferenceExpression)parent)); return; } if (parent instanceof PsiForeachStatement && ((PsiForeachStatement)parent).getIteratedValue() == reference) { makeQueried(); return; } if (parent instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)parent).getLExpression() == reference) { PsiExpression rValue = ((PsiAssignmentExpression)parent).getRExpression(); if (rValue == null) return; if (ExpressionUtils.nonStructuralChildren(rValue) .allMatch(MismatchedCollectionQueryUpdateInspection::isEmptyCollectionInitializer)) { return; } if (ExpressionUtils.nonStructuralChildren(rValue) .allMatch(MismatchedCollectionQueryUpdateInspection::isCollectionInitializer)) { makeUpdated(); return; } } if (parent instanceof PsiPolyadicExpression) { IElementType tokenType = ((PsiPolyadicExpression)parent).getOperationTokenType(); if (tokenType.equals(JavaTokenType.PLUS)) { // String concatenation makeQueried(); return; } if (tokenType.equals(JavaTokenType.EQEQ) || tokenType.equals(JavaTokenType.NE)) { return; } } if (parent instanceof PsiAssertStatement && ((PsiAssertStatement)parent).getAssertDescription() == reference) { makeQueried(); return; } if (parent instanceof PsiInstanceOfExpression || parent instanceof PsiSynchronizedStatement) return; // Any other reference makeUpdated(); makeQueried(); }