void (@Nullable final RefMethod refMethod, @Nullable final PsiMethod psiMethod, final CommonProblemDescriptor @Nullable [] problems) { if (psiMethod == null) return; if (problems == null) return; final Project project = psiMethod.getProject(); final PsiManager psiManager = PsiManager.getInstance(project); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(psiManager.getProject()); fixTryStatements(psiMethod, problems); final Set<PsiElement> refsToDelete = Arrays.stream(problems) .map(problem -> (ProblemDescriptor)problem) .map(ProblemDescriptor::getPsiElement) .filter(psiElement -> psiElement instanceof PsiJavaCodeReferenceElement) .map(reference -> (PsiJavaCodeReferenceElement)reference) .map(factory::createType) .flatMap(psiClassType -> removeException(refMethod, psiClassType, psiMethod)) .collect(Collectors.toSet()); if (!FileModificationService.getInstance().preparePsiElementsForWrite(refsToDelete)) return; WriteAction.run(() -> { for (final PsiElement element : refsToDelete) { new CommentTracker().deleteAndRestoreComments(element); } }); }