From 86cd1d1adbf46b835e54e5306f86225db32aa9fd Mon Sep 17 00:00:00 2001 From: James Strachan Date: Mon, 5 Mar 2012 09:34:24 +0000 Subject: [PATCH] added support for nullable types for kdoc --- .../org/jetbrains/kotlin/model/KotlinModel.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt index 52a8cd7f0dd..901ad7b43aa 100644 --- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt +++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt @@ -227,7 +227,8 @@ class KModel(var context: BindingContext, var title: String = "Documentation", v protected fun createFunction(owner: KClassOrPackage, descriptor: CallableDescriptor): KFunction? { val returnType = getType(descriptor.getReturnType()) if (returnType != null) { - val function = KFunction(owner, descriptor.getName() ?: "null", returnType) + val name = descriptor.getName() ?: "null" + val function = KFunction(descriptor, owner, name, returnType) addTypeParameters(function.typeParameters, descriptor.getTypeParameters()) function.description = commentsFor(descriptor) val params = descriptor.getValueParameters() @@ -352,9 +353,9 @@ abstract class KNamed(val name: String) : KAnnotated(), Comparable { override fun compareTo(other: KNamed): Int = name.compareTo(other.name) - fun equals(other: KPackage) = name == other.name + open fun equals(other: KPackage) = name == other.name - fun toString() = name + open fun toString() = name } @@ -464,6 +465,11 @@ class KType(val jetType: JetType, val model: KModel, val klass: KClass?, val arg } } } + + override fun toString() = if (nullable) "$name?" else name + + val nullable: Boolean + get() = jetType.isNullable() } class KClass(val pkg: KPackage, val descriptor: ClassDescriptor, @@ -517,7 +523,7 @@ class KClass(val pkg: KPackage, val descriptor: ClassDescriptor, } } -class KFunction(val owner: KClassOrPackage, val name: String, +class KFunction(val descriptor: CallableDescriptor, val owner: KClassOrPackage, val name: String, var returnType: KType, var extensionClass: KClass? = null, var modifiers: List = arrayList(),