PsiElement (PsiMethodCallExpression call) { PsiMethodCallExpression qualifierCall = getQualifierMethodCall(call); if (qualifierCall == null) return null; if (myDeleteMap) { CommentTracker ct = new CommentTracker(); call = (PsiMethodCallExpression)ct.replaceAndRestoreComments(call, qualifierCall); } PsiMethodCallExpression result = call; while (call != null) { if (STREAM_MAP_TO_ALL.test(call) || STREAM_FILTER.test(call)) { PsiExpression arg = skipParenthesizedExprDown(call.getArgumentList().getExpressions()[0]); if (arg instanceof PsiLambdaExpression) { updateLambda((PsiLambdaExpression)arg); } else if (arg instanceof PsiMethodReferenceExpression) { PsiType type = LambdaUtil.getFunctionalInterfaceReturnType((PsiFunctionalExpression)arg); String name = new VariableNameGenerator(arg, VariableKind.PARAMETER).byType(type).byName(myNames).generate(false); new CommentTracker().replaceAndRestoreComments(arg, name + "->" + name); } } call = getQualifierMethodCall(call); if (MAP_ENTRY_SET.test(call)) { ExpressionUtils.bindCallTo(call, myMapMethod); break; } } LambdaCanBeMethodReferenceInspection.replaceAllLambdasWithMethodReferences(result); return result; }