aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Model
diff options
context:
space:
mode:
authoraleksZubakov <aleks.zubakov@gmail.com>2018-08-06 13:42:44 +0300
committeraleksZubakov <aleks.zubakov@gmail.com>2018-08-06 13:42:44 +0300
commit77ce80517f79a774ef985be47ae00db828e34273 (patch)
tree3e2998d3e54a8c7e3c8335c72eeaa037b279acdd /core/src/main/kotlin/Model
parentba09711a1ecbdaede86cab9e76d13ff1047f89b2 (diff)
downloaddokka-77ce80517f79a774ef985be47ae00db828e34273.tar.gz
dokka-77ce80517f79a774ef985be47ae00db828e34273.tar.bz2
dokka-77ce80517f79a774ef985be47ae00db828e34273.zip
DocumentationMerger refactoring
Diffstat (limited to 'core/src/main/kotlin/Model')
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt1
-rw-r--r--core/src/main/kotlin/Model/DocumentationReference.kt26
2 files changed, 13 insertions, 14 deletions
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index bdb7cf20..23137364 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -163,7 +163,6 @@ open class DocumentationNode(val name: String,
fun member(kind: NodeKind): DocumentationNode = members.filter { it.kind == kind }.single()
fun link(kind: NodeKind): DocumentationNode = links.filter { it.kind == kind }.single()
- fun anyReference(predicate: (DocumentationReference) -> Boolean): Boolean = references.any(predicate)
fun references(kind: RefKind): List<DocumentationReference> = references.filter { it.kind == kind }
fun allReferences(): Set<DocumentationReference> = references
diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt
index 9223c17a..282d87d8 100644
--- a/core/src/main/kotlin/Model/DocumentationReference.kt
+++ b/core/src/main/kotlin/Model/DocumentationReference.kt
@@ -26,15 +26,15 @@ data class DocumentationReference(val from: DocumentationNode, val to: Documenta
}
sealed class NodeResolver {
- abstract fun resolve(): DocumentationNode?
- class BySignature(var signature: String, var nodeMap: Map<String, DocumentationNode>) : NodeResolver() {
- override fun resolve(): DocumentationNode? {
- return nodeMap[signature]
+ abstract fun resolve(nodeRephGraph: NodeReferenceGraph): DocumentationNode?
+ class BySignature(var signature: String) : NodeResolver() {
+ override fun resolve(nodeRephGraph: NodeReferenceGraph): DocumentationNode? {
+ return nodeRephGraph.lookup(signature)
}
}
class Exact(var exactNode: DocumentationNode?) : NodeResolver() {
- override fun resolve(): DocumentationNode? {
+ override fun resolve(nodeRephGraph: NodeReferenceGraph): DocumentationNode? {
return exactNode
}
}
@@ -43,9 +43,9 @@ sealed class NodeResolver {
class PendingDocumentationReference(val lazyNodeFrom: NodeResolver,
val lazyNodeTo: NodeResolver,
val kind: RefKind) {
- fun resolve() {
- val fromNode = lazyNodeFrom.resolve()
- val toNode = lazyNodeTo.resolve()
+ fun resolve(nodeRephGraph: NodeReferenceGraph) {
+ val fromNode = lazyNodeFrom.resolve(nodeRephGraph)
+ val toNode = lazyNodeTo.resolve(nodeRephGraph)
if (fromNode != null && toNode != null) {
fromNode.addReferenceTo(toNode, kind)
}
@@ -67,7 +67,7 @@ class NodeReferenceGraph {
references.add(
PendingDocumentationReference(
NodeResolver.Exact(fromNode),
- NodeResolver.BySignature(toSignature, nodeMap),
+ NodeResolver.BySignature(toSignature),
kind
))
}
@@ -75,7 +75,7 @@ class NodeReferenceGraph {
fun link(fromSignature: String, toNode: DocumentationNode, kind: RefKind) {
references.add(
PendingDocumentationReference(
- NodeResolver.BySignature(fromSignature, nodeMap),
+ NodeResolver.BySignature(fromSignature),
NodeResolver.Exact(toNode),
kind
)
@@ -85,8 +85,8 @@ class NodeReferenceGraph {
fun link(fromSignature: String, toSignature: String, kind: RefKind) {
references.add(
PendingDocumentationReference(
- NodeResolver.BySignature(fromSignature, nodeMap),
- NodeResolver.BySignature(toSignature, nodeMap),
+ NodeResolver.BySignature(fromSignature),
+ NodeResolver.BySignature(toSignature),
kind
)
)
@@ -107,7 +107,7 @@ class NodeReferenceGraph {
}
fun resolveReferences() {
- references.forEach { it.resolve() }
+ references.forEach { it.resolve(this) }
}
}