diff options
author | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-08-06 11:59:13 +0300 |
---|---|---|
committer | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-08-06 11:59:13 +0300 |
commit | 325f4f3a29850e12c074e7e7a50d9e950d46d4ef (patch) | |
tree | 10bf0f6612c0ae51a28fb648e285bd090c99dc14 /javadoc/src/main | |
parent | 9b0c1b9b0d132aba484cafbb7e12d2e132522715 (diff) | |
download | dokka-325f4f3a29850e12c074e7e7a50d9e950d46d4ef.tar.gz dokka-325f4f3a29850e12c074e7e7a50d9e950d46d4ef.tar.bz2 dokka-325f4f3a29850e12c074e7e7a50d9e950d46d4ef.zip |
~ avoid possible parameter name clash with "receiver"
Diffstat (limited to 'javadoc/src/main')
-rw-r--r-- | javadoc/src/main/kotlin/docbase.kt | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt index 4e822fc8..c6b84059 100644 --- a/javadoc/src/main/kotlin/docbase.kt +++ b/javadoc/src/main/kotlin/docbase.kt @@ -247,11 +247,17 @@ class ParameterAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : override fun annotations(): Array<out AnnotationDesc>? = node.details(DocumentationNode.Kind.Annotation).map { AnnotationDescAdapter(module, it) }.toTypedArray() } -class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: DocumentationNode) : DocumentationNodeAdapter(module, receiverType), Parameter { +class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: DocumentationNode, val parent: ExecutableMemberAdapter) : DocumentationNodeAdapter(module, receiverType), Parameter { override fun typeName(): String? = receiverType.name override fun type(): Type? = TypeAdapter(module, receiverType) override fun annotations(): Array<out AnnotationDesc> = emptyArray() - override fun name(): String = "receiver" + override fun name(): String = tryName("receiver") + + tailRecursive + private fun tryName(name: String): String = when (name) { + in parent.parameters().drop(1).map { it.name() } -> tryName("$$name") + else -> name + } } fun classOf(fqName: String, kind: DocumentationNode.Kind = DocumentationNode.Kind.Class) = DocumentationNode(fqName.substringAfterLast(".", fqName), Content.Empty, kind).let { node -> @@ -290,7 +296,7 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, val node: Document override fun signature(): String = node.details(DocumentationNode.Kind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")") // TODO it should be FQ types override fun parameters(): Array<out Parameter> = - ((receiverNode()?.let { receiver -> listOf<Parameter>(ReceiverParameterAdapter(module, receiver)) } ?: emptyList()) + ((receiverNode()?.let { receiver -> listOf<Parameter>(ReceiverParameterAdapter(module, receiver, this)) } ?: emptyList()) + node.details(DocumentationNode.Kind.Parameter).map { ParameterAdapter(module, it) } ).toTypedArray() |