From a0e66aed3d44b1be95d45ed25f8f7a3d4930307f Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Wed, 20 Sep 2023 20:02:32 +0200 Subject: [PATCH] Code cleanup --- .../codegen/kotlinpoet/js/JsAnnotations.kt | 33 +++++++++---------- .../src/main/kotlin/annotator/Annotator.kt | 5 +-- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt index d90b183..3a51454 100644 --- a/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt +++ b/kotlinpoet/build/generated/ksp/generationSource/generationSourceMain/kotlin/dev/kord/codegen/kotlinpoet/js/JsAnnotations.kt @@ -6,80 +6,79 @@ import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.PropertySpec import com.squareup.kotlinpoet.TypeSpec import dev.kord.codegen.kotlinpoet.addAnnotation -import kotlin.String /** * Adds `JsName` to this [FunSpec] */ public fun FunSpec.Builder.jsName(name: String) { - addAnnotation(ClassName("kotlin.js", "JsName")) { - addMember("%S", name) - } + addAnnotation(ClassName("kotlin.js", "JsName")) { + addMember("%S", name) + } } /** * Adds `JsName` to this [TypeSpec] */ public fun TypeSpec.Builder.jsName(name: String) { - addAnnotation(ClassName("kotlin.js", "JsName")) { - addMember("%S", name) - } + addAnnotation(ClassName("kotlin.js", "JsName")) { + addMember("%S", name) + } } /** * Adds `JsName` to this [PropertySpec] */ public fun PropertySpec.Builder.jsName(name: String) { - addAnnotation(ClassName("kotlin.js", "JsName")) { - addMember("%S", name) - } + addAnnotation(ClassName("kotlin.js", "JsName")) { + addMember("%S", name) + } } /** * Adds `JsExport` to this [FileSpec] */ public fun FileSpec.Builder.jsExport() { - addAnnotation(ClassName("kotlin.js", "JsExport")) + addAnnotation(ClassName("kotlin.js", "JsExport")) } /** * Adds `JsExport` to this [FunSpec] */ public fun FunSpec.Builder.jsExport() { - addAnnotation(ClassName("kotlin.js", "JsExport")) + addAnnotation(ClassName("kotlin.js", "JsExport")) } /** * Adds `JsExport` to this [TypeSpec] */ public fun TypeSpec.Builder.jsExport() { - addAnnotation(ClassName("kotlin.js", "JsExport")) + addAnnotation(ClassName("kotlin.js", "JsExport")) } /** * Adds `JsExport` to this [PropertySpec] */ public fun PropertySpec.Builder.jsExport() { - addAnnotation(ClassName("kotlin.js", "JsExport")) + addAnnotation(ClassName("kotlin.js", "JsExport")) } /** * Adds `Ignore` to this [FunSpec] */ public fun FunSpec.Builder.ignore() { - addAnnotation(ClassName("kotlin.js", "JsExport", "Ignore")) + addAnnotation(ClassName("kotlin.js", "JsExport", "Ignore")) } /** * Adds `Ignore` to this [TypeSpec] */ public fun TypeSpec.Builder.ignore() { - addAnnotation(ClassName("kotlin.js", "JsExport", "Ignore")) + addAnnotation(ClassName("kotlin.js", "JsExport", "Ignore")) } /** * Adds `Ignore` to this [PropertySpec] */ public fun PropertySpec.Builder.ignore() { - addAnnotation(ClassName("kotlin.js", "JsExport", "Ignore")) + addAnnotation(ClassName("kotlin.js", "JsExport", "Ignore")) } diff --git a/kotlinpoet/processor/src/main/kotlin/annotator/Annotator.kt b/kotlinpoet/processor/src/main/kotlin/annotator/Annotator.kt index 817f200..9e5dba5 100644 --- a/kotlinpoet/processor/src/main/kotlin/annotator/Annotator.kt +++ b/kotlinpoet/processor/src/main/kotlin/annotator/Annotator.kt @@ -16,11 +16,11 @@ import com.squareup.kotlinpoet.ksp.writeTo import dev.kord.codegen.generator.utils.ADD_ANNOTATION import dev.kord.codegen.generator.utils.mapToValueParameterList import dev.kord.codegen.kotlinpoet.CodeBlock -import dev.kord.codegen.kotlinpoet.FileSpec import dev.kord.codegen.kotlinpoet.addFunction import dev.kord.codegen.kotlinpoet.withControlFlow import dev.kord.codegen.ksp.annotations.AnnotationArguments.Companion.arguments import dev.kord.codegen.ksp.getAnnotationByType +import dev.kord.codegen.generator.utils.FileSpec @OptIn(KspExperimental::class) fun SymbolProcessorEnvironment.processAnnotators(resolver: Resolver, origin: KSFile, annotators: Sequence) { @@ -31,9 +31,6 @@ fun SymbolProcessorEnvironment.processAnnotators(resolver: Resolver, origin: KSF .filter { it.classKind == ClassKind.ANNOTATION_CLASS } .filter { it.simpleName.asString() !in annotator.ignore } .forEach { - val targetAnnotation = it.getAnnotationByType() - val targetsRaw = targetAnnotation.arguments() - val targets = targetsRaw[Target::allowedTargets]!! it.generateAnnotator(origin, this) } }