diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-25 19:03:51 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-25 19:03:51 +0100 |
commit | 184a24c93e0939c5a9ceb10cf3c3992f11165219 (patch) | |
tree | f4334b51d9f2bc021d5af55aca3e0be9e8ceec37 /src/Kotlin | |
parent | 29e48dcbf30ac16013d9c8951e4fa088e8d9b016 (diff) | |
download | dokka-184a24c93e0939c5a9ceb10cf3c3992f11165219.tar.gz dokka-184a24c93e0939c5a9ceb10cf3c3992f11165219.tar.bz2 dokka-184a24c93e0939c5a9ceb10cf3c3992f11165219.zip |
resolve references through single map from signature to DocumentationNode (enables cross-language references)
Diffstat (limited to 'src/Kotlin')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index b620a4f9..693f2675 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -35,10 +35,9 @@ private fun isSamePackage(descriptor1: DeclarationDescriptor, descriptor2: Decla class DocumentationBuilder(val session: ResolveSession, val options: DocumentationOptions, - val pendingReferences: MutableList<PendingDocumentationReference>, + val refGraph: NodeReferenceGraph, val logger: DokkaLogger) { val visibleToDocumentation = setOf(Visibilities.INTERNAL, Visibilities.PROTECTED, Visibilities.PUBLIC) - val descriptorToNode = hashMapOf<String, DocumentationNode>() fun parseDocumentation(descriptor: DeclarationDescriptor): Content { val kdoc = KDocFinder.findKDoc(descriptor) @@ -106,7 +105,7 @@ class DocumentationBuilder(val session: ResolveSession, // assume that if an href doesn't contain '/', it's not an attempt to reference an external file if (symbols.isNotEmpty()) { val symbol = symbols.first() - return ContentNodeLazyLink(href, {() -> descriptorToNode[symbol.signature()] }) + return ContentNodeLazyLink(href, {() -> refGraph.lookup(symbol.signature()) }) } if ("/" in href) { return ContentExternalLink(href) @@ -129,23 +128,17 @@ class DocumentationBuilder(val session: ResolveSession, } fun link(node: DocumentationNode, descriptor: DeclarationDescriptor) { - pendingReferences.add(PendingDocumentationReference( - {() -> node}, - {() -> descriptorToNode[descriptor.signature()]}, - DocumentationReference.Kind.Link)) + refGraph.link(node, descriptor.signature(), DocumentationReference.Kind.Link) } fun link(fromDescriptor: DeclarationDescriptor?, toDescriptor: DeclarationDescriptor?, kind: DocumentationReference.Kind) { if (fromDescriptor != null && toDescriptor != null) { - pendingReferences.add(PendingDocumentationReference( - {() -> descriptorToNode[fromDescriptor.signature()]}, - {() -> descriptorToNode[toDescriptor.signature()]}, - kind)) + refGraph.link(fromDescriptor.signature(), toDescriptor.signature(), kind) } } fun register(descriptor: DeclarationDescriptor, node: DocumentationNode) { - descriptorToNode.put(descriptor.signature(), node) + refGraph.register(descriptor.signature(), node) } fun DocumentationNode<T>(descriptor: T, kind: Kind): DocumentationNode where T : DeclarationDescriptor, T : Named { |