diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-20 17:12:57 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-20 17:12:57 +0100 |
commit | 6620764c5f18c87933369131602b24bd2fa490e8 (patch) | |
tree | dd7045487ac5fabe78574a4b41eb49cc2e58f395 /src/Kotlin | |
parent | bfe53b9ea3359baee1785c2f6291bb5408597e28 (diff) | |
download | dokka-6620764c5f18c87933369131602b24bd2fa490e8.tar.gz dokka-6620764c5f18c87933369131602b24bd2fa490e8.tar.bz2 dokka-6620764c5f18c87933369131602b24bd2fa490e8.zip |
pending references logic moved from DocumentationBuilder to model
Diffstat (limited to 'src/Kotlin')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 5d9857a7..dae1c4ea 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -33,14 +33,12 @@ private fun isSamePackage(descriptor1: DeclarationDescriptor, descriptor2: Decla return package1 != null && package2 != null && package1.fqName == package2.fqName } -class PendingLink(val lazyNodeFrom: () -> DocumentationNode?, - val lazyNodeTo: () -> DocumentationNode?, - val kind: DocumentationReference.Kind) - -class DocumentationBuilder(val session: ResolveSession, val options: DocumentationOptions, val logger: DokkaLogger) { +class DocumentationBuilder(val session: ResolveSession, + val options: DocumentationOptions, + val pendingReferences: MutableList<PendingDocumentationReference>, + val logger: DokkaLogger) { val visibleToDocumentation = setOf(Visibilities.INTERNAL, Visibilities.PROTECTED, Visibilities.PUBLIC) val descriptorToNode = hashMapOf<DeclarationDescriptor, DocumentationNode>() - val links = arrayListOf<PendingLink>() fun parseDocumentation(descriptor: DeclarationDescriptor): Content { val kdoc = KDocFinder.findKDoc(descriptor) @@ -104,12 +102,18 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati } fun link(node: DocumentationNode, descriptor: DeclarationDescriptor) { - links.add(PendingLink({() -> node}, {() -> descriptorToNode[descriptor]}, DocumentationReference.Kind.Link)) + pendingReferences.add(PendingDocumentationReference( + {() -> node}, + {() -> descriptorToNode[descriptor]}, + DocumentationReference.Kind.Link)) } fun link(fromDescriptor: DeclarationDescriptor?, toDescriptor: DeclarationDescriptor?, kind: DocumentationReference.Kind) { if (fromDescriptor != null && toDescriptor != null) { - links.add(PendingLink({() -> descriptorToNode[fromDescriptor]}, {() -> descriptorToNode[toDescriptor]}, kind)) + pendingReferences.add(PendingDocumentationReference( + {() -> descriptorToNode[fromDescriptor]}, + {() -> descriptorToNode[toDescriptor]}, + kind)) } } @@ -489,20 +493,4 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati } return if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null } - - /** - * Generates cross-references for documentation such as extensions for a type, inheritors, etc - * - * $receiver: [DocumentationContext] for node/descriptor resolutions - * $node: [DocumentationNode] to visit - */ - public fun resolveReferences() { - for (link in links) { - val fromNode = link.lazyNodeFrom() - val toNode = link.lazyNodeTo() - if (fromNode != null && toNode != null) { - fromNode.addReferenceTo(toNode, link.kind) - } - } - } } |