aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-27 17:14:21 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-27 17:14:21 +0100
commit6af51fdd6ee41cee6b5a7fd5714b80ad4b077a42 (patch)
tree166d9a3c7428f18be2b299909bc22972e38eb76a
parent8a65a7ab62e4567bbb20cececcad88eb9ac396d9 (diff)
downloaddokka-6af51fdd6ee41cee6b5a7fd5714b80ad4b077a42.tar.gz
dokka-6af51fdd6ee41cee6b5a7fd5714b80ad4b077a42.tar.bz2
dokka-6af51fdd6ee41cee6b5a7fd5714b80ad4b077a42.zip
fix link resolution with other variants of the javadoc PSI structure
-rw-r--r--src/Java/JavaDocumentationBuilder.kt21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index 055d64d3..bb2fb639 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -104,9 +104,13 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
}
private fun MutableContent.convertSeeTag(tag: PsiDocTag) {
+ val linkElement = tag.linkElement()
+ if (linkElement == null) {
+ return
+ }
val seeSection = findSectionByTag("See Also") ?: addSection("See Also", null)
- val linkSignature = resolveLink(tag.getValueElement())
- val text = ContentText(tag.getValueElement()!!.getText())
+ val linkSignature = resolveLink(linkElement)
+ val text = ContentText(linkElement.getText())
if (linkSignature != null) {
val linkNode = ContentNodeLazyLink(tag.getValueElement()!!.getText(), {() -> refGraph.lookup(linkSignature)})
linkNode.append(text)
@@ -118,14 +122,16 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
private fun convertInlineDocTag(tag: PsiInlineDocTag) = when (tag.getName()) {
"link", "linkplain" -> {
- val valueElement = tag.getValueElement()
+ val valueElement = tag.linkElement()
val linkSignature = resolveLink(valueElement)
if (linkSignature != null) {
val link = "<a href=\"##$linkSignature\">${valueElement!!.getText().htmlEscape()}</a>"
if (tag.getName() == "link") "<code>$link</code>" else link
}
- else {
- valueElement!!.getText()
+ else if (valueElement != null) {
+ valueElement.getText()
+ } else {
+ ""
}
}
"code", "literal" -> {
@@ -137,7 +143,10 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
else -> tag.getText()
}
- private fun resolveLink(valueElement: PsiDocTagValue?): String? {
+ private fun PsiDocTag.linkElement(): PsiElement? =
+ getValueElement() ?: getDataElements().firstOrNull { it !is PsiWhiteSpace }
+
+ private fun resolveLink(valueElement: PsiElement?): String? {
val target = valueElement?.getReference()?.resolve()
if (target != null) {
return getSignature(target)