示例#1
0
 @Override
 public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
   final PsiElement element = descriptor.getPsiElement();
   if (element != null) {
     if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
     final PsiLambdaExpression lambdaExpression =
         PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class);
     if (lambdaExpression != null) {
       final PsiElement body = lambdaExpression.getBody();
       if (body != null) {
         PsiExpression expression = LambdaUtil.extractSingleExpressionFromBody(body);
         if (expression != null) {
           body.replace(expression);
         }
       }
     }
   }
 }