void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiReferenceExpression ref = PsiTreeUtil.getParentOfType(element, PsiReferenceExpression.class); if (ref == null) return; PsiMethodCallExpression call; if (ref instanceof PsiMethodReferenceExpression) { PsiLambdaExpression lambda = LambdaRefactoringUtil.convertMethodReferenceToLambda((PsiMethodReferenceExpression)ref, true, true); if (lambda == null) return; call = ObjectUtils.tryCast(lambda.getBody(), PsiMethodCallExpression.class); } else { call = ObjectUtils.tryCast(ref.getParent(), PsiMethodCallExpression.class); } if (call == null) return; PsiElement result = call.getArgumentList().add(JavaPsiFacade.getElementFactory(project).createExpressionFromText(myExpressionText, call)); JavaCodeStyleManager.getInstance(project).shortenClassReferences(result); }