diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-11-16 19:45:45 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-11-16 19:46:09 +0100 |
commit | 64946eac93632e615a48a72ab1bcb7d4978b6edf (patch) | |
tree | 17ed367e99dfa4ae3f4535030e37b2567bc75f97 /src | |
parent | 53f6584797ea8898df937be0835e274a10a12f28 (diff) | |
download | dokka-64946eac93632e615a48a72ab1bcb7d4978b6edf.tar.gz dokka-64946eac93632e615a48a72ab1bcb7d4978b6edf.tar.bz2 dokka-64946eac93632e615a48a72ab1bcb7d4978b6edf.zip |
update to Kotlin beta 2
Diffstat (limited to 'src')
-rw-r--r-- | src/Analysis/AnalysisEnvironment.kt | 2 | ||||
-rw-r--r-- | src/Kotlin/DescriptorDocumentationParser.kt | 21 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 31 | ||||
-rw-r--r-- | src/Kotlin/KotlinAsJavaDocumentationBuilder.kt | 8 |
4 files changed, 34 insertions, 28 deletions
diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt index 11bd7ac4..a5e35a0e 100644 --- a/src/Analysis/AnalysisEnvironment.kt +++ b/src/Analysis/AnalysisEnvironment.kt @@ -170,7 +170,7 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector) : Dispo public fun contentRootFromPath(path: String): ContentRoot { val file = File(path) - return if (file.extension == "java") JavaSourceRoot(file) else KotlinSourceRoot(path) + return if (file.extension == "java") JavaSourceRoot(file, null) else KotlinSourceRoot(path) } diff --git a/src/Kotlin/DescriptorDocumentationParser.kt b/src/Kotlin/DescriptorDocumentationParser.kt index 76bad31e..b7705ec9 100644 --- a/src/Kotlin/DescriptorDocumentationParser.kt +++ b/src/Kotlin/DescriptorDocumentationParser.kt @@ -19,8 +19,9 @@ import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.scopes.KtScope -import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope +import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import org.jetbrains.kotlin.resolve.scopes.ResolutionScope +import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.source.PsiSourceElement class DescriptorDocumentationParser @@ -90,9 +91,11 @@ class DescriptorDocumentationParser } if (DescriptorUtils.getFqName(deepestDescriptor.containingDeclaration).asString() == "kotlin.Any") { val anyClassDescriptors = resolutionFacade.resolveSession.getTopLevelClassDescriptors( - FqName.fromSegments(listOf("kotlin", "Any")), NoLookupLocation.UNSORTED) + FqName.fromSegments(listOf("kotlin", "Any")), NoLookupLocation.FROM_IDE) anyClassDescriptors.forEach { - val anyMethod = it.getMemberScope(listOf()).getFunctions(descriptor.name, NoLookupLocation.UNSORTED).single() + val anyMethod = it.getMemberScope(listOf()) + .getDescriptorsFiltered(DescriptorKindFilter.FUNCTIONS, { it == descriptor.name }) + .single() val kdoc = KDocFinder.findKDoc(anyMethod) if (kdoc != null) { return kdoc @@ -136,7 +139,7 @@ class DescriptorDocumentationParser logger.warn("Missing function name in @sample in ${descriptor.signature()}") return ContentBlockCode().let() { it.append(ContentText("Missing function name in @sample")); it } } - val scope = getResolutionScope(resolutionFacade, descriptor).asJetScope() + val scope = getResolutionScope(resolutionFacade, descriptor) val rootPackage = resolutionFacade.moduleDescriptor.getPackage(FqName.ROOT) val rootScope = rootPackage.memberScope val symbol = resolveInScope(functionName, scope) ?: resolveInScope(functionName, rootScope) @@ -167,7 +170,7 @@ class DescriptorDocumentationParser return ContentBlockCode("kotlin").let() { it.append(ContentText(finalText)); it } } - private fun resolveInScope(functionName: String, scope: KtScope): DeclarationDescriptor? { + private fun resolveInScope(functionName: String, scope: ResolutionScope): DeclarationDescriptor? { var currentScope = scope val parts = functionName.split('.') @@ -176,7 +179,9 @@ class DescriptorDocumentationParser for (part in parts) { // short name val symbolName = Name.guess(part) - val partSymbol = currentScope.getAllDescriptors().filter { it.name == symbolName }.firstOrNull() + val partSymbol = currentScope.getContributedDescriptors(DescriptorKindFilter.ALL, { it == symbolName }) + .filter { it.name == symbolName } + .firstOrNull() if (partSymbol == null) { symbol = null @@ -185,7 +190,7 @@ class DescriptorDocumentationParser currentScope = if (partSymbol is ClassDescriptor) partSymbol.defaultType.memberScope else - getResolutionScope(resolutionFacade, partSymbol).asJetScope() + getResolutionScope(resolutionFacade, partSymbol) symbol = partSymbol } diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 97f2462b..f45da4fe 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjection public data class DocumentationOptions(val outputDir: String, @@ -130,7 +130,7 @@ class DocumentationBuilder } } - private fun ignoreSupertype(superType: KtType): Boolean { + private fun ignoreSupertype(superType: KotlinType): Boolean { val superClass = superType.constructor.declarationDescriptor as? ClassDescriptor if (superClass != null) { val fqName = DescriptorUtils.getFqNameSafe(superClass).asString() @@ -148,10 +148,10 @@ class DocumentationBuilder } } - fun DocumentationNode.appendType(jetType: KtType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") { - if (jetType == null) + fun DocumentationNode.appendType(kotlinType: KotlinType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") { + if (kotlinType == null) return - val classifierDescriptor = jetType.constructor.declarationDescriptor + val classifierDescriptor = kotlinType.constructor.declarationDescriptor val name = when (classifierDescriptor) { is ClassDescriptor -> { if (classifierDescriptor.isCompanionObject) { @@ -169,7 +169,7 @@ class DocumentationBuilder if (prefix != "") { node.appendTextNode(prefix, Kind.Modifier) } - if (jetType.isMarkedNullable) { + if (kotlinType.isMarkedNullable) { node.appendTextNode("?", Kind.NullabilityModifier) } if (classifierDescriptor != null) { @@ -178,8 +178,8 @@ class DocumentationBuilder } append(node, DocumentationReference.Kind.Detail) - node.appendAnnotations(jetType) - for (typeArgument in jetType.arguments) { + node.appendAnnotations(kotlinType) + for (typeArgument in kotlinType.arguments) { node.appendProjection(typeArgument) } } @@ -243,7 +243,8 @@ class DocumentationBuilder null } else { - appendChild(descriptor, DocumentationReference.Kind.Member) + val descriptorToUse = if (descriptor is ConstructorDescriptor) descriptor else descriptor.original + appendChild(descriptorToUse, DocumentationReference.Kind.Member) } } return nodes.filterNotNull() @@ -262,7 +263,7 @@ class DocumentationBuilder val allFqNames = fragments.map { it.fqName }.distinct() for (packageName in allFqNames) { - val declarations = fragments.filter { it.fqName == packageName }.flatMap { it.getMemberScope().getAllDescriptors() } + val declarations = fragments.filter { it.fqName == packageName }.flatMap { it.getMemberScope().getContributedDescriptors() } if (options.skipEmptyPackages && declarations.none { it.isDocumented() }) continue logger.info(" package $packageName: ${declarations.count()} declarations") @@ -304,14 +305,14 @@ class DocumentationBuilder constructors node.appendMembers(constructorsToDocument) } - val members = defaultType.memberScope.getAllDescriptors().filter { it != companionObjectDescriptor } + val members = defaultType.memberScope.getContributedDescriptors().filter { it != companionObjectDescriptor } node.appendMembers(members) - node.appendMembers(staticScope.getDescriptors()).forEach { + node.appendMembers(staticScope.getContributedDescriptors()).forEach { it.appendTextNode("static", Kind.Modifier) } val companionObjectDescriptor = companionObjectDescriptor if (companionObjectDescriptor != null) { - node.appendMembers(companionObjectDescriptor.defaultType.memberScope.getAllDescriptors()) + node.appendMembers(companionObjectDescriptor.defaultType.memberScope.getContributedDescriptors()) } node.appendAnnotations(this) node.appendModifiers(this) @@ -539,7 +540,7 @@ class KotlinJavaDocumentationBuilder file.classes.forEach { val javaDescriptorResolver = KotlinCacheService.getInstance(file.project).getProjectService(JvmPlatform, - it.getModuleInfo(), javaClass<JavaDescriptorResolver>()) + it.getModuleInfo(), JavaDescriptorResolver::class.java) val descriptor = javaDescriptorResolver.resolveClass(JavaClassImpl(it)) if (descriptor == null) { @@ -627,7 +628,7 @@ fun CallableMemberDescriptor.parameterSignature(): String { return "(" + params.map { it.signature() }.joinToString() + ")" } -fun KtType.signature(): String { +fun KotlinType.signature(): String { val declarationDescriptor = constructor.declarationDescriptor ?: return "<null>" val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString() if (typeName == "Array" && arguments.size == 1) { diff --git a/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt b/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt index a802e06c..7a1d591c 100644 --- a/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt +++ b/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt @@ -5,7 +5,7 @@ import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass import com.intellij.psi.PsiNamedElement import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser -import org.jetbrains.kotlin.asJava.KotlinLightElement +import org.jetbrains.kotlin.asJava.KtLightElement import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.FqName @@ -31,13 +31,13 @@ class KotlinAsJavaDocumentationBuilder documentationBuilder.refGraph, kotlinAsJavaDocumentationParser) - psiPackage.classes.filter { it is KotlinLightElement<*, *> }.filter { it.isVisibleInDocumentation() }.forEach { + psiPackage.classes.filter { it is KtLightElement<*, *> }.filter { it.isVisibleInDocumentation() }.forEach { javaDocumentationBuilder.appendClasses(packageNode, arrayOf(it)) } } fun PsiClass.isVisibleInDocumentation() : Boolean { - val origin: KtDeclaration? = (this as KotlinLightElement<*, *>).getOrigin() + val origin: KtDeclaration? = (this as KtLightElement<*, *>).getOrigin() return origin?.hasModifier(KtTokens.INTERNAL_KEYWORD) != true && origin?.hasModifier(KtTokens.PRIVATE_KEYWORD) != true } @@ -48,7 +48,7 @@ class KotlinAsJavaDocumentationParser val descriptorDocumentationParser: DescriptorDocumentationParser) : JavaDocumentationParser { override fun parseDocumentation(element: PsiNamedElement): JavadocParseResult { - val kotlinLightElement = element as? KotlinLightElement<*, *> ?: return JavadocParseResult.Empty + val kotlinLightElement = element as? KtLightElement<*, *> ?: return JavadocParseResult.Empty val origin = kotlinLightElement.getOrigin() ?: return JavadocParseResult.Empty if (origin is KtParameter) { // LazyDeclarationResolver does not support setter parameters |