aboutsummaryrefslogtreecommitdiff
path: root/src/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model')
-rw-r--r--src/Model/DocumentationModule.kt2
-rw-r--r--src/Model/DocumentationNode.kt13
2 files changed, 12 insertions, 3 deletions
diff --git a/src/Model/DocumentationModule.kt b/src/Model/DocumentationModule.kt
index 25cbb600..1f30268e 100644
--- a/src/Model/DocumentationModule.kt
+++ b/src/Model/DocumentationModule.kt
@@ -4,7 +4,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.descriptors.*
-public class DocumentationModule(val module: ModuleDescriptor) : DocumentationNode(module, "model", DocumentationContent.Empty, DocumentationNode.Kind.Module) {
+public class DocumentationModule(val module: ModuleDescriptor) : DocumentationNode(module, "module", DocumentationContent.Empty, DocumentationNode.Kind.Module) {
fun merge(other: DocumentationModule): DocumentationModule {
val model = DocumentationModule(module)
model.addAllReferencesFrom(other)
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
index f095e8b0..da0f27e5 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka
import org.jetbrains.jet.lang.descriptors.*
+import java.util.LinkedHashSet
public open class DocumentationNode(val descriptor: DeclarationDescriptor,
@@ -8,7 +9,7 @@ public open class DocumentationNode(val descriptor: DeclarationDescriptor,
val doc: DocumentationContent,
val kind: DocumentationNode.Kind) {
- private val references = arrayListOf<DocumentationReference>()
+ private val references = LinkedHashSet<DocumentationReference>()
public val owner: DocumentationNode?
get() = references(DocumentationReference.Kind.Owner).firstOrNull()?.to // TODO: should be singleOrNull, but bugz!
@@ -28,8 +29,16 @@ public open class DocumentationNode(val descriptor: DeclarationDescriptor,
references.addAll(other.references)
}
+ public fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind }
+ public fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind }
+ public fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind }
+
+ public fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single()
+ public fun member(kind: DocumentationNode.Kind): DocumentationNode = members.filter { it.kind == kind }.single()
+ public fun link(kind: DocumentationNode.Kind): DocumentationNode = links.filter { it.kind == kind }.single()
+
public fun references(kind: DocumentationReference.Kind): List<DocumentationReference> = references.filter { it.kind == kind }
- public fun allReferences(): List<DocumentationReference> = references
+ public fun allReferences(): Set<DocumentationReference> = references
public override fun toString(): String {
return "$kind:$name"