diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-06 16:11:32 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-06 16:11:32 +0100 |
commit | 8f159151f182f4561594a4c23c22e82830bcc9b4 (patch) | |
tree | 6b351f83ae3808bdcc93c6a9755f9139b184c36b /src/Kotlin/DocumentationBuilder.kt | |
parent | 0cab60b604cd7f0f642ab389973bfce1bbbe6071 (diff) | |
download | dokka-8f159151f182f4561594a4c23c22e82830bcc9b4.tar.gz dokka-8f159151f182f4561594a4c23c22e82830bcc9b4.tar.bz2 dokka-8f159151f182f4561594a4c23c22e82830bcc9b4.zip |
generate documentation for default object extension properties
Diffstat (limited to 'src/Kotlin/DocumentationBuilder.kt')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 9ca3ad79..aa4a0caf 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -144,11 +144,12 @@ class DocumentationBuilder(val session: ResolveSession, } fun JetType.signature(): String { - val typeName = getConstructor().getDeclarationDescriptor()?.getName()?.asString() + val declarationDescriptor = getConstructor().getDeclarationDescriptor() ?: return "<null>" + val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString() if (typeName == "Array" && getArguments().size() == 1) { return "Array<" + getArguments().first().getType().signature() + ">" } - return typeName ?: "<null>" + return typeName } fun resolveContentLink(descriptor: DeclarationDescriptor, href: String): ContentBlock { @@ -266,6 +267,15 @@ class DocumentationBuilder(val session: ResolveSession, return val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor() val name = when (classifierDescriptor) { + is ClassDescriptor -> { + if (classifierDescriptor.isDefaultObject()) { + classifierDescriptor.getContainingDeclaration().getName().asString() + + "." + classifierDescriptor.getName().asString() + } + else { + classifierDescriptor.getName().asString() + } + } is Named -> classifierDescriptor.getName().asString() else -> "<anonymous>" } @@ -428,8 +438,14 @@ class DocumentationBuilder(val session: ResolveSession, return node } - private fun DeclarationDescriptor.inDefaultObject() = - getContainingDeclaration().let { it is ClassDescriptor && it.isDefaultObject() } + private fun CallableMemberDescriptor.inDefaultObject(): Boolean { + val containingDeclaration = getContainingDeclaration() + if ((containingDeclaration as? ClassDescriptor)?.isDefaultObject() ?: false) { + return true + } + val receiver = getExtensionReceiverParameter() + return (receiver?.getType()?.getConstructor()?.getDeclarationDescriptor() as? ClassDescriptor)?.isDefaultObject() ?: false + } fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor? { val extensionReceiver = getExtensionReceiverParameter() @@ -614,7 +630,11 @@ class DocumentationBuilder(val session: ResolveSession, } fun ReceiverParameterDescriptor.build(): DocumentationNode { - link(getType().getConstructor().getDeclarationDescriptor(), + var receiverClass: DeclarationDescriptor = getType().getConstructor().getDeclarationDescriptor() + if ((receiverClass as? ClassDescriptor)?.isDefaultObject() ?: false) { + receiverClass = receiverClass.getContainingDeclaration()!! + } + link(receiverClass, getContainingDeclaration(), DocumentationReference.Kind.Extension) |