void (StringBuilder buffer, PsiElement[] elements, int startIndex, InheritDocProvider<PsiElement[]> provider) { int predictOffset = startIndex < elements.length ? elements[startIndex].getTextOffset() + elements[startIndex].getText().length() : 0; for (int i = startIndex; i < elements.length; i++) { if (elements[i].getTextOffset() > predictOffset) buffer.append(' '); predictOffset = elements[i].getTextOffset() + elements[i].getText().length(); PsiElement element = elements[i]; if (element instanceof PsiInlineDocTag tag) { String tagName = tag.getName(); switch (tagName) { case LINK_TAG -> generateLinkValue(tag, buffer, false); case LITERAL_TAG -> generateLiteralValue(buffer, tag, true); case CODE_TAG, SYSTEM_PROPERTY_TAG -> generateCodeValue(tag, buffer); case LINKPLAIN_TAG -> generateLinkValue(tag, buffer, true); case INHERIT_DOC_TAG -> { if (provider == null) continue; Pair<PsiElement[], InheritDocProvider<PsiElement[]>> inheritInfo = provider.getInheritDoc(); if (inheritInfo != null) { generateValue(buffer, inheritInfo.first, inheritInfo.second); } } case DOC_ROOT_TAG -> buffer.append(getDocRoot()); case VALUE_TAG -> generateValueValue(tag, buffer, element); case INDEX_TAG -> generateIndexValue(buffer, tag); case SUMMARY_TAG -> generateLiteralValue(buffer, tag, false); case SNIPPET_TAG -> generateSnippetValue(buffer, tag); case RETURN_TAG -> generateInlineReturnValue(buffer, tag, provider); default -> generateUnknownInlineTagValue(buffer, tag); } } else { final String text; if (element instanceof PsiWhiteSpace) { text = getWhitespacesBeforeLFWhenLeadingAsterisk(element); } else { text = element.getText(); } appendPlainText(buffer, text); } } }