aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/main/kotlin
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-03-16 14:33:38 +0100
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-03-16 14:35:12 +0100
commit996feefe717ac623daabaadda71b5b9d2bbe1cf1 (patch)
treefca8d99c2cf4f9dcc64159b4e1ebe5644f2bd81b /plugins/kotlin-as-java/src/main/kotlin
parentcd38992a28a8b16cd91661f05829610d1373e47c (diff)
downloaddokka-996feefe717ac623daabaadda71b5b9d2bbe1cf1.tar.gz
dokka-996feefe717ac623daabaadda71b5b9d2bbe1cf1.tar.bz2
dokka-996feefe717ac623daabaadda71b5b9d2bbe1cf1.zip
Rename Documentables to avoid name conflicts
Diffstat (limited to 'plugins/kotlin-as-java/src/main/kotlin')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt54
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt34
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt4
3 files changed, 46 insertions, 46 deletions
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 cf777e67..991ee07d 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -4,9 +4,9 @@ import org.jetbrains.dokka.links.Callable
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.withClass
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.Annotation
-import org.jetbrains.dokka.model.Enum
-import org.jetbrains.dokka.model.Function
+import org.jetbrains.dokka.model.DAnnotation
+import org.jetbrains.dokka.model.DEnum
+import org.jetbrains.dokka.model.DFunction
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.name.ClassId
@@ -21,21 +21,21 @@ private fun <T : WithExpectActual> List<T>.groupedByLocation() =
} // TODO: first() does not look reasonable
}) { it.second }
-internal fun Package.asJava(): Package {
+internal fun DPackage.asJava(): DPackage {
@Suppress("UNCHECKED_CAST")
val syntheticClasses = ((properties + functions) as List<WithExpectActual>)
.groupedByLocation()
.map { (syntheticClassName, nodes) ->
- Class(
+ DClass(
dri = dri.withClass(syntheticClassName),
name = syntheticClassName,
- properties = nodes.filterIsInstance<Property>().map { it.asJava() },
+ properties = nodes.filterIsInstance<DProperty>().map { it.asJava() },
constructors = emptyList(),
functions = (
- nodes.filterIsInstance<Property>()
+ nodes.filterIsInstance<DProperty>()
.map { it.javaAccessors() } +
- nodes.filterIsInstance<Function>()
- .map { it.asJava(syntheticClassName) }) as List<Function>, // TODO: methods are static and receiver is a param
+ nodes.filterIsInstance<DFunction>()
+ .map { it.asJava(syntheticClassName) }) as List<DFunction>, // TODO: methods are static and receiver is a param
classlikes = emptyList(),
sources = PlatformDependent.empty(),
visibility = PlatformDependent(
@@ -60,7 +60,7 @@ internal fun Package.asJava(): Package {
)
}
-internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: String? = null) =
+internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: String? = null) =
copy(
dri = if (relocateToClass.isNullOrBlank()) {
dri
@@ -81,7 +81,7 @@ internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: Strin
extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else extra
)
-internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List<Function> =
+internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List<DFunction> =
listOfNotNull(
getter?.copy(
dri = if (relocateToClass.isNullOrBlank()) {
@@ -122,7 +122,7 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass
)
-internal fun Function.asJava(containingClassName: String): Function {
+internal fun DFunction.asJava(containingClassName: String): DFunction {
val newName = when {
isConstructor -> containingClassName
else -> name
@@ -137,16 +137,16 @@ internal fun Function.asJava(containingClassName: String): Function {
) // TODO static if toplevel
}
-internal fun Classlike.asJava(): Classlike = when (this) {
- is Class -> asJava()
- is Enum -> asJava()
- is Annotation -> asJava()
- is Object -> asJava()
- is Interface -> asJava()
+internal fun DClasslike.asJava(): DClasslike = when (this) {
+ is DClass -> asJava()
+ is DEnum -> asJava()
+ is DAnnotation -> asJava()
+ is DObject -> asJava()
+ is DInterface -> asJava()
else -> throw IllegalArgumentException("$this shouldn't be here")
}
-internal fun Class.asJava(): Class = copy(
+internal fun DClass.asJava(): DClass = copy(
constructors = constructors.map { it.asJava(name) },
functions = (functions + properties.map { it.getter } + properties.map { it.setter }).filterNotNull().map {
it.asJava(name)
@@ -160,7 +160,7 @@ internal fun Class.asJava(): Class = copy(
modifier = if (modifier is KotlinModifier.Empty) JavaModifier.Final else modifier
)
-private fun TypeParameter.asJava(): TypeParameter = copy(
+private fun DTypeParameter.asJava(): DTypeParameter = copy(
dri = dri.possiblyAsJava(),
bounds = bounds.map { it.asJava() }
)
@@ -175,7 +175,7 @@ private fun Bound.asJava(): Bound = when (this) {
else -> this
}
-internal fun Enum.asJava(): Enum = copy(
+internal fun DEnum.asJava(): DEnum = copy(
constructors = constructors.map { it.asJava(name) },
functions = (functions + properties.map { it.getter } + properties.map { it.setter }).filterNotNull().map {
it.asJava(name)
@@ -188,12 +188,12 @@ internal fun Enum.asJava(): Enum = copy(
// , entries = entries.map { it.asJava() }
)
-internal fun Object.asJava(): Object = copy(
+internal fun DObject.asJava(): DObject = copy(
functions = (functions + properties.map { it.getter } + properties.map { it.setter })
.filterNotNull()
.map { it.asJava(name.orEmpty()) },
properties = properties.map { it.asJava() } +
- Property(
+ DProperty(
name = "INSTANCE",
modifier = JavaModifier.Final,
dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())),
@@ -209,7 +209,7 @@ internal fun Object.asJava(): Object = copy(
getter = null,
platformData = platformData,
receiver = null,
- extra = PropertyContainer.empty<Property>() + AdditionalModifiers(setOf(ExtraModifiers.STATIC))
+ extra = PropertyContainer.empty<DProperty>() + AdditionalModifiers(setOf(ExtraModifiers.STATIC))
),
classlikes = classlikes.map { it.asJava() },
supertypes = supertypes.copy(
@@ -217,7 +217,7 @@ internal fun Object.asJava(): Object = copy(
)
)
-internal fun Interface.asJava(): Interface = copy(
+internal fun DInterface.asJava(): DInterface = copy(
functions = (functions + properties.map { it.getter } + properties.map { it.setter })
.filterNotNull()
.map { it.asJava(name) },
@@ -229,13 +229,13 @@ internal fun Interface.asJava(): Interface = copy(
)
)
-internal fun Annotation.asJava(): Annotation = copy(
+internal fun DAnnotation.asJava(): DAnnotation = copy(
properties = properties.map { it.asJava() },
constructors = emptyList(),
classlikes = classlikes.map { it.asJava() }
) // TODO investigate if annotation class can have methods and properties not from constructor
-internal fun Parameter.asJava(): Parameter = copy(
+internal fun DParameter.asJava(): DParameter = copy(
type = type.asJava(),
name = if (name.isNullOrBlank()) "\$self" else name
)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
index 55dd7a97..0ec7d0af 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -5,9 +5,9 @@ import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentCon
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.sureClassNames
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.Annotation
-import org.jetbrains.dokka.model.Enum
-import org.jetbrains.dokka.model.Function
+import org.jetbrains.dokka.model.DAnnotation
+import org.jetbrains.dokka.model.DEnum
+import org.jetbrains.dokka.model.DFunction
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.TextStyle
@@ -22,28 +22,28 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
override fun signature(documentable: Documentable): ContentNode = when (documentable) {
- is Function -> signature(documentable)
- is Property -> signature(documentable)
- is Classlike -> signature(documentable)
- is TypeParameter -> signature(documentable)
+ is DFunction -> signature(documentable)
+ is DProperty -> signature(documentable)
+ is DClasslike -> signature(documentable)
+ is DTypeParameter -> signature(documentable)
else -> throw NotImplementedError(
"Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}"
)
}
- private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
+ private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
- if (c is Class) {
+ if (c is DClass) {
text(c.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
}
when (c) {
- is Class -> text("class ")
- is Interface -> text("interface ")
- is Enum -> text("enum ")
- is Object -> text("class ")
- is Annotation -> text("@interface ")
+ is DClass -> text("class ")
+ is DInterface -> text("interface ")
+ is DEnum -> text("enum ")
+ is DObject -> text("class ")
+ is DAnnotation -> text("@interface ")
}
link(c.name!!, c.dri)
if (c is WithGenerics) {
@@ -60,11 +60,11 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
}
- private fun signature(p: Property) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
+ private fun signature(p: DProperty) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
signatureForProjection(p.type)
}
- private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
+ private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
val returnType = f.type
signatureForProjection(returnType)
@@ -82,7 +82,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
text(")")
}
- private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) {
+ private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) {
text(t.name.substringAfterLast("."))
list(t.bounds, prefix = " extends ") {
signatureForProjection(it)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt
index 8f51e105..8b07670f 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt
@@ -1,11 +1,11 @@
package org.jetbrains.dokka.kotlinAsJava.transformers
import org.jetbrains.dokka.kotlinAsJava.converters.asJava
-import org.jetbrains.dokka.model.Module
+import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer
class KotlinAsJavaDocumentableTransformer : DocumentableTransformer {
- override fun invoke(original: Module, context: DokkaContext): Module =
+ override fun invoke(original: DModule, context: DokkaContext): DModule =
original.copy(packages = original.packages.map { it.asJava() })
}