diff options
Diffstat (limited to 'src/Kotlin')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 20 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 15 |
2 files changed, 17 insertions, 18 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 7804fd72..da7552a7 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -212,12 +212,7 @@ class DocumentationBuilder(val session: ResolveSession, } fun DocumentationNode.appendProjection(projection: TypeProjection, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) { - val prefix = when (projection.getProjectionKind()) { - Variance.IN_VARIANCE -> "in " - Variance.OUT_VARIANCE -> "out " - else -> "" - } - appendType(projection.getType(), kind, prefix) + appendType(projection.getType(), kind, projection.getProjectionKind().label) } fun DocumentationNode.appendType(jetType: JetType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") { @@ -225,11 +220,14 @@ class DocumentationBuilder(val session: ResolveSession, return val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor() val name = when (classifierDescriptor) { - is Named -> prefix + classifierDescriptor.getName().asString() + if (jetType.isMarkedNullable()) "?" else "" + is Named -> classifierDescriptor.getName().asString() + if (jetType.isMarkedNullable()) "?" else "" else -> "<anonymous>" } val node = DocumentationNode(name, Content.Empty, kind) - if (classifierDescriptor != null) + if (prefix != "") { + node.appendTextNode(prefix, Kind.Modifier) + } + if (classifierDescriptor != null){} link(node, classifierDescriptor) append(node, DocumentationReference.Kind.Detail) @@ -473,11 +471,7 @@ class DocumentationBuilder(val session: ResolveSession, fun TypeParameterDescriptor.build(): DocumentationNode { val doc = parseDocumentation(this) val name = getName().asString() - val prefix = when (getVariance()) { - Variance.IN_VARIANCE -> "in" - Variance.OUT_VARIANCE -> "out" - else -> "" - } + val prefix = getVariance().label val node = DocumentationNode(name, doc, DocumentationNode.Kind.TypeParameter) if (prefix != "") { diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index a4f62c3f..ab1f7016 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -104,6 +104,7 @@ class KotlinLanguageService : LanguageService { renderType(typeArguments.last()) return } + renderSingleModifier(node) renderLinked(node) { identifier(it.name) } if (typeArguments.any()) { symbol("<") @@ -125,11 +126,7 @@ class KotlinLanguageService : LanguageService { } private fun ContentBlock.renderTypeParameter(node: DocumentationNode) { - val modifier = node.details(DocumentationNode.Kind.Modifier).singleOrNull() - if (modifier != null) { - keyword(modifier.name) - nbsp() - } + renderSingleModifier(node) identifier(node.name) @@ -144,6 +141,14 @@ class KotlinLanguageService : LanguageService { } } + private fun ContentBlock.renderSingleModifier(node: DocumentationNode) { + val modifier = node.details(DocumentationNode.Kind.Modifier).singleOrNull() + if (modifier != null) { + keyword(modifier.name) + nbsp() + } + } + private fun ContentBlock.renderParameter(node: DocumentationNode) { renderAnnotationsForNode(node) identifier(node.name) |