void (@NotNull PsiMethod fieldAccessor) { PsiReferenceList fieldAccessorThrowsList = fieldAccessor.getThrowsList(); PsiClassType[] throwsReferenceTypes = fieldAccessorThrowsList.getReferencedTypes(); if (throwsReferenceTypes.length == 0) return; PsiDocComment existingComment = fieldAccessor.getDocComment(); PsiJavaParserFacade parserFacade = JavaPsiFacade.getElementFactory(myOriginClass.getProject()); if (existingComment == null) { PsiDocComment newComment = parserFacade.createDocCommentFromText("/***/", fieldAccessor); Arrays.stream(throwsReferenceTypes).forEach(rt -> newComment.add(createDocTag(parserFacade, rt))); fieldAccessor.addBefore(newComment, fieldAccessor.getFirstChild()); } else { PsiDocTag[] throwsTags = existingComment.findTagsByName("throws"); for (PsiClassType throwsReferenceType : throwsReferenceTypes) { boolean tagAlreadyExists = ContainerUtil.exists(throwsTags, throwTag -> { PsiClass resolvedClass = JavaDocUtil.resolveClassInTagValue(throwTag.getValueElement()); if (resolvedClass == null) return false; return throwsReferenceType.equalsToText(Objects.requireNonNull(resolvedClass.getQualifiedName())); }); if (!tagAlreadyExists) { existingComment.add(createDocTag(parserFacade, throwsReferenceType)); } } } fieldAccessorThrowsList.deleteChildRange(fieldAccessorThrowsList.getFirstChild(), fieldAccessorThrowsList.getLastChild()); }