aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin/ResolveReferences.kt
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-10-03 23:41:16 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-10-03 23:41:16 +0400
commit10068c5b31a2e3df746638da8c440d325a32f67d (patch)
tree9f70d1ddd4d298ded93152f25ab545749b02fa2b /src/Kotlin/ResolveReferences.kt
parent04135d13e4f1fc41893767b8719e9189cd41617a (diff)
downloaddokka-10068c5b31a2e3df746638da8c440d325a32f67d.tar.gz
dokka-10068c5b31a2e3df746638da8c440d325a32f67d.tar.bz2
dokka-10068c5b31a2e3df746638da8c440d325a32f67d.zip
Unify link resolution for short and full forms, remove ContentNameLink.
Diffstat (limited to 'src/Kotlin/ResolveReferences.kt')
-rw-r--r--src/Kotlin/ResolveReferences.kt30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/Kotlin/ResolveReferences.kt b/src/Kotlin/ResolveReferences.kt
index b14d3718..1349c69e 100644
--- a/src/Kotlin/ResolveReferences.kt
+++ b/src/Kotlin/ResolveReferences.kt
@@ -49,33 +49,27 @@ public fun DocumentationContext.resolveReferences(node: DocumentationNode) {
fun DocumentationContext.resolveContentLinks(node: DocumentationNode, content: ContentNode) {
val snapshot = content.children.toList()
for (child in snapshot) {
- val referenceText = when (child) {
- is ContentExternalLink -> child.href
- is ContentNameLink -> child.name
- else -> null
- }
+ if (child is ContentExternalLink) {
+ val referenceText = child.href
+ if (Name.isValidIdentifier(referenceText)) {
+ val scope = getResolutionScope(node)
+ val symbolName = Name.guess(referenceText)
+ val symbol = scope.getLocalVariable(symbolName) ?:
+ scope.getProperties(symbolName).firstOrNull() ?:
+ scope.getFunctions(symbolName).firstOrNull() ?:
+ scope.getClassifier(symbolName)
- if (referenceText != null && Name.isValidIdentifier(referenceText)) {
- val scope = getResolutionScope(node)
- val symbolName = Name.guess(referenceText)
- val symbol =
- scope.getLocalVariable(symbolName) ?:
- scope.getProperties(symbolName).firstOrNull() ?:
- scope.getFunctions(symbolName).firstOrNull() ?:
- scope.getClassifier(symbolName)
+ if (symbol != null) {
+ val targetNode = descriptorToNode[symbol]
+ val contentLink = if (targetNode != null) ContentNodeLink(targetNode) else ContentExternalLink("#")
- if (symbol != null) {
- val targetNode = descriptorToNode[symbol]
- if (targetNode != null) {
val index = content.children.indexOf(child)
content.children.remove(index)
- val contentLink = ContentNodeLink(targetNode)
contentLink.children.addAll(child.children)
content.children.add(index, contentLink)
}
}
}
-
resolveContentLinks(node, child)
}
} \ No newline at end of file