diff options
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/DocumentationModel.kt | 4 | ||||
-rw-r--r-- | src/Model/DocumentationResolver.kt | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/Model/DocumentationModel.kt b/src/Model/DocumentationModel.kt index 61c3b28a..77bd8373 100644 --- a/src/Model/DocumentationModel.kt +++ b/src/Model/DocumentationModel.kt @@ -53,6 +53,10 @@ public open class DocumentationNode(val name: String, val doc: String, val kind: } public fun references(kind: DocumentationReferenceKind): List<DocumentationReference> = references.filter { it.kind == kind } + + public override fun toString() : String { + return "$kind $name" + } } public class DocumentationModel : DocumentationNode("model", "", DocumentationNodeKind.Model) { diff --git a/src/Model/DocumentationResolver.kt b/src/Model/DocumentationResolver.kt index 70ee4aae..1d470867 100644 --- a/src/Model/DocumentationResolver.kt +++ b/src/Model/DocumentationResolver.kt @@ -1,6 +1,8 @@ package org.jetbrains.dokka import org.jetbrains.jet.lang.resolve.scopes.* +import org.jetbrains.jet.lang.resolve.name.* +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor fun DocumentationNode.resolve(): DocumentationNode { @@ -8,5 +10,18 @@ fun DocumentationNode.resolve(): DocumentationNode { } fun DocumentationNode.resolve(scope: JetScope): DocumentationNode { + for (detail in details) { + val symbol = when (detail.kind) { + DocumentationNodeKind.Receiver -> (scope.getContainingDeclaration() as FunctionDescriptor).getReceiverParameter() + DocumentationNodeKind.Parameter -> scope.getLocalVariable(Name.guess(detail.name)) + DocumentationNodeKind.Function -> scope.getFunctions(Name.guess(detail.name)).single() + DocumentationNodeKind.Property -> scope.getProperties(Name.guess(detail.name)).single() + DocumentationNodeKind.TypeParameter -> scope.getClassifier(Name.guess(detail.name)) + else -> scope.getClassifier(Name.guess(detail.name)) + } + + if (symbol == null) + throw IllegalStateException("Cannot resolve node $this detail $detail") + } return this }
\ No newline at end of file |