void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiElement foreach = element instanceof PsiForeachStatement ? element : element.getParent(); if (foreach instanceof PsiForeachStatement) { fixInForeach((PsiForeachStatement)foreach); return; } PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class); if (call == null) return; PsiMethodCallExpression entrySetCall = MethodCallUtils.getQualifierMethodCall(call); if (entrySetCall == null) return; PsiExpression[] args = call.getArgumentList().getExpressions(); if (args.length != 1) return; PsiLambdaExpression lambda = ObjectUtils.tryCast(args[0], PsiLambdaExpression.class); if (lambda == null) return; PsiElement body = lambda.getBody(); if (body == null) return; PsiParameterList parameterList = lambda.getParameterList(); PsiParameter[] lambdaParameters = parameterList.getParameters(); if (lambdaParameters.length != 1) return; CommentTracker ct = new CommentTracker(); PsiParameter entryParameter = lambdaParameters[0]; String replacement = createReplacementExpression(entrySetCall, entryParameter, body, ct); ct.replaceAndRestoreComments(call, replacement); }