diff options
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 23 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/KotlinLanguageService.kt | 11 | ||||
-rw-r--r-- | core/src/main/kotlin/Model/DocumentationReference.kt | 1 |
3 files changed, 29 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index f922a25b..afb95fe6 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -197,11 +197,15 @@ class DocumentationBuilder DescriptorUtils.getFqName(this).asString() in boringBuiltinClasses fun DocumentationNode.appendAnnotations(annotated: Annotated) { - annotated.annotations.filter { it.isDocumented() }.forEach { - val annotationNode = it.build() - if (annotationNode != null) { - append(annotationNode, - if (annotationNode.isDeprecation()) RefKind.Deprecation else RefKind.Annotation) + annotated.annotations.forEach { + it.build()?.let { annotationNode -> + val refKind = when { + it.isDocumented() && annotationNode.isDeprecation() -> RefKind.Deprecation + it.isDocumented() -> RefKind.Annotation + it.isHiddenInDocumentation() -> RefKind.HiddenAnnotation + else -> return@forEach + } + append(annotationNode, refKind) } } } @@ -687,10 +691,17 @@ class KotlinJavaDocumentationBuilder } } +private val hiddenAnnotations = setOf( + KotlinBuiltIns.FQ_NAMES.parameterName.asString() +) + +private fun AnnotationDescriptor.isHiddenInDocumentation() = + type.constructor.declarationDescriptor?.fqNameSafe?.asString() in hiddenAnnotations + private fun AnnotationDescriptor.isDocumented(): Boolean { if (source.getPsi() != null && mustBeDocumented()) return true val annotationClassName = type.constructor.declarationDescriptor?.fqNameSafe?.asString() - return annotationClassName == "kotlin.ExtensionFunctionType" + return annotationClassName == KotlinBuiltIns.FQ_NAMES.extensionFunctionType.asString() } fun AnnotationDescriptor.mustBeDocumented(): Boolean { diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt index 6fcf3772..75a8a948 100644 --- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt +++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt @@ -141,6 +141,16 @@ class KotlinLanguageService : LanguageService { } } + private fun ContentBlock.renderFunctionalTypeParameterName(node: DocumentationNode, renderMode: RenderMode) { + node.references(RefKind.HiddenAnnotation).map { it.to } + .find { it.name == "ParameterName" }?.let { + val parameterNameValue = it.detail(NodeKind.Parameter).detail(NodeKind.Value) + identifier(parameterNameValue.name.removeSurrounding("\""), IdentifierKind.ParameterName) + symbol(":") + nbsp() + } + } + private fun ContentBlock.renderType(node: DocumentationNode, renderMode: RenderMode) { var typeArguments = node.details(NodeKind.Type) if (node.name == "Function${typeArguments.count() - 1}") { @@ -153,6 +163,7 @@ class KotlinLanguageService : LanguageService { } symbol("(") renderList(typeArguments.take(typeArguments.size - 1), noWrap = true) { + renderFunctionalTypeParameterName(it, renderMode) renderType(it, renderMode) } symbol(")") diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt index 0c87d719..0165b567 100644 --- a/core/src/main/kotlin/Model/DocumentationReference.kt +++ b/core/src/main/kotlin/Model/DocumentationReference.kt @@ -16,6 +16,7 @@ enum class RefKind { Superclass, Override, Annotation, + HiddenAnnotation, Deprecation, TopLevelPage } |