aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-02-24 17:56:05 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-02-27 10:51:51 +0100
commitc7dc9db1dabfa2847df5c15862889b2c17e9d58d (patch)
tree4921582f399afed0a174a0b4abd1233a06590457 /core
parentf8194a41c600ebd6a06277f056c728a65f1327ed (diff)
downloaddokka-c7dc9db1dabfa2847df5c15862889b2c17e9d58d.tar.gz
dokka-c7dc9db1dabfa2847df5c15862889b2c17e9d58d.tar.bz2
dokka-c7dc9db1dabfa2847df5c15862889b2c17e9d58d.zip
Model for type parameters
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/links/DRI.kt2
-rw-r--r--core/src/main/kotlin/model/Documentable.kt30
2 files changed, 26 insertions, 6 deletions
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<TypeWrapper> // TODO: fix the generics
+ val generics: List<TypeParameter>
}
interface Callable : WithVisibility, WithType, WithAbstraction, WithExpectActual {
@@ -125,7 +125,7 @@ class Class(
override val actual: PlatformDependent<DocumentableSource>,
override val visibility: PlatformDependent<Visibility>,
override val companion: Object?,
- override val generics: PlatformDependent<TypeWrapper>,
+ override val generics: List<TypeParameter>,
override val supertypes: PlatformDependent<List<DRI>>,
override val documentation: PlatformDependent<DocumentationNode>,
override val original: PlatformDependent<Class> = PlatformDependent.empty(),
@@ -177,7 +177,7 @@ class Function(
override val actual: PlatformDependent<DocumentableSource>,
override val visibility: PlatformDependent<Visibility>,
override val type: TypeWrapper,
- override val generics: PlatformDependent<TypeWrapper>,
+ override val generics: List<TypeParameter>,
override val receiver: Parameter?,
override val original: PlatformDependent<Function> = PlatformDependent.empty(),
override val modifier: WithAbstraction.Modifier
@@ -197,7 +197,7 @@ class Interface(
override val classlikes: List<Classlike>,
override val visibility: PlatformDependent<Visibility>,
override val companion: Object?,
- override val generics: PlatformDependent<TypeWrapper>,
+ override val generics: List<TypeParameter>,
override val supertypes: PlatformDependent<List<DRI>>
) : Classlike(), WithCompanion, WithGenerics {
override val children: List<Documentable>
@@ -249,7 +249,7 @@ class Property(
override val original: PlatformDependent<Property> = PlatformDependent.empty(),
override val modifier: WithAbstraction.Modifier
) : Documentable(), Callable {
- override val children: List<Documentable>
+ override val children: List<Nothing>
get() = emptyList()
}
@@ -261,10 +261,28 @@ class Parameter(
val type: TypeWrapper,
override val original: PlatformDependent<Parameter>
) : Documentable() {
- override val children: List<Documentable>
+ override val children: List<Nothing>
+ get() = emptyList()
+}
+
+class TypeParameter(
+ override val dri: DRI,
+ override val name: String,
+ override val documentation: PlatformDependent<DocumentationNode>,
+ override val original: PlatformDependent<TypeParameter> = PlatformDependent.empty(),
+ val bounds: List<Projection>
+): Documentable() {
+ override val children: List<Nothing>
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>): 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
}