void (RefElement refWhat, RefElement refFrom) { if (refWhat.getUserData(ALWAYS_INVERTED) != Boolean.TRUE) return; final RefMethod refMethod = (RefMethod)refWhat; final PsiElement psiElement = refMethod.getPsiElement(); if (!(psiElement instanceof PsiMethod psiMethod)) return; final PsiElement psiFrom = refFrom.getPsiElement(); psiFrom.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { super.visitMethodCallExpression(call); final PsiReferenceExpression methodExpression = call.getMethodExpression(); if (methodExpression.isReferenceTo(psiMethod)) { if (isInvertedMethodCall(call, psiFrom)) return; refMethod.putUserData(ALWAYS_INVERTED, Boolean.FALSE); } } @Override public void visitMethodReferenceExpression(@NotNull PsiMethodReferenceExpression expression) { super.visitMethodReferenceExpression(expression); if (expression.isReferenceTo(psiElement)) { refMethod.putUserData(ALWAYS_INVERTED, Boolean.FALSE); } } }); }