void (StringBuilder buffer, PsiMethod method, PsiDocComment comment) { final PsiDocTag[] throwsJavadocTags = getThrowsTags(comment); final PsiJavaCodeReferenceElement[] methodThrows = isRendered() ? PsiJavaCodeReferenceElement.EMPTY_ARRAY : method.getThrowsList().getReferenceElements(); final int totalThrowsToDocument = throwsJavadocTags.length + methodThrows.length; if (totalThrowsToDocument == 0) return; final class Data { final @NotNull PsiJavaCodeReferenceElement ref; final @Nullable PsiDocTag tag; private Data(@NotNull PsiJavaCodeReferenceElement ref, @Nullable PsiDocTag tag) { this.ref = ref; this.tag = tag; } } final Map<@NotNull String, @NotNull Data> throwTags = new LinkedHashMap<>(totalThrowsToDocument, 1.0f); for (PsiDocTag tag : throwsJavadocTags) { final PsiDocTagValue value = tag.getValueElement(); if (value == null) continue; final ASTNode[] children = value.getNode().getChildren(TokenSet.create(JavaDocElementType.DOC_REFERENCE_HOLDER)); if (children.length != 1) continue; final PsiJavaCodeReferenceElement element = ObjectUtils.tryCast(children[0].getFirstChildNode(), PsiJavaCodeReferenceElement.class); if (element != null) { throwTags.put(element.getQualifiedName(), new Data(element, tag)); } } Arrays.stream(methodThrows) .filter(e -> !throwTags.containsKey(e.getQualifiedName())) .forEach(e -> throwTags.put(e.getQualifiedName(), new Data(e, null))); if (throwTags.isEmpty()) return; startHeaderSection(buffer, CodeInsightBundle.message("javadoc.throws")); for (Map.Entry<String, Data> throwTag : throwTags.entrySet()) { final Data value = throwTag.getValue(); final PsiJavaCodeReferenceElement exceptionType = value.ref; final PsiClass target = ObjectUtils.tryCast(exceptionType.resolve(), PsiClass.class); final PsiDocTag tag = value.tag; buffer.append("<p>"); final PsiElement[] elements = tag != null ? tag.getDataElements() : PsiElement.EMPTY_ARRAY; if (target != null) { generateLink(buffer, target); } else if (elements.length != 0) { generateLink(buffer, elements[0].getText(), null, method, false); } else { generateUnresolvedLink(buffer, exceptionType); } if (elements.length < 2) continue; buffer.append(" &ndash; "); final Pair<PsiDocTag, InheritDocProvider<PsiDocTag>> tagToInheritDocProvider = findInheritDocTag(method, exceptionLocator(exceptionType.getQualifiedName())); generateValue(buffer, elements, 1, tagToInheritDocProvider == null ? null : new InheritDocProvider<>() { @Override public Pair<PsiElement[], InheritDocProvider<PsiElement[]>> getInheritDoc() { final PsiElement[] docElements = tagToInheritDocProvider.first.getDataElements(); final PsiElement[] result = Arrays.stream(docElements) .skip(1) .toArray(PsiElement[]::new); return Pair.pair(result, null); } @Override public PsiClass getElement() { return tagToInheritDocProvider.getSecond().getElement(); } }); } buffer.append(DocumentationMarkup.SECTION_END); }