Fix handling of underscores in Markdown links (KT-14452)
This commit is contained in:
@@ -170,8 +170,12 @@ object KDocRenderer {
|
||||
}
|
||||
MarkdownElementTypes.SHORT_REFERENCE_LINK,
|
||||
MarkdownElementTypes.FULL_REFERENCE_LINK -> {
|
||||
val label = node.child(MarkdownElementTypes.LINK_LABEL)?.child(MarkdownTokenTypes.TEXT)?.text
|
||||
if (label != null) {
|
||||
val linkLabelNode = node.child(MarkdownElementTypes.LINK_LABEL)
|
||||
val linkLabelContent = linkLabelNode?.children
|
||||
?.dropWhile { it.type == MarkdownTokenTypes.LBRACKET }
|
||||
?.dropLastWhile { it.type == MarkdownTokenTypes.RBRACKET }
|
||||
if (linkLabelContent != null) {
|
||||
val label = linkLabelContent.joinToString(separator = "") { it.text }
|
||||
val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.toHtml() ?: label
|
||||
DocumentationManagerUtil.createHyperlink(sb, label, linkText, true)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
/** Use [SOME_REFERENCED_VAL] to do something */
|
||||
fun fo<caret>o() {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
val SOME_REFERENCED_VAL = 1
|
||||
}
|
||||
}
|
||||
|
||||
//INFO: <b>public</b> <b>final</b> <b>fun</b> foo(): Unit <i>defined in</i> C<p>Use <a href="psi_element://SOME_REFERENCED_VAL">SOME_REFERENCED_VAL</a> to do something</p>
|
||||
+6
@@ -35,6 +35,12 @@ public class QuickDocProviderTestGenerated extends AbstractQuickDocProviderTest
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/editor/quickDoc"), Pattern.compile("^([^_]+)\\.[^\\.]*$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("AtConstantWithUnderscore.kt")
|
||||
public void testAtConstantWithUnderscore() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/quickDoc/AtConstantWithUnderscore.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AtFunctionParameter.kt")
|
||||
public void testAtFunctionParameter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/quickDoc/AtFunctionParameter.kt");
|
||||
|
||||
Reference in New Issue
Block a user