diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index f8467b4..c264799 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/JVMTarget.kt b/buildSrc/src/main/kotlin/JVMTarget.kt index 2cf2773..9538b86 100644 --- a/buildSrc/src/main/kotlin/JVMTarget.kt +++ b/buildSrc/src/main/kotlin/JVMTarget.kt @@ -1,6 +1,6 @@ -import gradle.kotlin.dsl.accessors._8d1ef46afdac024fc616c6e49cc7c389.java import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.kotlin.dsl.the import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget fun Project.configureJVMTarget() { plugins.withId("org.gradle.java") { - java { + configure { sourceCompatibility = JavaVersion.VERSION_1_8 } } @@ -22,12 +22,10 @@ fun Project.configureJVMTarget() { } plugins.withId("org.jetbrains.kotlin.multiplatform") { - the().targets { - withType().configureEach { - compilations.all { - compilerOptions.configure { - jvmTarget = JvmTarget.JVM_1_8 - } + the().targets.withType { + compilations.all { + compilerOptions.configure { + jvmTarget = JvmTarget.JVM_1_8 } } } diff --git a/buildSrc/src/main/kotlin/code-generator.gradle.kts b/buildSrc/src/main/kotlin/code-generator.gradle.kts index e9fbf74..c044cd4 100644 --- a/buildSrc/src/main/kotlin/code-generator.gradle.kts +++ b/buildSrc/src/main/kotlin/code-generator.gradle.kts @@ -1,77 +1,57 @@ -@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - +import com.google.devtools.ksp.gradle.KspTask import dev.kord.codegen.gradle.CodeGenerationExtension import dev.kord.codegen.gradle.DownloadSourceTask -import java.lang.Boolean as JBoolean plugins { - org.jetbrains.kotlin.multiplatform + org.jetbrains.kotlin.jvm com.google.devtools.ksp } val codeGenerationExtension = extensions.create("codeGeneration", CodeGenerationExtension::class) -val generationSourceAttribute = Attribute.of("generationSource", JBoolean::class.java) val downloadSources by tasks.creating(DownloadSourceTask::class) { dependency = codeGenerationExtension.dependency } kotlin { explicitApi() - jvm() - - targets { - jvm { - attributes { - attribute(generationSourceAttribute, false as java.lang.Boolean) - } - } - jvm("generationSource") { - attributes { - attribute(generationSourceAttribute, true as java.lang.Boolean) - } - - compilations.all { - compilerOptions.configure { - freeCompilerArgs.add("-Xjvm-default=all") - // TODO: Suppress warnings once KT-8087 hits - } + target.compilations { + create("generationSource") { + compilerOptions.configure { + freeCompilerArgs.add("-Xjvm-default=all") + // TODO: Suppress warnings once KT-8087 hits } } } sourceSets { - all { + main { languageSettings.optIn("dev.kord.codegen.kotlinpoet.CodeGenInternal") + kotlin.srcDir("build/generated/ksp/generationSource/kotlin") } - commonMain { - kotlin.srcDir("build/generated/ksp/generationSource/generationSourceMain/kotlin") - } - - named("generationSourceMain") { - kotlin.srcDir(downloadSources.destinationDirectory.map { it.dir("main") }) + named("generationSource") { + kotlin.srcDir(downloadSources.destinationDirectory.map { it.dir("commonMain") }) } } } tasks { - named("compileKotlinGenerationSource") { - dependsOn(downloadSources) - } - afterEvaluate { - val ksp = named("kspKotlinGenerationSource") { + val kspGenerationSourceKotlin by getting(KspTask::class) { dependsOn(downloadSources) + // We don't need to reify twice, actual reification occurs in main source + commandLineArgumentProviders.add(CommandLineArgumentProvider{ listOf("disable-reification=true") }) } - - listOf("compileKotlinJvm", "jvmSourcesJar").forEach { - named(it) { - dependsOn(ksp) - } + compileKotlin { + dependsOn(kspGenerationSourceKotlin) + } + named("kspKotlin") { + dependsOn(kspGenerationSourceKotlin) } } } + ksp { arg { listOf("package-name=${codeGenerationExtension.packageName.get()}") } } diff --git a/buildSrc/src/main/kotlin/dev/kord/codegen/gradle/DownloadSourceTask.kt b/buildSrc/src/main/kotlin/dev/kord/codegen/gradle/DownloadSourceTask.kt index 3f992c6..9901ffc 100644 --- a/buildSrc/src/main/kotlin/dev/kord/codegen/gradle/DownloadSourceTask.kt +++ b/buildSrc/src/main/kotlin/dev/kord/codegen/gradle/DownloadSourceTask.kt @@ -28,7 +28,7 @@ abstract class DownloadSourceTask : DefaultTask() { } val artifacts = project.dependencies.createArtifactResolutionQuery() - .forModule(dependency.group as String, dependency.name, dependency.version as String) + .forModule(dependency.group!!, dependency.name, dependency.version as String) .withArtifacts(JvmLibrary::class.java, SourcesArtifact::class.java) .execute() diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 9eee34a..60fee7b 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -1,9 +1,9 @@ import com.vanniktech.maven.publish.JavadocJar import com.vanniktech.maven.publish.KotlinJvm import com.vanniktech.maven.publish.KotlinMultiplatform -import gradle.kotlin.dsl.accessors._8d1ef46afdac024fc616c6e49cc7c389.kotlin import org.intellij.lang.annotations.Language import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget @@ -58,46 +58,8 @@ mavenPublishing { plugins.withId("org.jetbrains.kotlin.jvm") { configure(KotlinJvm(JavadocJar.Dokka("dokkaHtml"))) } -} -afterEvaluate { plugins.withId("org.jetbrains.kotlin.multiplatform") { - if (kotlin.targets.any { it !is KotlinJvmTarget && it !is KotlinMetadataTarget }) { - mavenPublishing.configure(KotlinMultiplatform(JavadocJar.Dokka("dokkaHtml"))) - return@withId - } - val dokkaJar by tasks.registering(Jar::class) { - from(tasks.named("dokkaHtml")) - archiveClassifier = "javadoc" - } - - - // We're kinda abusing the KMP target system here - // We make an extra jvm target for the kotlinpoet source to run ksp on it, however we don't want to publish - // that target, so we emulate the "jvm" target being a normal Kotlin/JVM project and publish it that way - afterEvaluate { - publishing.publications.create("maven") { - from(kotlin.targets.getByName("jvm").components.first()) - artifact(dokkaJar) - } - } - - // Remove auto-generated KMP publications - tasks { - withType { - enabled = name == "publishMavenPublicationToMavenLocal" - } - - withType { - enabled = name == "publishMavenPublicationToMavenRepository" - || name == "publishMavenPublicationToMavenCentralRepository" - } - - // Theoretically, this makes us loose information, however, that information is not relevant, since this is - // pretty much only a JVM lib targeting JVM 1.8 (so validation of that is unnecessary) - withType { - enabled = false - } - } + configure(KotlinMultiplatform(JavadocJar.Dokka("dokkaHtml"))) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3482613..53f7362 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,25 +1,25 @@ [versions] -kotlin = "1.9.10" -kotlinpoet = "1.14.2" -ksp = "1.9.10-1.0.13" +kotlin = "2.0.0-Beta1" +kotlinpoet = "1.15.0" +ksp = "2.0.0-Beta1-1.0.14" # The compiled binary of codegen.kt we use to compile codegen.kt itself codegen-kt = "main-SNAPSHOT" [libraries] ksp-api = { group = "com.google.devtools.ksp", name = "symbol-processing-api", version.ref = "ksp" } -kotlinpoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinpoet" } +kotlinpoet = { group = "com.squareup", name = "kotlinpoet-jvm", version.ref = "kotlinpoet" } kotlinpoet-ksp = { group = "com.squareup", name = "kotlinpoet-ksp", version.ref = "kotlinpoet" } codegen-kotlinpoet = { group = "dev.kord.codegen", name = "kotlinpoet", version = "main-20230912.212936-5" } codegen-ksp = { group = "dev.kord.codegen", name = "ksp", version = "main-20230912.211940-5" } codegen-ksp-processor = { group = "dev.kord.codegen", name = "ksp-processor", version = "main-20230912.211940-7" } -mockk = { group = "io.mockk", name = "mockk", version = "1.13.7" } +mockk = { group = "io.mockk", name = "mockk", version = "1.13.8" } kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } ksp-plugin = { group = "com.google.devtools.ksp", name = "symbol-processing-gradle-plugin", version.ref = "ksp" } -dokka-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version = "1.9.0" } +dokka-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version = "1.9.10" } maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.3" } binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version = "0.13.2" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34..3fa8f86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 0adc8e1..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/kotlinpoet/api/jvm/kotlinpoet.api b/kotlinpoet/api/kotlinpoet.api similarity index 100% rename from kotlinpoet/api/jvm/kotlinpoet.api rename to kotlinpoet/api/kotlinpoet.api diff --git a/kotlinpoet/build.gradle.kts b/kotlinpoet/build.gradle.kts index 64e63c4..bdbd196 100644 --- a/kotlinpoet/build.gradle.kts +++ b/kotlinpoet/build.gradle.kts @@ -6,12 +6,12 @@ plugins { } dependencies { - commonMainApi(libs.kotlinpoet) - commonMainImplementation(kotlin("reflect")) - commonMainCompileOnly(projects.kotlinpoet.internalAnnotations) - kspCommonMainMetadata(projects.kotlinpoet.processor) + api(libs.kotlinpoet) + implementation(kotlin("reflect")) + compileOnly(projects.kotlinpoet.internalAnnotations) + ksp(projects.kotlinpoet.processor) - commonTestImplementation(kotlin("test-junit5")) + testImplementation(kotlin("test-junit5")) } kotlin { diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt deleted file mode 100644 index 263b968..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.Annotatable -import com.squareup.kotlinpoet.asClassName - -public inline fun , reified A> Annotatable.Builder.addAnnotation(): T - = addAnnotation(A::class.asClassName()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecReified.kt deleted file mode 100644 index db65db5..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecReified.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.asClassName -import kotlin.Annotation - -public inline fun AnnotationSpec.Companion.builder(): - AnnotationSpec.Builder = builder(T::class.asClassName()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt deleted file mode 100644 index 2a6f0fe..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.asClassName -import kotlin.Int - -public inline fun ClassName.compareTo(): Int = compareTo(O::class.asClassName()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt deleted file mode 100644 index c3b17e5..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt +++ /dev/null @@ -1,24 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.FileSpec -import com.squareup.kotlinpoet.asClassName -import kotlin.String -import kotlin.collections.Iterable - -public inline fun FileSpec.Builder.addImport(vararg names: String): FileSpec.Builder = - addImport(C::class.asClassName(), names = names) - -public inline fun FileSpec.Builder.addImport(names: Iterable): FileSpec.Builder - = addImport(C::class.asClassName(), names) - -public inline fun FileSpec.Builder.addAliasedImport(`as`: String): FileSpec.Builder = - addAliasedImport(C::class.asClassName(), `as`) - -public inline fun FileSpec.Builder.addAliasedImport(memberName: String, `as`: String): - FileSpec.Builder = addAliasedImport(C::class.asClassName(), memberName, `as`) - -public inline fun FileSpec.Builder.addAnnotation(): FileSpec.Builder = - addAnnotation(A::class.asClassName()) - -public inline fun FileSpec.Companion.builder(): FileSpec.Builder = - builder(C::class.asClassName()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt deleted file mode 100644 index 044992c..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.CodeBlock -import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.asClassName -import com.squareup.kotlinpoet.typeNameOf - -public inline fun FunSpec.Builder.`receiver`(kdoc: CodeBlock = emptyCodeBlock()): - FunSpec.Builder = `receiver`(typeNameOf(), kdoc) - -public inline fun FunSpec.Builder.returns(kdoc: CodeBlock = emptyCodeBlock()): - FunSpec.Builder = returns(typeNameOf(), kdoc) - -public inline fun FunSpec.Builder.addAnnotation(): FunSpec.Builder = - addAnnotation(A::class.asClassName()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt deleted file mode 100644 index 52f6195..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt +++ /dev/null @@ -1,26 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi -import com.squareup.kotlinpoet.LambdaTypeName -import com.squareup.kotlinpoet.ParameterSpec -import com.squareup.kotlinpoet.TypeName -import com.squareup.kotlinpoet.typeNameOf -import kotlin.collections.List - -@ExperimentalKotlinPoetApi -public inline fun - LambdaTypeName.Companion.`get`(parameters: List = emptyList(), - contextReceivers: List = emptyList()): LambdaTypeName = `get`(typeNameOf(), - parameters, typeNameOf(), contextReceivers) - -public inline fun - LambdaTypeName.Companion.`get`(parameters: List = emptyList()): LambdaTypeName = - `get`(typeNameOf(), parameters, typeNameOf()) - -public inline fun LambdaTypeName.Companion.`get`(vararg parameters: TypeName - = emptyArray()): LambdaTypeName = `get`(typeNameOf(), parameters = parameters, - typeNameOf()) - -public inline fun LambdaTypeName.Companion.`get`(vararg - parameters: ParameterSpec = emptyArray()): LambdaTypeName = `get`(typeNameOf(), - parameters = parameters, typeNameOf()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt deleted file mode 100644 index ccdbaae..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.KModifier -import com.squareup.kotlinpoet.ParameterSpec -import com.squareup.kotlinpoet.asClassName -import com.squareup.kotlinpoet.typeNameOf -import kotlin.String -import kotlin.collections.Iterable - -public inline fun ParameterSpec.toBuilder(name: String = this.name): - ParameterSpec.Builder = toBuilder(name, typeNameOf()) - -public inline fun ParameterSpec.Builder.addAnnotation(): ParameterSpec.Builder = - addAnnotation(A::class.asClassName()) - -public inline fun ParameterSpec.Companion.builder(name: String, vararg - modifiers: KModifier): ParameterSpec.Builder = builder(name, typeNameOf(), - modifiers = modifiers) - -public inline fun ParameterSpec.Companion.builder(name: String, - modifiers: Iterable): ParameterSpec.Builder = builder(name, typeNameOf(), - modifiers) - -public inline fun ParameterSpec.Companion.unnamed(): ParameterSpec = - unnamed(typeNameOf()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt deleted file mode 100644 index 2f83614..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.ParameterizedTypeName -import com.squareup.kotlinpoet.typeNameOf - -public inline fun ParameterizedTypeName.plusParameter(): ParameterizedTypeName = - plusParameter(typeNameOf()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt deleted file mode 100644 index 878e137..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.KModifier -import com.squareup.kotlinpoet.PropertySpec -import com.squareup.kotlinpoet.asClassName -import com.squareup.kotlinpoet.typeNameOf -import kotlin.String -import kotlin.collections.Iterable - -public inline fun PropertySpec.toBuilder(name: String = this.name): PropertySpec.Builder - = toBuilder(name, typeNameOf()) - -public inline fun PropertySpec.Builder.`receiver`(): PropertySpec.Builder = - `receiver`(typeNameOf()) - -public inline fun PropertySpec.Builder.addAnnotation(): PropertySpec.Builder = - addAnnotation(A::class.asClassName()) - -public inline fun PropertySpec.Companion.builder(name: String, vararg - modifiers: KModifier): PropertySpec.Builder = builder(name, typeNameOf(), - modifiers = modifiers) - -public inline fun PropertySpec.Companion.builder(name: String, - modifiers: Iterable): PropertySpec.Builder = builder(name, typeNameOf(), - modifiers) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt deleted file mode 100644 index 0cf0f9b..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.TypeAliasSpec -import com.squareup.kotlinpoet.asClassName -import com.squareup.kotlinpoet.typeNameOf -import kotlin.String - -public inline fun TypeAliasSpec.toBuilder(name: String = this.name): - TypeAliasSpec.Builder = toBuilder(name, typeNameOf()) - -public inline fun TypeAliasSpec.Builder.addAnnotation(): TypeAliasSpec.Builder = - addAnnotation(A::class.asClassName()) - -public inline fun TypeAliasSpec.Companion.builder(name: String): TypeAliasSpec.Builder = - builder(name, typeNameOf()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuilders.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuilders.kt deleted file mode 100644 index cd7deb0..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuilders.kt +++ /dev/null @@ -1,205 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.FileSpec -import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.TypeSpec -import kotlin.contracts.InvocationKind.EXACTLY_ONCE -import kotlin.contracts.contract - -public inline fun TypeSpec.Builder.addClass(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`class`(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addClass(className: ClassName, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`class`(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addExpectClass(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.expectClass(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addExpectClass(className: ClassName, block: TypeSpecBuilderScope - = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.expectClass(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addValueClass(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.valueClass(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addObject(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`object`(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addObject(className: ClassName, block: TypeSpecBuilderScope = - {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`object`(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addCompanionObject(name: String? = null, - block: TypeSpecBuilderScope = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.companionObject(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addInterface(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`interface`(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addInterface(className: ClassName, block: TypeSpecBuilderScope = - {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`interface`(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addFunInterface(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.funInterface(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addFunInterface(className: ClassName, block: TypeSpecBuilderScope - = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.funInterface(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addEnum(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`enum`(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addEnum(className: ClassName, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`enum`(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addAnnotationClass(name: String, block: TypeSpecBuilderScope = - {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`annotation`(name, block).also(::addType) -} - -public inline fun TypeSpec.Builder.addAnnotationClass(className: ClassName, - block: TypeSpecBuilderScope = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`annotation`(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addClass(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`class`(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addClass(className: ClassName, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`class`(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addExpectClass(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.expectClass(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addExpectClass(className: ClassName, block: TypeSpecBuilderScope - = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.expectClass(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addValueClass(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.valueClass(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addObject(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`object`(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addObject(className: ClassName, block: TypeSpecBuilderScope = - {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`object`(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addCompanionObject(name: String? = null, - block: TypeSpecBuilderScope = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.companionObject(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addInterface(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`interface`(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addInterface(className: ClassName, block: TypeSpecBuilderScope = - {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`interface`(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addFunInterface(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.funInterface(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addFunInterface(className: ClassName, block: TypeSpecBuilderScope - = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.funInterface(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addEnum(name: String, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`enum`(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addEnum(className: ClassName, block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`enum`(className, block).also(::addType) -} - -public inline fun FileSpec.Builder.addAnnotationClass(name: String, block: TypeSpecBuilderScope = - {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`annotation`(name, block).also(::addType) -} - -public inline fun FileSpec.Builder.addAnnotationClass(className: ClassName, - block: TypeSpecBuilderScope = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return TypeSpec.`annotation`(className, block).also(::addType) -} - -public inline fun TypeSpec.Builder.primaryConstructor(block: FunSpecBuilderScope = {}): FunSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return FunSpec.`constructor`(block).also(::primaryConstructor) -} diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuildersReified.kt deleted file mode 100644 index 515b3b7..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuildersReified.kt +++ /dev/null @@ -1,89 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.FileSpec -import com.squareup.kotlinpoet.TypeSpec -import com.squareup.kotlinpoet.asClassName -import kotlin.contracts.InvocationKind.EXACTLY_ONCE -import kotlin.contracts.contract - -public inline fun TypeSpec.Builder.addClass(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addClass(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addClass(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addClass(C::class.asClassName(), block) -} - -public inline fun TypeSpec.Builder.addExpectClass(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addExpectClass(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addExpectClass(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addExpectClass(C::class.asClassName(), block) -} - -public inline fun TypeSpec.Builder.addObject(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addObject(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addObject(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addObject(C::class.asClassName(), block) -} - -public inline fun TypeSpec.Builder.addInterface(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addInterface(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addInterface(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addInterface(C::class.asClassName(), block) -} - -public inline fun TypeSpec.Builder.addFunInterface(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addFunInterface(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addFunInterface(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addFunInterface(C::class.asClassName(), block) -} - -public inline fun TypeSpec.Builder.addEnum(block: TypeSpecBuilderScope = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addEnum(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addEnum(block: TypeSpecBuilderScope = {}): TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addEnum(C::class.asClassName(), block) -} - -public inline fun TypeSpec.Builder.addAnnotationClass(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addAnnotationClass(C::class.asClassName(), block) -} - -public inline fun FileSpec.Builder.addAnnotationClass(block: TypeSpecBuilderScope = {}): - TypeSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addAnnotationClass(C::class.asClassName(), block) -} diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt deleted file mode 100644 index cd0e677..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt +++ /dev/null @@ -1,40 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.CodeBlock -import com.squareup.kotlinpoet.TypeSpec -import com.squareup.kotlinpoet.asClassName -import com.squareup.kotlinpoet.typeNameOf -import kotlin.String - -public inline fun TypeSpec.Builder.superclass(): TypeSpec.Builder = - superclass(typeNameOf()) - -public inline fun TypeSpec.Builder.addSuperinterface(`delegate`: CodeBlock = - emptyCodeBlock()): TypeSpec.Builder = addSuperinterface(typeNameOf(), `delegate`) - -public inline fun TypeSpec.Builder.addSuperinterface(constructorParameter: String): - TypeSpec.Builder = addSuperinterface(typeNameOf(), constructorParameter) - -public inline fun TypeSpec.Builder.addAnnotation(): TypeSpec.Builder = - addAnnotation(A::class.asClassName()) - -public inline fun TypeSpec.Companion.classBuilder(): TypeSpec.Builder = - classBuilder(C::class.asClassName()) - -public inline fun TypeSpec.Companion.expectClassBuilder(): TypeSpec.Builder = - expectClassBuilder(C::class.asClassName()) - -public inline fun TypeSpec.Companion.objectBuilder(): TypeSpec.Builder = - objectBuilder(C::class.asClassName()) - -public inline fun TypeSpec.Companion.interfaceBuilder(): TypeSpec.Builder = - interfaceBuilder(C::class.asClassName()) - -public inline fun TypeSpec.Companion.funInterfaceBuilder(): TypeSpec.Builder = - funInterfaceBuilder(C::class.asClassName()) - -public inline fun TypeSpec.Companion.enumBuilder(): TypeSpec.Builder = - enumBuilder(C::class.asClassName()) - -public inline fun TypeSpec.Companion.annotationBuilder(): TypeSpec.Builder = - annotationBuilder(C::class.asClassName()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt deleted file mode 100644 index bf1cc3e..0000000 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.kord.codegen.kotlinpoet - -import com.squareup.kotlinpoet.WildcardTypeName -import com.squareup.kotlinpoet.typeNameOf - -public inline fun WildcardTypeName.Companion.producerOf(): WildcardTypeName = - producerOf(typeNameOf()) - -public inline fun WildcardTypeName.Companion.consumerOf(): WildcardTypeName = - consumerOf(typeNameOf()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactories.kt similarity index 82% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactories.kt index 30d6085..300f49d 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactories.kt +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactories.kt @@ -3,6 +3,7 @@ package dev.kord.codegen.kotlinpoet import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FileSpec.Companion.`get` +import com.squareup.kotlinpoet.MemberName import com.squareup.kotlinpoet.TypeSpec import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract @@ -17,6 +18,11 @@ public inline fun FileSpec(className: ClassName, block: FileSpecBuilderScope = { return FileSpec.builder(className).apply(block).build() } +public inline fun FileSpec(memberName: MemberName, block: FileSpecBuilderScope = {}): FileSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return FileSpec.builder(memberName).apply(block).build() +} + public inline fun FileSpec( packageName: String, fileName: String, diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunSpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowCodeBlock.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowCodeBlock.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowCodeBlock.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowCodeBlock.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFileSpec.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFileSpec.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFileSpec.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFileSpec.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFunSpec.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFunSpec.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFunSpec.kt rename to kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WithControlFlowFunSpec.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AccessorBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AccessorBuilders.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AccessorBuilders.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AccessorBuilders.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuilders.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuilders.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuilders.kt index b0c0b18..af51990 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuilders.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuilders.kt @@ -10,17 +10,6 @@ import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract import kotlin.reflect.KClass -@DelicateKotlinPoetApi(message = - "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") -public fun Annotatable.Builder<*>.addAnnotation(`annotation`: Annotation, - includeDefaultValues: Boolean = false): AnnotationSpec = AnnotationSpec(`annotation`, - includeDefaultValues).also(::addAnnotation) - -@DelicateKotlinPoetApi(message = - "Mirror APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") -public fun Annotatable.Builder<*>.addAnnotation(`annotation`: AnnotationMirror): AnnotationSpec = - AnnotationSpec(`annotation`).also(::addAnnotation) - public inline fun Annotatable.Builder<*>.addAnnotation(type: ClassName, block: AnnotationSpecBuilderScope = {}): AnnotationSpec { contract { callsInPlace(block, EXACTLY_ONCE) } @@ -46,3 +35,14 @@ public inline fun Annotatable.Builder<*>.addAnnotation(type: KClass.addAnnotation(`annotation`: AnnotationMirror): AnnotationSpec = + AnnotationSpec(`annotation`).also(::addAnnotation) + +@DelicateKotlinPoetApi(message = + "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") +public fun Annotatable.Builder<*>.addAnnotation(`annotation`: Annotation, + includeDefaultValues: Boolean = false): AnnotationSpec = AnnotationSpec(`annotation`, + includeDefaultValues).also(::addAnnotation) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuildersReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuildersReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecBuildersReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/AnnotationSpecFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockBuilders.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockBuilders.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/CodeBlockBuilders.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/FileSpecFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunctionSpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/FunctionSpecBuilders.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunctionSpecBuilders.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/FunctionSpecBuilders.kt index 1149bdb..d1181d3 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/FunctionSpecBuilders.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/FunctionSpecBuilders.kt @@ -7,27 +7,21 @@ import com.squareup.kotlinpoet.TypeSpec import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract -public inline fun TypeSpec.Builder.addFunction(name: String, block: FunSpecBuilderScope = {}): - FunSpec { - contract { callsInPlace(block, EXACTLY_ONCE) } - return FunSpec(name, block).also(::addFunction) -} - public inline fun TypeSpec.Builder.addFunction(memberName: MemberName, block: FunSpecBuilderScope = {}): FunSpec { contract { callsInPlace(block, EXACTLY_ONCE) } return FunSpec(memberName, block).also(::addFunction) } -public inline fun TypeSpec.Builder.addConstructor(block: FunSpecBuilderScope = {}): FunSpec { +public inline fun TypeSpec.Builder.addFunction(name: String, block: FunSpecBuilderScope = {}): + FunSpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return FunSpec.`constructor`(block).also(::addFunction) + return FunSpec(name, block).also(::addFunction) } -public inline fun FileSpec.Builder.addFunction(name: String, block: FunSpecBuilderScope = {}): - FunSpec { +public inline fun TypeSpec.Builder.addConstructor(block: FunSpecBuilderScope = {}): FunSpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return FunSpec(name, block).also(::addFunction) + return FunSpec.`constructor`(block).also(::addFunction) } public inline fun FileSpec.Builder.addFunction(memberName: MemberName, block: FunSpecBuilderScope = @@ -35,3 +29,9 @@ public inline fun FileSpec.Builder.addFunction(memberName: MemberName, block: Fu contract { callsInPlace(block, EXACTLY_ONCE) } return FunSpec(memberName, block).also(::addFunction) } + +public inline fun FileSpec.Builder.addFunction(name: String, block: FunSpecBuilderScope = {}): + FunSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return FunSpec(name, block).also(::addFunction) +} diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt index 5c20daf..5fe8687 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt @@ -13,11 +13,6 @@ import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract import kotlin.reflect.KClass -@DelicateKotlinPoetApi(message = - "Element APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") -public fun FunSpec.Builder.addParameter(element: VariableElement): ParameterSpec = - ParameterSpec(element).also(::addParameter) - public inline fun FunSpec.Builder.addParameter( name: String, type: TypeName, @@ -41,28 +36,28 @@ public fun FunSpec.Builder.addParameter( public inline fun FunSpec.Builder.addParameter( name: String, - type: Type, - vararg modifiers: KModifier, + type: TypeName, + modifiers: Iterable, block: ParameterSpecBuilderScope = {}, ): ParameterSpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) + return ParameterSpec(name, type, modifiers, block).also(::addParameter) } public fun FunSpec.Builder.addParameter( - type: Type, - vararg modifiers: KModifier, + type: TypeName, + modifiers: Iterable, block: ParameterSpecBuilderScope = {}, ): SubSpecDelegateProvider { contract { callsInPlace(block, EXACTLY_ONCE) } return produceByName { name -> - ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) + ParameterSpec(name, type, modifiers, block).also(::addParameter) } } public inline fun FunSpec.Builder.addParameter( name: String, - type: KClass<*>, + type: Type, vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, ): ParameterSpec { @@ -71,7 +66,7 @@ public inline fun FunSpec.Builder.addParameter( } public fun FunSpec.Builder.addParameter( - type: KClass<*>, + type: Type, vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, ): SubSpecDelegateProvider { @@ -83,7 +78,7 @@ public fun FunSpec.Builder.addParameter( public inline fun FunSpec.Builder.addParameter( name: String, - type: TypeName, + type: Type, modifiers: Iterable, block: ParameterSpecBuilderScope = {}, ): ParameterSpec { @@ -92,7 +87,7 @@ public inline fun FunSpec.Builder.addParameter( } public fun FunSpec.Builder.addParameter( - type: TypeName, + type: Type, modifiers: Iterable, block: ParameterSpecBuilderScope = {}, ): SubSpecDelegateProvider { @@ -104,22 +99,22 @@ public fun FunSpec.Builder.addParameter( public inline fun FunSpec.Builder.addParameter( name: String, - type: Type, - modifiers: Iterable, + type: KClass<*>, + vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, ): ParameterSpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return ParameterSpec(name, type, modifiers, block).also(::addParameter) + return ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) } public fun FunSpec.Builder.addParameter( - type: Type, - modifiers: Iterable, + type: KClass<*>, + vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, ): SubSpecDelegateProvider { contract { callsInPlace(block, EXACTLY_ONCE) } return produceByName { name -> - ParameterSpec(name, type, modifiers, block).also(::addParameter) + ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) } } @@ -143,3 +138,8 @@ public fun FunSpec.Builder.addParameter( ParameterSpec(name, type, modifiers, block).also(::addParameter) } } + +@DelicateKotlinPoetApi(message = + "Element APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") +public fun FunSpec.Builder.addParameter(element: VariableElement): ParameterSpec = + ParameterSpec(element).also(::addParameter) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt index f140d0f..bc2d7ae 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt @@ -36,28 +36,28 @@ public fun TypeSpec.Builder.addProperty( public inline fun TypeSpec.Builder.addProperty( name: String, - type: Type, - vararg modifiers: KModifier, + type: TypeName, + modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): PropertySpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) + return PropertySpec(name, type, modifiers, block).also(::addProperty) } public fun TypeSpec.Builder.addProperty( - type: Type, - vararg modifiers: KModifier, + type: TypeName, + modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { contract { callsInPlace(block, EXACTLY_ONCE) } return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) + PropertySpec(name, type, modifiers, block).also(::addProperty) } } public inline fun TypeSpec.Builder.addProperty( name: String, - type: KClass<*>, + type: Type, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): PropertySpec { @@ -66,7 +66,7 @@ public inline fun TypeSpec.Builder.addProperty( } public fun TypeSpec.Builder.addProperty( - type: KClass<*>, + type: Type, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { @@ -76,9 +76,11 @@ public fun TypeSpec.Builder.addProperty( } } +@DelicateKotlinPoetApi(message = + "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public inline fun TypeSpec.Builder.addProperty( name: String, - type: TypeName, + type: Type, modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): PropertySpec { @@ -86,8 +88,10 @@ public inline fun TypeSpec.Builder.addProperty( return PropertySpec(name, type, modifiers, block).also(::addProperty) } +@DelicateKotlinPoetApi(message = + "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public fun TypeSpec.Builder.addProperty( - type: TypeName, + type: Type, modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { @@ -97,28 +101,24 @@ public fun TypeSpec.Builder.addProperty( } } -@DelicateKotlinPoetApi(message = - "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public inline fun TypeSpec.Builder.addProperty( name: String, - type: Type, - modifiers: Iterable, + type: KClass<*>, + vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): PropertySpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return PropertySpec(name, type, modifiers, block).also(::addProperty) + return PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } -@DelicateKotlinPoetApi(message = - "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public fun TypeSpec.Builder.addProperty( - type: Type, - modifiers: Iterable, + type: KClass<*>, + vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { contract { callsInPlace(block, EXACTLY_ONCE) } return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } } @@ -166,28 +166,28 @@ public fun FileSpec.Builder.addProperty( public inline fun FileSpec.Builder.addProperty( name: String, - type: Type, - vararg modifiers: KModifier, + type: TypeName, + modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): PropertySpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) + return PropertySpec(name, type, modifiers, block).also(::addProperty) } public fun FileSpec.Builder.addProperty( - type: Type, - vararg modifiers: KModifier, + type: TypeName, + modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { contract { callsInPlace(block, EXACTLY_ONCE) } return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) + PropertySpec(name, type, modifiers, block).also(::addProperty) } } public inline fun FileSpec.Builder.addProperty( name: String, - type: KClass<*>, + type: Type, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): PropertySpec { @@ -196,7 +196,7 @@ public inline fun FileSpec.Builder.addProperty( } public fun FileSpec.Builder.addProperty( - type: KClass<*>, + type: Type, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { @@ -206,9 +206,11 @@ public fun FileSpec.Builder.addProperty( } } +@DelicateKotlinPoetApi(message = + "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public inline fun FileSpec.Builder.addProperty( name: String, - type: TypeName, + type: Type, modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): PropertySpec { @@ -216,8 +218,10 @@ public inline fun FileSpec.Builder.addProperty( return PropertySpec(name, type, modifiers, block).also(::addProperty) } +@DelicateKotlinPoetApi(message = + "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public fun FileSpec.Builder.addProperty( - type: TypeName, + type: Type, modifiers: Iterable, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { @@ -227,28 +231,24 @@ public fun FileSpec.Builder.addProperty( } } -@DelicateKotlinPoetApi(message = - "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public inline fun FileSpec.Builder.addProperty( name: String, - type: Type, - modifiers: Iterable, + type: KClass<*>, + vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): PropertySpec { contract { callsInPlace(block, EXACTLY_ONCE) } - return PropertySpec(name, type, modifiers, block).also(::addProperty) + return PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } -@DelicateKotlinPoetApi(message = - "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.") public fun FileSpec.Builder.addProperty( - type: Type, - modifiers: Iterable, + type: KClass<*>, + vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, ): SubSpecDelegateProvider { contract { callsInPlace(block, EXACTLY_ONCE) } return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } } diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuilders.kt new file mode 100644 index 0000000..baafaa5 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuilders.kt @@ -0,0 +1,109 @@ +package dev.kord.codegen.kotlinpoet + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.TypeSpec +import com.squareup.kotlinpoet.TypeSpecHolder +import kotlin.contracts.InvocationKind.EXACTLY_ONCE +import kotlin.contracts.contract + +public inline fun TypeSpecHolder.Builder<*>.addAnnotationClass(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`annotation`(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addAnnotationClass(name: String, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`annotation`(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addClass(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`class`(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addClass(name: String, block: TypeSpecBuilderScope = + {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`class`(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addCompanionObject(name: String? = null, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.companionObject(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addEnum(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`enum`(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addEnum(name: String, block: TypeSpecBuilderScope = {}): + TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`enum`(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addExpectClass(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.expectClass(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addExpectClass(name: String, block: TypeSpecBuilderScope + = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.expectClass(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addFunInterface(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.funInterface(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addFunInterface(name: String, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.funInterface(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addInterface(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`interface`(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addInterface(name: String, block: TypeSpecBuilderScope = + {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`interface`(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addObject(className: ClassName, + block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`object`(className, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addObject(name: String, block: TypeSpecBuilderScope = + {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.`object`(name, block).also(::addType) +} + +public inline fun TypeSpecHolder.Builder<*>.addValueClass(name: String, block: TypeSpecBuilderScope + = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return TypeSpec.valueClass(name, block).also(::addType) +} + +public inline fun TypeSpec.Builder.primaryConstructor(block: FunSpecBuilderScope = {}): FunSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return FunSpec.`constructor`(block).also(::primaryConstructor) +} diff --git a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuildersReified.kt new file mode 100644 index 0000000..da6bce7 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecBuildersReified.kt @@ -0,0 +1,49 @@ +package dev.kord.codegen.kotlinpoet + +import com.squareup.kotlinpoet.TypeSpec +import com.squareup.kotlinpoet.TypeSpecHolder +import com.squareup.kotlinpoet.asClassName +import kotlin.contracts.InvocationKind.EXACTLY_ONCE +import kotlin.contracts.contract + +public inline fun + TypeSpecHolder.Builder<*>.addAnnotationClass(block: TypeSpecBuilderScope = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addAnnotationClass(C::class.asClassName(), block) +} + +public inline fun TypeSpecHolder.Builder<*>.addClass(block: TypeSpecBuilderScope = {}): + TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addClass(C::class.asClassName(), block) +} + +public inline fun TypeSpecHolder.Builder<*>.addEnum(block: TypeSpecBuilderScope = {}): + TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addEnum(C::class.asClassName(), block) +} + +public inline fun TypeSpecHolder.Builder<*>.addExpectClass(block: TypeSpecBuilderScope = + {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addExpectClass(C::class.asClassName(), block) +} + +public inline fun TypeSpecHolder.Builder<*>.addFunInterface(block: TypeSpecBuilderScope + = {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addFunInterface(C::class.asClassName(), block) +} + +public inline fun TypeSpecHolder.Builder<*>.addInterface(block: TypeSpecBuilderScope = + {}): TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addInterface(C::class.asClassName(), block) +} + +public inline fun TypeSpecHolder.Builder<*>.addObject(block: TypeSpecBuilderScope = {}): + TypeSpec { + contract { callsInPlace(block, EXACTLY_ONCE) } + return addObject(C::class.asClassName(), block) +} diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt similarity index 100% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt similarity index 56% rename from kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt rename to kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt index 3a51454..ac52575 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt @@ -3,10 +3,47 @@ package dev.kord.codegen.kotlinpoet.js import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.ParameterSpec import com.squareup.kotlinpoet.PropertySpec +import com.squareup.kotlinpoet.TypeAliasSpec import com.squareup.kotlinpoet.TypeSpec import dev.kord.codegen.kotlinpoet.addAnnotation +/** + * Adds `ExperimentalJsReflectionCreateInstance` to this [FunSpec] + */ +public fun FunSpec.Builder.experimentalJsReflectionCreateInstance() { + addAnnotation(ClassName("kotlin.js", "ExperimentalJsReflectionCreateInstance")) +} + +/** + * Adds `ExperimentalJsReflectionCreateInstance` to this [ParameterSpec] + */ +public fun ParameterSpec.Builder.experimentalJsReflectionCreateInstance() { + addAnnotation(ClassName("kotlin.js", "ExperimentalJsReflectionCreateInstance")) +} + +/** + * Adds `ExperimentalJsReflectionCreateInstance` to this [TypeSpec] + */ +public fun TypeSpec.Builder.experimentalJsReflectionCreateInstance() { + addAnnotation(ClassName("kotlin.js", "ExperimentalJsReflectionCreateInstance")) +} + +/** + * Adds `ExperimentalJsReflectionCreateInstance` to this [TypeAliasSpec] + */ +public fun TypeAliasSpec.Builder.experimentalJsReflectionCreateInstance() { + addAnnotation(ClassName("kotlin.js", "ExperimentalJsReflectionCreateInstance")) +} + +/** + * Adds `ExperimentalJsReflectionCreateInstance` to this [PropertySpec] + */ +public fun PropertySpec.Builder.experimentalJsReflectionCreateInstance() { + addAnnotation(ClassName("kotlin.js", "ExperimentalJsReflectionCreateInstance")) +} + /** * Adds `JsName` to this [FunSpec] */ @@ -34,6 +71,15 @@ public fun PropertySpec.Builder.jsName(name: String) { } } +/** + * Adds `JsFileName` to this [FileSpec] + */ +public fun FileSpec.Builder.jsFileName(name: String) { + addAnnotation(ClassName("kotlin.js", "JsFileName")) { + addMember("%S", name) + } +} + /** * Adds `JsExport` to this [FileSpec] */ diff --git a/kotlinpoet/processor/src/main/kotlin/AnnotatorProcessor.kt b/kotlinpoet/processor/src/main/kotlin/AnnotatorProcessor.kt index 834baf2..b08da12 100644 --- a/kotlinpoet/processor/src/main/kotlin/AnnotatorProcessor.kt +++ b/kotlinpoet/processor/src/main/kotlin/AnnotatorProcessor.kt @@ -1,6 +1,5 @@ package dev.kord.codegen.generator -import com.google.devtools.ksp.containingFile import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.processing.SymbolProcessor import com.google.devtools.ksp.processing.SymbolProcessorEnvironment diff --git a/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt b/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt index 22937fb..173501b 100644 --- a/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt +++ b/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt @@ -26,7 +26,10 @@ val SymbolProcessorEnvironment.packageName: String private class CodeProcessor private constructor(private val environment: SymbolProcessorEnvironment) : SymbolProcessor { override fun process(resolver: Resolver): List { resolver.getNewFiles() - .onEach { it.accept(environment, ReifyingVisitor) } + .onEach { + if (!environment.options["disable-reification"].toBoolean()) + it.accept(environment, ReifyingVisitor) + } .flatMap(KSFile::declarations) .filter(KSDeclaration::isPublic) .forEach { file -> diff --git a/kotlinpoet/processor/src/main/kotlin/constructor_inliner/ConstructorInliner.kt b/kotlinpoet/processor/src/main/kotlin/constructor_inliner/ConstructorInliner.kt index 35b353a..23020e1 100644 --- a/kotlinpoet/processor/src/main/kotlin/constructor_inliner/ConstructorInliner.kt +++ b/kotlinpoet/processor/src/main/kotlin/constructor_inliner/ConstructorInliner.kt @@ -1,5 +1,3 @@ -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") - package dev.kord.codegen.generator.constructor_inliner import com.google.devtools.ksp.getDeclaredFunctions diff --git a/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt b/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt index 88ce09b..8583af9 100644 --- a/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt +++ b/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt @@ -1,5 +1,3 @@ -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") - package dev.kord.codegen.generator.constructor_inliner import com.google.devtools.ksp.symbol.KSValueParameter diff --git a/kotlinpoet/processor/src/main/kotlin/reification/IsReifyable.kt b/kotlinpoet/processor/src/main/kotlin/reification/IsReifyable.kt index 2e5ba41..9a3d275 100644 --- a/kotlinpoet/processor/src/main/kotlin/reification/IsReifyable.kt +++ b/kotlinpoet/processor/src/main/kotlin/reification/IsReifyable.kt @@ -5,7 +5,7 @@ import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.squareup.kotlinpoet.* import kotlin.reflect.KClass -val ignoreList = listOf("addParameter", "addProperty") +val ignoreList = listOf("addParameter", "addProperty", "builder") /** * Checks whether a [KSFunctionDeclaration] is reifiable. diff --git a/kotlinpoet/processor/src/main/kotlin/utils/Names.kt b/kotlinpoet/processor/src/main/kotlin/utils/Names.kt index 69ec91e..33a8ed3 100644 --- a/kotlinpoet/processor/src/main/kotlin/utils/Names.kt +++ b/kotlinpoet/processor/src/main/kotlin/utils/Names.kt @@ -1,4 +1,3 @@ -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") @file:OptIn(CodeGenInternal::class, DelicateKotlinPoetApi::class) package dev.kord.codegen.generator.utils @@ -10,14 +9,12 @@ import dev.kord.codegen.kotlinpoet.CodeGenDsl import dev.kord.codegen.kotlinpoet.CodeGenInternal import dev.kord.codegen.kotlinpoet.asMemberName import dev.kord.codegen.kotlinpoet.delegate.SubSpecDelegateProvider -import dev.kord.codegen.kotlinpoet.delegate.produceByName import dev.kord.codegen.kotlinpoet.emptyCodeBlock -import kotlin.reflect.KFunction -private val produceByName: KFunction> = ::produceByName +//private val produceByName: KFunction> = ::produceByName val CODEGEN_DSL = CodeGenDsl::class.asClassName() val EMPTY_CODE_BLOCK = ::emptyCodeBlock.asMemberName() -val PRODUCE_BY_NAME = produceByName.asMemberName() +val PRODUCE_BY_NAME = MemberName("dev.kord.codegen.kotlinpoet.delegate", "produceByName") val ADD_ANNOTATION = MemberName("dev.kord.codegen.kotlinpoet", "addAnnotation") val SUB_SPEC_DELEGATE_PROVIDER = SubSpecDelegateProvider::class.asClassName() diff --git a/kotlinpoet/src/commonMain/kotlin/Annotations.kt b/kotlinpoet/src/main/kotlin/Annotations.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/Annotations.kt rename to kotlinpoet/src/main/kotlin/Annotations.kt diff --git a/kotlinpoet/src/commonMain/kotlin/EnumConstantHelper.kt b/kotlinpoet/src/main/kotlin/EnumConstantHelper.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/EnumConstantHelper.kt rename to kotlinpoet/src/main/kotlin/EnumConstantHelper.kt diff --git a/kotlinpoet/src/commonMain/kotlin/MemberName.kt b/kotlinpoet/src/main/kotlin/MemberName.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/MemberName.kt rename to kotlinpoet/src/main/kotlin/MemberName.kt diff --git a/kotlinpoet/src/commonMain/kotlin/ParameterizedClassName.kt b/kotlinpoet/src/main/kotlin/ParameterizedClassName.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/ParameterizedClassName.kt rename to kotlinpoet/src/main/kotlin/ParameterizedClassName.kt diff --git a/kotlinpoet/src/commonMain/kotlin/Utils.kt b/kotlinpoet/src/main/kotlin/Utils.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/Utils.kt rename to kotlinpoet/src/main/kotlin/Utils.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/AccessorBuilders.kt b/kotlinpoet/src/main/kotlin/builders/AccessorBuilders.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/builders/AccessorBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/AccessorBuilders.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/AnnotationSpecBuilders.kt b/kotlinpoet/src/main/kotlin/builders/AnnotationSpecBuilders.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/builders/AnnotationSpecBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/AnnotationSpecBuilders.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/CodeBlockBuilders.kt b/kotlinpoet/src/main/kotlin/builders/CodeBlockBuilders.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/builders/CodeBlockBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/CodeBlockBuilders.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/FunctionSpecBuilders.kt b/kotlinpoet/src/main/kotlin/builders/FunctionSpecBuilders.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/builders/FunctionSpecBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/FunctionSpecBuilders.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/ParameterSpecBuilders.kt b/kotlinpoet/src/main/kotlin/builders/ParameterSpecBuilders.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/builders/ParameterSpecBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/ParameterSpecBuilders.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/PropertySpecBuilders.kt b/kotlinpoet/src/main/kotlin/builders/PropertySpecBuilders.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/builders/PropertySpecBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/PropertySpecBuilders.kt diff --git a/kotlinpoet/src/commonMain/kotlin/builders/TypeSpecBuilders.kt b/kotlinpoet/src/main/kotlin/builders/TypeSpecBuilders.kt similarity index 61% rename from kotlinpoet/src/commonMain/kotlin/builders/TypeSpecBuilders.kt rename to kotlinpoet/src/main/kotlin/builders/TypeSpecBuilders.kt index f4be779..965287c 100644 --- a/kotlinpoet/src/commonMain/kotlin/builders/TypeSpecBuilders.kt +++ b/kotlinpoet/src/main/kotlin/builders/TypeSpecBuilders.kt @@ -1,14 +1,5 @@ @file:InlineConstructor( - forClass = TypeSpec.Builder::class, - functionName = "addType", - nameMapping = [ - InlineConstructor.NameMapping("Annotation", "AnnotationClass") - ], - ignoreBuilders = ["anonymousClassBuilder"] -) - -@file:InlineConstructor( - forClass = FileSpec.Builder::class, + forClass = TypeSpecHolder.Builder::class, functionName = "addType", nameMapping = [ InlineConstructor.NameMapping("Annotation", "AnnotationClass") @@ -24,6 +15,6 @@ package dev.kord.codegen.kotlinpoet.builders -import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.TypeSpecHolder import com.squareup.kotlinpoet.TypeSpec import dev.kord.codegen.ksp.annotations.InlineConstructor diff --git a/kotlinpoet/src/commonMain/kotlin/delegate/SubSpecDelegate.kt b/kotlinpoet/src/main/kotlin/delegate/SubSpecDelegate.kt similarity index 100% rename from kotlinpoet/src/commonMain/kotlin/delegate/SubSpecDelegate.kt rename to kotlinpoet/src/main/kotlin/delegate/SubSpecDelegate.kt diff --git a/kotlinpoet/src/commonMain/kotlin/js/JsAnnotations.kt b/kotlinpoet/src/main/kotlin/js/JsAnnotations.kt similarity index 66% rename from kotlinpoet/src/commonMain/kotlin/js/JsAnnotations.kt rename to kotlinpoet/src/main/kotlin/js/JsAnnotations.kt index 36c2aa6..4829b0a 100644 --- a/kotlinpoet/src/commonMain/kotlin/js/JsAnnotations.kt +++ b/kotlinpoet/src/main/kotlin/js/JsAnnotations.kt @@ -1,6 +1,6 @@ @file:Annotator( "kotlin.js", - ignore = ["ExperimentalJsExport"] + ignore = ["ExperimentalJsExport", "ExperimentalJsFileName"] ) package dev.kord.codegen.kotlinpoet.js diff --git a/kotlinpoet/src/commonTest/kotlin/ExampleTest.kt b/kotlinpoet/src/test/kotlin/ExampleTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/ExampleTest.kt rename to kotlinpoet/src/test/kotlin/ExampleTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/MemberNameTest.kt b/kotlinpoet/src/test/kotlin/MemberNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/MemberNameTest.kt rename to kotlinpoet/src/test/kotlin/MemberNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/NameDelegateTest.kt b/kotlinpoet/src/test/kotlin/NameDelegateTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/NameDelegateTest.kt rename to kotlinpoet/src/test/kotlin/NameDelegateTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/ParameterizedClassNameTest.kt b/kotlinpoet/src/test/kotlin/ParameterizedClassNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/ParameterizedClassNameTest.kt rename to kotlinpoet/src/test/kotlin/ParameterizedClassNameTest.kt diff --git a/ksp/processor/src/main/kotlin/generator/DataClassRepresentation.kt b/ksp/processor/src/main/kotlin/generator/DataClassRepresentation.kt index 5b631a1..f8a95a1 100644 --- a/ksp/processor/src/main/kotlin/generator/DataClassRepresentation.kt +++ b/ksp/processor/src/main/kotlin/generator/DataClassRepresentation.kt @@ -80,7 +80,7 @@ private fun KSClassDeclaration.dataClassSpec( packageName: String, additionalBuilder: TypeSpec.Builder.() -> Unit = {} ): TypeSpec { - return `class`(simpleName.asString()) { + return `class`(simpleName.asString()) clazz@{ addKdoc( """Data class representation of [%T]. |@see Companion.%L @@ -100,7 +100,7 @@ private fun KSClassDeclaration.dataClassSpec( val name = it.simpleName.asString() val type = it.dataClassType(this@dataClassSpec) val parameter = addParameter(name, type) {} - this@`class`.addProperty(name, type) { + this@clazz.addProperty(name, type) { initializer("%N", parameter) } }