From 42f4fc66ff357eeac1a2254daa9152ed4e4e939d Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 18 Nov 2023 21:05:59 +0100 Subject: [PATCH] Generator Improvements - No longer generated incorrect contracts on delegates and reifications - Also add deprecations to reified versions Remove some Suppression of INVISIBLE_REFERENCE --- .../src/main/kotlin/code-generator.gradle.kts | 2 +- kotlinpoet/api/kotlinpoet.api | 104 +++++++----------- .../codegen/kotlinpoet/AnnotatableReified.kt | 7 ++ .../codegen/kotlinpoet/ClassNameReified.kt | 7 ++ .../codegen/kotlinpoet/FileSpecReified.kt | 21 ++++ .../kord/codegen/kotlinpoet/FunSpecReified.kt | 15 +++ .../kotlinpoet/LambdaTypeNameReified.kt | 26 +++++ .../kotlinpoet/ParameterSpecReified.kt | 15 +++ .../ParameterizedTypeNameReified.kt | 7 ++ .../codegen/kotlinpoet/PropertySpecReified.kt | 15 +++ .../kotlinpoet/TypeAliasSpecReified.kt | 12 ++ .../codegen/kotlinpoet/TypeSpecFactories.kt | 21 ++++ .../codegen/kotlinpoet/TypeSpecReified.kt | 51 +++++++++ .../kotlinpoet/WildcardTypeNameReified.kt | 10 ++ .../kotlinpoet/ParameterSpecBuilders.kt | 42 ++----- .../ParameterSpecBuildersReified.kt | 12 +- .../kotlinpoet/PropertySpecBuilders.kt | 84 ++++---------- .../kotlinpoet/PropertySpecBuildersReified.kt | 24 ++-- .../codegen/kotlinpoet/TypeSpecBuilders.kt | 21 ++++ .../kotlinpoet/TypeSpecBuildersReified.kt | 11 ++ .../kotlinpoet/TypeSpecFactoriesReified.kt | 11 ++ .../src/main/kotlin/CodeProcessor.kt | 1 - .../InlinedConstructorGenerator.kt | 4 +- .../src/main/kotlin/reification/Reifyer.kt | 2 +- .../kotlin/reification/ReifyingVisitor.kt | 2 + .../src/main/kotlin/utils/AnnotationUtil.kt | 12 +- kotlinpoet/src/main/kotlin/MemberName.kt | 2 - kotlinpoet/src/main/kotlin/Utils.kt | 5 +- kotlinpoet/src/test/kotlin/ExampleTest.kt | 1 + 29 files changed, 357 insertions(+), 190 deletions(-) create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt create mode 100644 kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt diff --git a/buildSrc/src/main/kotlin/code-generator.gradle.kts b/buildSrc/src/main/kotlin/code-generator.gradle.kts index c044cd4..edd2b42 100644 --- a/buildSrc/src/main/kotlin/code-generator.gradle.kts +++ b/buildSrc/src/main/kotlin/code-generator.gradle.kts @@ -40,7 +40,7 @@ tasks { 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") }) + commandLineArgumentProviders.add(CommandLineArgumentProvider{ listOf("only-reify=com.squareup.kotlinpoet") }) } compileKotlin { dependsOn(kspGenerationSourceKotlin) diff --git a/kotlinpoet/api/kotlinpoet.api b/kotlinpoet/api/kotlinpoet.api index 87235f4..d3bc70c 100644 --- a/kotlinpoet/api/kotlinpoet.api +++ b/kotlinpoet/api/kotlinpoet.api @@ -64,9 +64,11 @@ public final class dev/kord/codegen/kotlinpoet/EnumConstantHelperKt { public final class dev/kord/codegen/kotlinpoet/FileSpecFactoriesKt { public static final fun FileSpec (Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/FileSpec; + public static final fun FileSpec (Lcom/squareup/kotlinpoet/MemberName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/FileSpec; public static final fun FileSpec (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/FileSpec; public static final fun FileSpec (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/FileSpec; public static synthetic fun FileSpec$default (Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec; + public static synthetic fun FileSpec$default (Lcom/squareup/kotlinpoet/MemberName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec; public static synthetic fun FileSpec$default (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec; public static final fun script (Lcom/squareup/kotlinpoet/FileSpec$Companion;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/FileSpec; public static synthetic fun script$default (Lcom/squareup/kotlinpoet/FileSpec$Companion;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec; @@ -234,70 +236,38 @@ public final class dev/kord/codegen/kotlinpoet/TypeAliasSpecFactoriesKt { } public final class dev/kord/codegen/kotlinpoet/TypeSpecBuildersKt { - public static final fun addAnnotationClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addAnnotationClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addAnnotationClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addAnnotationClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addAnnotationClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addAnnotationClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addAnnotationClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addAnnotationClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addCompanionObject (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addCompanionObject (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addCompanionObject$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addCompanionObject$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addEnum (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addEnum (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addEnum (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addEnum (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addEnum$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addEnum$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addEnum$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addEnum$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addExpectClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addExpectClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addExpectClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addExpectClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addExpectClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addExpectClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addExpectClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addExpectClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addFunInterface (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addFunInterface (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addFunInterface (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addFunInterface (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addFunInterface$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addFunInterface$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addFunInterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addFunInterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addInterface (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addInterface (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addInterface (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addInterface (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addInterface$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addInterface$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addInterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addInterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addObject (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addObject (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addObject (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addObject (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addObject$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addObject$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addObject$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addObject$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addValueClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static final fun addValueClass (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addValueClass$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; - public static synthetic fun addValueClass$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addAnnotationClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addAnnotationClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addAnnotationClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addAnnotationClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addCompanionObject (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addCompanionObject$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addEnum (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addEnum (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addEnum$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addEnum$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addExpectClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addExpectClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addExpectClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addExpectClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addFunInterface (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addFunInterface (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addFunInterface$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addFunInterface$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addInterface (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addInterface (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addInterface$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addInterface$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addObject (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addObject (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addObject$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addObject$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; + public static final fun addValueClass (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/TypeSpec; + public static synthetic fun addValueClass$default (Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec; public static final fun primaryConstructor (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/FunSpec; public static synthetic fun primaryConstructor$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec; } @@ -367,6 +337,11 @@ public final class dev/kord/codegen/kotlinpoet/delegate/SubSpecDelegateProvider } public final class dev/kord/codegen/kotlinpoet/js/JsAnnotationsKt { + public static final fun experimentalJsReflectionCreateInstance (Lcom/squareup/kotlinpoet/FunSpec$Builder;)V + public static final fun experimentalJsReflectionCreateInstance (Lcom/squareup/kotlinpoet/ParameterSpec$Builder;)V + public static final fun experimentalJsReflectionCreateInstance (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)V + public static final fun experimentalJsReflectionCreateInstance (Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder;)V + public static final fun experimentalJsReflectionCreateInstance (Lcom/squareup/kotlinpoet/TypeSpec$Builder;)V public static final fun ignore (Lcom/squareup/kotlinpoet/FunSpec$Builder;)V public static final fun ignore (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)V public static final fun ignore (Lcom/squareup/kotlinpoet/TypeSpec$Builder;)V @@ -374,6 +349,7 @@ public final class dev/kord/codegen/kotlinpoet/js/JsAnnotationsKt { public static final fun jsExport (Lcom/squareup/kotlinpoet/FunSpec$Builder;)V public static final fun jsExport (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)V public static final fun jsExport (Lcom/squareup/kotlinpoet/TypeSpec$Builder;)V + public static final fun jsFileName (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;)V public static final fun jsName (Lcom/squareup/kotlinpoet/FunSpec$Builder;Ljava/lang/String;)V public static final fun jsName (Lcom/squareup/kotlinpoet/PropertySpec$Builder;Ljava/lang/String;)V public static final fun jsName (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;)V diff --git a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt new file mode 100644 index 0000000..263b968 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.kt @@ -0,0 +1,7 @@ +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/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt new file mode 100644 index 0000000..2a6f0fe --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.kt @@ -0,0 +1,7 @@ +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/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt new file mode 100644 index 0000000..e61f2b5 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.kt @@ -0,0 +1,21 @@ +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()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt new file mode 100644 index 0000000..044992c --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.kt @@ -0,0 +1,15 @@ +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/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt new file mode 100644 index 0000000..52f6195 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.kt @@ -0,0 +1,26 @@ +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/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt new file mode 100644 index 0000000..a60aa06 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.kt @@ -0,0 +1,15 @@ +package dev.kord.codegen.kotlinpoet + +import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.asClassName +import com.squareup.kotlinpoet.typeNameOf +import kotlin.String + +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.unnamed(): ParameterSpec = + unnamed(typeNameOf()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt new file mode 100644 index 0000000..2f83614 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.kt @@ -0,0 +1,7 @@ +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/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt new file mode 100644 index 0000000..32ccd98 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.kt @@ -0,0 +1,15 @@ +package dev.kord.codegen.kotlinpoet + +import com.squareup.kotlinpoet.PropertySpec +import com.squareup.kotlinpoet.asClassName +import com.squareup.kotlinpoet.typeNameOf +import kotlin.String + +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()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt new file mode 100644 index 0000000..c6a9e94 --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.kt @@ -0,0 +1,12 @@ +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()) diff --git a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt index 1e2195f..93b272e 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactories.kt @@ -19,18 +19,39 @@ public inline fun TypeSpec.Companion.`class`(className: ClassName, block: TypeSp return TypeSpec.classBuilder(className).apply(block).build() } +@Deprecated( + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(name).addModifiers(KModifier.EXPECT)"), + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpec.Companion.expectClass(name: String, block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } return TypeSpec.expectClassBuilder(name).apply(block).build() } +@Deprecated( + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"), + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpec.Companion.expectClass(className: ClassName, block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } return TypeSpec.expectClassBuilder(className).apply(block).build() } +@Deprecated( + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(name).addModifiers(KModifier.VALUE)"), + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpec.Companion.valueClass(name: String, block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } diff --git a/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt new file mode 100644 index 0000000..a8dfcce --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.kt @@ -0,0 +1,51 @@ +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.Deprecated +import kotlin.DeprecationLevel +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress + +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()) + +@Deprecated( + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"), + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) +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/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt new file mode 100644 index 0000000..bf1cc3e --- /dev/null +++ b/kotlinpoet/build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.kt @@ -0,0 +1,10 @@ +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/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt index 5fe8687..cb92300 100644 --- a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuilders.kt @@ -27,11 +27,8 @@ public fun FunSpec.Builder.addParameter( type: TypeName, vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) - } +): SubSpecDelegateProvider = produceByName { name -> + ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) } public inline fun FunSpec.Builder.addParameter( @@ -48,11 +45,8 @@ public fun FunSpec.Builder.addParameter( type: TypeName, modifiers: Iterable, block: ParameterSpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - ParameterSpec(name, type, modifiers, block).also(::addParameter) - } +): SubSpecDelegateProvider = produceByName { name -> + ParameterSpec(name, type, modifiers, block).also(::addParameter) } public inline fun FunSpec.Builder.addParameter( @@ -69,11 +63,8 @@ public fun FunSpec.Builder.addParameter( type: Type, vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) - } +): SubSpecDelegateProvider = produceByName { name -> + ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) } public inline fun FunSpec.Builder.addParameter( @@ -90,11 +81,8 @@ public fun FunSpec.Builder.addParameter( type: Type, modifiers: Iterable, block: ParameterSpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - ParameterSpec(name, type, modifiers, block).also(::addParameter) - } +): SubSpecDelegateProvider = produceByName { name -> + ParameterSpec(name, type, modifiers, block).also(::addParameter) } public inline fun FunSpec.Builder.addParameter( @@ -111,11 +99,8 @@ public fun FunSpec.Builder.addParameter( type: KClass<*>, vararg modifiers: KModifier, block: ParameterSpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) - } +): SubSpecDelegateProvider = produceByName { name -> + ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter) } public inline fun FunSpec.Builder.addParameter( @@ -132,11 +117,8 @@ public fun FunSpec.Builder.addParameter( type: KClass<*>, modifiers: Iterable, block: ParameterSpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - ParameterSpec(name, type, modifiers, block).also(::addParameter) - } +): SubSpecDelegateProvider = produceByName { name -> + ParameterSpec(name, type, modifiers, block).also(::addParameter) } @DelicateKotlinPoetApi(message = diff --git a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt index 612fae5..ce686f1 100644 --- a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecBuildersReified.kt @@ -20,10 +20,8 @@ public inline fun FunSpec.Builder.addParameter( } public inline fun FunSpec.Builder.addParameter(vararg modifiers: KModifier, noinline - block: ParameterSpecBuilderScope = {}): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addParameter(typeNameOf(), modifiers = modifiers, block) -} + block: ParameterSpecBuilderScope = {}): SubSpecDelegateProvider = + addParameter(typeNameOf(), modifiers = modifiers, block) public inline fun FunSpec.Builder.addParameter( name: String, @@ -35,7 +33,5 @@ public inline fun FunSpec.Builder.addParameter( } public inline fun FunSpec.Builder.addParameter(modifiers: Iterable, noinline - block: ParameterSpecBuilderScope = {}): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addParameter(typeNameOf(), modifiers, block) -} + block: ParameterSpecBuilderScope = {}): SubSpecDelegateProvider = + addParameter(typeNameOf(), modifiers, block) diff --git a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt index bc2d7ae..d0cb3f7 100644 --- a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuilders.kt @@ -27,11 +27,8 @@ public fun TypeSpec.Builder.addProperty( type: TypeName, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } public inline fun TypeSpec.Builder.addProperty( @@ -48,11 +45,8 @@ public fun TypeSpec.Builder.addProperty( type: TypeName, modifiers: Iterable, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers, block).also(::addProperty) } public inline fun TypeSpec.Builder.addProperty( @@ -69,11 +63,8 @@ public fun TypeSpec.Builder.addProperty( type: Type, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } @DelicateKotlinPoetApi(message = @@ -94,11 +85,8 @@ public fun TypeSpec.Builder.addProperty( type: Type, modifiers: Iterable, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers, block).also(::addProperty) } public inline fun TypeSpec.Builder.addProperty( @@ -115,11 +103,8 @@ public fun TypeSpec.Builder.addProperty( type: KClass<*>, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } public inline fun TypeSpec.Builder.addProperty( @@ -136,11 +121,8 @@ public fun TypeSpec.Builder.addProperty( type: KClass<*>, modifiers: Iterable, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers, block).also(::addProperty) } public inline fun FileSpec.Builder.addProperty( @@ -157,11 +139,8 @@ public fun FileSpec.Builder.addProperty( type: TypeName, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } public inline fun FileSpec.Builder.addProperty( @@ -178,11 +157,8 @@ public fun FileSpec.Builder.addProperty( type: TypeName, modifiers: Iterable, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers, block).also(::addProperty) } public inline fun FileSpec.Builder.addProperty( @@ -199,11 +175,8 @@ public fun FileSpec.Builder.addProperty( type: Type, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } @DelicateKotlinPoetApi(message = @@ -224,11 +197,8 @@ public fun FileSpec.Builder.addProperty( type: Type, modifiers: Iterable, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers, block).also(::addProperty) } public inline fun FileSpec.Builder.addProperty( @@ -245,11 +215,8 @@ public fun FileSpec.Builder.addProperty( type: KClass<*>, vararg modifiers: KModifier, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty) } public inline fun FileSpec.Builder.addProperty( @@ -266,9 +233,6 @@ public fun FileSpec.Builder.addProperty( type: KClass<*>, modifiers: Iterable, block: PropertySpecBuilderScope = {}, -): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return produceByName { name -> - PropertySpec(name, type, modifiers, block).also(::addProperty) - } +): SubSpecDelegateProvider = produceByName { name -> + PropertySpec(name, type, modifiers, block).also(::addProperty) } diff --git a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt index 0ad0540..75069c2 100644 --- a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecBuildersReified.kt @@ -21,10 +21,8 @@ public inline fun TypeSpec.Builder.addProperty( } public inline fun TypeSpec.Builder.addProperty(vararg modifiers: KModifier, noinline - block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addProperty(typeNameOf(), modifiers = modifiers, block) -} + block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider = + addProperty(typeNameOf(), modifiers = modifiers, block) public inline fun TypeSpec.Builder.addProperty( name: String, @@ -36,10 +34,8 @@ public inline fun TypeSpec.Builder.addProperty( } public inline fun TypeSpec.Builder.addProperty(modifiers: Iterable, noinline - block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addProperty(typeNameOf(), modifiers, block) -} + block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider = + addProperty(typeNameOf(), modifiers, block) public inline fun FileSpec.Builder.addProperty( name: String, @@ -51,10 +47,8 @@ public inline fun FileSpec.Builder.addProperty( } public inline fun FileSpec.Builder.addProperty(vararg modifiers: KModifier, noinline - block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addProperty(typeNameOf(), modifiers = modifiers, block) -} + block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider = + addProperty(typeNameOf(), modifiers = modifiers, block) public inline fun FileSpec.Builder.addProperty( name: String, @@ -66,7 +60,5 @@ public inline fun FileSpec.Builder.addProperty( } public inline fun FileSpec.Builder.addProperty(modifiers: Iterable, noinline - block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider { - contract { callsInPlace(block, EXACTLY_ONCE) } - return addProperty(typeNameOf(), modifiers, block) -} + block: PropertySpecBuilderScope = {}): SubSpecDelegateProvider = + addProperty(typeNameOf(), modifiers, block) 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 index baafaa5..0104371 100644 --- 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 @@ -49,12 +49,26 @@ public inline fun TypeSpecHolder.Builder<*>.addEnum(name: String, block: TypeSpe return TypeSpec.`enum`(name, block).also(::addType) } +@Deprecated( + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"), + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpecHolder.Builder<*>.addExpectClass(className: ClassName, block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } return TypeSpec.expectClass(className, block).also(::addType) } +@Deprecated( + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(name).addModifiers(KModifier.EXPECT)"), + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpecHolder.Builder<*>.addExpectClass(name: String, block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } @@ -97,6 +111,13 @@ public inline fun TypeSpecHolder.Builder<*>.addObject(name: String, block: TypeS return TypeSpec.`object`(name, block).also(::addType) } +@Deprecated( + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(name).addModifiers(KModifier.VALUE)"), + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpecHolder.Builder<*>.addValueClass(name: String, block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } 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 index da6bce7..f7b9639 100644 --- 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 @@ -3,6 +3,10 @@ package dev.kord.codegen.kotlinpoet import com.squareup.kotlinpoet.TypeSpec import com.squareup.kotlinpoet.TypeSpecHolder import com.squareup.kotlinpoet.asClassName +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.ReplaceWith +import kotlin.Suppress import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract @@ -24,6 +28,13 @@ public inline fun TypeSpecHolder.Builder<*>.addEnum(block: TypeSpecB return addEnum(C::class.asClassName(), block) } +@Deprecated( + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"), + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpecHolder.Builder<*>.addExpectClass(block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } diff --git a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt index 12ecdff..25c5553 100644 --- a/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt +++ b/kotlinpoet/build/generated/ksp/main/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecFactoriesReified.kt @@ -2,6 +2,10 @@ package dev.kord.codegen.kotlinpoet import com.squareup.kotlinpoet.TypeSpec import com.squareup.kotlinpoet.asClassName +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.ReplaceWith +import kotlin.Suppress import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract @@ -11,6 +15,13 @@ public inline fun TypeSpec.Companion.`class`(block: TypeSpecBuilderS return `class`(C::class.asClassName(), block) } +@Deprecated( + message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", + replaceWith = ReplaceWith(imports = arrayOf(), expression = + "TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"), + level = DeprecationLevel.WARNING, +) +@Suppress(names = arrayOf("DEPRECATION")) public inline fun TypeSpec.Companion.expectClass(block: TypeSpecBuilderScope = {}): TypeSpec { contract { callsInPlace(block, EXACTLY_ONCE) } diff --git a/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt b/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt index 173501b..e98ab71 100644 --- a/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt +++ b/kotlinpoet/processor/src/main/kotlin/CodeProcessor.kt @@ -27,7 +27,6 @@ private class CodeProcessor private constructor(private val environment: SymbolP override fun process(resolver: Resolver): List { resolver.getNewFiles() .onEach { - if (!environment.options["disable-reification"].toBoolean()) it.accept(environment, ReifyingVisitor) } .flatMap(KSFile::declarations) diff --git a/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt b/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt index 8583af9..8a36cf1 100644 --- a/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt +++ b/kotlinpoet/processor/src/main/kotlin/constructor_inliner/InlinedConstructorGenerator.kt @@ -37,6 +37,9 @@ fun FactoryFunction.generateInlinedConstructorWithNameParameter( ): FunSpec = generateInlinedConstructor(packageName, constructor) { addParameters(this@generateInlinedConstructorWithNameParameter.parameters.map(KSValueParameter::toParameterSpec)) returns(specType.toClassName()) + if (hasBuilder) { + addCallsInPlaceExactlyOnce(getBuilderParameter(packageName)) + } addCode( "returnĀ·%L(%L).also(::%L)", builderFunctionName(), @@ -122,7 +125,6 @@ private fun FactoryFunction.generateInlinedConstructor( if (!noinline) { addModifiers(KModifier.INLINE) } - addCallsInPlaceExactlyOnce(builderParameter) } addAnnotationsFromFunction(this@generateInlinedConstructor) diff --git a/kotlinpoet/processor/src/main/kotlin/reification/Reifyer.kt b/kotlinpoet/processor/src/main/kotlin/reification/Reifyer.kt index 54a36b4..0656cdd 100644 --- a/kotlinpoet/processor/src/main/kotlin/reification/Reifyer.kt +++ b/kotlinpoet/processor/src/main/kotlin/reification/Reifyer.kt @@ -106,7 +106,7 @@ fun MaybeReifiableFunction.reify(): FunSpec { addAnnotationsFromFunction(this@reify) val builderParameter = this@reify.parameters.firstOrNull { it.type.isCallableType() } - if (builderParameter != null) { + if (builderParameter != null && Modifier.INLINE in this@reify.modifiers) { addCallsInPlaceExactlyOnce(ParameterSpec(builderParameter.name!!.asString(), NOTHING)) } addCode("returnĀ·%N(%L)", simpleName.asString(), valueParameters) diff --git a/kotlinpoet/processor/src/main/kotlin/reification/ReifyingVisitor.kt b/kotlinpoet/processor/src/main/kotlin/reification/ReifyingVisitor.kt index a678b61..d0d532e 100644 --- a/kotlinpoet/processor/src/main/kotlin/reification/ReifyingVisitor.kt +++ b/kotlinpoet/processor/src/main/kotlin/reification/ReifyingVisitor.kt @@ -56,6 +56,7 @@ object ReifyingVisitor : VisitorBase() { data: SymbolProcessorEnvironment ) { val ignoredFiles = data.options["ignore-reification"].toString().split(" ") + val packages = data.options["only-reify"] val fileSpec = FileSpec.builder(data.packageName, declarationContainer.simpleName + "Reified").apply { (declarationContainer.getDeclaredFunctions() + declarationContainer.declarations .filterIsInstance() @@ -66,6 +67,7 @@ object ReifyingVisitor : VisitorBase() { } .filter { it is KSFile || (it as KSClassDeclaration).isPublic() } .flatMap(KSDeclarationContainer::getDeclaredFunctions)) + .filter { packages == null || it.packageName.asString().startsWith(packages) } .filter { it.isReifiable() && !it.isConstructor() && it.isPublic() } .process() .forEach { diff --git a/kotlinpoet/processor/src/main/kotlin/utils/AnnotationUtil.kt b/kotlinpoet/processor/src/main/kotlin/utils/AnnotationUtil.kt index 191d8e8..f534e53 100644 --- a/kotlinpoet/processor/src/main/kotlin/utils/AnnotationUtil.kt +++ b/kotlinpoet/processor/src/main/kotlin/utils/AnnotationUtil.kt @@ -1,19 +1,27 @@ package dev.kord.codegen.generator.utils import com.google.devtools.ksp.symbol.KSFunctionDeclaration +import com.squareup.kotlinpoet.DelicateKotlinPoetApi import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.ksp.toAnnotationSpec +import dev.kord.codegen.kotlinpoet.addAnnotation /** * Adds all the annotations from [function] to this [FunSpec]. */ +@OptIn(DelicateKotlinPoetApi::class) fun FunSpec.Builder.addAnnotationsFromFunction(function: KSFunctionDeclaration) { function.annotations.forEach { - val packageName = it.annotationType.resolve().declaration.packageName.asString() + val declaration = it.annotationType.resolve().declaration + val name = declaration.simpleName.asString() + val packageName = declaration.packageName.asString() // Do not add the platform annotations like @JvmStatic or @JsName, since they don't apply in most cases // Or annotations like @Suppress - if (packageName != "kotlin.jvm" && packageName != "kotlin.js" && packageName != "kotlin") { + if ((packageName != "kotlin.jvm" && packageName != "kotlin.js" && packageName != "kotlin") || name == "Deprecated") { addAnnotation(it.toAnnotationSpec()) } + if (name == "Deprecated") { + addAnnotation(Suppress("DEPRECATION")) + } } } diff --git a/kotlinpoet/src/main/kotlin/MemberName.kt b/kotlinpoet/src/main/kotlin/MemberName.kt index 8851e82..c75938a 100644 --- a/kotlinpoet/src/main/kotlin/MemberName.kt +++ b/kotlinpoet/src/main/kotlin/MemberName.kt @@ -1,5 +1,3 @@ -@file:Suppress("INVISIBLE_REFERENCE") - package dev.kord.codegen.kotlinpoet import com.squareup.kotlinpoet.DelicateKotlinPoetApi diff --git a/kotlinpoet/src/main/kotlin/Utils.kt b/kotlinpoet/src/main/kotlin/Utils.kt index ce78ac4..c208b99 100644 --- a/kotlinpoet/src/main/kotlin/Utils.kt +++ b/kotlinpoet/src/main/kotlin/Utils.kt @@ -1,9 +1,6 @@ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") - package dev.kord.codegen.kotlinpoet import com.squareup.kotlinpoet.* -import kotlin.internal.HidesMembers /** * Scope for [withNameAllocator]. @@ -15,7 +12,7 @@ public typealias NamingScope = @CodeGenDsl NameAllocator.() -> Unit * * @see CodeBlock */ -@Suppress("INVISIBLE_MEMBER") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") public fun emptyCodeBlock(): CodeBlock = CodeBlock.EMPTY /** diff --git a/kotlinpoet/src/test/kotlin/ExampleTest.kt b/kotlinpoet/src/test/kotlin/ExampleTest.kt index 87c8a23..59da146 100644 --- a/kotlinpoet/src/test/kotlin/ExampleTest.kt +++ b/kotlinpoet/src/test/kotlin/ExampleTest.kt @@ -46,6 +46,7 @@ class ExampleTest { @Test fun test() = main() + @OptIn(DelicateKotlinPoetApi::class) @Test fun test2() { fun generateListOf() = FunSpec("minOf") {