boolean (@NotNull PsiReference reference, @NotNull String updaterName) { if (!(reference instanceof JavaLangClassMemberReference)) { // optimization return true; } PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(reference.getElement(), PsiMethodCallExpression.class); if (methodCall == null || !isCallToMethod(methodCall, updaterName, NEW_UPDATER)) { return true; } PsiElement callParent = skipParenthesizedExprUp(methodCall.getParent()); PsiVariable updaterVariable = null; if (callParent instanceof PsiVariable var && skipParenthesizedExprDown(var.getInitializer()) == methodCall) { updaterVariable = var; } else if (callParent instanceof PsiAssignmentExpression assignment) { if (assignment.getOperationTokenType() == JavaTokenType.EQ && skipParenthesizedExprDown(assignment.getRExpression()) == methodCall && skipParenthesizedExprDown(assignment.getLExpression()) instanceof PsiReferenceExpression refExpr && refExpr.resolve() instanceof PsiVariable var) { updaterVariable = var; } } if (updaterVariable != null && InheritanceUtil.isInheritor(updaterVariable.getType(), updaterName)) { Query<PsiReference> updaterQuery = ReferencesSearch.search(updaterVariable); if (!updaterQuery.forEach(AtomicReferenceImplicitUsageProvider::findWrites)) { return false; } } return true; }