From a9b3ee192ac09e2e1569a828a9da05d502fb2c75 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Wed, 17 May 2023 21:07:19 +0300 Subject: Update KGP to 1.8.20 (#2989) * Update KGP to 1.8.20 * Update AGP to be compatible with KGP * Replace `AndroidSourceSet` * Dump API * Update integration tests * Update GH actions tests * Refactor Gradle Runner * Fix `TYPE_MISMATCH_WARNING_FOR_INCORRECT_CAPTURE_APPROXIMATION` * Suppress source sets without compilations Dokka suppresses source sets that do no have compilation since such configuration is invalid, it reports a warning or an error * Introduce `dependsOn` for a new `com.android.build.api.dsl.AndroidSourceSet` * API dump * Add comment * Suppress remaining `TYPE_MISMATCH_WARNING_FOR_INCORRECT_CAPTURE_APPROXIMATION` * Add comment --------- Co-authored-by: Ignat Beresnev --- .../src/main/kotlin/converters/KotlinToJavaConverter.kt | 4 ++-- plugins/kotlin-as-java/src/main/kotlin/jvmField.kt | 4 ++-- plugins/kotlin-as-java/src/main/kotlin/jvmName.kt | 6 +++--- plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt | 4 ++-- plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt | 4 ++-- plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt | 5 ++--- .../kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) (limited to 'plugins/kotlin-as-java/src') 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 5f98494e..4df0d3c5 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -482,7 +482,7 @@ internal fun ClassKind.asJava(): ClassKind { } } -private fun PropertyContainer.mergeAdditionalModifiers(second: SourceSetDependent>) = +private fun PropertyContainer.mergeAdditionalModifiers(second: SourceSetDependent>) = this[AdditionalModifiers]?.squash(AdditionalModifiers(second)) ?: AdditionalModifiers(second) private fun AdditionalModifiers.squash(second: AdditionalModifiers) = @@ -494,4 +494,4 @@ internal fun ClassId.classNames(): String = private fun DProperty.hasModifier(modifier: ExtraModifiers.KotlinOnlyModifiers): Boolean = extra[AdditionalModifiers] ?.content - ?.any { (_, modifiers) -> modifier in modifiers } == true \ No newline at end of file + ?.any { (_, modifiers) -> modifier in modifiers } == true diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt index b421bd3d..fea78abb 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.kotlin.util.firstNotNullResult -internal fun WithExtraProperties.jvmField(): Annotations.Annotation? = +internal fun WithExtraProperties.jvmField(): Annotations.Annotation? = extra[Annotations]?.directAnnotations?.entries?.firstNotNullResult { (_, annotations) -> annotations.jvmFieldAnnotation() } internal fun List.jvmFieldAnnotation(): Annotations.Annotation? = - firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmField" } \ No newline at end of file + firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmField" } diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt index 44271f2c..600318e5 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt @@ -7,13 +7,13 @@ import org.jetbrains.dokka.model.isJvmName import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.kotlin.util.firstNotNullResult -internal fun WithExtraProperties.directlyAnnotatedJvmName(): Annotations.Annotation? = +internal fun WithExtraProperties.directlyAnnotatedJvmName(): Annotations.Annotation? = extra[Annotations]?.directAnnotations?.entries?.firstNotNullResult { (_, annotations)-> annotations.jvmNameAnnotation() } -internal fun WithExtraProperties.fileLevelJvmName(): Annotations.Annotation? = +internal fun WithExtraProperties.fileLevelJvmName(): Annotations.Annotation? = extra[Annotations]?.fileLevelAnnotations?.entries?.firstNotNullResult { (_, annotations) -> annotations.jvmNameAnnotation() } internal fun List.jvmNameAnnotation(): Annotations.Annotation? = firstOrNull { it.isJvmName() } -internal fun Annotations.Annotation.jvmNameAsString(): String? = (params["name"] as? StringValue)?.value \ No newline at end of file +internal fun Annotations.Annotation.jvmNameAsString(): String? = (params["name"] as? StringValue)?.value diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt index d8e4f67c..9913d017 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt @@ -4,11 +4,11 @@ import org.jetbrains.dokka.model.Annotations import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties -internal fun WithExtraProperties.hasJvmOverloads(): Boolean { +internal fun WithExtraProperties.hasJvmOverloads(): Boolean { return extra[Annotations] ?.directAnnotations ?.entries ?.any { (_, annotations) -> annotations.any { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmOverloads" } } == true -} \ No newline at end of file +} diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt index 10372ac9..50ea7795 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.kotlin.util.firstNotNullResult -internal fun WithExtraProperties.jvmStatic(): Annotations.Annotation? = +internal fun WithExtraProperties.jvmStatic(): Annotations.Annotation? = extra[Annotations]?.directAnnotations?.entries?.firstNotNullResult { (_, annotations) -> annotations.jvmStaticAnnotation() } internal fun List.jvmStaticAnnotation(): Annotations.Annotation? = - firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmStatic" } \ No newline at end of file + firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmStatic" } diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt index e866ec8b..9629db0c 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt @@ -1,14 +1,13 @@ package org.jetbrains.dokka.kotlinAsJava import org.jetbrains.dokka.model.Annotations -import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties -internal fun WithExtraProperties.hasJvmSynthetic(): Boolean { +internal fun WithExtraProperties.hasJvmSynthetic(): Boolean { return extra[Annotations] ?.directAnnotations ?.entries ?.any { (_, annotations) -> annotations.any { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmSynthetic" } } == true -} \ No newline at end of file +} diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt index c928ea67..4c35def7 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt @@ -11,12 +11,12 @@ data class Name(val fqName: String) { } class JvmNameProvider { - fun nameFor(entry: T): String where T : Documentable, T : WithExtraProperties = + fun nameFor(entry: T): String where T : Documentable, T : WithExtraProperties = entry.directlyAnnotatedJvmName()?.jvmNameAsString() ?: entry.name ?: throw IllegalStateException("Failed to provide a name for ${entry.javaClass.canonicalName}") - fun nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties, T : Documentable { + fun nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties, T : Documentable { val name: String = (entry.fileLevelJvmName()?.params?.get("name") as? StringValue)?.value ?: (entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt") return Name("${entry.dri.packageName}.$name") -- cgit