PsiMethodCallExpression (@NotNull PsiFile copy, @NotNull PsiMethod method) { PsiMethodCallExpression[] result = new PsiMethodCallExpression[1]; copy.accept(new JavaRecursiveElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { if (method.equals(expression.resolveMethod())) { if (result[0] != null) { LOG.error("To many generated method invocations found"); } else { result[0] = expression; } } } }); return result[0]; }