PsiElement (PsiMethodCallExpression call) { PsiLambdaExpression lambda = tryCast(skipParenthesizedExprDown(call.getArgumentList().getExpressions()[0]), PsiLambdaExpression.class); if (lambda == null) return null; PsiCodeBlock block = tryCast(lambda.getBody(), PsiCodeBlock.class); if (block == null) return null; PsiReturnStatement statement = tryCast(ArrayUtil.getLastElement(block.getStatements()), PsiReturnStatement.class); if (statement == null) return null; ExpressionUtils.bindCallTo(call, "peek"); new CommentTracker().deleteAndRestoreComments(statement); LambdaRefactoringUtil.simplifyToExpressionLambda(lambda); LambdaCanBeMethodReferenceInspection.replaceLambdaWithMethodReference(lambda); return call; }