aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-01-12 16:14:21 +0100
committerDmitry Jemerov <yole@jetbrains.com>2016-01-12 16:14:21 +0100
commita3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af (patch)
treec0a87789124c2fff312c5b32f1a4e6815129abca /core/src/main/kotlin/Kotlin
parent99b6196bde4773fd26bd733ecf5e3984ce0a4c63 (diff)
downloaddokka-a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af.tar.gz
dokka-a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af.tar.bz2
dokka-a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af.zip
generate signature-based anchors for overloads; use signature instead of name as an anchor for in-page links
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt20
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt2
2 files changed, 16 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index f91f160b..3c4c0c39 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -227,6 +227,10 @@ class DocumentationBuilder
appendSourceLink(sourceElement.getPsi(), options.sourceLinks)
}
+ fun DocumentationNode.appendSignature(descriptor: DeclarationDescriptor) {
+ appendTextNode(descriptor.signature(), NodeKind.Signature, RefKind.Detail)
+ }
+
fun DocumentationNode.appendChild(descriptor: DeclarationDescriptor, kind: RefKind): DocumentationNode? {
// do not include generated code
if (descriptor is CallableMemberDescriptor && descriptor.kind != CallableMemberDescriptor.Kind.DECLARATION)
@@ -440,6 +444,7 @@ class DocumentationBuilder
node.appendAnnotations(this)
node.appendModifiers(this)
node.appendSourceLink(source)
+ node.appendSignature(this)
overriddenDescriptors.forEach {
addOverrideLink(it, this)
@@ -468,6 +473,7 @@ class DocumentationBuilder
node.appendAnnotations(this)
node.appendModifiers(this)
node.appendSourceLink(source)
+ node.appendSignature(this)
if (isVar) {
node.appendTextNode("var", NodeKind.Modifier)
}
@@ -518,6 +524,7 @@ class DocumentationBuilder
}
node.appendAnnotations(this)
node.appendModifiers(this)
+ node.appendSignature(this)
if (varargElementType != null && node.details(NodeKind.Modifier).none { it.name == "vararg" }) {
node.appendTextNode("vararg", NodeKind.Modifier)
}
@@ -699,10 +706,10 @@ fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor
fun DeclarationDescriptor.signature(): String = when(this) {
is ClassDescriptor, is PackageFragmentDescriptor -> DescriptorUtils.getFqName(this).asString()
- is PropertyDescriptor -> containingDeclaration.signature() + "#" + name + receiverSignature()
- is FunctionDescriptor -> containingDeclaration.signature() + "#" + name + parameterSignature()
- is ValueParameterDescriptor -> containingDeclaration.signature() + ":" + name
- is TypeParameterDescriptor -> containingDeclaration.signature() + "<" + name
+ is PropertyDescriptor -> containingDeclaration.signature() + "$" + name + receiverSignature()
+ is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature()
+ is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name
+ is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name
else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this")
}
@@ -727,7 +734,10 @@ fun CallableMemberDescriptor.parameterSignature(): String {
fun KotlinType.signature(): String {
val declarationDescriptor = constructor.declarationDescriptor ?: return "<null>"
val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString()
- return typeName + arguments.joinToString(prefix = "<", postfix = ">") { it.type.signature() }
+ if (arguments.isEmpty()) {
+ return typeName
+ }
+ return typeName + arguments.joinToString(prefix = "((", postfix = "))") { it.type.signature() }
}
fun DeclarationDescriptor.signatureWithSourceLocation(): String {
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index a5bb5ee7..a0d8f95d 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -215,7 +215,7 @@ class KotlinLanguageService : LanguageService {
renderAnnotationsForNode(node)
}
renderModifiersForNode(node, renderMode)
- identifier(node.name, IdentifierKind.ParameterName)
+ identifier(node.name, IdentifierKind.ParameterName, node.detailOrNull(NodeKind.Signature)?.name)
symbol(":")
nbsp()
val parameterType = node.detail(NodeKind.Type)