PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression methodCall) { super.visitMethodCallExpression(methodCall); if (isCallToMethod(methodCall, JAVA_LANG_REFLECT_METHOD, INVOKE)) { checkReflectionCall(methodCall, 1, holder, JavaReflectionInvocationInspection::isReflectionMethod); } else if (isCallToMethod(methodCall, JAVA_LANG_REFLECT_CONSTRUCTOR, NEW_INSTANCE)) { checkReflectionCall(methodCall, 0, holder, JavaReflectionInvocationInspection::isReflectionConstructor); } } }; }