From c7dc9db1dabfa2847df5c15862889b2c17e9d58d Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 24 Feb 2020 17:56:05 +0100 Subject: Model for type parameters --- core/src/main/kotlin/links/DRI.kt | 2 ++ core/src/main/kotlin/model/Documentable.kt | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 220ed719..aefaf8f6 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -16,6 +16,7 @@ data class DRI( val classNames: String? = null, val callable: Callable? = null, val target: Int? = null, + val genericTarget: Int? = null, val extra: String? = null ) { override fun toString(): String = @@ -44,6 +45,7 @@ fun DRI.withClass(name: String) = copy(classNames = if (classNames.isNullOrBlank val DRI.parent: DRI get() = when { extra != null -> copy(extra = null) + genericTarget != null -> copy(genericTarget = null) target != null -> copy(target = null) callable != null -> copy(callable = null) classNames != null -> copy(classNames = classNames.substringBeforeLast('.').takeIf { it.isNotBlank() }) diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index fbf163b0..121d0293 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -79,7 +79,7 @@ interface WithConstructors { } interface WithGenerics { - val generics: PlatformDependent // TODO: fix the generics + val generics: List } interface Callable : WithVisibility, WithType, WithAbstraction, WithExpectActual { @@ -125,7 +125,7 @@ class Class( override val actual: PlatformDependent, override val visibility: PlatformDependent, override val companion: Object?, - override val generics: PlatformDependent, + override val generics: List, override val supertypes: PlatformDependent>, override val documentation: PlatformDependent, override val original: PlatformDependent = PlatformDependent.empty(), @@ -177,7 +177,7 @@ class Function( override val actual: PlatformDependent, override val visibility: PlatformDependent, override val type: TypeWrapper, - override val generics: PlatformDependent, + override val generics: List, override val receiver: Parameter?, override val original: PlatformDependent = PlatformDependent.empty(), override val modifier: WithAbstraction.Modifier @@ -197,7 +197,7 @@ class Interface( override val classlikes: List, override val visibility: PlatformDependent, override val companion: Object?, - override val generics: PlatformDependent, + override val generics: List, override val supertypes: PlatformDependent> ) : Classlike(), WithCompanion, WithGenerics { override val children: List @@ -249,7 +249,7 @@ class Property( override val original: PlatformDependent = PlatformDependent.empty(), override val modifier: WithAbstraction.Modifier ) : Documentable(), Callable { - override val children: List + override val children: List get() = emptyList() } @@ -261,10 +261,28 @@ class Parameter( val type: TypeWrapper, override val original: PlatformDependent ) : Documentable() { - override val children: List + override val children: List + get() = emptyList() +} + +class TypeParameter( + override val dri: DRI, + override val name: String, + override val documentation: PlatformDependent, + override val original: PlatformDependent = PlatformDependent.empty(), + val bounds: List +): Documentable() { + override val children: List get() = emptyList() } +sealed class Projection { + data class OtherParameter(val name: String): Projection() + object Star: Projection() + data class TypeConstructor(val dri: DRI, val projections: List): Projection() + data class Nullable(val inner: Projection): Projection() +} + private fun String.shorten(maxLength: Int) = lineSequence().first().let { if (it.length != length || it.length > maxLength) it.take(maxLength - 3) + "..." else it } -- cgit