aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/model/Documentable.kt25
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt10
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt6
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/JavaSignatureProvider.kt6
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt30
6 files changed, 40 insertions, 41 deletions
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<TypeParameter>,
override val supertypes: PlatformDependent<List<DRI>>,
override val documentation: PlatformDependent<DocumentationNode>,
- override val modifier: WithAbstraction.Modifier,
+ override val modifier: Modifier,
override val platformData: List<PlatformData>,
override val extra: PropertyContainer<Class> = PropertyContainer.empty()
) : Classlike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes,
@@ -206,7 +217,7 @@ data class Function(
override val type: TypeWrapper,
override val generics: List<TypeParameter>,
override val receiver: Parameter?,
- override val modifier: WithAbstraction.Modifier,
+ override val modifier: Modifier,
override val platformData: List<PlatformData>,
override val extra: PropertyContainer<Function> = PropertyContainer.empty()
) : Documentable(), Callable, WithGenerics, WithExtraProperties<Function> {
@@ -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<PlatformData>,
override val extra: PropertyContainer<Property> = PropertyContainer.empty()
) : Documentable(), Callable, WithExtraProperties<Property> {
@@ -331,7 +342,7 @@ data class OtherParameter(val name: String) : Bound()
object Star : Projection()
data class TypeConstructor(val dri: DRI, val projections: List<Projection>) : 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 }
}
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 97445b2b..c8a5105d 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -29,7 +29,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol) {
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is Class) {
- text(c.modifier.toString() + " ")
+ text(c.modifier.name + " ")
}
when (c) {
is Class -> text("class ")
@@ -50,7 +50,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol) {
platformText(f.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
- text(f.modifier.toString().toLowerCase() + " ")
+ text(f.modifier.name + " ")
text("fun ")
f.receiver?.also {
type(it.type)
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index f30ffa00..29441ac1 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -434,11 +434,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
}
fun MemberDescriptor.modifier() = when (modality) {
- Modality.FINAL -> WithAbstraction.Modifier.Final
- Modality.SEALED -> WithAbstraction.Modifier.Sealed
- Modality.OPEN -> WithAbstraction.Modifier.Open
- Modality.ABSTRACT -> WithAbstraction.Modifier.Abstract
- else -> WithAbstraction.Modifier.Empty
+ Modality.FINAL -> KotlinModifier.Final
+ Modality.SEALED -> KotlinModifier.Sealed
+ Modality.OPEN -> KotlinModifier.Open
+ Modality.ABSTRACT -> KotlinModifier.Abstract
+ else -> KotlinModifier.Empty
}
private fun MemberDescriptor.createSources(): PlatformDependent<DocumentableSource> = if (isExpect()) {
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 6b25639f..81de12eb 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -243,9 +243,9 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
}
private fun PsiModifierListOwner.getModifier() = when {
- hasModifier(JvmModifier.ABSTRACT) -> WithAbstraction.Modifier.Abstract
- hasModifier(JvmModifier.FINAL) -> WithAbstraction.Modifier.Final
- else -> WithAbstraction.Modifier.Empty
+ hasModifier(JvmModifier.ABSTRACT) -> JavaModifier.Abstract
+ hasModifier(JvmModifier.FINAL) -> JavaModifier.Final
+ else -> JavaModifier.Empty
}
private fun PsiTypeParameterListOwner.mapTypeParameters(dri: DRI): List<TypeParameter> {
diff --git a/plugins/kotlin-as-java/src/main/kotlin/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/JavaSignatureProvider.kt
index 8e2c783e..06224a7a 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/JavaSignatureProvider.kt
@@ -18,7 +18,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
private val ignoredVisibilities = setOf(JavaVisibility.Default, KotlinVisibility.Public)
private val ignoredModifiers =
- setOf(WithAbstraction.Modifier.Open, WithAbstraction.Modifier.Empty, WithAbstraction.Modifier.Sealed)
+ setOf(KotlinModifier.Open, JavaModifier.Empty, KotlinModifier.Empty, KotlinModifier.Sealed)
override fun signature(documentable: Documentable): ContentNode = when (documentable) {
@@ -34,7 +34,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is Class) {
- text(c.modifier.takeIf { it !in ignoredModifiers }?.toString()?.toLowerCase().orEmpty() + " ")
+ text(c.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
}
when (c) {
@@ -60,7 +60,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol) {
- text(f.modifier.takeIf { it != WithAbstraction.Modifier.Empty }?.toString()?.toLowerCase().orEmpty() + " ")
+ text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
val returnType = f.type
if (!f.isConstructor && returnType.constructorFqName != Unit::class.qualifiedName) {
type(returnType)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
index a8b45db0..7c66e91f 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -42,7 +42,7 @@ internal fun Package.asJava(): Package {
generics = emptyList(),
supertypes = PlatformDependent.empty(),
documentation = PlatformDependent.empty(),
- modifier = WithAbstraction.Modifier.Final,
+ modifier = JavaModifier.Final,
platformData = platformData,
extra = PropertyContainer.empty()
)
@@ -64,9 +64,9 @@ internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: Strin
dri.withClass(relocateToClass)
},
modifier = if (setter == null) {
- WithAbstraction.Modifier.Final
+ JavaModifier.Final
} else {
- WithAbstraction.Modifier.Empty
+ JavaModifier.Empty
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Private }
@@ -87,9 +87,9 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass
},
name = "get" + name.capitalize(),
modifier = if (setter == null) {
- WithAbstraction.Modifier.Final
+ JavaModifier.Final
} else {
- WithAbstraction.Modifier.Empty
+ JavaModifier.Empty
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Public }
@@ -105,9 +105,9 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass
},
name = "set" + name.capitalize(),
modifier = if (setter == null) {
- WithAbstraction.Modifier.Final
+ JavaModifier.Final
} else {
- WithAbstraction.Modifier.Empty
+ JavaModifier.Empty
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Public }
@@ -189,7 +189,7 @@ internal fun Object.asJava(): Object = copy(
properties = properties.map { it.asJava() } +
Property(
name = "INSTANCE",
- modifier = WithAbstraction.Modifier.Final,
+ modifier = JavaModifier.Final,
dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())),
documentation = PlatformDependent.empty(),
sources = PlatformDependent.empty(),
@@ -281,16 +281,4 @@ private fun AdditionalModifiers.squash(second: AdditionalModifiers) =
AdditionalModifiers((content + second.content).distinct())
internal fun ClassId.classNames(): String =
- shortClassName.identifier + (outerClassId?.classNames()?.let { ".$it" } ?: "")
-
-//fun TypeConstructor.asJava(): TypeReference =
-// fullyQualifiedName.mapToJava()
-// ?.let { tc.copy(fullyQualifiedName = it.asString(), params = tc.params.map { it.asJava() }) } ?: tc
-
-//fun TypeParam.asJava(): TypeReference = copy(bounds = bounds.map { it.asJava() })
-
-//fun TypeReference.asJava(): TypeReference = when (this) {
-// is TypeConstructor -> asJava()
-// is TypeParam -> asJava()
-// else -> this
-//} \ No newline at end of file
+ shortClassName.identifier + (outerClassId?.classNames()?.let { ".$it" } ?: "") \ No newline at end of file