diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 23:47:29 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 23:47:29 +0400 |
commit | 1fc5f504c77e98f80c7f6921e26ca7c9463c8bf3 (patch) | |
tree | 3b55cb9949db0e432051401ba76526494ef95c1a /src/Model/DocumentationBuildingVisitor.kt | |
parent | cec0fc9f3eaa5df8fc2654ce90d87b9be48b16c0 (diff) | |
download | dokka-1fc5f504c77e98f80c7f6921e26ca7c9463c8bf3.tar.gz dokka-1fc5f504c77e98f80c7f6921e26ca7c9463c8bf3.tar.bz2 dokka-1fc5f504c77e98f80c7f6921e26ca7c9463c8bf3.zip |
Create resolution scopes for all entities to resolve names inside doc-comments.
Diffstat (limited to 'src/Model/DocumentationBuildingVisitor.kt')
-rw-r--r-- | src/Model/DocumentationBuildingVisitor.kt | 48 |
1 files changed, 23 insertions, 25 deletions
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) -} |