aboutsummaryrefslogtreecommitdiff
path: root/src/Model
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 00:28:14 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 00:28:14 +0400
commit2f4e56d77ac72c3f47cd2799094b1b987b0d9522 (patch)
tree3f56b086efcc52de26a4c59f3ec0bd4239cb2bf8 /src/Model
parent1fc5f504c77e98f80c7f6921e26ca7c9463c8bf3 (diff)
downloaddokka-2f4e56d77ac72c3f47cd2799094b1b987b0d9522.tar.gz
dokka-2f4e56d77ac72c3f47cd2799094b1b987b0d9522.tar.bz2
dokka-2f4e56d77ac72c3f47cd2799094b1b987b0d9522.zip
Implement symbol resolution for function body context, class type parameters, add code that checks that all details are resolved.
Diffstat (limited to 'src/Model')
-rw-r--r--src/Model/DocumentationModel.kt4
-rw-r--r--src/Model/DocumentationResolver.kt15
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