@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) {
      final PsiElement parent = element.getParent();
      if (!(parent instanceof PsiReferenceExpression methodExpression)) {
        return;
      }
      final PsiExpression qualifier = methodExpression.getQualifierExpression();
      if (qualifier == null) {
        return;
      }
      final PsiElement grandParent = parent.getParent();
      if (!(grandParent instanceof PsiMethodCallExpression methodCallExpression)) {
        return;
      }
      final PsiElement parentOfType = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiTryStatement.class, PsiLambdaExpression.class);
      if (parentOfType instanceof PsiTryStatement tryStatement) {
        addCatchBlock(tryStatement, "java.lang.NoSuchMethodException", "java.lang.reflect.InvocationTargetException");
      }
      else if (parentOfType instanceof PsiLambdaExpression) {
        final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(parentOfType);
        if (FileModificationService.getInstance().preparePsiElementsForWrite(method)) {
          addThrowsClause(method, "java.lang.NoSuchMethodException",
                          "java.lang.reflect.InvocationTargetException");
        }
      }
      else if (parentOfType instanceof PsiMethod method){
        addThrowsClause(method, "java.lang.NoSuchMethodException", "java.lang.reflect.InvocationTargetException");
      }
      @NonNls final String newExpression = qualifier.getText() + ".getConstructor().newInstance()";
      PsiReplacementUtil.replaceExpression(methodCallExpression, newExpression, new CommentTracker());
    }
@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater)