TextContent (@NotNull PsiElement root, @NotNull Set<TextContent.TextDomain> allowedDomains) { if (allowedDomains.contains(DOCUMENTATION)) { if (root instanceof PsiDocComment) { return HtmlUtilsKt.removeHtml(javadocBuilder.excluding(e -> e instanceof PsiDocTagImpl).build(root, DOCUMENTATION)); } if (root instanceof PsiDocTagImpl) { return HtmlUtilsKt.removeHtml(javadocBuilder.build(root, DOCUMENTATION)); } } if (root instanceof PsiCommentImpl && allowedDomains.contains(COMMENTS)) { List<PsiElement> roots = PsiUtilsKt.getNotSoDistantSimilarSiblings(root, e -> JAVA_PLAIN_COMMENT_BIT_SET.contains(PsiUtilCore.getElementType(e))); return TextContent.joinWithWhitespace('\n', ContainerUtil.mapNotNull(roots, c -> TextContentBuilder.FromPsi.removingIndents(" \t*/").removingLineSuffixes(" \t").build(c, COMMENTS))); } if (root instanceof PsiLiteralExpression && allowedDomains.contains(LITERALS) && ((PsiLiteralExpression) root).getValue() instanceof String) { TextContent content = TextContentBuilder.FromPsi.build(root, LITERALS); int indent = PsiLiteralUtil.getTextBlockIndent((PsiLiteralExpression)root); if (indent >= 0 && indent < 1000 && content != null) { if (indent > 0) { content = content.excludeRanges( ContainerUtil.map(Text.allOccurrences(Pattern.compile("(?<=\n)" + "\\s{" + indent + "}"), content), Exclusion::exclude)); } content = content.excludeRanges(ContainerUtil.map(Text.allOccurrences(Pattern.compile("\\\\\n"), content), Exclusion::exclude)); return content.trimWhitespace(); } return content; } return null; }