aboutsummaryrefslogtreecommitdiff
path: root/src/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model')
-rw-r--r--src/Model/DocumentationModel.kt3
-rw-r--r--src/Model/DocumentationResolver.kt33
2 files changed, 25 insertions, 11 deletions
diff --git a/src/Model/DocumentationModel.kt b/src/Model/DocumentationModel.kt
index 90fe40e4..c5dd6603 100644
--- a/src/Model/DocumentationModel.kt
+++ b/src/Model/DocumentationModel.kt
@@ -59,6 +59,7 @@ public open class DocumentationNode(val name: String,
}
public fun references(kind: DocumentationReferenceKind): List<DocumentationReference> = references.filter { it.kind == kind }
+ public fun allReferences(): List<DocumentationReference> = references
public override fun toString(): String {
return "$kind $name"
@@ -87,5 +88,7 @@ fun BindingContext.createDocumentationModel(file: JetFile): DocumentationModel {
val visitor = DocumentationNodeBuilder(this)
packageFragment.accept(DocumentationBuildingVisitor(this, visitor), model)
+ model.resolveAll()
+
return model
}
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