From 08e690021ce2df402134ea5cebd769183499c771 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Mon, 14 Jul 2014 15:44:32 +0400 Subject: Migrate to PackageView processing to unify all package fragments into single item. --- src/Model/DocumentationModule.kt | 14 ++++++-------- src/Model/DocumentationNodeBuilder.kt | 6 ++++++ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/Model') diff --git a/src/Model/DocumentationModule.kt b/src/Model/DocumentationModule.kt index 1f30268e..6b2773ed 100644 --- a/src/Model/DocumentationModule.kt +++ b/src/Model/DocumentationModule.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka import org.jetbrains.jet.lang.resolve.BindingContext -import org.jetbrains.jet.lang.psi.JetFile import org.jetbrains.jet.lang.descriptors.* +import org.jetbrains.jet.lang.resolve.name.FqName public class DocumentationModule(val module: ModuleDescriptor) : DocumentationNode(module, "module", DocumentationContent.Empty, DocumentationNode.Kind.Module) { fun merge(other: DocumentationModule): DocumentationModule { @@ -13,15 +13,13 @@ public class DocumentationModule(val module: ModuleDescriptor) : DocumentationNo } } -fun BindingContext.createDocumentationModule(module: ModuleDescriptor, file: JetFile): DocumentationModule { - val packageFragment = getPackageFragment(file) +fun BindingContext.createDocumentationModule(module: ModuleDescriptor, packages: Set): DocumentationModule { val documentationModule = DocumentationModule(module) - if (packageFragment == null) throw IllegalArgumentException("File $file should have package fragment") - val visitor = DocumentationNodeBuilder(this) - packageFragment.accept(DocumentationBuildingVisitor(this, visitor), documentationModule) - + for (packageName in packages) { + val pkg = module.getPackage(packageName) + pkg!!.accept(DocumentationBuildingVisitor(this, visitor), documentationModule) + } checkResolveChildren(documentationModule) - return documentationModule } diff --git a/src/Model/DocumentationNodeBuilder.kt b/src/Model/DocumentationNodeBuilder.kt index f974ab11..8d75a45c 100644 --- a/src/Model/DocumentationNodeBuilder.kt +++ b/src/Model/DocumentationNodeBuilder.kt @@ -130,6 +130,12 @@ class DocumentationNodeBuilder(val context: BindingContext) : DeclarationDescrip return node } + override fun visitPackageViewDescriptor(descriptor: PackageViewDescriptor?, data: DocumentationNode?): DocumentationNode? { + val node = DocumentationNode(descriptor!!, descriptor.getFqName().asString(), DocumentationContent.Empty, DocumentationNode.Kind.Package) + reference(data!!, node, DocumentationReference.Kind.Member) + return node + } + override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor?, data: DocumentationNode?): DocumentationNode? { val node = DocumentationNode(descriptor!!, descriptor.fqName.asString(), DocumentationContent.Empty, DocumentationNode.Kind.Package) reference(data!!, node, DocumentationReference.Kind.Member) -- cgit