From cad221f454adceb12d74fc563788b3d8247e44f6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 2 Mar 2015 12:25:00 +0100 Subject: represent nullability in doc model instead of appending ? to type name --- src/Kotlin/DocumentationBuilder.kt | 5 ++++- src/Kotlin/KotlinLanguageService.kt | 4 ++++ src/Model/DocumentationNode.kt | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index d8933087..3b7f25d6 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -224,13 +224,16 @@ class DocumentationBuilder(val session: ResolveSession, return val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor() val name = when (classifierDescriptor) { - is Named -> classifierDescriptor.getName().asString() + if (jetType.isMarkedNullable()) "?" else "" + is Named -> classifierDescriptor.getName().asString() else -> "" } val node = DocumentationNode(name, Content.Empty, kind) if (prefix != "") { node.appendTextNode(prefix, Kind.Modifier) } + if (jetType.isMarkedNullable()) { + node.appendTextNode("?", Kind.NullabilityModifier) + } if (classifierDescriptor != null && !classifierDescriptor.isBoringBuiltinClass()) { link(node, classifierDescriptor) } diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index 4b43fb88..855745e0 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -114,6 +114,10 @@ class KotlinLanguageService : LanguageService { } symbol(">") } + val nullabilityModifier = node.details(DocumentationNode.Kind.NullabilityModifier).singleOrNull() + if (nullabilityModifier != null) { + symbol(nullabilityModifier.name) + } } private fun ContentBlock.renderModifier(node: DocumentationNode) { diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 3fc1198c..c9373849 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -91,6 +91,7 @@ public open class DocumentationNode(val name: String, Exception Modifier + NullabilityModifier Module -- cgit