aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin/DocumentationBuilder.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-05 16:53:40 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-05 16:53:40 +0100
commit4ed5b2ec786b0f67405e5db81be2a2d9f4b6e591 (patch)
tree8e7907f3d0739cfbf841000f87496185aaefb52c /src/Kotlin/DocumentationBuilder.kt
parentda1b31b03bc70bf6feb1111e68e5ffd032a6d82c (diff)
downloaddokka-4ed5b2ec786b0f67405e5db81be2a2d9f4b6e591.tar.gz
dokka-4ed5b2ec786b0f67405e5db81be2a2d9f4b6e591.tar.bz2
dokka-4ed5b2ec786b0f67405e5db81be2a2d9f4b6e591.zip
use code from Kotlin plugin for resolving references in KDoc; delete some dead code
Diffstat (limited to 'src/Kotlin/DocumentationBuilder.kt')
-rw-r--r--src/Kotlin/DocumentationBuilder.kt31
1 files changed, 5 insertions, 26 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 976626db..041b7617 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.kdoc.findKDoc
import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
+import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
public data class DocumentationOptions(val includeNonPublic: Boolean = false,
val sourceLinks: List<SourceLinkDefinition>)
@@ -542,11 +543,11 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
private fun resolveContentLink(node: DocumentationNode, content: ContentNode): ContentNode {
if (content is ContentExternalLink) {
val referenceText = content.href
- val symbol = resolveReference(getResolutionScope(node), referenceText)
+ val symbols = resolveKDocLink(session, getResolutionScope(node), null, referenceText.split('.').toList())
// don't include unresolved links in generated doc
// assume that if an href doesn't contain '/', it's not an attempt to reference an external file
- if (symbol != null || "/" !in referenceText) {
- val targetNode = descriptorToNode[symbol]
+ if (symbols.isNotEmpty() || "/" !in referenceText) {
+ val targetNode = if (symbols.isEmpty()) null else descriptorToNode[symbols.first()]
val contentLink = if (targetNode != null) ContentNodeLink(targetNode) else ContentExternalLink("#")
contentLink.children.addAll(content.children.map { resolveContentLink(node, it) })
return contentLink
@@ -555,26 +556,4 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
resolveContentLinks(node, content)
return content
}
-
- private fun resolveReference(context: DeclarationDescriptor, reference: String): DeclarationDescriptor? {
- if (Name.isValidIdentifier(reference)) {
- val scope = getResolutionScope(context)
- val symbolName = Name.guess(reference)
- return scope.getLocalVariable(symbolName) ?:
- scope.getProperties(symbolName).firstOrNull() ?:
- scope.getFunctions(symbolName).firstOrNull() ?:
- scope.getClassifier(symbolName)
-
- }
-
- if ("." !in reference)
- return null
-
- val names = reference.split('.')
- val result = names.fold<String, DeclarationDescriptor?>(context) {(nextContext, name) ->
- nextContext?.let { resolveReference(it, name) }
- }
-
- return result
- }
-} \ No newline at end of file
+}