aboutsummaryrefslogtreecommitdiff
path: root/src/Model/DocumentationResolver.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/DocumentationResolver.kt')
-rw-r--r--src/Model/DocumentationResolver.kt33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/Model/DocumentationResolver.kt b/src/Model/DocumentationResolver.kt
index dee68f49..40968f4f 100644
--- a/src/Model/DocumentationResolver.kt
+++ b/src/Model/DocumentationResolver.kt
@@ -1,23 +1,34 @@
package org.jetbrains.dokka
-import org.jetbrains.jet.lang.resolve.scopes.*
import org.jetbrains.jet.lang.resolve.name.*
import org.jetbrains.jet.lang.descriptors.*
-fun DocumentationNode.resolve(): DocumentationNode {
- for (detail in details) {
- val symbol: DeclarationDescriptor? = when (detail.kind) {
+fun DocumentationNode.resolve() {
+ for (item in details + members) {
+ val symbolName = item.name
+ val symbol: DeclarationDescriptor? = when (item.kind) {
DocumentationNodeKind.Receiver -> (scope.getContainingDeclaration() as FunctionDescriptor).getReceiverParameter()
- DocumentationNodeKind.Parameter -> scope.getLocalVariable(Name.guess(detail.name))
- DocumentationNodeKind.Function -> scope.getFunctions(Name.guess(detail.name)).firstOrNull()
- DocumentationNodeKind.Property -> scope.getProperties(Name.guess(detail.name)).firstOrNull()
- DocumentationNodeKind.TypeParameter -> scope.getClassifier(Name.guess(detail.name))
- else -> scope.getClassifier(Name.guess(detail.name))
+ DocumentationNodeKind.Parameter -> scope.getLocalVariable(Name.guess(symbolName))
+ DocumentationNodeKind.Function -> scope.getFunctions(Name.guess(symbolName)).firstOrNull()
+ DocumentationNodeKind.Property -> scope.getProperties(Name.guess(symbolName)).firstOrNull()
+ DocumentationNodeKind.Constructor -> scope.getFunctions(Name.guess(symbolName)).firstOrNull()
+
+ DocumentationNodeKind.Package -> {
+ // TODO: do not resolve constructors and packages for now
+ item.scope.getContainingDeclaration()
+ }
+ else -> scope.getClassifier(Name.guess(symbolName))
}
if (symbol == null)
- throw IllegalStateException("Cannot resolve node $this detail $detail")
+ throw IllegalStateException("Cannot resolve $item in $this")
+ }
+
+ for (reference in allReferences().filterNot { it.kind == DocumentationReferenceKind.Owner }) {
+ reference.to.resolve()
}
- return this
}
+fun DocumentationModel.resolveAll() {
+ resolve()
+} \ No newline at end of file