void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!(element instanceof PsiReferenceParameterList typeArgumentList)) return; try { PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiMethodReferenceExpression ref = PsiTreeUtil.getParentOfType(typeArgumentList, PsiMethodReferenceExpression.class); PsiTypeElement qualifierType = ref != null ? ref.getQualifierType() : null; if (PsiTreeUtil.isAncestor(qualifierType, typeArgumentList, false)) { PsiClass targetClass = PsiUtil.resolveClassInType(qualifierType.getType()); if (targetClass != null) { new CommentTracker().replaceAndRestoreComments(qualifierType, elementFactory.createReferenceExpression(targetClass)); } } else { final PsiMethodCallExpression expr = (PsiMethodCallExpression)elementFactory.createExpressionFromText("foo()", null); new CommentTracker().replaceAndRestoreComments(typeArgumentList, expr.getTypeArgumentList()); } } catch (IncorrectOperationException e) { LOG.error(e); } }