mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
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:
committed by
intellij-monorepo-bot
parent
d4e45d6061
commit
286567da08
@@ -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,
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<fold text='/// outer class javadoc ...'>/// outer class javadoc
|
||||
/// javadoc body</fold>
|
||||
|
||||
class Test {
|
||||
|
||||
<fold text='/// method javadoc ...'>/// method javadoc
|
||||
/// javadoc body
|
||||
///
|
||||
/// @param i</fold>
|
||||
|
||||
void foo(int i) <fold text='{...}'>{
|
||||
<fold text='/// method var javadoc ...'>/// method var javadoc
|
||||
/// javadoc body</fold>
|
||||
|
||||
int j = i;
|
||||
}</fold>
|
||||
|
||||
<fold text='/// first line ...'>/// first line
|
||||
/// second line</fold>
|
||||
|
||||
void illFormedJavaDocMultilines() <fold text='{}'>{
|
||||
}</fold>
|
||||
|
||||
<fold text='/// first line ...'>/// first line
|
||||
///
|
||||
///</fold>
|
||||
|
||||
void javaDocWithTextOnlyOnFirstLine() <fold text='{}'>{
|
||||
|
||||
}</fold>
|
||||
|
||||
<fold text='/// second line ...'>/// second line
|
||||
///</fold>
|
||||
|
||||
void javaDocWithTextOnlyOnSecondLine() <fold text='{}'>{
|
||||
|
||||
}</fold>
|
||||
|
||||
<fold text='/// '>/// </fold>
|
||||
|
||||
void emptyJavadoc() <fold text='{}'>{
|
||||
|
||||
}</fold>
|
||||
|
||||
<fold text='/// dangling javadoc ...'>/// dangling javadoc
|
||||
/// javadoc body</fold>
|
||||
|
||||
|
||||
<fold text='/// inner class javadoc ...'>/// inner class javadoc
|
||||
/// javadoc body</fold>
|
||||
|
||||
class Inner <fold text='{...}'>{
|
||||
|
||||
<fold text='/// javadoc for method in inner class ...'>/// javadoc for method in inner class
|
||||
/// javadoc body</fold>
|
||||
|
||||
void foo() <fold text='{...}'>{
|
||||
<fold text='/// javadoc for class in method ...'>/// javadoc for class in method
|
||||
/// javadoc body</fold>
|
||||
|
||||
class MethodInner <fold text='{...}'>{
|
||||
|
||||
<fold text='/// javadoc for method inside class defined in method ...'>/// javadoc for method inside class defined in method
|
||||
/// javadoc body</fold>
|
||||
|
||||
void bar() <fold text='{}'>{
|
||||
}</fold>
|
||||
}</fold>
|
||||
}</fold>
|
||||
}</fold>
|
||||
}
|
||||
@@ -49,6 +49,8 @@ public class JavaFoldingTest extends JavaFoldingTestCase {
|
||||
|
||||
public void testJavadocComments() { doTest(); }
|
||||
|
||||
public void testJavadocMarkdownComments() { doTest(); }
|
||||
|
||||
public void testEditingImports() {
|
||||
configure("""
|
||||
import java.util.List;
|
||||
|
||||
Reference in New Issue
Block a user