aboutsummaryrefslogtreecommitdiff
path: root/src/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model')
-rw-r--r--src/Model/DocumentationBuilder.kt4
-rw-r--r--src/Model/DocumentationBuildingVisitor.kt48
-rw-r--r--src/Model/DocumentationResolver.kt12
3 files changed, 37 insertions, 27 deletions
diff --git a/src/Model/DocumentationBuilder.kt b/src/Model/DocumentationBuilder.kt
index 464a5ab2..353e839e 100644
--- a/src/Model/DocumentationBuilder.kt
+++ b/src/Model/DocumentationBuilder.kt
@@ -6,13 +6,13 @@ import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.lang.descriptors.impl.*
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
-fun BindingContext.createSourceModel(file: JetFile): DocumentationModel {
+fun BindingContext.createDocumentationModel(file: JetFile): DocumentationModel {
val model = DocumentationModel()
val packageFragment = getPackageFragment(file)
if (packageFragment == null) throw IllegalArgumentException("File $file should have package fragment")
val visitor = DocumentationBuilderVisitor(this)
- visitDescriptor(packageFragment, model, visitor)
+ packageFragment.accept(DocumentationBuildingVisitor(this, visitor), model)
return model
}
diff --git a/src/Model/DocumentationBuildingVisitor.kt b/src/Model/DocumentationBuildingVisitor.kt
index e7b3fc09..81a6474c 100644
--- a/src/Model/DocumentationBuildingVisitor.kt
+++ b/src/Model/DocumentationBuildingVisitor.kt
@@ -1,9 +1,10 @@
package org.jetbrains.dokka
import org.jetbrains.jet.lang.descriptors.*
-import org.jetbrains.jet.lang.resolve.name.FqName
+import org.jetbrains.jet.lang.resolve.name.*
+import org.jetbrains.jet.lang.resolve.*
-class DocumentationBuildingVisitor(private val worker: DeclarationDescriptorVisitor<DocumentationNode, DocumentationNode>)
+class DocumentationBuildingVisitor(val context: BindingContext, private val worker: DeclarationDescriptorVisitor<DocumentationNode, DocumentationNode>)
: DeclarationDescriptorVisitor<DocumentationNode, DocumentationNode> {
private fun visitChildren(descriptors: Collection<DeclarationDescriptor>, data: DocumentationNode) {
@@ -27,19 +28,19 @@ class DocumentationBuildingVisitor(private val worker: DeclarationDescriptorVisi
visitChildren(descriptor.getTypeParameters(), node)
visitChild(descriptor.getReceiverParameter(), node)
visitChildren(descriptor.getValueParameters(), node)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
public override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = createDocumentation(descriptor!!, data!!)
visitChildren(descriptor.getMemberScope().getAllDescriptors(), node)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
public override fun visitPackageViewDescriptor(descriptor: PackageViewDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = createDocumentation(descriptor!!, data!!)
visitChildren(descriptor.getMemberScope().getAllDescriptors(), node)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
public override fun visitVariableDescriptor(descriptor: VariableDescriptor?, data: DocumentationNode?): DocumentationNode? {
@@ -56,12 +57,12 @@ class DocumentationBuildingVisitor(private val worker: DeclarationDescriptorVisi
public override fun visitFunctionDescriptor(descriptor: FunctionDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = processCallable(descriptor!!, data!!)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
public override fun visitTypeParameterDescriptor(descriptor: TypeParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = createDocumentation(descriptor!!, data!!)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
public override fun visitClassDescriptor(descriptor: ClassDescriptor?, data: DocumentationNode?): DocumentationNode? {
@@ -76,46 +77,43 @@ class DocumentationBuildingVisitor(private val worker: DeclarationDescriptorVisi
it !is CallableMemberDescriptor || it.isUserCode()
}
visitChildren(members, node)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
public override fun visitModuleDeclaration(descriptor: ModuleDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = createDocumentation(descriptor!!, data!!)
visitChild(descriptor.getPackage(FqName.ROOT), node)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
- public override fun visitConstructorDescriptor(constructorDescriptor: ConstructorDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitFunctionDescriptor(constructorDescriptor, data)
- return node
+ public override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor?, data: DocumentationNode?): DocumentationNode? {
+ val node = visitFunctionDescriptor(descriptor!!, data)
+ return node?.resolve(context.getResolutionScope(descriptor))
}
public override fun visitScriptDescriptor(scriptDescriptor: ScriptDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitClassDescriptor(scriptDescriptor!!.getClassDescriptor(), data)
- return node
+ val classDescriptor = scriptDescriptor!!.getClassDescriptor()
+ val node = visitClassDescriptor(classDescriptor, data)
+ return node?.resolve(context.getResolutionScope(classDescriptor))
}
public override fun visitValueParameterDescriptor(descriptor: ValueParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitVariableDescriptor(descriptor, data)
- return node
+ val node = visitVariableDescriptor(descriptor!!, data)
+ return node?.resolve(context.getResolutionScope(descriptor))
}
public override fun visitPropertyGetterDescriptor(descriptor: PropertyGetterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitFunctionDescriptor(descriptor, data)
- return node
+ val node = visitFunctionDescriptor(descriptor!!, data)
+ return node?.resolve(context.getResolutionScope(descriptor))
}
public override fun visitPropertySetterDescriptor(descriptor: PropertySetterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitFunctionDescriptor(descriptor, data)
- return node
+ val node = visitFunctionDescriptor(descriptor!!, data)
+ return node?.resolve(context.getResolutionScope(descriptor))
}
public override fun visitReceiverParameterDescriptor(descriptor: ReceiverParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = createDocumentation(descriptor!!, data!!)
- return node
+ return node.resolve(context.getResolutionScope(descriptor))
}
}
-
-public fun visitDescriptor(descriptor: DeclarationDescriptor, data: DocumentationNode, visitor: DeclarationDescriptorVisitor<DocumentationNode, DocumentationNode>): DocumentationNode {
- return descriptor.accept(DocumentationBuildingVisitor(visitor), data)
-}
diff --git a/src/Model/DocumentationResolver.kt b/src/Model/DocumentationResolver.kt
new file mode 100644
index 00000000..70ee4aae
--- /dev/null
+++ b/src/Model/DocumentationResolver.kt
@@ -0,0 +1,12 @@
+package org.jetbrains.dokka
+
+import org.jetbrains.jet.lang.resolve.scopes.*
+
+
+fun DocumentationNode.resolve(): DocumentationNode {
+ return this
+}
+
+fun DocumentationNode.resolve(scope: JetScope): DocumentationNode {
+ return this
+} \ No newline at end of file