fix(JavaDoc): Collapsed markdown comments with wrong suffixes

Not perfect at all, it should be able to rely on the commenter API instead.

GitOrigin-RevId: f41d181e9f27905bca1156912b7850f5a96ba943
This commit is contained in:
Mathias Boulay
2024-09-02 16:18:23 +02:00
committed by intellij-monorepo-bot
parent d4e45d6061
commit 286567da08
3 changed files with 86 additions and 1 deletions

View File

@@ -198,7 +198,19 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
final FoldingDescriptor commentDescriptor = CommentFoldingUtil.getCommentDescriptor(comment, document, processedComments,
element -> isCustomRegionElement(element),
isCollapseCommentByDefault(comment));
if (commentDescriptor != null) list.add(commentDescriptor);
if (commentDescriptor != null) {
if (comment instanceof PsiDocComment && ((PsiDocComment)comment).isMarkdownComment()) {
// Hack: Markdown comments aren't documented in the Commenter for the Java language
// To avoid the `/** */` tokens, we remove them
String placeHolderText = commentDescriptor.getPlaceholderText();
if (placeHolderText != null) {
placeHolderText = StringUtil.trimEnd(StringUtil.trimStart(placeHolderText, "/**"), "*/");
commentDescriptor.setPlaceholderText(placeHolderText);
}
}
list.add(commentDescriptor);
}
}
private static void addMethodGenericParametersFolding(@NotNull List<? super FoldingDescriptor> list,