void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiMethodCallExpression chain = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class); if (chain == null) return; CollectTerminal terminal = extractTerminal(chain); if (terminal == null) return; CommentTracker ct = new CommentTracker(); String stream = terminal.generateIntermediate(ct) + terminal.generateTerminal(ct, myStrictMode); PsiElement toReplace = terminal.getElementToReplace(); PsiElement result; terminal.cleanUp(ct); if (toReplace != null) { result = ct.replaceAndRestoreComments(toReplace, stream); } else { PsiVariable variable = Objects.requireNonNull(terminal.getTargetVariable()); PsiExpression initializer = Objects.requireNonNull(variable.getInitializer()); result = ct.replaceAndRestoreComments(initializer, stream); } LambdaCanBeMethodReferenceInspection.replaceAllLambdasWithMethodReferences(result); }