PsiElement (PsiMethodCallExpression streamCall) { PsiMethodCallExpression collectionCall = getQualifierMethodCall(streamCall); if (collectionCall == null) return null; CommentTracker ct = new CommentTracker(); ct.replace(streamCall.getArgumentList(), collectionCall.getArgumentList()); String typeParameter = getTypeParameter(ct, collectionCall); String replacement; if (typeParameter != null) { replacement = myClassName + ".<" + typeParameter + ">" + myMethodName; } else { replacement = myClassName + "." + myMethodName; } Project project = streamCall.getProject(); PsiElement result = ct.replaceAndRestoreComments(streamCall.getMethodExpression(), replacement); return JavaCodeStyleManager.getInstance(project).shortenClassReferences(result); }