aboutsummaryrefslogtreecommitdiff
path: root/src/Model
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 01:49:53 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 01:49:53 +0400
commit992bf22a5e2209e8305ce86255518c4dd918894d (patch)
tree5bd47f7c1d465bd83aa8e5e68df31dbb804ac540 /src/Model
parenta5999ec90d77e6fe1f8ce292e0b570588eba9f73 (diff)
downloaddokka-992bf22a5e2209e8305ce86255518c4dd918894d.tar.gz
dokka-992bf22a5e2209e8305ce86255518c4dd918894d.tar.bz2
dokka-992bf22a5e2209e8305ce86255518c4dd918894d.zip
Resolve all the referenced node, except owners.
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