From fc875fe5f8bc52ac75053db097b3349465705732 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 4 Mar 2020 17:04:50 +0100 Subject: Refactor Modifiers --- core/src/main/kotlin/model/Documentable.kt | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 9116b6e6..d073d39a 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -73,10 +73,21 @@ interface WithType { interface WithAbstraction { val modifier: Modifier +} - enum class Modifier { - Abstract, Open, Final, Sealed, Empty - } +sealed class Modifier(val name: String) +sealed class KotlinModifier(name: String) : Modifier(name) { + object Abstract : KotlinModifier("abstract") + object Open : KotlinModifier("open") + object Final : KotlinModifier("final") + object Sealed : KotlinModifier("sealed") + object Empty : KotlinModifier("") +} + +sealed class JavaModifier(name: String) : Modifier(name) { + object Abstract : JavaModifier("abstract") + object Final : JavaModifier("final") + object Empty : JavaModifier("") } interface WithCompanion { @@ -145,7 +156,7 @@ data class Class( override val generics: List, override val supertypes: PlatformDependent>, override val documentation: PlatformDependent, - override val modifier: WithAbstraction.Modifier, + override val modifier: Modifier, override val platformData: List, override val extra: PropertyContainer = PropertyContainer.empty() ) : Classlike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, @@ -206,7 +217,7 @@ data class Function( override val type: TypeWrapper, override val generics: List, override val receiver: Parameter?, - override val modifier: WithAbstraction.Modifier, + override val modifier: Modifier, override val platformData: List, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), Callable, WithGenerics, WithExtraProperties { @@ -286,7 +297,7 @@ data class Property( override val receiver: Parameter?, val setter: Function?, val getter: Function?, - override val modifier: WithAbstraction.Modifier, + override val modifier: Modifier, override val platformData: List, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), Callable, WithExtraProperties { @@ -331,7 +342,7 @@ data class OtherParameter(val name: String) : Bound() object Star : Projection() data class TypeConstructor(val dri: DRI, val projections: List) : Bound() data class Nullable(val inner: Bound) : Bound() -data class Variance(val kind: Kind, val inner: Bound): Projection() { +data class Variance(val kind: Kind, val inner: Bound) : Projection() { enum class Kind { In, Out } } -- cgit