diff --git a/.editorconfig b/.editorconfig index 2ab021a..dd90a07 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ end_of_line = lf insert_final_newline = true charset = utf-8 trim_trailing_whitespace = true -max_line_length = 160 +max_line_length = 200 [*.md] trim_trailing_whitespace = false diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index cf7c138..24793b4 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,3 +1,3 @@ Please use one of the following templates: -https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/issues/new/choose +https://github.com/toolisticon/kotlin-code-generation/issues/new/choose diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4cc25b8..149eb22 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,9 @@ updates: open-pull-requests-limit: 10 default-labels: - "Type: dependencies" + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + default-labels: + - "Type: dependencies" diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index e969ec0..0e8bbde 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -41,7 +41,7 @@ jobs: # Publish release - name: Deploy a new release version to Maven Central - run: ./mvnw clean deploy -B -DskipTests -DskipExamples -Prelease -Dgpg.keyname="${{ secrets.GPG_KEYNAME }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -ntp + run: ./mvnw clean deploy -B -ntp -DskipTests -DskipItest -DskipExamples -Prelease -Dgpg.keyname="${{ secrets.GPG_KEYNAME }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" env: OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml index 5e7360d..be535ab 100644 --- a/.github/workflows/release-notes.yml +++ b/.github/workflows/release-notes.yml @@ -9,6 +9,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@master + - name: Create Release Notes Markdown uses: docker://decathlon/release-notes-generator-action:3.1.5 env: @@ -23,7 +24,7 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Create a Draft Release Notes on GitHub id: create_release - uses: actions/create-release@v1 + uses: actions/create-release@v1.1.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: diff --git a/.gitignore b/.gitignore index 3123bc4..51343a9 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,3 @@ build/ ### DEV _tmp/ -.repository/ diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000..9186c2d --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1,2 @@ +--add-opens=java.base/java.lang=ALL-UNNAMED +--add-opens=java.base/java.io=ALL-UNNAMED diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index eacdc9e..8a20f19 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,18 +1,3 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..f8c177b --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ + +This product includes software developed by ZacSweers (https://github.com/ZacSweers). +`dev.zacsweers.kctfork:core:` is published under the MPL-2 license which is considered to be +compatible with the APACHE LICENSE. + diff --git a/README.md b/README.md index 0135d1d..f008425 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,79 @@ -# BASE_ARTIFACT_ID - -Template repository for usage in organizations: toolisticon, holunda-io, holixon... +# kotlin-code-generation [![incubating](https://img.shields.io/badge/lifecycle-INCUBATING-orange.svg)](https://github.com/holisticon#open-source-lifecycle) -[![Build Status](https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/workflows/Development%20branches/badge.svg)](https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/actions) +[![Build Status](https://github.com/toolisticon/kotlin-code-generation/workflows/Development%20branches/badge.svg)](https://github.com/toolisticon/kotlin-code-generation/actions) [![sponsored](https://img.shields.io/badge/sponsoredBy-Holisticon-RED.svg)](https://holisticon.de/) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/BASE_GROUP_ID/BASE_ARTIFACT_ID/badge.svg)](https://maven-badges.herokuapp.com/maven-central/BASE_GROUP_ID/BASE_ARTIFACT_ID) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.kotlin.generation/kotlin-code-generation/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.kotlin.generation/kotlin-code-generation) -This repository is a **template repository** designed to be a template for the next project. +**Usage:** -## How to use +```xml + + + + io.toolisticon.kotlin.generation + kotlin-code-generation-bom + LATEST_VERSION + import + pom + + + +``` -* create a new repo on github (can be in any organization). Choose this project as template repository. Copy all branches, so the `master`exists in your repo (for the github actions) -* on the command line: clone your new repo locally -* in the `setup.sh` script: set your organization, repository and base package -* run the `setup.sh` script, all placeholders are filled with your information -* delete the setup-script -* Update the `README.md` -* in the `developers` section of the `pom.xml`: mention yourself ... it is your project. +## Documentation -## Things to change after usage of template +* see [kotlin-poet](https://square.github.io/kotlinpoet/) -To change the following values, modify the placeholders in `setup.sh` and run it. -This is a one-time operation, you can safely delete the `setup.sh` file afterwards. +## Features -Of course, you can also edit manually .... and do not forget to change this `README.md` with YOUR project specific information :-). +* KotlinAnnotationSpec + * KotlinAnnotationSpecBuilder +* KotlinFileSpec + * KotlinFileSpecBuilder +* KotlinFunSpec + * KotlinFunSpecBuilder +* KotlinParameterSpec + * KotlinParameterSpecBuilder +* KotlinPropertySpec + * KotlinPropertySpecBuilder -### Maven pom.xml -* Maven coordinates: `groupId`, `artifactId` and `version` -* Main description: `name`, `url`, `description` -* SCM: `connection`, `url`, `developerConnection` -### Issue Template +## Roadmap -* correct the URL to repo +### Specs to support -### Issue Labels +* com/squareup/kotlinpoet/TypeAliasSpec +* com/squareup/kotlinpoet/TypeSpec -* Check the release-notes.yml for details, but create the following labels: Type: dependencies, Type: bug, Type: documentation, Type: question, Type: enhancement +### Builders to implement +* com/squareup/kotlinpoet/AnnotationSpec$Builder + * Taggable.Builder +* com/squareup/kotlinpoet/CodeBlock$Builder + * None +* com/squareup/kotlinpoet/FileSpec$Builder + * Annotatable.Builder + * Taggable.Builder + * TypeSpecHolder.Builder +* com/squareup/kotlinpoet/FunSpec$Builder + * Annotatable.Builder + * ContextReceivable.Builder + * Documentable.Builder + * Taggable.Builder + * OriginatingElementsHolder.Builder +* com/squareup/kotlinpoet/ParameterSpec$Builder + * Annotatable.Builder + * Documentable.Builder + * Taggable.Builder +* com/squareup/kotlinpoet/PropertySpec$Builder + * Annotatable.Builder + * ContextReceivable.Builder + * Documentable.Builder + * OriginatingElementsHolder.Builder + * Taggable.Builder +* com/squareup/kotlinpoet/TypeAliasSpec$Builder + * Annotatable.Builder + * Documentable.Builder + * Taggable.Builder diff --git a/_itest/README.md b/_itest/README.md new file mode 100644 index 0000000..167bb39 --- /dev/null +++ b/_itest/README.md @@ -0,0 +1,8 @@ +# Kotlin Code Generation Integration tests + +The repository provides both, the generation module and the test module. +As the test module depends on the generation module, we cannot provide tests using the test module inside that module. + +This additional module is used to define and run all nontrivial integration tests, where we "eat our own dog food" +and use the generation tools and builders to created code and then compile and assert it is working correctly using +the test module. diff --git a/_itest/pom.xml b/_itest/pom.xml new file mode 100644 index 0000000..03500c4 --- /dev/null +++ b/_itest/pom.xml @@ -0,0 +1,85 @@ + + 4.0.0 + + + io.toolisticon.kotlin.generation._ + kotlin-code-generation-parent + 0.0.1 + ../_mvn/parent/pom.xml + + + io.toolisticon.kotlin.generation.itest + kotlin-code-generation-itest + test: ${project.artifactId} + Integration Tests applied on specs, builders and compilation tests. + + + + true + true + + + + + + io.toolisticon.kotlin.generation + kotlin-code-generation-bom + ${project.version} + import + pom + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + provided + + + org.jetbrains.kotlin + kotlin-reflect + provided + + + io.github.microutils + kotlin-logging-jvm + + + + + io.toolisticon.kotlin.generation + kotlin-code-generation + ${project.version} + + + + io.toolisticon.kotlin.generation + kotlin-code-generation-test + ${project.version} + + + + org.jetbrains.kotlinx + kotlinx-serialization-core-jvm + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi + -opt-in=com.squareup.kotlinpoet.ExperimentalKotlinPoetApi + + + + + + diff --git a/_itest/src/main/kotlin/KotlinCodeGenerationITest.kt b/_itest/src/main/kotlin/KotlinCodeGenerationITest.kt new file mode 100644 index 0000000..5d82872 --- /dev/null +++ b/_itest/src/main/kotlin/KotlinCodeGenerationITest.kt @@ -0,0 +1,5 @@ +package io.toolisticon.kotlin.generation.itest + +object KotlinCodeGenerationITest { + const val ROOT_PACKAGE = "io.toolisticon.kotlin.generation.itest.created" +} diff --git a/_itest/src/main/kotlin/MyCustomAnnotationSpec.kt b/_itest/src/main/kotlin/MyCustomAnnotationSpec.kt new file mode 100644 index 0000000..974ddff --- /dev/null +++ b/_itest/src/main/kotlin/MyCustomAnnotationSpec.kt @@ -0,0 +1,21 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.ClassName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotationClass +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFile +import io.toolisticon.kotlin.generation.itest.KotlinCodeGenerationITest.ROOT_PACKAGE + +object MyCustomAnnotationSpec { + val name = ClassName(ROOT_PACKAGE, "MyCustomAnnotation") + + val spec = buildAnnotationClass(name) { + mustBeDocumented() + retention(AnnotationRetention.RUNTIME) + target(AnnotationTarget.CLASS) + addConstructorProperty("value", String::class) + } + + val file = buildFile(name) { + addType(spec) + } +} diff --git a/src/main/resources/.gitkeep b/_itest/src/main/resources/.gitkeep similarity index 100% rename from src/main/resources/.gitkeep rename to _itest/src/main/resources/.gitkeep diff --git a/_itest/src/test/kotlin/HelloWorldExampleTest.kt b/_itest/src/test/kotlin/HelloWorldExampleTest.kt new file mode 100644 index 0000000..8780f55 --- /dev/null +++ b/_itest/src/test/kotlin/HelloWorldExampleTest.kt @@ -0,0 +1,43 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.ClassName +import com.tschuchort.compiletesting.KotlinCompilation +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildClass +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFile +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFun +import io.toolisticon.kotlin.generation.test.KotlinCodeGenerationTest +import io.toolisticon.kotlin.generation.test.model.KotlinCompilationCommand +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HelloWorldExampleTest { + + @Test + fun `hello world from kotlin poet talk`() { + val name = ClassName("foo.bar", "HelloWorld") + + val type = buildClass(name) { + addFunction( + buildFun("helloWorld") { + builder { + returns(String::class) + addCode("return %S", "Hello World!") + } + }) + addKdoc("%L", "Simple hello world class") + } + + val file = buildFile(name) { + addType(type) + } + println(file.code) + + assertThat(file.packageName).isEqualTo("foo.bar") + + val result = KotlinCodeGenerationTest.compile(cmd = KotlinCompilationCommand(fileSpec = file)) + + println(result) + + KotlinCodeGenerationTest.assertThat(result).hasExitCode(KotlinCompilation.ExitCode.OK) + } +} diff --git a/_itest/src/test/kotlin/KotlinAnnotationSpecTest.kt b/_itest/src/test/kotlin/KotlinAnnotationSpecTest.kt new file mode 100644 index 0000000..9ef6cd6 --- /dev/null +++ b/_itest/src/test/kotlin/KotlinAnnotationSpecTest.kt @@ -0,0 +1,11 @@ +package io.toolisticon.kotlin.generation.itest + +import org.junit.jupiter.api.Test + +internal class KotlinAnnotationSpecTest { + + @Test + fun `generate annotation spec`() { + + } +} diff --git a/_itest/src/test/kotlin/KotlinClassBuilderTest.kt b/_itest/src/test/kotlin/KotlinClassBuilderTest.kt new file mode 100644 index 0000000..de0944c --- /dev/null +++ b/_itest/src/test/kotlin/KotlinClassBuilderTest.kt @@ -0,0 +1,15 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.TypeSpec +import org.junit.jupiter.api.Test + +internal class KotlinClassBuilderTest { + + @Test + fun `kotlin poet only generation`() { + val builder = TypeSpec.classBuilder("Bar") + .addKdoc("%L","hello world") + + println(builder.build()) + } +} diff --git a/_itest/src/test/kotlin/KotlinDataClassSpecTest.kt b/_itest/src/test/kotlin/KotlinDataClassSpecTest.kt new file mode 100644 index 0000000..c713710 --- /dev/null +++ b/_itest/src/test/kotlin/KotlinDataClassSpecTest.kt @@ -0,0 +1,37 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.asTypeName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildDataClass +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.dataClassBuilder +import io.toolisticon.kotlin.generation.builder.KotlinDataClassSpecBuilder +import org.junit.jupiter.api.Test + +internal class KotlinDataClassSpecTest { + + @Test + fun `create simple data class`() { + val className = ClassName("foo.bar", "Bar") + val builder: KotlinDataClassSpecBuilder = dataClassBuilder(className) + .addConstructorProperty("name", String::class) + .addConstructorProperty("age", Int::class) + + val spec = buildDataClass(className) { + addConstructorProperty("name", String::class.asTypeName()) + addConstructorProperty("age", Int::class.asTypeName()) + } + +// val file = spec.toFileSpec() +// println(file.code) + +// val result = KotlinCodeGenerationTest.compile(KotlinCompilationCommand(file)) +// +// assertThat(result).errorMessages().isEmpty() +// assertThat(result).hasExitCode(KotlinCompilation.ExitCode.OK) +// +// val klass = result.loadClass() +// assertThat(klass.primaryConstructor!!.call("hello world", 25)) +// .hasToString("Bar(name=hello world, age=25)") +// } + } +} diff --git a/_itest/src/test/kotlin/KotlinFileSpecTest.kt b/_itest/src/test/kotlin/KotlinFileSpecTest.kt new file mode 100644 index 0000000..ef1eb4d --- /dev/null +++ b/_itest/src/test/kotlin/KotlinFileSpecTest.kt @@ -0,0 +1,38 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.FileSpec +import io.toolisticon.kotlin.generation.builder.KotlinFileSpecBuilder +import org.jetbrains.kotlin.metadata.ProtoBuf +import org.junit.jupiter.api.Test + +internal class KotlinFileSpecTest { + + @Target(AnnotationTarget.FILE) + annotation class Foo + + @Test + fun name() { + val spec = FileSpec.builder(ClassName("some","Stuff")) + .addFileComment("%L", "this is a comment") + .addAnnotation(Foo::class) + .build() + + println(spec) + } + + @Test + fun `build filespec`() { + val builder: KotlinFileSpecBuilder = KotlinFileSpecBuilder.builder(ClassName("foo", "Bar")).builder { + addFileComment("%L", "this is a comment.") + } + + val b = builder.builder { + addAnnotation(Foo::class) + } + + val spec = b.build() + + println(spec.code) + } +} diff --git a/_itest/src/test/kotlin/KotlinValueClassIT.kt b/_itest/src/test/kotlin/KotlinValueClassIT.kt new file mode 100644 index 0000000..4ce9026 --- /dev/null +++ b/_itest/src/test/kotlin/KotlinValueClassIT.kt @@ -0,0 +1,58 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.jvm.jvmInline +import io.toolisticon.kotlin.generation.KotlinCodeGeneration +import org.junit.jupiter.api.Test + +internal class KotlinValueClassIT { + + @Test + fun `poet only`() { + val name = ClassName("test","Foo") + + val builder = TypeSpec.classBuilder(name) + .addModifiers(KModifier.VALUE) + .jvmInline() + + val property = PropertySpec.builder("bar", String::class) + .addModifiers(KModifier.PRIVATE) + .build() + + val parameter = ParameterSpec.builder(property.name,property.type) + + println(parameter.build()) + + val constructor = FunSpec.constructorBuilder() + .addParameter(parameter.build()) + builder.addProperty(property.toBuilder() + .initializer("%N", parameter.build()) + .build()) + + builder.primaryConstructor(constructor.build()) + + //println(FileSpec.builder(name).addType(builder.build()).build()) + println(builder.build()) + +// val parameters = parameterSpecs.map(ParameterSpecSupplier::get) +// +// val constructor = FunSpec.constructorBuilder() +// .addParameters(parameters) +// .build() +// val properties = parameters.map { +// PropertySpec.builder(it.name, it.type) +// .initializer("%N", it) +// .build() +// } + +// delegate.primaryConstructor(constructor) +// .addProperties(properties) +// +// return KotlinDataClassSpec(className = className, spec = delegate.build()) + } + + @Test + fun `generate value class wrapping string`() { + TODO() + } +} diff --git a/_itest/src/test/kotlin/MyCustomAnnotationSpecTest.kt b/_itest/src/test/kotlin/MyCustomAnnotationSpecTest.kt new file mode 100644 index 0000000..597c2b0 --- /dev/null +++ b/_itest/src/test/kotlin/MyCustomAnnotationSpecTest.kt @@ -0,0 +1,46 @@ +package io.toolisticon.kotlin.generation.itest + +import com.squareup.kotlinpoet.ClassName +import com.tschuchort.compiletesting.KotlinCompilation +import io.toolisticon.kotlin.generation.KotlinCodeGeneration +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotation +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFile +import io.toolisticon.kotlin.generation.test.KotlinCodeGenerationTest +import io.toolisticon.kotlin.generation.test.model.KotlinCompilationCommand +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import kotlin.reflect.KClass +import io.toolisticon.kotlin.generation.test.KotlinCodeGenerationTest.assertThat as assertThatCompilation + + +internal class MyCustomAnnotationSpecTest { + + @Test + fun `generate class with custom annotation`() { + val name = ClassName(KotlinCodeGenerationITest.ROOT_PACKAGE, "MyClass") + + val customAnnotation = buildAnnotation(MyCustomAnnotationSpec.name) { + addStringMember("value", "hello") + } + + val myClass = KotlinCodeGeneration.buildClass(name) { + addAnnotation(customAnnotation) + } + + val file = buildFile(name) { + addType(myClass) + } + + println(myClass.code) + + val result = KotlinCodeGenerationTest.compile(KotlinCompilationCommand(MyCustomAnnotationSpec.file).plus(file)) + + assertThatCompilation(result).hasExitCode(KotlinCompilation.ExitCode.OK); + + val klass: KClass = result.loadClass(name) + assertThat(klass.annotations).hasSize(1) + val annotation: Annotation = klass.annotations[0] + + //assertThat(annotation::class.) + } +} diff --git a/_itest/src/test/kotlin/TestFixtures.kt b/_itest/src/test/kotlin/TestFixtures.kt new file mode 100644 index 0000000..aea69ae --- /dev/null +++ b/_itest/src/test/kotlin/TestFixtures.kt @@ -0,0 +1,4 @@ +package io.toolisticon.kotlin.generation.itest + +data object TestFixtures { +} diff --git a/src/test/java/.gitkeep b/_itest/src/test/resources/.gitkeep similarity index 100% rename from src/test/java/.gitkeep rename to _itest/src/test/resources/.gitkeep diff --git a/_mvn/bom/pom.xml b/_mvn/bom/pom.xml new file mode 100644 index 0000000..99c60e5 --- /dev/null +++ b/_mvn/bom/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + + + io.toolisticon.kotlin.generation._ + kotlin-code-generation-root + 0.0.1 + ../../pom.xml + + + io.toolisticon.kotlin.generation + kotlin-code-generation-bom + Bill of material for kotlin-code-generation. + pom + + + + + ${project.groupId} + kotlin-code-generation + ${project.version} + + + + ${project.groupId} + kotlin-code-generation-test + ${project.version} + test + + + + diff --git a/_mvn/parent/pom.xml b/_mvn/parent/pom.xml new file mode 100644 index 0000000..5d76f4e --- /dev/null +++ b/_mvn/parent/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + + + io.toolisticon.kotlin.generation._ + kotlin-code-generation-root + 0.0.1 + ../../pom.xml + + + kotlin-code-generation-parent + pom: ${project.artifactId} + Common parent pom for all modules. + pom + + + 1.17.0 + 0.5.0-alpha08 + + + 3.26.0 + 1.5.6 + + + + + + com.squareup + kotlinpoet-jvm + ${kotlin-poet.version} + + + + dev.zacsweers.kctfork + core + test + ${kotlin-compile-testing.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + ch.qos.logback + logback-classic + ${logback.version} + test + + + + + diff --git a/docs/_ADR.md b/docs/_ADR.md new file mode 100644 index 0000000..8e38531 --- /dev/null +++ b/docs/_ADR.md @@ -0,0 +1,5 @@ +# Architecture Decision Records + +## Wrap kotlin-poets specs and builders + +## Builders have an internal constructor and otherwise use the `builder()` factory function diff --git a/docs/kotlinpoet.api b/docs/kotlinpoet.api new file mode 100644 index 0000000..eef2b61 --- /dev/null +++ b/docs/kotlinpoet.api @@ -0,0 +1,1260 @@ +public abstract interface class com/squareup/kotlinpoet/Annotatable { + public abstract fun getAnnotations ()Ljava/util/List; +} + +public abstract interface class com/squareup/kotlinpoet/Annotatable$Builder { + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public abstract fun getAnnotations ()Ljava/util/List; +} + +public final class com/squareup/kotlinpoet/AnnotationSpec : com/squareup/kotlinpoet/Taggable { + public static final field Companion Lcom/squareup/kotlinpoet/AnnotationSpec$Companion; + public static final fun builder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public static final fun builder (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public static final fun builder (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public static final fun builder (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Ljava/lang/annotation/Annotation;)Lcom/squareup/kotlinpoet/AnnotationSpec; + public static final fun get (Ljava/lang/annotation/Annotation;Z)Lcom/squareup/kotlinpoet/AnnotationSpec; + public static final fun get (Ljavax/lang/model/element/AnnotationMirror;)Lcom/squareup/kotlinpoet/AnnotationSpec; + public final fun getClassName ()Lcom/squareup/kotlinpoet/ClassName; + public final fun getMembers ()Ljava/util/List; + public fun getTags ()Ljava/util/Map; + public final fun getTypeName ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getUseSiteTarget ()Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public fun hashCode ()I + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/AnnotationSpec$Builder : com/squareup/kotlinpoet/Taggable$Builder { + public static final field Companion Lcom/squareup/kotlinpoet/AnnotationSpec$Builder$Companion; + public final fun addMember (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public final fun addMember (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/AnnotationSpec; + public final fun getMembers ()Ljava/util/List; + public fun getTags ()Ljava/util/Map; + public final fun useSiteTarget (Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; +} + +public final class com/squareup/kotlinpoet/AnnotationSpec$Builder$Companion { +} + +public final class com/squareup/kotlinpoet/AnnotationSpec$Companion { + public final fun builder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public final fun builder (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public final fun builder (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public final fun builder (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/AnnotationSpec$Builder; + public final fun get (Ljava/lang/annotation/Annotation;)Lcom/squareup/kotlinpoet/AnnotationSpec; + public final fun get (Ljava/lang/annotation/Annotation;Z)Lcom/squareup/kotlinpoet/AnnotationSpec; + public final fun get (Ljavax/lang/model/element/AnnotationMirror;)Lcom/squareup/kotlinpoet/AnnotationSpec; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/AnnotationSpec$Companion;Ljava/lang/annotation/Annotation;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/AnnotationSpec; +} + +public final class com/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget : java/lang/Enum { + public static final field DELEGATE Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field FIELD Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field FILE Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field GET Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field PARAM Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field PROPERTY Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field RECEIVER Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field SET Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static final field SETPARAM Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; + public static fun values ()[Lcom/squareup/kotlinpoet/AnnotationSpec$UseSiteTarget; +} + +public final class com/squareup/kotlinpoet/ClassName : com/squareup/kotlinpoet/TypeName, java/lang/Comparable { + public static final field Companion Lcom/squareup/kotlinpoet/ClassName$Companion; + public fun (Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V + public fun (Ljava/lang/String;Ljava/util/List;)V + public fun (Ljava/lang/String;[Ljava/lang/String;)V + public static final fun bestGuess (Ljava/lang/String;)Lcom/squareup/kotlinpoet/ClassName; + public fun compareTo (Lcom/squareup/kotlinpoet/ClassName;)I + public synthetic fun compareTo (Ljava/lang/Object;)I + public final fun constructorReference ()Lcom/squareup/kotlinpoet/CodeBlock; + public fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/ClassName; + public synthetic fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public final fun enclosingClassName ()Lcom/squareup/kotlinpoet/ClassName; + public fun equals (Ljava/lang/Object;)Z + public final fun getCanonicalName ()Ljava/lang/String; + public final fun getPackageName ()Ljava/lang/String; + public final fun getSimpleName ()Ljava/lang/String; + public final fun getSimpleNames ()Ljava/util/List; + public fun hashCode ()I + public final fun nestedClass (Ljava/lang/String;)Lcom/squareup/kotlinpoet/ClassName; + public final fun peerClass (Ljava/lang/String;)Lcom/squareup/kotlinpoet/ClassName; + public final fun reflectionName ()Ljava/lang/String; + public final fun topLevelClassName ()Lcom/squareup/kotlinpoet/ClassName; +} + +public final class com/squareup/kotlinpoet/ClassName$Companion { + public final fun bestGuess (Ljava/lang/String;)Lcom/squareup/kotlinpoet/ClassName; +} + +public final class com/squareup/kotlinpoet/ClassNames { + public static final fun get (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/ClassName; + public static final fun get (Ljavax/lang/model/element/TypeElement;)Lcom/squareup/kotlinpoet/ClassName; + public static final fun get (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ClassName; +} + +public final class com/squareup/kotlinpoet/CodeBlock { + public static final field Companion Lcom/squareup/kotlinpoet/CodeBlock$Companion; + public synthetic fun (Ljava/util/List;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final fun builder ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public final fun isEmpty ()Z + public final fun isNotEmpty ()Z + public static final fun of (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/CodeBlock$Builder { + public fun ()V + public final fun add (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun add (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun addNamed (Ljava/lang/String;Ljava/util/Map;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun addStatement (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun beginControlFlow (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun clear ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun endControlFlow ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun indent ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun isEmpty ()Z + public final fun isNotEmpty ()Z + public final fun nextControlFlow (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun unindent ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; +} + +public final class com/squareup/kotlinpoet/CodeBlock$Companion { + public final fun builder ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun of (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock; +} + +public final class com/squareup/kotlinpoet/CodeBlocks { + public static final fun buildCodeBlock (Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/CodeBlock; + public static final fun joinToCode (Ljava/util/Collection;)Lcom/squareup/kotlinpoet/CodeBlock; + public static final fun joinToCode (Ljava/util/Collection;Ljava/lang/CharSequence;)Lcom/squareup/kotlinpoet/CodeBlock; + public static final fun joinToCode (Ljava/util/Collection;Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Lcom/squareup/kotlinpoet/CodeBlock; + public static final fun joinToCode (Ljava/util/Collection;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Lcom/squareup/kotlinpoet/CodeBlock; + public static final fun joinToCode (Ljava/util/Collection;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/CodeBlock; + public static synthetic fun joinToCode$default (Ljava/util/Collection;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock; + public static synthetic fun joinToCode$default (Ljava/util/Collection;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/CodeBlock; + public static final fun withIndent (Lcom/squareup/kotlinpoet/CodeBlock$Builder;Lkotlin/jvm/functions/Function1;)Lcom/squareup/kotlinpoet/CodeBlock$Builder; +} + +public abstract interface class com/squareup/kotlinpoet/ContextReceivable { +} + +public abstract interface class com/squareup/kotlinpoet/ContextReceivable$Builder { +} + +public abstract interface annotation class com/squareup/kotlinpoet/DelicateKotlinPoetApi : java/lang/annotation/Annotation { + public abstract fun message ()Ljava/lang/String; +} + +public abstract interface class com/squareup/kotlinpoet/Documentable { + public abstract fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; +} + +public abstract interface class com/squareup/kotlinpoet/Documentable$Builder { + public fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public abstract fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; +} + +public final class com/squareup/kotlinpoet/Dynamic : com/squareup/kotlinpoet/TypeName { + public static final field INSTANCE Lcom/squareup/kotlinpoet/Dynamic; + public synthetic fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public fun copy (ZLjava/util/List;Ljava/util/Map;)Ljava/lang/Void; +} + +public abstract interface annotation class com/squareup/kotlinpoet/ExperimentalKotlinPoetApi : java/lang/annotation/Annotation { +} + +public final class com/squareup/kotlinpoet/FileSpec : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/MemberSpecHolder, com/squareup/kotlinpoet/Taggable, com/squareup/kotlinpoet/TypeSpecHolder { + public static final field Companion Lcom/squareup/kotlinpoet/FileSpec$Companion; + public static final fun builder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static final fun builder (Lcom/squareup/kotlinpoet/MemberName;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static final fun builder (Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/FileSpec; + public fun getAnnotations ()Ljava/util/List; + public final fun getBody ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getComment ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getDefaultImports ()Ljava/util/Set; + public fun getFunSpecs ()Ljava/util/List; + public final fun getMembers ()Ljava/util/List; + public final fun getName ()Ljava/lang/String; + public final fun getPackageName ()Ljava/lang/String; + public fun getPropertySpecs ()Ljava/util/List; + public final fun getRelativePath ()Ljava/lang/String; + public fun getTags ()Ljava/util/Map; + public fun getTypeSpecs ()Ljava/util/List; + public fun hashCode ()I + public final fun isScript ()Z + public static final fun scriptBuilder (Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun toBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun toBuilder (Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static synthetic fun toBuilder$default (Lcom/squareup/kotlinpoet/FileSpec;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun toJavaFileObject ()Ljavax/tools/JavaFileObject; + public fun toString ()Ljava/lang/String; + public final fun writeTo (Ljava/io/File;)Ljava/io/File; + public final synthetic fun writeTo (Ljava/io/File;)V + public final fun writeTo (Ljava/lang/Appendable;)V + public final fun writeTo (Ljava/nio/file/Path;)Ljava/nio/file/Path; + public final synthetic fun writeTo (Ljava/nio/file/Path;)V + public final fun writeTo (Ljavax/annotation/processing/Filer;)V +} + +public final class com/squareup/kotlinpoet/FileSpec$Builder : com/squareup/kotlinpoet/Annotatable$Builder, com/squareup/kotlinpoet/MemberSpecHolder$Builder, com/squareup/kotlinpoet/Taggable$Builder, com/squareup/kotlinpoet/TypeSpecHolder$Builder { + public final fun addAliasedImport (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addAliasedImport (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addAliasedImport (Lcom/squareup/kotlinpoet/MemberName;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addAliasedImport (Ljava/lang/Class;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addAliasedImport (Lkotlin/reflect/KClass;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addBodyComment (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addCode (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addCode (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addComment (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addDefaultPackageImport (Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addFileComment (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun addFunction (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addFunction (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public final fun addImport (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Lcom/squareup/kotlinpoet/ClassName;[Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Lcom/squareup/kotlinpoet/Import;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Ljava/lang/Class;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Ljava/lang/Class;[Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Ljava/lang/Enum;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Ljava/lang/String;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Ljava/lang/String;[Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addImport (Lkotlin/reflect/KClass;[Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addKotlinDefaultImports (ZZ)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static synthetic fun addKotlinDefaultImports$default (Lcom/squareup/kotlinpoet/FileSpec$Builder;ZZILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun addNamedCode (Ljava/lang/String;Ljava/util/Map;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun addProperty (Lcom/squareup/kotlinpoet/PropertySpec;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addProperty (Lcom/squareup/kotlinpoet/PropertySpec;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public final fun addStatement (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun addType (Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addType (Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder; + public final fun addTypeAlias (Lcom/squareup/kotlinpoet/TypeAliasSpec;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun addTypes (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public synthetic fun addTypes (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder; + public final fun beginControlFlow (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/FileSpec; + public final fun clearBody ()Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun clearComment ()Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun clearImports ()Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun endControlFlow ()Lcom/squareup/kotlinpoet/FileSpec$Builder; + public fun getAnnotations ()Ljava/util/List; + public final fun getDefaultImports ()Ljava/util/Set; + public final fun getImports ()Ljava/util/List; + public final fun getMembers ()Ljava/util/List; + public final fun getName ()Ljava/lang/String; + public final fun getPackageName ()Ljava/lang/String; + public fun getTags ()Ljava/util/Map; + public final fun indent (Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun isScript ()Z + public final fun nextControlFlow (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; +} + +public final class com/squareup/kotlinpoet/FileSpec$Companion { + public final fun builder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun builder (Lcom/squareup/kotlinpoet/MemberName;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun builder (Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public final fun get (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/FileSpec; + public final fun scriptBuilder (Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static synthetic fun scriptBuilder$default (Lcom/squareup/kotlinpoet/FileSpec$Companion;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FileSpec$Builder; +} + +public final class com/squareup/kotlinpoet/FunSpec : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/ContextReceivable, com/squareup/kotlinpoet/Documentable, com/squareup/kotlinpoet/OriginatingElementsHolder, com/squareup/kotlinpoet/Taggable { + public static final field Companion Lcom/squareup/kotlinpoet/FunSpec$Companion; + public static final fun builder (Lcom/squareup/kotlinpoet/MemberName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun builder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun constructorBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public fun getAnnotations ()Ljava/util/List; + public final fun getBody ()Lcom/squareup/kotlinpoet/CodeBlock; + public fun getContextReceiverTypes ()Ljava/util/List; + public final fun getDelegateConstructor ()Ljava/lang/String; + public final fun getDelegateConstructorArguments ()Ljava/util/List; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getModifiers ()Ljava/util/Set; + public final fun getName ()Ljava/lang/String; + public fun getOriginatingElements ()Ljava/util/List; + public final fun getParameters ()Ljava/util/List; + public final fun getReceiverKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getReceiverType ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getReturnKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getReturnType ()Lcom/squareup/kotlinpoet/TypeName; + public fun getTags ()Ljava/util/Map; + public final fun getTypeVariables ()Ljava/util/List; + public static final fun getterBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public fun hashCode ()I + public final fun isAccessor ()Z + public final fun isConstructor ()Z + public static final fun overriding (Ljavax/lang/model/element/ExecutableElement;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun overriding (Ljavax/lang/model/element/ExecutableElement;Ljavax/lang/model/type/DeclaredType;Ljavax/lang/model/util/Types;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun setterBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun toBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun toBuilder$default (Lcom/squareup/kotlinpoet/FunSpec;Ljava/lang/String;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/FunSpec$Builder : com/squareup/kotlinpoet/Annotatable$Builder, com/squareup/kotlinpoet/ContextReceivable$Builder, com/squareup/kotlinpoet/Documentable$Builder, com/squareup/kotlinpoet/OriginatingElementsHolder$Builder, com/squareup/kotlinpoet/Taggable$Builder { + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addCode (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addCode (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addComment (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addModifiers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addModifiers ([Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addNamedCode (Ljava/lang/String;Ljava/util/Map;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Lcom/squareup/kotlinpoet/ParameterSpec;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameter (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addParameters (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addStatement (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addTypeVariable (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun addTypeVariables (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun beginControlFlow (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/FunSpec; + public final fun callSuperConstructor (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callSuperConstructor (Ljava/util/List;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callSuperConstructor ([Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callSuperConstructor ([Ljava/lang/String;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun callSuperConstructor$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;[Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callThisConstructor (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callThisConstructor (Ljava/util/List;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callThisConstructor ([Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun callThisConstructor ([Ljava/lang/String;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun callThisConstructor$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;[Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun clearBody ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public synthetic fun contextReceivers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ContextReceivable$Builder; + public final fun endControlFlow ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public fun getAnnotations ()Ljava/util/List; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun getModifiers ()Ljava/util/List; + public fun getOriginatingElements ()Ljava/util/List; + public final fun getParameters ()Ljava/util/List; + public fun getTags ()Ljava/util/Map; + public final fun getTypeVariables ()Ljava/util/List; + public final fun jvmModifiers (Ljava/lang/Iterable;)V + public final fun nextControlFlow (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Ljava/lang/reflect/Type;Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun receiver (Lkotlin/reflect/KClass;Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun receiver$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun receiver$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun receiver$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Ljava/lang/reflect/Type;Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun returns (Lkotlin/reflect/KClass;Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun returns$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun returns$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun returns$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; +} + +public final class com/squareup/kotlinpoet/FunSpec$Companion { + public final fun builder (Lcom/squareup/kotlinpoet/MemberName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun builder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun constructorBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun getterBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun overriding (Ljavax/lang/model/element/ExecutableElement;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun overriding (Ljavax/lang/model/element/ExecutableElement;Ljavax/lang/model/type/DeclaredType;Ljavax/lang/model/util/Types;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public final fun setterBuilder ()Lcom/squareup/kotlinpoet/FunSpec$Builder; +} + +public final class com/squareup/kotlinpoet/Import : java/lang/Comparable { + public fun compareTo (Lcom/squareup/kotlinpoet/Import;)I + public synthetic fun compareTo (Ljava/lang/Object;)I + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/kotlinpoet/Import; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/Import;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/Import; + public fun equals (Ljava/lang/Object;)Z + public final fun getAlias ()Ljava/lang/String; + public final fun getQualifiedName ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/KModifier : java/lang/Enum { + public static final field ABSTRACT Lcom/squareup/kotlinpoet/KModifier; + public static final field ACTUAL Lcom/squareup/kotlinpoet/KModifier; + public static final field ANNOTATION Lcom/squareup/kotlinpoet/KModifier; + public static final field COMPANION Lcom/squareup/kotlinpoet/KModifier; + public static final field CONST Lcom/squareup/kotlinpoet/KModifier; + public static final field CROSSINLINE Lcom/squareup/kotlinpoet/KModifier; + public static final field DATA Lcom/squareup/kotlinpoet/KModifier; + public static final field ENUM Lcom/squareup/kotlinpoet/KModifier; + public static final field EXPECT Lcom/squareup/kotlinpoet/KModifier; + public static final field EXTERNAL Lcom/squareup/kotlinpoet/KModifier; + public static final field FINAL Lcom/squareup/kotlinpoet/KModifier; + public static final field FUN Lcom/squareup/kotlinpoet/KModifier; + public static final field IN Lcom/squareup/kotlinpoet/KModifier; + public static final field INFIX Lcom/squareup/kotlinpoet/KModifier; + public static final field INLINE Lcom/squareup/kotlinpoet/KModifier; + public static final field INNER Lcom/squareup/kotlinpoet/KModifier; + public static final field INTERNAL Lcom/squareup/kotlinpoet/KModifier; + public static final field LATEINIT Lcom/squareup/kotlinpoet/KModifier; + public static final field NOINLINE Lcom/squareup/kotlinpoet/KModifier; + public static final field OPEN Lcom/squareup/kotlinpoet/KModifier; + public static final field OPERATOR Lcom/squareup/kotlinpoet/KModifier; + public static final field OUT Lcom/squareup/kotlinpoet/KModifier; + public static final field OVERRIDE Lcom/squareup/kotlinpoet/KModifier; + public static final field PRIVATE Lcom/squareup/kotlinpoet/KModifier; + public static final field PROTECTED Lcom/squareup/kotlinpoet/KModifier; + public static final field PUBLIC Lcom/squareup/kotlinpoet/KModifier; + public static final field REIFIED Lcom/squareup/kotlinpoet/KModifier; + public static final field SEALED Lcom/squareup/kotlinpoet/KModifier; + public static final field SUSPEND Lcom/squareup/kotlinpoet/KModifier; + public static final field TAILREC Lcom/squareup/kotlinpoet/KModifier; + public static final field VALUE Lcom/squareup/kotlinpoet/KModifier; + public static final field VARARG Lcom/squareup/kotlinpoet/KModifier; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/squareup/kotlinpoet/KModifier; + public static fun values ()[Lcom/squareup/kotlinpoet/KModifier; +} + +public final class com/squareup/kotlinpoet/KOperator : java/lang/Enum { + public static final field CONTAINS Lcom/squareup/kotlinpoet/KOperator; + public static final field DEC Lcom/squareup/kotlinpoet/KOperator; + public static final field DIV Lcom/squareup/kotlinpoet/KOperator; + public static final field DIV_ASSIGN Lcom/squareup/kotlinpoet/KOperator; + public static final field EQUALS Lcom/squareup/kotlinpoet/KOperator; + public static final field GE Lcom/squareup/kotlinpoet/KOperator; + public static final field GT Lcom/squareup/kotlinpoet/KOperator; + public static final field INC Lcom/squareup/kotlinpoet/KOperator; + public static final field ITERATOR Lcom/squareup/kotlinpoet/KOperator; + public static final field LE Lcom/squareup/kotlinpoet/KOperator; + public static final field LT Lcom/squareup/kotlinpoet/KOperator; + public static final field MINUS Lcom/squareup/kotlinpoet/KOperator; + public static final field MINUS_ASSIGN Lcom/squareup/kotlinpoet/KOperator; + public static final field NOT Lcom/squareup/kotlinpoet/KOperator; + public static final field NOT_CONTAINS Lcom/squareup/kotlinpoet/KOperator; + public static final field NOT_EQUALS Lcom/squareup/kotlinpoet/KOperator; + public static final field PLUS Lcom/squareup/kotlinpoet/KOperator; + public static final field PLUS_ASSIGN Lcom/squareup/kotlinpoet/KOperator; + public static final field RANGE_TO Lcom/squareup/kotlinpoet/KOperator; + public static final field REM Lcom/squareup/kotlinpoet/KOperator; + public static final field REM_ASSIGN Lcom/squareup/kotlinpoet/KOperator; + public static final field TIMES Lcom/squareup/kotlinpoet/KOperator; + public static final field TIMES_ASSIGN Lcom/squareup/kotlinpoet/KOperator; + public static final field UNARY_MINUS Lcom/squareup/kotlinpoet/KOperator; + public static final field UNARY_PLUS Lcom/squareup/kotlinpoet/KOperator; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/squareup/kotlinpoet/KOperator; + public static fun values ()[Lcom/squareup/kotlinpoet/KOperator; +} + +public final class com/squareup/kotlinpoet/LambdaTypeName : com/squareup/kotlinpoet/TypeName { + public static final field Companion Lcom/squareup/kotlinpoet/LambdaTypeName$Companion; + public fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public synthetic fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public final fun copy (ZLjava/util/List;ZLjava/util/Map;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/LambdaTypeName;ZLjava/util/List;ZLjava/util/Map;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Lcom/squareup/kotlinpoet/TypeName;Ljava/util/List;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public static final fun get (Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/ParameterSpec;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public static final fun get (Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public final fun getParameters ()Ljava/util/List; + public final fun getReceiver ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getReturnType ()Lcom/squareup/kotlinpoet/TypeName; + public fun hashCode ()I + public final fun isSuspending ()Z +} + +public final class com/squareup/kotlinpoet/LambdaTypeName$Companion { + public final fun get (Lcom/squareup/kotlinpoet/TypeName;Ljava/util/List;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public final fun get (Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/ParameterSpec;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public final fun get (Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/LambdaTypeName$Companion;Lcom/squareup/kotlinpoet/TypeName;Ljava/util/List;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/LambdaTypeName$Companion;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/ParameterSpec;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/LambdaTypeName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/LambdaTypeName$Companion;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/LambdaTypeName; +} + +public final class com/squareup/kotlinpoet/MemberName { + public static final field Companion Lcom/squareup/kotlinpoet/MemberName$Companion; + public fun (Lcom/squareup/kotlinpoet/ClassName;Lcom/squareup/kotlinpoet/KOperator;)V + public fun (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;)V + public fun (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;Z)V + public fun (Ljava/lang/String;Lcom/squareup/kotlinpoet/KOperator;)V + public fun (Ljava/lang/String;Ljava/lang/String;)V + public fun (Ljava/lang/String;Ljava/lang/String;Z)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Lcom/squareup/kotlinpoet/ClassName; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Lcom/squareup/kotlinpoet/KOperator; + public final fun component5 ()Z + public final fun copy (Ljava/lang/String;Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;Lcom/squareup/kotlinpoet/KOperator;Z)Lcom/squareup/kotlinpoet/MemberName; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/MemberName;Ljava/lang/String;Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;Lcom/squareup/kotlinpoet/KOperator;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/MemberName; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Ljava/lang/Class;Ljava/lang/String;)Lcom/squareup/kotlinpoet/MemberName; + public static final fun get (Lkotlin/reflect/KClass;Ljava/lang/String;)Lcom/squareup/kotlinpoet/MemberName; + public final fun getCanonicalName ()Ljava/lang/String; + public final fun getEnclosingClassName ()Lcom/squareup/kotlinpoet/ClassName; + public final fun getOperator ()Lcom/squareup/kotlinpoet/KOperator; + public final fun getPackageName ()Ljava/lang/String; + public final fun getSimpleName ()Ljava/lang/String; + public fun hashCode ()I + public final fun isExtension ()Z + public static final synthetic fun member (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;)Lcom/squareup/kotlinpoet/MemberName; + public final fun reference ()Lcom/squareup/kotlinpoet/CodeBlock; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/MemberName$Companion { + public final fun get (Ljava/lang/Class;Ljava/lang/String;)Lcom/squareup/kotlinpoet/MemberName; + public final fun get (Lkotlin/reflect/KClass;Ljava/lang/String;)Lcom/squareup/kotlinpoet/MemberName; + public final synthetic fun member (Lcom/squareup/kotlinpoet/ClassName;Ljava/lang/String;)Lcom/squareup/kotlinpoet/MemberName; +} + +public abstract interface class com/squareup/kotlinpoet/MemberSpecHolder { + public abstract fun getFunSpecs ()Ljava/util/List; + public abstract fun getPropertySpecs ()Ljava/util/List; +} + +public abstract interface class com/squareup/kotlinpoet/MemberSpecHolder$Builder { + public abstract fun addFunction (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addFunctions (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperties (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public abstract fun addProperty (Lcom/squareup/kotlinpoet/PropertySpec;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; +} + +public final class com/squareup/kotlinpoet/NameAllocator { + public fun ()V + public fun (Z)V + public final fun copy ()Lcom/squareup/kotlinpoet/NameAllocator; + public final fun get (Ljava/lang/Object;)Ljava/lang/String; + public final fun newName (Ljava/lang/String;)Ljava/lang/String; + public final fun newName (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String; + public static synthetic fun newName$default (Lcom/squareup/kotlinpoet/NameAllocator;Ljava/lang/String;Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/String; +} + +public abstract interface class com/squareup/kotlinpoet/OriginatingElementsHolder { + public abstract fun getOriginatingElements ()Ljava/util/List; +} + +public abstract interface class com/squareup/kotlinpoet/OriginatingElementsHolder$Builder { + public fun addOriginatingElement (Ljavax/lang/model/element/Element;)Lcom/squareup/kotlinpoet/OriginatingElementsHolder$Builder; + public abstract fun getOriginatingElements ()Ljava/util/List; +} + +public final class com/squareup/kotlinpoet/OriginatingElementsHolder$Builder$DefaultImpls { + public static fun addOriginatingElement (Lcom/squareup/kotlinpoet/OriginatingElementsHolder$Builder;Ljavax/lang/model/element/Element;)Lcom/squareup/kotlinpoet/OriginatingElementsHolder$Builder; +} + +public final class com/squareup/kotlinpoet/ParameterSpec : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/Documentable, com/squareup/kotlinpoet/Taggable { + public static final field Companion Lcom/squareup/kotlinpoet/ParameterSpec$Companion; + public fun (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)V + public fun (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)V + public static final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public static final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public static final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public static final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public static final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public static final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Ljavax/lang/model/element/VariableElement;)Lcom/squareup/kotlinpoet/ParameterSpec; + public fun getAnnotations ()Ljava/util/List; + public final fun getDefaultValue ()Lcom/squareup/kotlinpoet/CodeBlock; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getModifiers ()Ljava/util/Set; + public final fun getName ()Ljava/lang/String; + public fun getTags ()Ljava/util/Map; + public final fun getType ()Lcom/squareup/kotlinpoet/TypeName; + public fun hashCode ()I + public static final fun parametersOf (Ljavax/lang/model/element/ExecutableElement;)Ljava/util/List; + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public static synthetic fun toBuilder$default (Lcom/squareup/kotlinpoet/ParameterSpec;Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public fun toString ()Ljava/lang/String; + public static final fun unnamed (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterSpec; + public static final fun unnamed (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/ParameterSpec; + public static final fun unnamed (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterSpec; +} + +public final class com/squareup/kotlinpoet/ParameterSpec$Builder : com/squareup/kotlinpoet/Annotatable$Builder, com/squareup/kotlinpoet/Documentable$Builder, com/squareup/kotlinpoet/Taggable$Builder { + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public synthetic fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public synthetic fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public synthetic fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public synthetic fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public synthetic fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun addModifiers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun addModifiers ([Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/ParameterSpec; + public final fun defaultValue (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun defaultValue (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public fun getAnnotations ()Ljava/util/List; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun getModifiers ()Ljava/util/List; + public fun getTags ()Ljava/util/Map; + public final fun jvmModifiers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; +} + +public final class com/squareup/kotlinpoet/ParameterSpec$Companion { + public final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/ParameterSpec$Builder; + public final fun get (Ljavax/lang/model/element/VariableElement;)Lcom/squareup/kotlinpoet/ParameterSpec; + public final fun parametersOf (Ljavax/lang/model/element/ExecutableElement;)Ljava/util/List; + public final fun unnamed (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterSpec; + public final fun unnamed (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/ParameterSpec; + public final fun unnamed (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterSpec; +} + +public final class com/squareup/kotlinpoet/ParameterizedTypeName : com/squareup/kotlinpoet/TypeName { + public static final field Companion Lcom/squareup/kotlinpoet/ParameterizedTypeName$Companion; + public fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public synthetic fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public final fun copy (ZLjava/util/List;Ljava/util/Map;Ljava/util/List;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/ParameterizedTypeName;ZLjava/util/List;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Lcom/squareup/kotlinpoet/ClassName;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Lcom/squareup/kotlinpoet/ClassName;Ljava/util/List;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Lcom/squareup/kotlinpoet/ClassName;[Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Ljava/lang/Class;Ljava/lang/Class;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Ljava/lang/Class;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Ljava/lang/Class;[Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Lkotlin/reflect/KClass;Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public static final fun get (Lkotlin/reflect/KClass;[Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun getRawType ()Lcom/squareup/kotlinpoet/ClassName; + public final fun getTypeArguments ()Ljava/util/List; + public fun hashCode ()I + public final fun nestedClass (Ljava/lang/String;Ljava/util/List;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun plusParameter (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun plusParameter (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun plusParameter (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; +} + +public final class com/squareup/kotlinpoet/ParameterizedTypeName$Companion { + public final fun get (Lcom/squareup/kotlinpoet/ClassName;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Lcom/squareup/kotlinpoet/ClassName;Ljava/util/List;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Lcom/squareup/kotlinpoet/ClassName;[Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Ljava/lang/Class;Ljava/lang/Class;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Ljava/lang/Class;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Ljava/lang/Class;[Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Lkotlin/reflect/KClass;Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; + public final fun get (Lkotlin/reflect/KClass;[Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; +} + +public final class com/squareup/kotlinpoet/ParameterizedTypeNames { + public static final fun asTypeName (Lkotlin/reflect/KType;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun get (Ljava/lang/reflect/ParameterizedType;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; +} + +public final class com/squareup/kotlinpoet/PropertySpec : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/ContextReceivable, com/squareup/kotlinpoet/Documentable, com/squareup/kotlinpoet/OriginatingElementsHolder, com/squareup/kotlinpoet/Taggable { + public static final field Companion Lcom/squareup/kotlinpoet/PropertySpec$Companion; + public static final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public fun getAnnotations ()Ljava/util/List; + public fun getContextReceiverTypes ()Ljava/util/List; + public final fun getDelegated ()Z + public final fun getGetter ()Lcom/squareup/kotlinpoet/FunSpec; + public final fun getInitializer ()Lcom/squareup/kotlinpoet/CodeBlock; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getModifiers ()Ljava/util/Set; + public final fun getMutable ()Z + public final fun getName ()Ljava/lang/String; + public fun getOriginatingElements ()Ljava/util/List; + public final fun getReceiverType ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getSetter ()Lcom/squareup/kotlinpoet/FunSpec; + public fun getTags ()Ljava/util/Map; + public final fun getType ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getTypeVariables ()Ljava/util/List; + public fun hashCode ()I + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun toBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun toBuilder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static synthetic fun toBuilder$default (Lcom/squareup/kotlinpoet/PropertySpec;Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/PropertySpec$Builder : com/squareup/kotlinpoet/Annotatable$Builder, com/squareup/kotlinpoet/ContextReceivable$Builder, com/squareup/kotlinpoet/Documentable$Builder, com/squareup/kotlinpoet/OriginatingElementsHolder$Builder, com/squareup/kotlinpoet/Taggable$Builder { + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public synthetic fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public synthetic fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public synthetic fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public synthetic fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public synthetic fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun addModifiers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun addModifiers ([Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun addTypeVariable (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun addTypeVariables (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/PropertySpec; + public final fun delegate (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun delegate (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public fun getAnnotations ()Ljava/util/List; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun getModifiers ()Ljava/util/List; + public fun getOriginatingElements ()Ljava/util/List; + public fun getTags ()Ljava/util/Map; + public final fun getTypeVariables ()Ljava/util/List; + public final fun getter (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun initializer (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun initializer (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun mutable (Z)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static synthetic fun mutable$default (Lcom/squareup/kotlinpoet/PropertySpec$Builder;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun receiver (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun receiver (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun receiver (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun setter (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; +} + +public final class com/squareup/kotlinpoet/PropertySpec$Companion { + public final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; +} + +public abstract interface class com/squareup/kotlinpoet/Taggable { + public fun getTags ()Ljava/util/Map; + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; +} + +public abstract interface class com/squareup/kotlinpoet/Taggable$Builder { + public abstract fun getTags ()Ljava/util/Map; + public fun tag (Ljava/lang/Class;Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Taggable$Builder; + public fun tag (Lkotlin/reflect/KClass;Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Taggable$Builder; +} + +public final class com/squareup/kotlinpoet/Taggable$Builder$DefaultImpls { + public static fun tag (Lcom/squareup/kotlinpoet/Taggable$Builder;Ljava/lang/Class;Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Taggable$Builder; + public static fun tag (Lcom/squareup/kotlinpoet/Taggable$Builder;Lkotlin/reflect/KClass;Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Taggable$Builder; +} + +public final class com/squareup/kotlinpoet/Taggable$DefaultImpls { + public static fun getTags (Lcom/squareup/kotlinpoet/Taggable;)Ljava/util/Map; + public static fun tag (Lcom/squareup/kotlinpoet/Taggable;Ljava/lang/Class;)Ljava/lang/Object; + public static fun tag (Lcom/squareup/kotlinpoet/Taggable;Lkotlin/reflect/KClass;)Ljava/lang/Object; +} + +public final class com/squareup/kotlinpoet/TypeAliasSpec : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/Documentable, com/squareup/kotlinpoet/Taggable { + public static final field Companion Lcom/squareup/kotlinpoet/TypeAliasSpec$Companion; + public static final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public static final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public static final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public fun getAnnotations ()Ljava/util/List; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getModifiers ()Ljava/util/Set; + public final fun getName ()Ljava/lang/String; + public fun getTags ()Ljava/util/Map; + public final fun getType ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getTypeVariables ()Ljava/util/List; + public fun hashCode ()I + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun toBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun toBuilder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public static synthetic fun toBuilder$default (Lcom/squareup/kotlinpoet/TypeAliasSpec;Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/TypeAliasSpec$Builder : com/squareup/kotlinpoet/Annotatable$Builder, com/squareup/kotlinpoet/Documentable$Builder, com/squareup/kotlinpoet/Taggable$Builder { + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public synthetic fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public synthetic fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public synthetic fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public synthetic fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public synthetic fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun addModifiers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun addModifiers ([Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun addTypeVariable (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun addTypeVariables (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/TypeAliasSpec; + public fun getAnnotations ()Ljava/util/List; + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun getModifiers ()Ljava/util/Set; + public fun getTags ()Ljava/util/Map; + public final fun getTypeVariables ()Ljava/util/Set; +} + +public final class com/squareup/kotlinpoet/TypeAliasSpec$Companion { + public final fun builder (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun builder (Ljava/lang/String;Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; + public final fun builder (Ljava/lang/String;Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeAliasSpec$Builder; +} + +public abstract class com/squareup/kotlinpoet/TypeName : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/Taggable { + public static final field Companion Lcom/squareup/kotlinpoet/TypeName$Companion; + public synthetic fun (ZLjava/util/List;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy (ZLjava/util/List;)Lcom/squareup/kotlinpoet/TypeName; + public abstract fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/TypeName;ZLjava/util/List;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeName; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/TypeName;ZLjava/util/List;Ljava/util/Map;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeName; + public fun equals (Ljava/lang/Object;)Z + public fun getAnnotations ()Ljava/util/List; + public fun getTags ()Ljava/util/Map; + public fun hashCode ()I + public final fun isAnnotated ()Z + public final fun isNullable ()Z + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun toString ()Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/TypeName$Companion { +} + +public final class com/squareup/kotlinpoet/TypeNames { + public static final field ANNOTATION Lcom/squareup/kotlinpoet/ClassName; + public static final field ANY Lcom/squareup/kotlinpoet/ClassName; + public static final field ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field BOOLEAN Lcom/squareup/kotlinpoet/ClassName; + public static final field BOOLEAN_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field BYTE Lcom/squareup/kotlinpoet/ClassName; + public static final field BYTE_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field CHAR Lcom/squareup/kotlinpoet/ClassName; + public static final field CHAR_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field CHAR_SEQUENCE Lcom/squareup/kotlinpoet/ClassName; + public static final field COLLECTION Lcom/squareup/kotlinpoet/ClassName; + public static final field COMPARABLE Lcom/squareup/kotlinpoet/ClassName; + public static final field DOUBLE Lcom/squareup/kotlinpoet/ClassName; + public static final field DOUBLE_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field DYNAMIC Lcom/squareup/kotlinpoet/Dynamic; + public static final field ENUM Lcom/squareup/kotlinpoet/ClassName; + public static final field FLOAT Lcom/squareup/kotlinpoet/ClassName; + public static final field FLOAT_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field INT Lcom/squareup/kotlinpoet/ClassName; + public static final field INT_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field ITERABLE Lcom/squareup/kotlinpoet/ClassName; + public static final field LIST Lcom/squareup/kotlinpoet/ClassName; + public static final field LONG Lcom/squareup/kotlinpoet/ClassName; + public static final field LONG_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field MAP Lcom/squareup/kotlinpoet/ClassName; + public static final field MAP_ENTRY Lcom/squareup/kotlinpoet/ClassName; + public static final field MUTABLE_COLLECTION Lcom/squareup/kotlinpoet/ClassName; + public static final field MUTABLE_ITERABLE Lcom/squareup/kotlinpoet/ClassName; + public static final field MUTABLE_LIST Lcom/squareup/kotlinpoet/ClassName; + public static final field MUTABLE_MAP Lcom/squareup/kotlinpoet/ClassName; + public static final field MUTABLE_MAP_ENTRY Lcom/squareup/kotlinpoet/ClassName; + public static final field MUTABLE_SET Lcom/squareup/kotlinpoet/ClassName; + public static final field NOTHING Lcom/squareup/kotlinpoet/ClassName; + public static final field NUMBER Lcom/squareup/kotlinpoet/ClassName; + public static final field SET Lcom/squareup/kotlinpoet/ClassName; + public static final field SHORT Lcom/squareup/kotlinpoet/ClassName; + public static final field SHORT_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field STAR Lcom/squareup/kotlinpoet/WildcardTypeName; + public static final field STRING Lcom/squareup/kotlinpoet/ClassName; + public static final field THROWABLE Lcom/squareup/kotlinpoet/ClassName; + public static final field UNIT Lcom/squareup/kotlinpoet/ClassName; + public static final field U_BYTE Lcom/squareup/kotlinpoet/ClassName; + public static final field U_BYTE_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field U_INT Lcom/squareup/kotlinpoet/ClassName; + public static final field U_INT_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field U_LONG Lcom/squareup/kotlinpoet/ClassName; + public static final field U_LONG_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final field U_SHORT Lcom/squareup/kotlinpoet/ClassName; + public static final field U_SHORT_ARRAY Lcom/squareup/kotlinpoet/ClassName; + public static final fun get (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun get (Ljavax/lang/model/type/TypeMirror;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun get (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/ClassName; +} + +public final class com/squareup/kotlinpoet/TypeSpec : com/squareup/kotlinpoet/Annotatable, com/squareup/kotlinpoet/ContextReceivable, com/squareup/kotlinpoet/Documentable, com/squareup/kotlinpoet/MemberSpecHolder, com/squareup/kotlinpoet/OriginatingElementsHolder, com/squareup/kotlinpoet/Taggable, com/squareup/kotlinpoet/TypeSpecHolder { + public static final field Companion Lcom/squareup/kotlinpoet/TypeSpec$Companion; + public static final fun annotationBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun annotationBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun anonymousClassBuilder ()Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun classBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun classBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun companionObjectBuilder ()Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun companionObjectBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun enumBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun enumBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public fun equals (Ljava/lang/Object;)Z + public static final fun expectClassBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun expectClassBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun funInterfaceBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun funInterfaceBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun getAnnotationSpecs ()Ljava/util/List; + public fun getAnnotations ()Ljava/util/List; + public fun getContextReceiverTypes ()Ljava/util/List; + public final fun getEnumConstants ()Ljava/util/Map; + public fun getFunSpecs ()Ljava/util/List; + public final fun getInitializerBlock ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getInitializerIndex ()I + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock; + public final fun getKind ()Lcom/squareup/kotlinpoet/TypeSpec$Kind; + public final fun getModifiers ()Ljava/util/Set; + public final fun getName ()Ljava/lang/String; + public fun getOriginatingElements ()Ljava/util/List; + public final fun getPrimaryConstructor ()Lcom/squareup/kotlinpoet/FunSpec; + public fun getPropertySpecs ()Ljava/util/List; + public final fun getSuperclass ()Lcom/squareup/kotlinpoet/TypeName; + public final fun getSuperclassConstructorParameters ()Ljava/util/List; + public final fun getSuperinterfaces ()Ljava/util/Map; + public fun getTags ()Ljava/util/Map; + public fun getTypeSpecs ()Ljava/util/List; + public final fun getTypeVariables ()Ljava/util/List; + public fun hashCode ()I + public static final fun interfaceBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun interfaceBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun isAnnotation ()Z + public final fun isAnonymousClass ()Z + public final fun isCompanion ()Z + public final fun isEnum ()Z + public final fun isFunctionalInterface ()Z + public static final fun objectBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun objectBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public fun tag (Ljava/lang/Class;)Ljava/lang/Object; + public fun tag (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun toBuilder ()Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun toBuilder (Lcom/squareup/kotlinpoet/TypeSpec$Kind;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun toBuilder (Lcom/squareup/kotlinpoet/TypeSpec$Kind;Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun toBuilder$default (Lcom/squareup/kotlinpoet/TypeSpec;Lcom/squareup/kotlinpoet/TypeSpec$Kind;Ljava/lang/String;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public fun toString ()Ljava/lang/String; + public static final fun valueClassBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; +} + +public final class com/squareup/kotlinpoet/TypeSpec$Builder : com/squareup/kotlinpoet/Annotatable$Builder, com/squareup/kotlinpoet/ContextReceivable$Builder, com/squareup/kotlinpoet/Documentable$Builder, com/squareup/kotlinpoet/MemberSpecHolder$Builder, com/squareup/kotlinpoet/OriginatingElementsHolder$Builder, com/squareup/kotlinpoet/Taggable$Builder, com/squareup/kotlinpoet/TypeSpecHolder$Builder { + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/AnnotationSpec;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Ljava/lang/Class;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotation (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/Annotatable$Builder; + public fun addAnnotations (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addEnumConstant (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addEnumConstant (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun addEnumConstant$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeSpec;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addFunction (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addFunction (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addFunctions (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addFunctions (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addInitializerBlock (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/Documentable$Builder; + public fun addKdoc (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addModifiers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addModifiers ([Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperties (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperties (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Lcom/squareup/kotlinpoet/PropertySpec;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Lcom/squareup/kotlinpoet/PropertySpec;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lcom/squareup/kotlinpoet/TypeName;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Ljava/lang/reflect/Type;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Ljava/lang/reflect/Type;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lkotlin/reflect/KClass;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addProperty (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/MemberSpecHolder$Builder; + public fun addProperty (Ljava/lang/String;Lkotlin/reflect/KClass;[Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperclassConstructorParameter (Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperclassConstructorParameter (Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperinterface (Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperinterface (Lcom/squareup/kotlinpoet/TypeName;Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperinterface (Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperinterface (Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/CodeBlock;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperinterface (Lkotlin/reflect/KClass;Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun addSuperinterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun addSuperinterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun addSuperinterface$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/CodeBlock;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addSuperinterfaces (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public fun addType (Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addType (Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder; + public final fun addTypeVariable (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun addTypeVariables (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public fun addTypes (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public synthetic fun addTypes (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder; + public final fun build ()Lcom/squareup/kotlinpoet/TypeSpec; + public synthetic fun contextReceivers (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/ContextReceivable$Builder; + public final fun getAnnotationSpecs ()Ljava/util/List; + public fun getAnnotations ()Ljava/util/List; + public final fun getEnumConstants ()Ljava/util/Map; + public final fun getFunSpecs ()Ljava/util/List; + public final fun getInitializerIndex ()I + public fun getKdoc ()Lcom/squareup/kotlinpoet/CodeBlock$Builder; + public final fun getModifiers ()Ljava/util/Set; + public fun getOriginatingElements ()Ljava/util/List; + public final fun getPropertySpecs ()Ljava/util/List; + public final fun getSuperclassConstructorParameters ()Ljava/util/List; + public final fun getSuperinterfaces ()Ljava/util/Map; + public fun getTags ()Ljava/util/Map; + public final fun getTypeSpecs ()Ljava/util/List; + public final fun getTypeVariables ()Ljava/util/List; + public final fun primaryConstructor (Lcom/squareup/kotlinpoet/FunSpec;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun setInitializerIndex (I)V + public final fun superclass (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun superclass (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun superclass (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; +} + +public final class com/squareup/kotlinpoet/TypeSpec$Companion { + public final fun annotationBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun annotationBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun anonymousClassBuilder ()Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun classBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun classBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun companionObjectBuilder ()Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun companionObjectBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun companionObjectBuilder$default (Lcom/squareup/kotlinpoet/TypeSpec$Companion;Ljava/lang/String;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun enumBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun enumBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun expectClassBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun expectClassBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun funInterfaceBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun funInterfaceBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun interfaceBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun interfaceBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun objectBuilder (Lcom/squareup/kotlinpoet/ClassName;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun objectBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public final fun valueClassBuilder (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; +} + +public final class com/squareup/kotlinpoet/TypeSpec$Kind : java/lang/Enum { + public static final field CLASS Lcom/squareup/kotlinpoet/TypeSpec$Kind; + public static final field INTERFACE Lcom/squareup/kotlinpoet/TypeSpec$Kind; + public static final field OBJECT Lcom/squareup/kotlinpoet/TypeSpec$Kind; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeSpec$Kind; + public static fun values ()[Lcom/squareup/kotlinpoet/TypeSpec$Kind; +} + +public abstract interface class com/squareup/kotlinpoet/TypeSpecHolder { + public abstract fun getTypeSpecs ()Ljava/util/List; +} + +public abstract interface class com/squareup/kotlinpoet/TypeSpecHolder$Builder { + public abstract fun addType (Lcom/squareup/kotlinpoet/TypeSpec;)Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder; + public fun addTypes (Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeSpecHolder$Builder; +} + +public final class com/squareup/kotlinpoet/TypeVariableName : com/squareup/kotlinpoet/TypeName { + public static final field Companion Lcom/squareup/kotlinpoet/TypeVariableName$Companion; + public final fun copy (ZLjava/util/List;Ljava/util/List;ZLjava/util/Map;)Lcom/squareup/kotlinpoet/TypeVariableName; + public synthetic fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun copy$default (Lcom/squareup/kotlinpoet/TypeVariableName;ZLjava/util/List;Ljava/util/List;ZLjava/util/Map;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public fun equals (Ljava/lang/Object;)Z + public static final fun get (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;Ljava/util/List;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;Ljava/util/List;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;[Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;[Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;[Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;[Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;[Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljava/lang/String;[Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun getBounds ()Ljava/util/List; + public final fun getName ()Ljava/lang/String; + public final fun getVariance ()Lcom/squareup/kotlinpoet/KModifier; + public static final fun getWithClasses (Ljava/lang/String;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun getWithClasses (Ljava/lang/String;Ljava/lang/Iterable;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun getWithTypes (Ljava/lang/String;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun getWithTypes (Ljava/lang/String;Ljava/lang/Iterable;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public fun hashCode ()I + public final fun isReified ()Z +} + +public final class com/squareup/kotlinpoet/TypeVariableName$Companion { + public final fun get (Ljava/lang/String;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;Ljava/util/List;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;Ljava/util/List;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;[Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;[Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;[Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;[Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;[Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun get (Ljava/lang/String;[Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;Ljava/util/List;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;[Lcom/squareup/kotlinpoet/TypeName;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;[Ljava/lang/reflect/Type;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun get$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;[Lkotlin/reflect/KClass;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun getWithClasses (Ljava/lang/String;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun getWithClasses (Ljava/lang/String;Ljava/lang/Iterable;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun getWithClasses$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;Ljava/lang/Iterable;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun getWithTypes (Ljava/lang/String;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/TypeVariableName; + public final fun getWithTypes (Ljava/lang/String;Ljava/lang/Iterable;Lcom/squareup/kotlinpoet/KModifier;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static synthetic fun getWithTypes$default (Lcom/squareup/kotlinpoet/TypeVariableName$Companion;Ljava/lang/String;Ljava/lang/Iterable;Lcom/squareup/kotlinpoet/KModifier;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeVariableName; +} + +public final class com/squareup/kotlinpoet/TypeVariableNames { + public static final fun asTypeVariableName (Lkotlin/reflect/KTypeParameter;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljavax/lang/model/element/TypeParameterElement;)Lcom/squareup/kotlinpoet/TypeVariableName; + public static final fun get (Ljavax/lang/model/type/TypeVariable;)Lcom/squareup/kotlinpoet/TypeVariableName; +} + +public final class com/squareup/kotlinpoet/WildcardTypeName : com/squareup/kotlinpoet/TypeName { + public static final field Companion Lcom/squareup/kotlinpoet/WildcardTypeName$Companion; + public static final fun consumerOf (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public static final fun consumerOf (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public static final fun consumerOf (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public synthetic fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/TypeName; + public fun copy (ZLjava/util/List;Ljava/util/Map;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public fun equals (Ljava/lang/Object;)Z + public final fun getInTypes ()Ljava/util/List; + public final fun getOutTypes ()Ljava/util/List; + public fun hashCode ()I + public static final fun producerOf (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public static final fun producerOf (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public static final fun producerOf (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/WildcardTypeName; +} + +public final class com/squareup/kotlinpoet/WildcardTypeName$Companion { + public final fun consumerOf (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public final fun consumerOf (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public final fun consumerOf (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public final fun producerOf (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public final fun producerOf (Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/WildcardTypeName; + public final fun producerOf (Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/WildcardTypeName; +} + +public final class com/squareup/kotlinpoet/WildcardTypeNames { + public static final fun get (Ljava/lang/reflect/WildcardType;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun get (Ljavax/lang/model/type/WildcardType;)Lcom/squareup/kotlinpoet/TypeName; +} + +public final class com/squareup/kotlinpoet/jvm/JvmAnnotations { + public static final fun jvmDefault (Lcom/squareup/kotlinpoet/FunSpec$Builder;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun jvmDefault (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun jvmField (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun jvmInline (Lcom/squareup/kotlinpoet/TypeSpec$Builder;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun jvmMultifileClass (Lcom/squareup/kotlinpoet/FileSpec$Builder;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static final fun jvmName (Lcom/squareup/kotlinpoet/FileSpec$Builder;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FileSpec$Builder; + public static final fun jvmName (Lcom/squareup/kotlinpoet/FunSpec$Builder;Ljava/lang/String;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun jvmOverloads (Lcom/squareup/kotlinpoet/FunSpec$Builder;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun jvmRecord (Lcom/squareup/kotlinpoet/TypeSpec$Builder;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun jvmStatic (Lcom/squareup/kotlinpoet/FunSpec$Builder;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun jvmStatic (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun jvmSuppressWildcards (Lcom/squareup/kotlinpoet/FunSpec$Builder;Z)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun jvmSuppressWildcards (Lcom/squareup/kotlinpoet/PropertySpec$Builder;Z)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun jvmSuppressWildcards (Lcom/squareup/kotlinpoet/TypeName;Z)Lcom/squareup/kotlinpoet/TypeName; + public static final fun jvmSuppressWildcards (Lcom/squareup/kotlinpoet/TypeSpec$Builder;Z)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static synthetic fun jvmSuppressWildcards$default (Lcom/squareup/kotlinpoet/FunSpec$Builder;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static synthetic fun jvmSuppressWildcards$default (Lcom/squareup/kotlinpoet/PropertySpec$Builder;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static synthetic fun jvmSuppressWildcards$default (Lcom/squareup/kotlinpoet/TypeName;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeName; + public static synthetic fun jvmSuppressWildcards$default (Lcom/squareup/kotlinpoet/TypeSpec$Builder;ZILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeSpec$Builder; + public static final fun jvmWildcard (Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun strictfp (Lcom/squareup/kotlinpoet/FunSpec$Builder;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun synchronized (Lcom/squareup/kotlinpoet/FunSpec$Builder;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun throws (Lcom/squareup/kotlinpoet/FunSpec$Builder;Ljava/lang/Iterable;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun throws (Lcom/squareup/kotlinpoet/FunSpec$Builder;[Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun throws (Lcom/squareup/kotlinpoet/FunSpec$Builder;[Ljava/lang/reflect/Type;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun throws (Lcom/squareup/kotlinpoet/FunSpec$Builder;[Lkotlin/reflect/KClass;)Lcom/squareup/kotlinpoet/FunSpec$Builder; + public static final fun transient (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; + public static final fun volatile (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; +} + +public final class com/squareup/kotlinpoet/tags/TypeAliasTag { + public fun (Lcom/squareup/kotlinpoet/TypeName;)V + public final fun getAbbreviatedType ()Lcom/squareup/kotlinpoet/TypeName; +} + diff --git a/kotlin-code-generation-test/pom.xml b/kotlin-code-generation-test/pom.xml new file mode 100644 index 0000000..d3f2728 --- /dev/null +++ b/kotlin-code-generation-test/pom.xml @@ -0,0 +1,101 @@ + + 4.0.0 + + + io.toolisticon.kotlin.generation._ + kotlin-code-generation-parent + 0.0.1 + ../_mvn/parent/pom.xml + + + io.toolisticon.kotlin.generation + kotlin-code-generation-test + Tools for testing generated classes. This lib exposes testing libraries and is supposed to be included with `scope=test` + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + provided + + + org.jetbrains.kotlin + kotlin-reflect + provided + + + io.github.microutils + kotlin-logging-jvm + + + + ${project.groupId} + kotlin-code-generation + ${project.version} + + + + dev.zacsweers.kctfork + core + compile + + + org.slf4j + slf4j-simple + 2.0.12 + compile + + + + org.junit.jupiter + junit-jupiter + compile + + + org.junit.jupiter + junit-jupiter-params + compile + + + org.assertj + assertj-core + compile + + + org.jetbrains.kotlin + kotlin-test-junit5 + compile + + + org.jetbrains.kotlin + kotlin-maven-serialization + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + compile + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi + -opt-in=com.squareup.kotlinpoet.ExperimentalKotlinPoetApi + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + diff --git a/kotlin-code-generation-test/src/main/kotlin/KotlinCodeGenerationTest.kt b/kotlin-code-generation-test/src/main/kotlin/KotlinCodeGenerationTest.kt new file mode 100644 index 0000000..24bdf47 --- /dev/null +++ b/kotlin-code-generation-test/src/main/kotlin/KotlinCodeGenerationTest.kt @@ -0,0 +1,52 @@ +package io.toolisticon.kotlin.generation.test + +import com.tschuchort.compiletesting.JvmCompilationResult +import com.tschuchort.compiletesting.KotlinCompilation +import com.tschuchort.compiletesting.SourceFile +import io.toolisticon.kotlin.generation.spec.KotlinFileSpec +import io.toolisticon.kotlin.generation.test.model.KotlinCompilationCommand +import io.toolisticon.kotlin.generation.test.model.KotlinCompilationResult +import java.io.ByteArrayOutputStream + +/** + * + * Original lib provides these configuration options. They will be included in this opinionated lib + * when needed. + * + * ```kotlin + * val result = KotlinCompilation().apply { + * sources = listOf(kotlinSource, javaSource) + * + * // pass your own instance of an annotation processor + * annotationProcessors = listOf(MyAnnotationProcessor()) + * + * // pass your own instance of a compiler plugin + * compilerPlugins = listOf(MyComponentRegistrar()) + * commandLineProcessors = listOf(MyCommandlineProcessor()) + * + * inheritClassPath = true + * messageOutputStream = System.out // see diagnostics in real time + * }.compile() + * ``` + */ +object KotlinCodeGenerationTest { + + fun assertThat(actual: KotlinCompilationResult): KotlinCompilationAssert = KotlinCompilationAssert(actual) + + fun compile(cmd: KotlinCompilationCommand): KotlinCompilationResult { + + val result: JvmCompilationResult = KotlinCompilation().apply { + sources = cmd.sourceFiles + inheritClassPath = true + + this. + // needed so kotlin compile does not spam the console log (would default to System.out) + messageOutputStream = ByteArrayOutputStream() + //compilerPluginRegistrars = listOf(SerializationComponentRegistrar()) + }.compile() + + return KotlinCompilationResult(cmd = cmd, result = result) + } + + fun KotlinFileSpec.sourceFile() = SourceFile.kotlin(name = this.fileName, contents = this.code) +} diff --git a/kotlin-code-generation-test/src/main/kotlin/KotlinCompilationAssert.kt b/kotlin-code-generation-test/src/main/kotlin/KotlinCompilationAssert.kt new file mode 100644 index 0000000..9ba64ad --- /dev/null +++ b/kotlin-code-generation-test/src/main/kotlin/KotlinCompilationAssert.kt @@ -0,0 +1,17 @@ +package io.toolisticon.kotlin.generation.test + +import com.tschuchort.compiletesting.KotlinCompilation +import io.toolisticon.kotlin.generation.test.model.KotlinCompilationResult +import org.assertj.core.api.AbstractAssert +import org.assertj.core.api.Assertions + +class KotlinCompilationAssert( + actual: KotlinCompilationResult, +) : AbstractAssert(actual, KotlinCompilationAssert::class.java) { + + fun errorMessages() = Assertions.assertThat(actual.errors) + + fun hasExitCode(exitCode: KotlinCompilation.ExitCode) : KotlinCompilationAssert = apply { + Assertions.assertThat(actual.exitCode).isEqualTo(exitCode) + } +} diff --git a/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationCommand.kt b/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationCommand.kt new file mode 100644 index 0000000..428d291 --- /dev/null +++ b/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationCommand.kt @@ -0,0 +1,17 @@ +package io.toolisticon.kotlin.generation.test.model + +import com.tschuchort.compiletesting.SourceFile +import io.toolisticon.kotlin.generation.spec.KotlinFileSpec +import io.toolisticon.kotlin.generation.test.KotlinCodeGenerationTest.sourceFile + +data class KotlinCompilationCommand( + val fileSpecs: List +) { + + constructor(fileSpec: KotlinFileSpec) : this(listOf(fileSpec)) + + operator fun plus(fileSpec: KotlinFileSpec) = copy(fileSpecs = fileSpecs + fileSpec) + + + val sourceFiles: List by lazy { fileSpecs.map { it.sourceFile() } } +} diff --git a/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationError.kt b/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationError.kt new file mode 100644 index 0000000..2e9adde --- /dev/null +++ b/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationError.kt @@ -0,0 +1,11 @@ +package io.toolisticon.kotlin.generation.test.model + +/** + * Encapsulates a compiler error message. + */ +data class KotlinCompilationError( + val message: String, + val file: String +) { + override fun toString()= "KotlinCompilationError(message='$message', file='$file')" +} diff --git a/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationResult.kt b/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationResult.kt new file mode 100644 index 0000000..a4ee769 --- /dev/null +++ b/kotlin-code-generation-test/src/main/kotlin/model/KotlinCompilationResult.kt @@ -0,0 +1,36 @@ +package io.toolisticon.kotlin.generation.test.model + +import com.squareup.kotlinpoet.ClassName +import com.tschuchort.compiletesting.JvmCompilationResult +import com.tschuchort.compiletesting.KotlinCompilation +import org.assertj.core.api.Assertions.assertThat +import kotlin.reflect.KClass + +data class KotlinCompilationResult( + val cmd: KotlinCompilationCommand, + val result: JvmCompilationResult +) { + + val exitCode = result.exitCode + + val errors: List by lazy { + result.messages.lines() + .filter { it.startsWith("e:") } + .map { it.removePrefix("e: ") } + .map { + val file = it.substringBefore(" ") + val msg = it.substringAfter(" ") + KotlinCompilationError(message = msg, file = file) + } + } + + fun loadClass(className: ClassName): KClass = result.classLoader.loadClass(className.canonicalName).kotlin + + fun shouldBeOk() { + assertThat(exitCode) + .`as` { "compilation failed with errors: $errors" } + .isEqualTo(KotlinCompilation.ExitCode.OK) + } + + override fun toString() = "${this::class.simpleName}(cmd=$cmd, exitCode=$exitCode, errors=$errors)" +} diff --git a/src/test/resources/.gitkeep b/kotlin-code-generation-test/src/main/resources/.gitkeep similarity index 100% rename from src/test/resources/.gitkeep rename to kotlin-code-generation-test/src/main/resources/.gitkeep diff --git a/kotlin-code-generation-test/src/test/kotlin/.gitkeep b/kotlin-code-generation-test/src/test/kotlin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/kotlin-code-generation-test/src/test/resources/.gitkeep b/kotlin-code-generation-test/src/test/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/kotlin-code-generation/pom.xml b/kotlin-code-generation/pom.xml new file mode 100644 index 0000000..ca11de4 --- /dev/null +++ b/kotlin-code-generation/pom.xml @@ -0,0 +1,100 @@ + + 4.0.0 + + + io.toolisticon.kotlin.generation._ + kotlin-code-generation-parent + 0.0.1 + ../_mvn/parent/pom.xml + + + io.toolisticon.kotlin.generation + kotlin-code-generation + Wrapping core components for kotlin code generation with kotlin-poet. + + + + + org.jetbrains.kotlin + kotlin-stdlib + provided + + + org.jetbrains.kotlin + kotlin-reflect + provided + + + io.github.microutils + kotlin-logging-jvm + + + + + com.squareup + kotlinpoet-jvm + + + + org.jetbrains.kotlinx + kotlinx-serialization-core-jvm + + + + jakarta.annotation + jakarta.annotation-api + 3.0.0 + + + + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-params + test + + + org.assertj + assertj-core + test + + + org.jetbrains.kotlin + kotlin-test-junit5 + test + + + org.jetbrains.kotlin + kotlin-test + test + + + ch.qos.logback + logback-classic + test + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi + -opt-in=com.squareup.kotlinpoet.ExperimentalKotlinPoetApi + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + diff --git a/kotlin-code-generation/src/main/kotlin/KotlinCodeGeneration.kt b/kotlin-code-generation/src/main/kotlin/KotlinCodeGeneration.kt new file mode 100644 index 0000000..62dd5de --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/KotlinCodeGeneration.kt @@ -0,0 +1,76 @@ +package io.toolisticon.kotlin.generation + +import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.MemberName.Companion.member +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.annotationBuilder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.annotationClassBuilder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.classBuilder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.constructorPropertyBuilder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.fileBuilder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.funBuilder +import io.toolisticon.kotlin.generation.builder.* +import io.toolisticon.kotlin.generation.poet.FormatSpecifier.asCodeBlock +import io.toolisticon.kotlin.generation.spec.* +import io.toolisticon.kotlin.generation.support.SuppressAnnotation.Companion.CLASS_NAME +import kotlin.reflect.KClass + +object KotlinCodeGeneration { + + inline fun buildAnnotation(type: KClass<*>, block: KotlinAnnotationSpecBuilderReceiver = {}): KotlinAnnotationSpec = buildAnnotation(type.asClassName(), block) + inline fun buildAnnotation(className: ClassName, block: KotlinAnnotationSpecBuilderReceiver = {}): KotlinAnnotationSpec = annotationBuilder(className).also(block).build() + inline fun buildAnnotationClass(className: ClassName, block: KotlinAnnotationClassSpecBuilderReceiver = {}): KotlinAnnotationClassSpec = annotationClassBuilder(className).also(block).build() + + inline fun buildClass(className: ClassName, block: KotlinClassSpecBuilderReceiver = {}) = classBuilder(className).also(block).build() + + fun buildCodeBlock(format: String, vararg args: Any?) = CodeBlock.of(format, *args) + inline fun buildCodeBlock(builderAction: CodeBlock.Builder.() -> Unit): CodeBlock = CodeBlock.builder().apply(builderAction).build() + + inline fun buildConstructorProperty(name: String, type: TypeName, block: KotlinConstructorPropertySpecBuilderReceiver = {}) = constructorPropertyBuilder(name, type).also(block).build() + inline fun buildConstructorProperty(name: String, type: KClass<*>, block: KotlinConstructorPropertySpecBuilderReceiver = {}) = KotlinCodeGeneration.buildConstructorProperty(name, type.asTypeName(), block) + + inline fun buildDataClass(className: ClassName, block: KotlinDataClassSpecBuilderReceiver = {}): KotlinDataClassSpec = KotlinDataClassSpecBuilder.builder(className).also(block).build() + + inline fun buildFile(className: ClassName, block: KotlinFileSpecBuilderReceiver = {}): KotlinFileSpec = fileBuilder(className).also(block).build() + + inline fun buildFun(name: String, block: KotlinFunSpecBuilderReceiver = {}): KotlinFunSpec = funBuilder(name).also(block).build() + + inline fun buildValueClass(className: ClassName, block: KotlinValueClassSpecBuilderReceiver = {}): KotlinValueClassSpec = KotlinValueClassSpecBuilder.builder(className).also(block).build() + + fun toFileSpec(spec: KotlinValueClassSpecSupplier): KotlinFileSpec = spec.spec().let { + KotlinFileSpecBuilder.builder(it.className).addType(it).build() + } + + + @Suppress(CLASS_NAME) + object builder { + fun annotationBuilder(type: ClassName) = KotlinAnnotationSpecBuilder.builder(type) + fun annotationClassBuilder(className: ClassName) = KotlinAnnotationClassSpecBuilder.builder(className) + fun classBuilder(className: ClassName) = KotlinClassSpecBuilder.builder(className); + fun constructorPropertyBuilder(name: String, type: TypeName) = KotlinConstructorPropertySpecBuilder.builder(name, type) + fun dataClassBuilder(className: ClassName) = KotlinDataClassSpecBuilder.builder(className); + fun fileBuilder(className: ClassName) = KotlinFileSpecBuilder.builder(className) + fun funBuilder(name: String) = KotlinFunSpecBuilder.builder(name) + fun valueClassBuilder(className: ClassName) = KotlinValueClassSpecBuilder.builder(className) + } + + @Suppress(CLASS_NAME) + object typeSpec { + + fun TypeSpec.hasModifier(modifier: KModifier) = this.modifiers.contains(modifier) + + val TypeSpec.isDataClass: Boolean get() = hasModifier(KModifier.DATA) + val TypeSpec.isValueClass: Boolean get() = hasModifier(KModifier.VALUE) + } + + @Suppress(CLASS_NAME) + object name { + fun Collection.asCodeBlock(): CodeBlock = this.map { it.asCodeBlock() }.joinToCode(prefix = "[", suffix = "]") + + fun Enum<*>.asMemberName(): MemberName = this::class.asClassName().member(this.name) + + operator fun ClassName.plus(suffix: String?): ClassName = ClassName(this.packageName, this.simpleNames) + + fun TypeName.nullable(nullable: Boolean = true): TypeName = this.copy(nullable = nullable) + } + +} diff --git a/kotlin-code-generation/src/main/kotlin/_types.kt b/kotlin-code-generation/src/main/kotlin/_types.kt new file mode 100644 index 0000000..493afd6 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/_types.kt @@ -0,0 +1,13 @@ +package io.toolisticon.kotlin.generation + +import java.util.function.Supplier + + +/** + * Marks a type as capable of building a new product. + */ +fun interface Builder { + fun build(): PRODUCT +} + +interface BuilderSupplier : Builder, Supplier diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationClassSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationClassSpecBuilder.kt new file mode 100644 index 0000000..06e9d0b --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationClassSpecBuilder.kt @@ -0,0 +1,93 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.TypeName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotation +import io.toolisticon.kotlin.generation.builder.KotlinConstructorPropertySpecBuilder.Companion.primaryConstructorWithProperties +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationClassSpec +import io.toolisticon.kotlin.generation.spec.KotlinConstructorPropertySpecSupplier +import io.toolisticon.kotlin.generation.spec.toList +import javax.lang.model.element.Element + +class KotlinAnnotationClassSpecBuilder internal constructor( + val className: ClassName, + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder, + ConstructorPropertySupport { + + companion object { + + fun builder(name: String): KotlinAnnotationClassSpecBuilder = builder(ClassName("", name)) + + fun builder(className: ClassName): KotlinAnnotationClassSpecBuilder = KotlinAnnotationClassSpecBuilder( + className = className, + delegate = TypeSpecBuilder.annotationBuilder(className.simpleName) + ) + } + + private lateinit var _retention: AnnotationRetention + private val constructorProperties: LinkedHashMap = LinkedHashMap() + private val targets: MutableSet = mutableSetOf() + private var repeatable: Boolean = false + private var mustBeDocumented: Boolean = false + + override fun addConstructorProperty(spec: KotlinConstructorPropertySpecSupplier) = apply { constructorProperties[spec.name] = spec } + + fun mustBeDocumented() = apply { this.mustBeDocumented = true } + fun repeatable() = apply { this.repeatable = true } + fun target(vararg targets: AnnotationTarget) = apply { this.targets.addAll(targets) } + + fun retention(retention: AnnotationRetention) = apply { + this._retention = retention + } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + override fun builder(block: TypeSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinAnnotationClassSpec { + if (constructorProperties.isNotEmpty()) { + delegate.primaryConstructorWithProperties(toList(constructorProperties.values)) + } + if (targets.isNotEmpty()) { + delegate.addAnnotation(buildAnnotation(Target::class) { + addEnumMembers("allowedTargets", *(targets.sortedBy(AnnotationTarget::name).toTypedArray())) + }) + } + if (this::_retention.isInitialized) { + delegate.addAnnotation(buildAnnotation(Retention::class) { + addEnumMember("value", _retention) + }) + } + + if (repeatable) { + delegate.addAnnotation(Repeatable::class) + } + if (mustBeDocumented) { + delegate.addAnnotation(MustBeDocumented::class) + } + + return KotlinAnnotationClassSpec(className = className, spec = delegate.build()) + } + +} + +typealias KotlinAnnotationClassSpecBuilderReceiver = KotlinAnnotationClassSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationSpecBuilder.kt new file mode 100644 index 0000000..72ca8a8 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationSpecBuilder.kt @@ -0,0 +1,68 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildCodeBlock +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.name.asCodeBlock +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.name.asMemberName +import io.toolisticon.kotlin.generation.poet.AnnotationSpecBuilder +import io.toolisticon.kotlin.generation.poet.AnnotationSpecBuilder.Companion.wrap +import io.toolisticon.kotlin.generation.poet.AnnotationSpecBuilderReceiver +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpec +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier +import kotlin.reflect.KClass + +class KotlinAnnotationSpecBuilder internal constructor( + private val delegate: AnnotationSpecBuilder +) : BuilderSupplier, + KotlinAnnotationSpecSupplier, + DelegatingBuilder { + companion object { + fun builder(type: ClassName): KotlinAnnotationSpecBuilder = KotlinAnnotationSpecBuilder( + delegate = AnnotationSpecBuilder.builder(type) + ) + + fun builder(type: ParameterizedTypeName): KotlinAnnotationSpecBuilder = KotlinAnnotationSpecBuilder( + delegate = AnnotationSpecBuilder.builder(type) + ) + + fun builder(type: KClass): KotlinAnnotationSpecBuilder = builder(type.asClassName()) + + fun from(spec: KotlinAnnotationSpecSupplier) = KotlinAnnotationSpecBuilder( + delegate = spec.get().toBuilder().wrap() + ) + } + + fun addMember(format: String, vararg args: Any): KotlinAnnotationSpecBuilder = apply { + delegate.addMember(format, *args) + } + + fun addMember(codeBlock: CodeBlock): KotlinAnnotationSpecBuilder = apply { + delegate.addMember(codeBlock) + } + + fun addMember(memberName: MemberName): KotlinAnnotationSpecBuilder = addMember("%M", memberName) + + fun addKClassMember(name: String, klass: KClass<*>) = addMember("$name = %T::class", klass) + + fun addStringMember(name: String, value: String) = addMember("$name = %S", value) + + fun addEnumMember(name: String, value: Enum<*>): KotlinAnnotationSpecBuilder = addMember("$name = %M", value.asMemberName()) + + fun addNumberMember(name: String, value: Number) : KotlinAnnotationSpecBuilder = addMember("$name = %L", value) + + fun addEnumMembers(name: String, vararg value: Enum<*>): KotlinAnnotationSpecBuilder { + val members = value.map { it.asMemberName() }.asCodeBlock() + return addMember(buildCodeBlock(format = "$name = %L", args = arrayOf(members))) + } + + override fun builder(block: AnnotationSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinAnnotationSpec = KotlinAnnotationSpec(spec = delegate.build()) + override fun spec(): KotlinAnnotationSpec = build() + override fun get(): AnnotationSpec = build().get() +} + +typealias KotlinAnnotationSpecBuilderReceiver = KotlinAnnotationSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinAnonymousClassSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinAnonymousClassSpecBuilder.kt new file mode 100644 index 0000000..2c2ede6 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinAnonymousClassSpecBuilder.kt @@ -0,0 +1,61 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.TypeName +import com.squareup.kotlinpoet.TypeVariableName +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinAnonymousClassSpec +import javax.lang.model.element.Element +import kotlin.reflect.KClass + + +class KotlinAnonymousClassSpecBuilder internal constructor( + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder, + DelegatingBuilder { + + companion object { + fun builder(): KotlinAnonymousClassSpecBuilder = KotlinAnonymousClassSpecBuilder( + delegate = TypeSpecBuilder.anonymousClassBuilder() + ) + } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?) = builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName) = builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>) = builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any) = builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock) = builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable) = builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String) = builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String) = builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addInitializerBlock(block: CodeBlock) = builder { this.addInitializerBlock(block) } + + override fun builder(block: TypeSpecBuilderReceiver) = apply { delegate.builder.block() } + override fun build(): KotlinAnonymousClassSpec = KotlinAnonymousClassSpec(delegate.build()) +} + +typealias KotlinAnonymousClassSpecBuilderReceiver = KotlinAnonymousClassSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinClassSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinClassSpecBuilder.kt new file mode 100644 index 0000000..2fb2bee --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinClassSpecBuilder.kt @@ -0,0 +1,159 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.* +import javax.lang.model.element.Element +import kotlin.reflect.KClass + + +class KotlinClassSpecBuilder internal constructor( + private val className: ClassName, + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder { + + companion object { + fun builder(name: String): KotlinClassSpecBuilder = KotlinClassSpecBuilder( + className = ClassName("", name), + delegate = TypeSpecBuilder.classBuilder(name) + ) + + fun builder(className: ClassName): KotlinClassSpecBuilder = KotlinClassSpecBuilder( + className = className, + delegate = TypeSpecBuilder.classBuilder(className.simpleName) + ) + } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun addAnnotation(spec: KotlinAnnotationSpecSupplier) = builder { + delegate.addAnnotation(spec.get()) + } + + fun addFunction(funSpec : KotlinFunSpecSupplier) = apply { + delegate.addFunction(funSpec.get()) + } + + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + + fun contextReceivers(vararg receiverTypes: TypeName)= builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier)= builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier)= builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element)= builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier)= builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName)= builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?)= builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName)= builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>)= builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any)= builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock)= builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable)= builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName)= builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock)= builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>)= builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock)= builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String)= builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String)= builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addEnumConstant(name: String, typeSpec: TypeSpec = TypeSpec.anonymousClassBuilder().build())= builder { this.addEnumConstant(name, typeSpec) } + fun addInitializerBlock(block: CodeBlock)= builder { this.addInitializerBlock(block) } + + + override fun builder(block: TypeSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinClassSpec = KotlinClassSpec( + className = className, + spec = delegate.build() + ) + +// operator fun invoke(spec: KotlinDataClassSpec): _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder = +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder( +// className = spec.className, +// delegate = spec.get().toBuilder() +// ) +//} +// +//private val constructorProperties = LinkedHashMap() +// +//operator fun invoke(block: TypeSpecBuilder.() -> Unit): _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder = apply { +// delegate.block() +// override fun addKdoc(kdoc: CodeBlock) = apply { +// delegate.addKdoc(kdoc) +// } +// +// fun addType(typeSpecSupplier: TypeSpecSupplier) = apply { +// delegate.addType(typeSpecSupplier.get()) +// } +// +// fun addConstructorProperty(name: String, type: TypeName, block: _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinConstructorPropertyBuilder.() -> Unit = {}) = apply { +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder.Companion.constructorProperties[name] = buildConstructorProperty(name, type, block) +// } +// +// fun addConstructorProperty(constructorProperty: ConstructorPropertySupplier) = apply { +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder.Companion.constructorProperties[constructorProperty.name] = constructorProperty +// } +// +// /** +// * Finalize a data class based on its primary constructor parameters. +// * +// * * adds primary constructor. +// * * backs parameters with properties. +// */ +// override fun build(): KotlinDataClassSpec { +// check(_root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder.Companion.constructorProperties.isNotEmpty()) { "Data class must have at least one property." } +// +// val constructor = FunSpec.constructorBuilder() +// +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder.Companion.constructorProperties.values.map(ConstructorPropertySupplier::get).forEach { +// constructor.addParameter(it.parameter.get()) +// delegate.addProperty(it.property.get()) +// } +// +// delegate.primaryConstructor(constructor.build()) +// +// return KotlinDataClassSpec(className = className, spec = delegate.build()) +// } +// +// override fun addAnnotation(annotation: ClassName): _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder = apply { +// fun addAnnotation(annotation: ClassName): _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder = apply { +// delegate.addAnnotation(annotation) +// } +// +// override fun get(): TypeSpec = build().get() +// +// } +} + + +// @Suppress("ClassName") +// object builder : +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.ToKotlinPoetSpecBuilder { +// +// fun builder(className: ClassName) = _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder(className = className) +// operator fun invoke(packageName: String, name: String): _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder = +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder.Companion.builder.invoke(ClassName(packageName, name)) +// +// fun builder(packageName: String, name: String) = +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder.Companion.builder.builder(ClassName(packageName, name)) +// operator fun invoke(className: ClassName): _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder = +// _root_ide_package_.io.toolisticon.kotlin.generation._BAK.KotlinDataClassBuilder.KotlinDataClassSpecBuilder( +// className = className, +// delegate = TypeSpec.classBuilder(className) +// ) +// +// } + +typealias KotlinClassSpecBuilderReceiver = KotlinClassSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinConstructorPropertySpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinConstructorPropertySpecBuilder.kt new file mode 100644 index 0000000..2d7b290 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinConstructorPropertySpecBuilder.kt @@ -0,0 +1,68 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.TypeName +import io.toolisticon.kotlin.generation.Builder +import io.toolisticon.kotlin.generation.poet.TypeSpecBuilder +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinConstructorPropertySpec +import io.toolisticon.kotlin.generation.spec.KotlinConstructorPropertySpecSupplier + +class KotlinConstructorPropertySpecBuilder internal constructor( + override val name: String, + private val type: TypeName, + private val propertyBuilder: KotlinPropertySpecBuilder, + private val parameterBuilder: KotlinParameterSpecBuilder +) : Builder, KotlinConstructorPropertySpecSupplier { + + companion object { + fun builder(name: String, type: TypeName): KotlinConstructorPropertySpecBuilder = KotlinConstructorPropertySpecBuilder( + name = name, + type = type, + propertyBuilder = KotlinPropertySpecBuilder.builder(name = name, type = type), + parameterBuilder = KotlinParameterSpecBuilder.builder(name = name, type = type) + ) + + internal fun TypeSpecBuilder.primaryConstructorWithProperties(constructorProperties: List) { + val constructor = FunSpec.constructorBuilder() + constructorProperties.forEach { + constructor.addParameter(it.parameter.get()) + this.addProperty(it.property.get()) + } + + this.primaryConstructor(constructor.build()) + } + + } + + fun makePrivate() = apply { + propertyBuilder.builder { + addModifiers(KModifier.PRIVATE) + } + } + + fun addAnnotation(annotationSpec: KotlinAnnotationSpecSupplier) = apply { + parameterBuilder.addAnnotation(annotationSpec) + } +// parameterBuilder { +// addAnnotation(annotationSpec) +// } +// } + + override fun build(): KotlinConstructorPropertySpec { + val parameter = parameterBuilder.build() + val property = propertyBuilder + .builder { + initializer(parameter.name) + } + .build() + + return KotlinConstructorPropertySpec(parameter = parameter, property = property) + } + + override fun spec(): KotlinConstructorPropertySpec = build() +} + + +typealias KotlinConstructorPropertySpecBuilderReceiver = KotlinConstructorPropertySpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinDataClassSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinDataClassSpecBuilder.kt new file mode 100644 index 0000000..f8790e1 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinDataClassSpecBuilder.kt @@ -0,0 +1,96 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.builder.KotlinConstructorPropertySpecBuilder.Companion.primaryConstructorWithProperties +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinConstructorPropertySpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinDataClassSpec +import io.toolisticon.kotlin.generation.spec.toList +import mu.KLogging +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class KotlinDataClassSpecBuilder internal constructor( + private val className: ClassName, + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder, + ConstructorPropertySupport { + companion object : KLogging() { + + fun builder(name: String): KotlinDataClassSpecBuilder = KotlinDataClassSpecBuilder( + className = ClassName("", name), + delegate = TypeSpecBuilder.classBuilder(name) + ) + + fun builder(className: ClassName): KotlinDataClassSpecBuilder = KotlinDataClassSpecBuilder(className) + } + + internal constructor (className: ClassName) : this( + className = className, + delegate = TypeSpecBuilder.classBuilder(className) + ) + + init { + delegate.addModifiers(KModifier.DATA) + } + + private val constructorProperties = LinkedHashMap() + + override fun builder(block: TypeSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinDataClassSpec { + check(constructorProperties.isNotEmpty()) { "Data class must have at least one property." } + + delegate.primaryConstructorWithProperties(toList(constructorProperties.values)) + + return KotlinDataClassSpec(className = className, spec = delegate.build()) + } + + override fun addConstructorProperty(spec: KotlinConstructorPropertySpecSupplier) = apply { + this.constructorProperties[spec.name] = spec + } + + fun addAnnotation(annotation: KotlinAnnotationSpecSupplier) = apply { + delegate.addAnnotation(annotation.get()) + } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?) = builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName) = builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>) = builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any) = builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock) = builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable) = builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String) = builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String) = builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addEnumConstant(name: String, typeSpec: TypeSpec = TypeSpec.anonymousClassBuilder().build()) = builder { this.addEnumConstant(name, typeSpec) } + fun addInitializerBlock(block: CodeBlock) = builder { this.addInitializerBlock(block) } +} + + +typealias KotlinDataClassSpecBuilderReceiver = KotlinDataClassSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinEnumClassSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinEnumClassSpecBuilder.kt new file mode 100644 index 0000000..600872e --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinEnumClassSpecBuilder.kt @@ -0,0 +1,73 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinEnumClassSpec +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class KotlinEnumClassSpecBuilder internal constructor( + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder { + + companion object { + fun builder(name: String): KotlinEnumClassSpecBuilder = KotlinEnumClassSpecBuilder( + delegate = TypeSpecBuilder.enumBuilder(name) + ) + + fun builder(className: ClassName): KotlinEnumClassSpecBuilder = builder(className.simpleName) + + } + + init { + delegate.addModifiers(KModifier.ENUM) + } + + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?) = builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName) = builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>) = builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any) = builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock) = builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable) = builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String) = builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String) = builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addEnumConstant(name: String, typeSpec: TypeSpec = TypeSpec.anonymousClassBuilder().build()) = builder { this.addEnumConstant(name, typeSpec) } + fun addInitializerBlock(block: CodeBlock) = builder { this.addInitializerBlock(block) } + + + fun addEnumConstant(name: String) = apply { + delegate.addEnumConstant(name) + } + + override fun builder(block: TypeSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinEnumClassSpec = KotlinEnumClassSpec(delegate.build()) +} + +typealias KotlinEnumClassSpecBuilderReceiver = KotlinEnumClassSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinFileSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinFileSpecBuilder.kt new file mode 100644 index 0000000..6d452f0 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinFileSpecBuilder.kt @@ -0,0 +1,79 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.poet.FileSpecBuilder.Companion.wrap +import io.toolisticon.kotlin.generation.spec.KotlinFileSpec +import io.toolisticon.kotlin.generation.spec.KotlinFileSpecSupplier +import kotlin.reflect.KClass + +class KotlinFileSpecBuilder internal constructor( + private val delegate: FileSpecBuilder +) : BuilderSupplier, KotlinFileSpecSupplier, DelegatingBuilder { + companion object { + fun builder(className: ClassName): KotlinFileSpecBuilder = KotlinFileSpecBuilder( + delegate = FileSpecBuilder.builder(className) + ) + + fun builder(memberName: MemberName): KotlinFileSpecBuilder = KotlinFileSpecBuilder( + delegate = FileSpecBuilder.builder(memberName) + ) + + fun builder(packageName: String, fileName: String): KotlinFileSpecBuilder = KotlinFileSpecBuilder( + delegate = FileSpecBuilder.builder(packageName, fileName) + ) + + fun scriptBuilder(fileName: String, packageName: String = ""): KotlinFileSpecBuilder = KotlinFileSpecBuilder( + delegate = FileSpecBuilder.scriptBuilder(fileName, packageName) + ) + + fun builder(spec: KotlinFileSpec) = builder(spec.get()) + + fun builder(spec: FileSpec) = KotlinFileSpecBuilder(delegate = spec.toBuilder().wrap()) + } + + fun addAliasedImport(kclass: KClass<*>, alias: String)= builder { this.addAliasedImport(kclass, alias) } + fun addAliasedImport(className: ClassName, alias: String)= builder { this.addAliasedImport(className, alias) } + fun addAliasedImport(className: ClassName, memberName: String, alias: String)= builder { this.addAliasedImport(className, memberName, alias) } + fun addAliasedImport(memberName: MemberName, alias: String)= builder { this.addAliasedImport(memberName, alias) } + fun addAnnotation(annotationSpec: AnnotationSpecSupplier): KotlinFileSpecBuilder = builder { this.addAnnotation(annotationSpec.get()) } + fun addBodyComment(format: String, vararg args: Any)= builder { this.addBodyComment(format, *args) } + fun addCode(format: String, vararg args: Any?)= builder { this.addCode(format, *args) } + fun addCode(codeBlock: CodeBlock)= builder { this.addCode(codeBlock) } + fun addDefaultPackageImport(packageName: String)= builder { this.addDefaultPackageImport(packageName) } + fun addFileComment(format: String, vararg args: Any) = builder { this.addFileComment(format, *args) } + fun addFunction(funSpec: FunSpecSupplier): KotlinFileSpecBuilder = builder { this.addFunction(funSpec.get()) } + fun addImport(constant: Enum<*>) = builder { this.addImport(constant) } + fun addImport(kclass: KClass<*>, vararg names: String) = builder { this.addImport(kclass, *names) } + fun addImport(className: ClassName, vararg names: String) = builder { this.addImport(className, *names) } + fun addImport(kclass: KClass<*>, names: Iterable) = builder { this.addImport(kclass, names) } + fun addImport(className: ClassName, names: Iterable) = builder { this.addImport(className, names) } + fun addImport(packageName: String, vararg names: String) = builder { this.addImport(packageName, *names) } + fun addImport(packageName: String, names: Iterable)= builder { this.addImport(packageName, names) } + fun addImport(import: Import)= builder { this.addImport(import) } + fun addKotlinDefaultImports(includeJvm: Boolean = true, includeJs: Boolean = true)= builder { this.addKotlinDefaultImports(includeJvm, includeJs) } + fun addNamedCode(format: String, args: Map)= builder { this.addNamedCode(format, args) } + fun addProperty(propertySpec: PropertySpecSupplier): KotlinFileSpecBuilder = builder { this.addProperty(propertySpec.get()) } + fun addStatement(format: String, vararg args: Any)= builder { this.addStatement(format, *args) } + fun addType(typeSpecSupplier: TypeSpecSupplier) = builder { this.addType(typeSpecSupplier.get()) } + fun addTypeAlias(typeAliasSpec: TypeAliasSpecSupplier) = builder { this.addTypeAlias(typeAliasSpec.get()) } + fun beginControlFlow(controlFlow: String, vararg args: Any)= builder { this.beginControlFlow(controlFlow, *args) } + fun nextControlFlow(controlFlow: String, vararg args: Any)= builder { this.nextControlFlow(controlFlow, *args) } + fun endControlFlow()= builder { this.endControlFlow() } + + override fun builder(block: FileSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + + override fun build(): KotlinFileSpec { + val spec = delegate.build() + return KotlinFileSpec(spec = spec) + } + + override fun spec(): KotlinFileSpec = build() + override fun get(): FileSpec = build().get() +} + +typealias KotlinFileSpecBuilderReceiver = KotlinFileSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinFunSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinFunSpecBuilder.kt new file mode 100644 index 0000000..ea0be12 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinFunSpecBuilder.kt @@ -0,0 +1,117 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.poet.AnnotationSpecSupplier +import io.toolisticon.kotlin.generation.poet.FunSpecBuilder +import io.toolisticon.kotlin.generation.poet.FunSpecBuilder.Companion.wrap +import io.toolisticon.kotlin.generation.poet.FunSpecBuilderReceiver +import io.toolisticon.kotlin.generation.spec.KotlinFunSpec +import io.toolisticon.kotlin.generation.spec.KotlinFunSpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinParameterSpecSupplier +import javax.lang.model.element.Element +import javax.lang.model.element.Modifier +import kotlin.reflect.KClass + +class KotlinFunSpecBuilder internal constructor( + private val delegate: FunSpecBuilder +) : BuilderSupplier, + KotlinFunSpecSupplier, + DelegatingBuilder { + + companion object { + fun builder(name: String): KotlinFunSpecBuilder = KotlinFunSpecBuilder( + delegate = FunSpecBuilder.builder(name) + ) + + fun builder(memberName: MemberName): KotlinFunSpecBuilder = KotlinFunSpecBuilder( + delegate = FunSpecBuilder.builder(memberName) + ) + + fun constructorBuilder(): KotlinFunSpecBuilder = KotlinFunSpecBuilder( + delegate = FunSpecBuilder.constructorBuilder() + ) + + fun getterBuilder(): KotlinFunSpecBuilder = KotlinFunSpecBuilder( + delegate = FunSpecBuilder.getterBuilder() + ) + + fun setterBuilder(): KotlinFunSpecBuilder = KotlinFunSpecBuilder( + delegate = FunSpecBuilder.setterBuilder() + ) + + fun builder(spec: KotlinFunSpec) = builder(spec.get()) + + fun builder(spec: FunSpec) = KotlinFunSpecBuilder(delegate = spec.toBuilder().wrap()) + } + + fun addParameter(parameter: KotlinParameterSpecSupplier) = builder { this.addParameter(parameter.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun jvmModifiers(modifiers: Iterable) = builder { this.jvmModifiers(modifiers) } + + fun addTypeVariables(typeVariables: Iterable) = builder { this.addTypeVariables(typeVariables) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + + fun receiver(receiverType: TypeName) = builder { this.receiver(receiverType) } + fun receiver(receiverType: TypeName, kdoc: CodeBlock) = builder { this.receiver(receiverType, kdoc) } + + fun receiver(receiverType: KClass<*>) = builder { this.receiver(receiverType) } + fun receiver(receiverType: KClass<*>, kdoc: CodeBlock) = builder { this.receiver(receiverType, kdoc) } + + fun receiver(receiverType: KClass<*>, kdoc: String, vararg args: Any) = builder { this.receiver(receiverType, kdoc, *args) } + + fun returns(returnType: TypeName) = builder { this.returns(returnType) } + fun returns(returnType: TypeName, kdoc: CodeBlock) = builder { this.returns(returnType, kdoc) } + + fun returns(returnType: KClass<*>) = builder { this.returns(returnType) } + fun returns(returnType: KClass<*>, kdoc: CodeBlock) = builder { this.returns(returnType, kdoc) } + + fun returns(returnType: KClass<*>, kdoc: String, vararg args: Any) = builder { this.returns(returnType, kdoc, *args) } + + fun addParameters(parameterSpecs: Iterable) = builder { this.addParameters(parameterSpecs) } + fun addParameter(parameterSpec: ParameterSpec) = builder { this.addParameter(parameterSpec) } + fun callThisConstructor(args: List) = builder { this.callThisConstructor(args) } + + fun callThisConstructor(args: Iterable) = builder { this.callThisConstructor(args) } + fun callThisConstructor(vararg args: String) = builder { this.callThisConstructor(*args) } + fun callThisConstructor(vararg args: CodeBlock = emptyArray()) = builder { this.callThisConstructor(*args) } + fun callSuperConstructor(args: Iterable) = builder { this.callSuperConstructor(args) } + fun callSuperConstructor(args: List) = builder { this.callSuperConstructor(args) } + fun callSuperConstructor(vararg args: String) = builder { this.callSuperConstructor(*args) } + fun callSuperConstructor(vararg args: CodeBlock = emptyArray()) = builder { this.callSuperConstructor(*args) } + fun addParameter(name: String, type: TypeName, vararg modifiers: KModifier) = builder { this.addParameter(name, type, *modifiers) } + fun addParameter(name: String, type: KClass<*>, vararg modifiers: KModifier) = builder { this.addParameter(name, type, *modifiers) } + fun addParameter(name: String, type: TypeName, modifiers: Iterable) = builder { this.addParameter(name, type, modifiers) } + fun addParameter(name: String, type: KClass<*>, modifiers: Iterable) = builder { this.addParameter(name, type, modifiers) } + fun addCode(format: String, vararg args: Any?) = builder { this.addCode(format, *args) } + fun addNamedCode(format: String, args: Map) = builder { this.addNamedCode(format, args) } + fun addCode(codeBlock: CodeBlock) = builder { this.addCode(codeBlock) } + fun addComment(format: String, vararg args: Any) = builder { this.addComment(format, *args) } + + fun beginControlFlow(controlFlow: String, vararg args: Any) = builder { this.beginControlFlow(controlFlow, *args) } + fun nextControlFlow(controlFlow: String, vararg args: Any) = builder { this.nextControlFlow(controlFlow, *args) } + fun endControlFlow() = builder { this.endControlFlow() } + fun addStatement(format: String, vararg args: Any) = builder { this.addStatement(format, *args) } + + + override fun builder(block: FunSpecBuilderReceiver): KotlinFunSpecBuilder = apply { + delegate.builder.block() + } + + override fun build(): KotlinFunSpec = KotlinFunSpec(spec = delegate.build()) + override fun spec(): KotlinFunSpec = build() + override fun get(): FunSpec = build().get() +} + +typealias KotlinFunSpecBuilderReceiver = KotlinFunSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinInterfaceSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinInterfaceSpecBuilder.kt new file mode 100644 index 0000000..97cc0a2 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinInterfaceSpecBuilder.kt @@ -0,0 +1,68 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinInterfaceSpec +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class KotlinInterfaceSpecBuilder internal constructor( + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder { + companion object { + fun builder(name: String): KotlinInterfaceSpecBuilder = KotlinInterfaceSpecBuilder( + delegate = TypeSpecBuilder.interfaceBuilder(name) + ) + + fun builder(className: ClassName): KotlinInterfaceSpecBuilder = builder(className.simpleName) + + fun funInterfaceBuilder(name: String): KotlinInterfaceSpecBuilder = KotlinInterfaceSpecBuilder( + delegate = TypeSpecBuilder.funInterfaceBuilder(name) + ) + + fun funInterfaceBuilder(className: ClassName): KotlinInterfaceSpecBuilder = funInterfaceBuilder(className.simpleName) + } + + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?) = builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName) = builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>) = builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any) = builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock) = builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable) = builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String) = builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String) = builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addInitializerBlock(block: CodeBlock) = builder { this.addInitializerBlock(block) } + + + override fun builder(block: TypeSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinInterfaceSpec = KotlinInterfaceSpec(spec = delegate.build()) +} + +typealias KotlinInterfaceSpecBuilderReceiver = KotlinInterfaceSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinObjectSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinObjectSpecBuilder.kt new file mode 100644 index 0000000..15ddea4 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinObjectSpecBuilder.kt @@ -0,0 +1,60 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinObjectSpec +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class KotlinObjectSpecBuilder internal constructor( + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder { + companion object { + fun builder(name: String): KotlinObjectSpecBuilder = KotlinObjectSpecBuilder( + delegate = TypeSpecBuilder.objectBuilder(name) + ) + + fun builder(className: ClassName): KotlinObjectSpecBuilder = builder(className.simpleName) + } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?) = builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName) = builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>) = builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any) = builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock) = builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable) = builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String) = builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String) = builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addInitializerBlock(block: CodeBlock) = builder { this.addInitializerBlock(block) } + + override fun builder(block: TypeSpecBuilderReceiver): KotlinObjectSpecBuilder = apply { + delegate.builder.block() + } + + override fun build(): KotlinObjectSpec = KotlinObjectSpec(spec = delegate.build()) +} + +typealias KotlinObjectSpecBuilderReceiver = KotlinObjectSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinParameterSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinParameterSpecBuilder.kt new file mode 100644 index 0000000..310aafc --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinParameterSpecBuilder.kt @@ -0,0 +1,66 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.poet.AnnotationSpecSupplier +import io.toolisticon.kotlin.generation.poet.ParameterSpecBuilder +import io.toolisticon.kotlin.generation.poet.ParameterSpecBuilder.Companion.wrap +import io.toolisticon.kotlin.generation.poet.ParameterSpecBuilderReceiver +import io.toolisticon.kotlin.generation.spec.KotlinParameterSpec +import io.toolisticon.kotlin.generation.spec.KotlinParameterSpecSupplier +import java.lang.reflect.Type +import kotlin.reflect.KClass + +class KotlinParameterSpecBuilder internal constructor( + private val delegate: ParameterSpecBuilder +) : BuilderSupplier, + KotlinParameterSpecSupplier, + DelegatingBuilder { + companion object { + + fun builder(name: String, type: TypeName, vararg modifiers: KModifier): KotlinParameterSpecBuilder = KotlinParameterSpecBuilder( + delegate = ParameterSpecBuilder.builder(name, type, *modifiers) + ) + + fun builder(name: String, type: Type, vararg modifiers: KModifier): KotlinParameterSpecBuilder = builder(name, type.asTypeName(), *modifiers) + + fun builder(name: String, type: KClass<*>, vararg modifiers: KModifier): KotlinParameterSpecBuilder = KotlinParameterSpecBuilder( + delegate = ParameterSpecBuilder.builder(name, type.asTypeName(), *modifiers) + ) + + fun builder(name: String, type: TypeName, modifiers: Iterable): KotlinParameterSpecBuilder = KotlinParameterSpecBuilder( + delegate = ParameterSpecBuilder.builder(name, type, modifiers) + ) + + fun builder(name: String, type: Type, modifiers: Iterable): KotlinParameterSpecBuilder = KotlinParameterSpecBuilder( + delegate = ParameterSpecBuilder.builder(name, type.asTypeName(), modifiers) + ) + + fun builder(name: String, type: KClass<*>, modifiers: Iterable): KotlinParameterSpecBuilder = KotlinParameterSpecBuilder( + delegate = ParameterSpecBuilder.builder(name, type.asTypeName(), modifiers) + ) + + fun builder(spec: KotlinParameterSpec) = builder(spec.get()) + + fun builder(spec: ParameterSpec) = KotlinParameterSpecBuilder(delegate = spec.toBuilder().wrap()) + } + + override fun builder(block: ParameterSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier): KotlinParameterSpecBuilder = builder { this.addAnnotation(annotationSpec.get()) } + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun defaultValue(format: String, vararg args: Any?) = builder { this.defaultValue(format, *args) } + fun defaultValue(codeBlock: CodeBlock?) = builder { this.defaultValue(codeBlock) } + + override fun build(): KotlinParameterSpec = KotlinParameterSpec(spec = delegate.build()) + override fun spec(): KotlinParameterSpec = build() + override fun get(): ParameterSpec = build().get() +} + +typealias KotlinParameterSpecBuilderReceiver = KotlinParameterSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinPropertySpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinPropertySpecBuilder.kt new file mode 100644 index 0000000..9707564 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinPropertySpecBuilder.kt @@ -0,0 +1,83 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.poet.AnnotationSpecSupplier +import io.toolisticon.kotlin.generation.poet.FunSpecSupplier +import io.toolisticon.kotlin.generation.poet.PropertySpecBuilder +import io.toolisticon.kotlin.generation.poet.PropertySpecBuilder.Companion.wrap +import io.toolisticon.kotlin.generation.poet.PropertySpecBuilderReceiver +import io.toolisticon.kotlin.generation.spec.KotlinPropertySpec +import io.toolisticon.kotlin.generation.spec.KotlinPropertySpecSupplier +import java.lang.reflect.Type +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class KotlinPropertySpecBuilder internal constructor( + private val delegate: PropertySpecBuilder +) : BuilderSupplier, + KotlinPropertySpecSupplier, + DelegatingBuilder { + + companion object { + + fun builder(name: String, type: TypeName, vararg modifiers: KModifier, ): KotlinPropertySpecBuilder = KotlinPropertySpecBuilder( + delegate = PropertySpecBuilder.builder(name, type, *modifiers) + ) + + fun builder(name: String, type: Type, vararg modifiers: KModifier): KotlinPropertySpecBuilder = builder( + name = name, + type = type.asTypeName(), + modifiers = modifiers + ) + + fun builder(name: String, type: KClass<*>, vararg modifiers: KModifier): KotlinPropertySpecBuilder = builder(name, type.asTypeName(), *modifiers) + + fun builder(name: String, type: TypeName, modifiers: Iterable): KotlinPropertySpecBuilder = KotlinPropertySpecBuilder( + delegate = PropertySpecBuilder.builder(name, type, modifiers) + ) + + fun builder(name: String, type: KClass<*>, modifiers: Iterable): KotlinPropertySpecBuilder = KotlinPropertySpecBuilder( + delegate = PropertySpecBuilder.builder(name, type.asTypeName(), modifiers) + ) + + fun builder(spec: KotlinPropertySpec) = builder(spec.get()) + + fun builder(spec: PropertySpec) = KotlinPropertySpecBuilder(delegate = spec.toBuilder().wrap()) + } + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + + fun mutable(mutable: Boolean = true) = builder { this.mutable(mutable) } + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + fun addModifiers(modifiers: Iterable) = builder { this.addModifiers(modifiers) } + fun addTypeVariables(typeVariables: Iterable) = builder { this.addTypeVariables(typeVariables) } + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun initializer(format: String, vararg args: Any?) = builder { this.initializer(format, *args) } + fun initializer(codeBlock: CodeBlock?) = builder { this.initializer(codeBlock) } + fun delegate(format: String, vararg args: Any?) = builder { this.delegate(format, *args) } + fun delegate(codeBlock: CodeBlock) = builder { this.delegate(codeBlock) } + fun getter(getter: FunSpecSupplier?) = builder { this.getter(getter?.get()) } + fun setter(setter: FunSpecSupplier?) = builder { this.setter(setter?.get()) } + fun receiver(receiverType: TypeName?) = builder { this.receiver(receiverType) } + fun receiver(receiverType: KClass<*>) = builder { this.receiver(receiverType) } + + override fun builder(block: PropertySpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinPropertySpec { + val spec = delegate.build() + return KotlinPropertySpec(spec = spec) + } + + override fun spec(): KotlinPropertySpec = build() + override fun get(): PropertySpec = build().get() +} + +typealias KotlinPropertySpecBuilderReceiver = KotlinPropertySpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinTypeAliasSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinTypeAliasSpecBuilder.kt new file mode 100644 index 0000000..d744a62 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinTypeAliasSpecBuilder.kt @@ -0,0 +1,49 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.poet.AnnotationSpecSupplier +import io.toolisticon.kotlin.generation.poet.TypeAliasSpecBuilder +import io.toolisticon.kotlin.generation.poet.TypeAliasSpecBuilderReceiver +import io.toolisticon.kotlin.generation.spec.KotlinTypeAliasSpec +import io.toolisticon.kotlin.generation.spec.KotlinTypeAliasSpecSupplier +import kotlin.reflect.KClass + +class KotlinTypeAliasSpecBuilder internal constructor( + private val delegate: TypeAliasSpecBuilder +) : BuilderSupplier, + KotlinTypeAliasSpecSupplier, + DelegatingBuilder { + + companion object { + + fun builder(name: String, type: TypeName): KotlinTypeAliasSpecBuilder = KotlinTypeAliasSpecBuilder( + delegate = TypeAliasSpecBuilder.builder(name, type) + ) + + fun builder(name: String, type: KClass<*>): KotlinTypeAliasSpecBuilder = builder(name, type.asTypeName()) + } + + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariables(typeVariables: Iterable) = builder { this.addTypeVariables(typeVariables) } + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + + + override fun builder(block: TypeAliasSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build() = KotlinTypeAliasSpec(spec = delegate.build()) + override fun spec(): KotlinTypeAliasSpec = build() + override fun get(): TypeAliasSpec = build().get() + +} + +typealias KotlinTypeAliasSpecBuilderReceiver = KotlinTypeAliasSpecBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/builder/KotlinValueClassSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/builder/KotlinValueClassSpecBuilder.kt new file mode 100644 index 0000000..3bb8fbf --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/KotlinValueClassSpecBuilder.kt @@ -0,0 +1,98 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.jvm.jvmInline +import io.toolisticon.kotlin.generation.poet.* +import io.toolisticon.kotlin.generation.spec.KotlinConstructorPropertySpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinValueClassSpec +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class KotlinValueClassSpecBuilder internal constructor( + val className: ClassName, + private val delegate: TypeSpecBuilder +) : KotlinGeneratorTypeSpecBuilder, + ConstructorPropertySupport { + + companion object { + + fun builder(name: String): KotlinValueClassSpecBuilder = KotlinValueClassSpecBuilder( + className = ClassName("", name), + delegate = TypeSpecBuilder.classBuilder(name) + ) + + fun builder(className: ClassName): KotlinValueClassSpecBuilder = KotlinValueClassSpecBuilder(className) + } + + lateinit var constructorProperty: KotlinConstructorPropertySpecSupplier + + internal constructor(className: ClassName) : this( + className = className, + delegate = TypeSpecBuilder.classBuilder(className) + ) + + init { + delegate.addModifiers(KModifier.VALUE) + delegate.builder.jvmInline() + } + + override fun addConstructorProperty(spec: KotlinConstructorPropertySpecSupplier): KotlinValueClassSpecBuilder = apply { + this.constructorProperty = spec + } + + + fun addAnnotation(annotationSpec: AnnotationSpecSupplier) = builder { this.addAnnotation(annotationSpec.get()) } + + fun addKdoc(format: String, vararg args: Any) = builder { addKdoc(format, *args) } + fun addKdoc(block: CodeBlock) = builder { addKdoc(block) } + + fun contextReceivers(vararg receiverTypes: TypeName) = builder { this.contextReceivers(*receiverTypes) } + + fun addFunction(funSpec: FunSpecSupplier) = builder { this.addFunction(funSpec.get()) } + fun addProperty(propertySpec: PropertySpecSupplier) = builder { this.addProperty(propertySpec.get()) } + + fun addOriginatingElement(originatingElement: Element) = builder { this.addOriginatingElement(originatingElement) } + fun addType(typeSpec: TypeSpecSupplier) = builder { this.addType(typeSpec.get()) } + + fun addModifiers(vararg modifiers: KModifier) = builder { this.addModifiers(*modifiers) } + + fun addTypeVariable(typeVariable: TypeVariableName) = builder { this.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpecSupplier?) = builder { this.primaryConstructor(primaryConstructor?.get()) } + fun superclass(superclass: TypeName) = builder { this.superclass(superclass) } + fun superclass(superclass: KClass<*>) = builder { this.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any) = builder { this.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock) = builder { this.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable) = builder { this.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>) = builder { this.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock) = builder { this.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String) = builder { this.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String) = builder { this.addSuperinterface(superinterface, constructorParameter) } + + fun addEnumConstant(name: String, typeSpec: TypeSpec = TypeSpec.anonymousClassBuilder().build()) = builder { this.addEnumConstant(name, typeSpec) } + fun addInitializerBlock(block: CodeBlock) = builder { this.addInitializerBlock(block) } + + + override fun builder(block: TypeSpecBuilderReceiver) = apply { + delegate.builder.block() + } + + override fun build(): KotlinValueClassSpec { + check(::constructorProperty.isInitialized) { "Value class must have exactly one property." } + + val constructor = KotlinFunSpecBuilder.constructorBuilder() + .addParameter(this.constructorProperty.spec().parameter) + .build() + + delegate.addProperty(constructorProperty.spec().property.get()) + delegate.builder.primaryConstructor(constructor.get()) + + return KotlinValueClassSpec(className = className, spec = delegate.build()) + } +} + +typealias KotlinValueClassSpecBuilderReceiver = KotlinValueClassSpecBuilder.() -> Unit + diff --git a/kotlin-code-generation/src/main/kotlin/builder/_types.kt b/kotlin-code-generation/src/main/kotlin/builder/_types.kt new file mode 100644 index 0000000..a738e61 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/builder/_types.kt @@ -0,0 +1,78 @@ +package io.toolisticon.kotlin.generation.builder + +import com.squareup.kotlinpoet.TypeName +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.BuilderSupplier +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildConstructorProperty +import io.toolisticon.kotlin.generation.poet.TypeSpecBuilderReceiver +import io.toolisticon.kotlin.generation.spec.KotlinConstructorPropertySpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinGeneratorSpecSupplier +import io.toolisticon.kotlin.generation.spec.KotlinGeneratorTypeSpec +import kotlin.reflect.KClass + + +interface DelegatingBuilder { + fun builder(block: RECEIVER): SELF +} + +interface KotlinGeneratorTypeSpecBuilder> : BuilderSupplier, + DelegatingBuilder, + KotlinGeneratorSpecSupplier { + override fun spec(): SPEC = build() + + override fun get(): TypeSpec = spec().get() +} + +interface ConstructorPropertySupport { + + fun addConstructorProperty(spec: KotlinConstructorPropertySpecSupplier): SELF + + fun addConstructorProperty(name: String, type: TypeName, block: KotlinConstructorPropertySpecBuilderReceiver = {}) = addConstructorProperty( + buildConstructorProperty(name, type, block) + ) + + fun addConstructorProperty(name: String, type: KClass<*>, block: KotlinConstructorPropertySpecBuilderReceiver = {}) = addConstructorProperty( + buildConstructorProperty(name, type, block) + ) +} + +//BuilderSupplier, +//KotlinAnonymousClassSpecSupplier, +//DelegatingBuilder { +// +// BuilderSupplier, +// KotlinAnnotationSpecSupplier, +// DelegatingBuilder {} +// +//sealed class KotlinCodeGenerationSpecBuilder< +// SELF : Any, +// POET_SPEC : Any, +// SPEC: KotlinAnnotationSpec, +// POET_BUILDER, +// POET_BUILDER_RECCEIVER +// >(protected val delegate: POET_BUILDER) : +// DelegatingBuilder, BuilderSupplier { +// +//} + +// FIXME +//class FooSpecBuilder internal constructor( +// delegate: AnnotationSpecBuilder +//) : KotlinCodeGenerationSpecBuilder< +// FooSpecBuilder, +// AnnotationSpec, +// AnnotationSpecBuilder, +// AnnotationSpecBuilderReceiver +// >(delegate) +//{ +// override fun builder(block: AnnotationSpecBuilderReceiver): FooSpecBuilder { +// TODO("Not yet implemented") +// } +// +// override fun build(): FooSpecBuilder { +// TODO("Not yet implemented") +// } +// +// override fun get(): AnnotationSpec = build().get() +// +//} diff --git a/kotlin-code-generation/src/main/kotlin/poet/AnnotationSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/AnnotationSpecBuilder.kt new file mode 100644 index 0000000..08d769d --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/AnnotationSpecBuilder.kt @@ -0,0 +1,33 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.AnnotationSpec.UseSiteTarget +import kotlin.reflect.KClass + +class AnnotationSpecBuilder( + override val builder: AnnotationSpec.Builder +) : PoetSpecBuilder { + companion object { + fun AnnotationSpec.Builder.wrap() = AnnotationSpecBuilder(this) + + fun builder(type: ClassName): AnnotationSpecBuilder = AnnotationSpec.builder(type).wrap() + + fun builder(type: ParameterizedTypeName): AnnotationSpecBuilder = AnnotationSpec.builder(type).wrap() + + fun builder(type: KClass): AnnotationSpecBuilder = builder(type.asClassName()) + } + + // Taggable + fun tag(type: KClass<*>, tag: Any?) = apply { builder.tag(type, tag) } + + // Annotatable + fun addMember(format: String, vararg args: Any) = apply { builder.addMember(CodeBlock.of(format, *args)) } + fun addMember(codeBlock: CodeBlock) = apply { builder.addMember(codeBlock) } + fun useSiteTarget(useSiteTarget: UseSiteTarget?) = apply { builder.useSiteTarget(useSiteTarget) } + + + override fun build(): AnnotationSpec = builder.build() +} + +interface AnnotationSpecSupplier : PoetSpecSupplier +typealias AnnotationSpecBuilderReceiver = AnnotationSpec.Builder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/CodeBlockBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/CodeBlockBuilder.kt new file mode 100644 index 0000000..86e1fbc --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/CodeBlockBuilder.kt @@ -0,0 +1,34 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.CodeBlock.Builder + + +class CodeBlockBuilder( + override val builder: Builder +) : PoetSpecBuilder { + companion object { + private fun Builder.wrap() = CodeBlockBuilder(this) + fun of(format: String, vararg args: Any?): CodeBlock = CodeBlock.of(format, *args) + fun builder(): CodeBlockBuilder = CodeBlock.builder().wrap() + } + + fun add(format: String, vararg args: Any?): CodeBlockBuilder = apply { builder.add(format, *args) } + fun add(codeBlock: CodeBlock): CodeBlockBuilder = apply { builder.add(codeBlock) } + fun add(builder: CodeBlockBuilder): CodeBlockBuilder = add(builder.build()) + fun addNamed(format: String, arguments: Map): CodeBlockBuilder = apply { builder.addNamed(format, arguments) } + fun addStatement(format: String, vararg args: Any?): CodeBlockBuilder = apply { builder.addStatement(format, *args) } + fun beginControlFlow(controlFlow: String, vararg args: Any?): CodeBlockBuilder = apply { builder.beginControlFlow(controlFlow, *args) } + fun clear(): CodeBlockBuilder = apply { builder.clear() } + fun endControlFlow(): CodeBlockBuilder = apply { builder.endControlFlow() } + fun indent(): CodeBlockBuilder = apply { builder.indent() } + fun isEmpty(): Boolean = builder.isEmpty() + fun isNotEmpty(): Boolean = builder.isNotEmpty() + fun nextControlFlow(controlFlow: String, vararg args: Any?): CodeBlockBuilder = apply { builder.nextControlFlow(controlFlow, *args) } + fun unindent(): CodeBlockBuilder = apply { builder.unindent() } + + override fun build(): CodeBlock = builder.build() +} + +interface CodeBlockSupplier : PoetSpecSupplier +typealias CodeBlockBuilderReceiver = CodeBlockBuilder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/FileSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/FileSpecBuilder.kt new file mode 100644 index 0000000..98306c9 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/FileSpecBuilder.kt @@ -0,0 +1,70 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import kotlin.reflect.KClass + +class FileSpecBuilder( + override val builder: FileSpec.Builder +) : PoetSpecBuilder, + AnnotatableBuilder, + MemberSpecHolderBuilder, + TypeSpecHolderBuilder { + companion object { + internal fun FileSpec.Builder.wrap() = FileSpecBuilder(this) + + fun get(packageName: String, typeSpec: TypeSpec): FileSpec = FileSpec.get(packageName, typeSpec) + fun builder(className: ClassName): FileSpecBuilder = FileSpec.builder(className).wrap() + fun builder(memberName: MemberName): FileSpecBuilder = FileSpec.builder(memberName).wrap() + fun builder(packageName: String, fileName: String): FileSpecBuilder = FileSpec.builder(packageName, fileName).wrap() + fun scriptBuilder(fileName: String, packageName: String = ""): FileSpecBuilder = FileSpec.scriptBuilder(fileName, packageName).wrap() + } + + // AnnotatableBuilder + override fun addAnnotation(annotationSpec: AnnotationSpec) = apply { builder.addAnnotation(annotationSpec) } + override fun addAnnotations(annotationSpecs: Iterable) = apply { builder.addAnnotations(annotationSpecs) } + + // MemberSpecHolderBuilder + override fun addFunction(funSpec: FunSpec) = apply { builder.addFunction(funSpec) } + override fun addFunctions(funSpecs: Iterable) = apply { builder.addFunctions(funSpecs) } + override fun addProperty(propertySpec: PropertySpec) = apply { builder.addProperty(propertySpec) } + override fun addProperties(propertySpecs: Iterable) = apply { builder.addProperties(propertySpecs) } + + // TypeSpecHolderBuilder + override fun addType(typeSpec: TypeSpec) = apply { builder.addType(typeSpec) } + override fun addTypes(typeSpecs: Iterable) = apply { builder.addTypes(typeSpecs) } + + + fun addFileComment(format: String, vararg args: Any) = apply { builder.addFileComment(format, *args) } + fun clearComment(): FileSpecBuilder = apply { builder.clearComment() } + fun addTypeAlias(typeAliasSpec: TypeAliasSpec): FileSpecBuilder = apply { builder.addTypeAlias(typeAliasSpec) } + fun addImport(constant: Enum<*>): FileSpecBuilder = apply { builder.addImport(constant) } + fun addImport(kclass: KClass<*>, vararg names: String): FileSpecBuilder = apply { builder.addImport(kclass, *names) } + fun addImport(className: ClassName, vararg names: String): FileSpecBuilder = apply { builder.addImport(className, *names) } + fun addImport(kclass: KClass<*>, names: Iterable): FileSpecBuilder = apply { builder.addImport(kclass, names) } + fun addImport(className: ClassName, names: Iterable): FileSpecBuilder = apply { builder.addImport(className, names) } + fun addImport(packageName: String, vararg names: String): FileSpecBuilder = apply { builder.addImport(packageName, *names) } + fun addImport(packageName: String, names: Iterable): FileSpecBuilder = apply { builder.addImport(packageName, names) } + fun addImport(import: Import): FileSpecBuilder = apply { builder.addImport(import) } + fun clearImports(): FileSpecBuilder = apply { builder.clearImports() } + fun addAliasedImport(kclass: KClass<*>, alias: String): FileSpecBuilder = apply { builder.addAliasedImport(kclass, alias) } + fun addAliasedImport(className: ClassName, alias: String): FileSpecBuilder = apply { builder.addAliasedImport(className, alias) } + fun addAliasedImport(className: ClassName, memberName: String, alias: String): FileSpecBuilder = apply { builder.addAliasedImport(className, memberName, alias) } + fun addAliasedImport(memberName: MemberName, alias: String): FileSpecBuilder = apply { builder.addAliasedImport(memberName, alias) } + fun addDefaultPackageImport(packageName: String): FileSpecBuilder = apply { builder.addDefaultPackageImport(packageName) } + fun addKotlinDefaultImports(includeJvm: Boolean = true, includeJs: Boolean = true): FileSpecBuilder = apply { builder.addKotlinDefaultImports(includeJvm, includeJs) } + fun indent(indent: String): FileSpecBuilder = apply { builder.indent(indent) } + fun addCode(format: String, vararg args: Any?): FileSpecBuilder = apply { builder.addCode(format, *args) } + fun addNamedCode(format: String, args: Map): FileSpecBuilder = apply { builder.addNamedCode(format, args) } + fun addCode(codeBlock: CodeBlock): FileSpecBuilder = apply { builder.addCode(codeBlock) } + fun addBodyComment(format: String, vararg args: Any): FileSpecBuilder = apply { builder.addBodyComment(format, *args) } + fun beginControlFlow(controlFlow: String, vararg args: Any): FileSpecBuilder = apply { builder.beginControlFlow(controlFlow, *args) } + fun nextControlFlow(controlFlow: String, vararg args: Any): FileSpecBuilder = apply { builder.nextControlFlow(controlFlow, *args) } + fun endControlFlow(): FileSpecBuilder = apply { builder.endControlFlow() } + fun addStatement(format: String, vararg args: Any): FileSpecBuilder = apply { builder.addStatement(format, *args) } + fun clearBody(): FileSpecBuilder = apply { builder.clearBody() } + + override fun build(): FileSpec = builder.build() +} + +interface FileSpecSupplier : PoetSpecSupplier +typealias FileSpecBuilderReceiver = FileSpec.Builder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/FormatSpecifier.kt b/kotlin-code-generation/src/main/kotlin/poet/FormatSpecifier.kt new file mode 100644 index 0000000..1c1c2ec --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/FormatSpecifier.kt @@ -0,0 +1,16 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.MemberName + +object FormatSpecifier { + const val STRING = "%S" + const val STRING_TEMPLATE = "%P" + const val TYPE = "%T" + const val MEMBER = "%M" + const val NAME = "%N" + const val LITERAL = "%L" + + fun MemberName.asCodeBlock() = CodeBlock.of(MEMBER, this) + fun String.asCodeBlock() = CodeBlock.of(STRING, this) +} diff --git a/kotlin-code-generation/src/main/kotlin/poet/FunSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/FunSpecBuilder.kt new file mode 100644 index 0000000..6fdf1d3 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/FunSpecBuilder.kt @@ -0,0 +1,103 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import javax.lang.model.element.Element +import javax.lang.model.element.Modifier +import kotlin.reflect.KClass + +class FunSpecBuilder( + override val builder: FunSpec.Builder +) : PoetSpecBuilder, + AnnotatableBuilder, + ContextReceivableBuilder, + DocumentableBuilder, + OriginatingElementsHolderBuilder { + companion object { + fun FunSpec.Builder.wrap() = FunSpecBuilder(this) + + fun builder(name: String): FunSpecBuilder = FunSpec.builder(name).wrap() + + fun builder(memberName: MemberName): FunSpecBuilder = FunSpec.builder(memberName).wrap() + + fun constructorBuilder(): FunSpecBuilder = FunSpec.constructorBuilder().wrap() + + fun getterBuilder(): FunSpecBuilder = FunSpec.getterBuilder().wrap() + + fun setterBuilder(): FunSpecBuilder = FunSpec.setterBuilder().wrap() + } + + // AnnotatableBuilder + override fun addAnnotation(annotationSpec: AnnotationSpec) = apply { builder.addAnnotation(annotationSpec) } + override fun addAnnotations(annotationSpecs: Iterable) = apply { builder.addAnnotations(annotationSpecs) } + + // ContextReceiverBuilder + override fun contextReceivers(receiverTypes: Iterable) = apply { builder.contextReceivers(receiverTypes) } + + override fun contextReceivers(vararg receiverTypes: TypeName) = apply { builder.contextReceivers(*receiverTypes) } + + // DocumentableBuilder + override fun addKdoc(format: String, vararg args: Any) = apply { builder.addKdoc(format, *args) } + override fun addKdoc(block: CodeBlock) = apply { builder.addKdoc(block) } + + // OriginatingElementBuilder + override fun addOriginatingElement(originatingElement: Element) = apply { builder.addOriginatingElement(originatingElement) } + + // FunSpecBuilder + + fun addModifiers(vararg modifiers: KModifier): FunSpecBuilder = apply { builder.addModifiers(*modifiers) } + fun addModifiers(modifiers: Iterable): FunSpecBuilder = apply { builder.addModifiers(modifiers) } + + fun jvmModifiers(modifiers: Iterable) = builder.jvmModifiers(modifiers) + + fun addTypeVariables(typeVariables: Iterable): FunSpecBuilder = apply { builder.addTypeVariables(typeVariables) } + + fun addTypeVariable(typeVariable: TypeVariableName): FunSpecBuilder = apply { builder.addTypeVariable(typeVariable) } + + fun receiver(receiverType: TypeName): FunSpecBuilder = apply { builder.receiver(receiverType) } + fun receiver(receiverType: TypeName, kdoc: CodeBlock): FunSpecBuilder = apply { builder.receiver(receiverType, kdoc) } + + fun receiver(receiverType: KClass<*>): FunSpecBuilder = apply { builder.receiver(receiverType) } + fun receiver(receiverType: KClass<*>, kdoc: CodeBlock): FunSpecBuilder = apply { builder.receiver(receiverType, kdoc) } + + fun receiver(receiverType: KClass<*>, kdoc: String, vararg args: Any): FunSpecBuilder = apply { builder.receiver(receiverType, kdoc, *args) } + + fun returns(returnType: TypeName): FunSpecBuilder = apply { builder.returns(returnType) } + fun returns(returnType: TypeName, kdoc: CodeBlock): FunSpecBuilder = apply { builder.returns(returnType, kdoc) } + + fun returns(returnType: KClass<*>): FunSpecBuilder = apply { builder.returns(returnType) } + fun returns(returnType: KClass<*>, kdoc: CodeBlock): FunSpecBuilder = apply { builder.returns(returnType, kdoc) } + + fun returns(returnType: KClass<*>, kdoc: String, vararg args: Any): FunSpecBuilder = apply { builder.returns(returnType, kdoc, *args) } + + fun addParameters(parameterSpecs: Iterable): FunSpecBuilder = apply { builder.addParameters(parameterSpecs) } + fun addParameter(parameterSpec: ParameterSpec): FunSpecBuilder = apply { builder.addParameter(parameterSpec) } + fun callThisConstructor(args: List): FunSpecBuilder = apply { builder.callThisConstructor(args) } + + fun callThisConstructor(args: Iterable): FunSpecBuilder = apply { builder.callThisConstructor(args) } + fun callThisConstructor(vararg args: String): FunSpecBuilder = apply { builder.callThisConstructor(*args) } + fun callThisConstructor(vararg args: CodeBlock = emptyArray()): FunSpecBuilder = apply { builder.callThisConstructor(*args) } + fun callSuperConstructor(args: Iterable): FunSpecBuilder = apply { builder.callSuperConstructor(args) } + fun callSuperConstructor(args: List): FunSpecBuilder = apply { builder.callSuperConstructor(args) } + fun callSuperConstructor(vararg args: String): FunSpecBuilder = apply { builder.callSuperConstructor(*args) } + fun callSuperConstructor(vararg args: CodeBlock = emptyArray()): FunSpecBuilder = apply { builder.callSuperConstructor(*args) } + fun addParameter(name: String, type: TypeName, vararg modifiers: KModifier): FunSpecBuilder = apply { builder.addParameter(name, type, *modifiers) } + fun addParameter(name: String, type: KClass<*>, vararg modifiers: KModifier): FunSpecBuilder = apply { builder.addParameter(name, type, *modifiers) } + fun addParameter(name: String, type: TypeName, modifiers: Iterable): FunSpecBuilder = apply { builder.addParameter(name, type, modifiers) } + fun addParameter(name: String, type: KClass<*>, modifiers: Iterable): FunSpecBuilder = apply { builder.addParameter(name, type, modifiers) } + fun addCode(format: String, vararg args: Any?): FunSpecBuilder = apply { builder.addCode(format, *args) } + fun addNamedCode(format: String, args: Map): FunSpecBuilder = apply { builder.addNamedCode(format, args) } + fun addCode(codeBlock: CodeBlock): FunSpecBuilder = apply { builder.addCode(codeBlock) } + fun addComment(format: String, vararg args: Any): FunSpecBuilder = apply { builder.addComment(format, *args) } + + fun beginControlFlow(controlFlow: String, vararg args: Any): FunSpecBuilder = apply { builder.beginControlFlow(controlFlow, *args) } + fun nextControlFlow(controlFlow: String, vararg args: Any): FunSpecBuilder = apply { builder.nextControlFlow(controlFlow, *args) } + fun endControlFlow(): FunSpecBuilder = apply { builder.endControlFlow() } + fun addStatement(format: String, vararg args: Any): FunSpecBuilder = apply { builder.addStatement(format, *args) } + + fun clearBody(): FunSpecBuilder = apply { builder.clearBody() } + + override fun build(): FunSpec = builder.build() +} + +interface FunSpecSupplier : PoetSpecSupplier +typealias FunSpecBuilderReceiver = FunSpec.Builder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/ParameterSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/ParameterSpecBuilder.kt new file mode 100644 index 0000000..0f388a9 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/ParameterSpecBuilder.kt @@ -0,0 +1,53 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import java.lang.reflect.Type +import kotlin.reflect.KClass + +class ParameterSpecBuilder( + override val builder: ParameterSpec.Builder +) : PoetSpecBuilder, + AnnotatableBuilder, + DocumentableBuilder { + companion object { + fun ParameterSpec.Builder.wrap() = ParameterSpecBuilder(this) + + fun builder(name: String, type: TypeName, vararg modifiers: KModifier): ParameterSpecBuilder = ParameterSpec.builder(name, type, *modifiers).wrap() + + fun builder(name: String, type: Type, vararg modifiers: KModifier): ParameterSpecBuilder = builder(name, type.asTypeName(), *modifiers) + + fun builder(name: String, type: KClass<*>, vararg modifiers: KModifier): ParameterSpecBuilder = ParameterSpec.builder(name, type.asTypeName(), *modifiers).wrap() + + fun builder(name: String, type: TypeName, modifiers: Iterable): ParameterSpecBuilder = ParameterSpec.builder(name, type, modifiers).wrap() + + fun builder(name: String, type: Type, modifiers: Iterable): ParameterSpecBuilder = ParameterSpec.builder(name, type.asTypeName(), modifiers).wrap() + + fun builder(name: String, type: KClass<*>, modifiers: Iterable): ParameterSpecBuilder = ParameterSpec.builder(name, type.asTypeName(), modifiers).wrap() + + fun unnamed(type: KClass<*>): ParameterSpec = ParameterSpec.unnamed(type.asTypeName()) + + fun unnamed(type: Type): ParameterSpec = ParameterSpec.unnamed(type.asTypeName()) + + fun unnamed(type: TypeName): ParameterSpec = ParameterSpec.unnamed(type) + } + + + // AnnotatableBuilder + override fun addAnnotation(annotationSpec: AnnotationSpec) = apply { builder.addAnnotation(annotationSpec) } + override fun addAnnotations(annotationSpecs: Iterable) = apply { builder.addAnnotations(annotationSpecs) } + + // DocumentableBuilder + override fun addKdoc(format: String, vararg args: Any) = apply { builder.addKdoc(format, *args) } + override fun addKdoc(block: CodeBlock) = apply { builder.addKdoc(block) } + + fun addModifiers(vararg modifiers: KModifier): ParameterSpecBuilder = apply { builder.addModifiers(*modifiers) } + fun addModifiers(modifiers: Iterable): ParameterSpecBuilder = apply { builder.addModifiers(modifiers) } + fun defaultValue(format: String, vararg args: Any?): ParameterSpecBuilder = apply { builder.defaultValue(format, *args) } + fun defaultValue(codeBlock: CodeBlock?): ParameterSpecBuilder = apply { builder.defaultValue(codeBlock) } + + override fun build(): ParameterSpec = builder.build() +} + +interface ParameterSpecSupplier : PoetSpecSupplier +typealias ParameterSpecBuilderReceiver = ParameterSpec.Builder.() -> Unit + diff --git a/kotlin-code-generation/src/main/kotlin/poet/PropertySpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/PropertySpecBuilder.kt new file mode 100644 index 0000000..9a229ce --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/PropertySpecBuilder.kt @@ -0,0 +1,69 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import java.lang.reflect.Type +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +class PropertySpecBuilder( + override val builder: PropertySpec.Builder +) : PoetSpecBuilder, + AnnotatableBuilder, + ContextReceivableBuilder, + DocumentableBuilder, + OriginatingElementsHolderBuilder { + companion object { + fun PropertySpec.Builder.wrap() = PropertySpecBuilder(builder = this) + + fun builder(name: String, type: TypeName, vararg modifiers: KModifier, ): PropertySpecBuilder = PropertySpec.builder(name, type, *modifiers).wrap() + + fun builder(name: String, type: Type, vararg modifiers: KModifier): PropertySpecBuilder = builder( + name = name, + type = type.asTypeName(), + modifiers = modifiers + ) + + fun builder(name: String, type: KClass<*>, vararg modifiers: KModifier): PropertySpecBuilder = builder(name, type.asTypeName(), *modifiers) + + fun builder(name: String, type: TypeName, modifiers: Iterable): PropertySpecBuilder = PropertySpec.builder(name, type, modifiers).wrap() + + fun builder(name: String, type: KClass<*>, modifiers: Iterable): PropertySpecBuilder = PropertySpec.builder(name, type.asTypeName(), modifiers).wrap() + } + + + // AnnotatableBuilder + override fun addAnnotation(annotationSpec: AnnotationSpec) = apply { builder.addAnnotation(annotationSpec) } + override fun addAnnotations(annotationSpecs: Iterable) = apply { builder.addAnnotations(annotationSpecs) } + + // ContextReceiverBuilder + override fun contextReceivers(receiverTypes: Iterable) = apply { builder.contextReceivers(receiverTypes) } + + override fun contextReceivers(vararg receiverTypes: TypeName) = apply { builder.contextReceivers(*receiverTypes) } + + // DocumentableBuilder + override fun addKdoc(format: String, vararg args: Any) = apply { builder.addKdoc(format, *args) } + override fun addKdoc(block: CodeBlock) = apply { builder.addKdoc(block) } + + // OriginatingElementBuilder + override fun addOriginatingElement(originatingElement: Element) = apply { builder.addOriginatingElement(originatingElement) } + + fun mutable(mutable: Boolean = true): PropertySpecBuilder = apply { builder.mutable(mutable) } + fun addModifiers(vararg modifiers: KModifier): PropertySpecBuilder = apply { builder.addModifiers(*modifiers) } + fun addModifiers(modifiers: Iterable): PropertySpecBuilder = apply { builder.addModifiers(modifiers) } + fun addTypeVariables(typeVariables: Iterable): PropertySpecBuilder = apply { builder.addTypeVariables(typeVariables) } + fun addTypeVariable(typeVariable: TypeVariableName): PropertySpecBuilder = apply { builder.addTypeVariable(typeVariable) } + fun initializer(format: String, vararg args: Any?): PropertySpecBuilder = apply { builder.initializer(format, *args) } + fun initializer(codeBlock: CodeBlock?): PropertySpecBuilder = apply { builder.initializer(codeBlock) } + fun delegate(format: String, vararg args: Any?): PropertySpecBuilder = apply { builder.delegate(format, *args) } + fun delegate(codeBlock: CodeBlock): PropertySpecBuilder = apply { builder.delegate(codeBlock) } + fun getter(getter: FunSpec?): PropertySpecBuilder = apply { builder.getter(getter) } + fun setter(setter: FunSpec?): PropertySpecBuilder = apply { builder.setter(setter) } + fun receiver(receiverType: TypeName?): PropertySpecBuilder = apply { builder.receiver(receiverType) } + fun receiver(receiverType: KClass<*>): PropertySpecBuilder = apply { builder.receiver(receiverType) } + + + override fun build(): PropertySpec = builder.build() +} + +interface PropertySpecSupplier : PoetSpecSupplier +typealias PropertySpecBuilderReceiver = PropertySpec.Builder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/TypeAliasSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/TypeAliasSpecBuilder.kt new file mode 100644 index 0000000..bcccf84 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/TypeAliasSpecBuilder.kt @@ -0,0 +1,37 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import kotlin.reflect.KClass + +class TypeAliasSpecBuilder( + override val builder: TypeAliasSpec.Builder +) : PoetSpecBuilder, + AnnotatableBuilder, + DocumentableBuilder { + companion object { + fun TypeAliasSpec.Builder.wrap() = TypeAliasSpecBuilder(builder = this) + + fun builder(name: String, type: TypeName): TypeAliasSpecBuilder = TypeAliasSpec.builder(name, type).wrap() + + fun builder(name: String, type: KClass<*>): TypeAliasSpecBuilder = builder(name, type.asTypeName()) + } + + + // AnnotatableBuilder + override fun addAnnotation(annotationSpec: AnnotationSpec) = apply { builder.addAnnotation(annotationSpec) } + override fun addAnnotations(annotationSpecs: Iterable) = apply { builder.addAnnotations(annotationSpecs) } + + // DocumentableBuilder + override fun addKdoc(format: String, vararg args: Any) = apply { builder.addKdoc(format, *args) } + override fun addKdoc(block: CodeBlock) = apply { builder.addKdoc(block) } + + fun addModifiers(vararg modifiers: KModifier): TypeAliasSpecBuilder = apply { builder.addModifiers(*modifiers) } + fun addModifiers(modifiers: Iterable): TypeAliasSpecBuilder = apply { builder.addModifiers(modifiers) } + fun addTypeVariables(typeVariables: Iterable): TypeAliasSpecBuilder = apply { builder.addTypeVariables(typeVariables) } + fun addTypeVariable(typeVariable: TypeVariableName): TypeAliasSpecBuilder = apply { builder.addTypeVariable(typeVariable) } + + override fun build(): TypeAliasSpec = builder.build() +} + +interface TypeAliasSpecSupplier : PoetSpecSupplier +typealias TypeAliasSpecBuilderReceiver = TypeAliasSpec.Builder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/TypeSpecBuilder.kt b/kotlin-code-generation/src/main/kotlin/poet/TypeSpecBuilder.kt new file mode 100644 index 0000000..cbb2051 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/TypeSpecBuilder.kt @@ -0,0 +1,115 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +/** + * TypeSpec includes: + * + * * AnnotationClassSpec + * * AnonymousClassSpec + * * ClassSpec + * * CompanionObjectSpec + * * DataClassSpec + * * EnumClassSpec + * * InterfaceSpec + * * ObjectSpec + * * ValueClassSpec + */ +class TypeSpecBuilder( + override val builder: TypeSpec.Builder +) : PoetSpecBuilder, + AnnotatableBuilder, + ContextReceivableBuilder, + DocumentableBuilder, + MemberSpecHolderBuilder, + OriginatingElementsHolderBuilder, + TypeSpecHolderBuilder { + + companion object { + internal fun TypeSpec.Builder.wrap() = TypeSpecBuilder(builder = this) + + fun annotationBuilder(name: String): TypeSpecBuilder = TypeSpec.annotationBuilder(name).wrap() + + fun annotationBuilder(className: ClassName): TypeSpecBuilder = annotationBuilder(className.simpleName) + + fun classBuilder(name: String): TypeSpecBuilder = TypeSpec.classBuilder(name).wrap() + + fun classBuilder(className: ClassName): TypeSpecBuilder = classBuilder(className.simpleName) + + fun objectBuilder(name: String): TypeSpecBuilder = TypeSpec.objectBuilder(name).wrap() + + fun objectBuilder(className: ClassName): TypeSpecBuilder = objectBuilder(className.simpleName) + + fun companionObjectBuilder(name: String? = null): TypeSpecBuilder = TypeSpec.companionObjectBuilder(name).wrap() + + fun interfaceBuilder(name: String): TypeSpecBuilder = TypeSpec.interfaceBuilder(name).wrap() + + fun interfaceBuilder(className: ClassName): TypeSpecBuilder = interfaceBuilder(className.simpleName) + + fun funInterfaceBuilder(name: String): TypeSpecBuilder = TypeSpec.funInterfaceBuilder(name).wrap() + + fun funInterfaceBuilder(className: ClassName): TypeSpecBuilder = funInterfaceBuilder(className.simpleName) + + fun enumBuilder(name: String): TypeSpecBuilder = TypeSpec.enumBuilder(name).wrap() + + fun enumBuilder(className: ClassName): TypeSpecBuilder = enumBuilder(className.simpleName) + + fun anonymousClassBuilder(): TypeSpecBuilder = TypeSpec.anonymousClassBuilder().wrap() + } + + + // AnnotatableBuilder + override fun addAnnotation(annotationSpec: AnnotationSpec) = apply { builder.addAnnotation(annotationSpec) } + override fun addAnnotations(annotationSpecs: Iterable) = apply { builder.addAnnotations(annotationSpecs) } + + // DocumentableBuilder + override fun addKdoc(format: String, vararg args: Any) = apply { builder.addKdoc(format, *args) } + override fun addKdoc(block: CodeBlock) = apply { builder.addKdoc(block) } + + // ContextReceiverBuilder + override fun contextReceivers(receiverTypes: Iterable) = apply { builder.contextReceivers(receiverTypes) } + override fun contextReceivers(vararg receiverTypes: TypeName) = apply { builder.contextReceivers(*receiverTypes) } + + // MemberSpecHolderBuilder + override fun addFunction(funSpec: FunSpec) = apply { builder.addFunction(funSpec) } + override fun addFunctions(funSpecs: Iterable) = apply { builder.addFunctions(funSpecs) } + override fun addProperty(propertySpec: PropertySpec) = apply { builder.addProperty(propertySpec) } + override fun addProperties(propertySpecs: Iterable) = apply { builder.addProperties(propertySpecs) } + + // OriginatingElementBuilder + override fun addOriginatingElement(originatingElement: Element) = apply { builder.addOriginatingElement(originatingElement) } + + // TypeSpecHolderBuilder + override fun addType(typeSpec: TypeSpec) = apply { builder.addType(typeSpec) } + override fun addTypes(typeSpecs: Iterable) = apply { builder.addTypes(typeSpecs) } + + + fun addModifiers(vararg modifiers: KModifier): TypeSpecBuilder = apply { builder.addModifiers(*modifiers) } + fun addModifiers(modifiers: Iterable): TypeSpecBuilder = apply { builder.addModifiers(modifiers) } + fun addTypeVariables(typeVariables: Iterable): TypeSpecBuilder = apply { builder.addTypeVariables(typeVariables) } + fun addTypeVariable(typeVariable: TypeVariableName): TypeSpecBuilder = apply { builder.addTypeVariable(typeVariable) } + fun primaryConstructor(primaryConstructor: FunSpec?): TypeSpecBuilder = apply { builder.primaryConstructor(primaryConstructor) } + fun superclass(superclass: TypeName): TypeSpecBuilder = apply { builder.superclass(superclass) } + fun superclass(superclass: KClass<*>): TypeSpecBuilder = apply { builder.superclass(superclass) } + + fun addSuperclassConstructorParameter(format: String, vararg args: Any): TypeSpecBuilder = apply { builder.addSuperclassConstructorParameter(format, *args) } + fun addSuperclassConstructorParameter(codeBlock: CodeBlock): TypeSpecBuilder = apply { builder.addSuperclassConstructorParameter(codeBlock) } + + fun addSuperinterfaces(superinterfaces: Iterable): TypeSpecBuilder = apply { builder.addSuperinterfaces(superinterfaces) } + fun addSuperinterface(superinterface: TypeName): TypeSpecBuilder = apply { builder.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock): TypeSpecBuilder = apply { builder.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>): TypeSpecBuilder = apply { builder.addSuperinterface(superinterface) } + fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock): TypeSpecBuilder = apply { builder.addSuperinterface(superinterface, delegate) } + fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String): TypeSpecBuilder = apply { builder.addSuperinterface(superinterface, constructorParameterName) } + fun addSuperinterface(superinterface: TypeName, constructorParameter: String): TypeSpecBuilder = apply { builder.addSuperinterface(superinterface, constructorParameter) } + + fun addEnumConstant(name: String, typeSpec: TypeSpec = TypeSpec.anonymousClassBuilder().build()): TypeSpecBuilder = apply { builder.addEnumConstant(name, typeSpec) } + fun addInitializerBlock(block: CodeBlock): TypeSpecBuilder = apply { builder.addInitializerBlock(block) } + + override fun build(): TypeSpec = builder.build() +} + +interface TypeSpecSupplier : PoetSpecSupplier +typealias TypeSpecBuilderReceiver = TypeSpec.Builder.() -> Unit diff --git a/kotlin-code-generation/src/main/kotlin/poet/_types.kt b/kotlin-code-generation/src/main/kotlin/poet/_types.kt new file mode 100644 index 0000000..b0e7e7f --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/poet/_types.kt @@ -0,0 +1,73 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.* +import io.toolisticon.kotlin.generation.Builder +import java.util.function.Supplier +import javax.lang.model.element.Element +import kotlin.reflect.KClass + +/** + * Unfortunately, kotlin-poet specs do not share a common interface, this alias simulates that. + */ +typealias PoetSpec = Any + +/** + * Any class that can provide a kotlin-poet-native type like [com.squareup.kotlinpoet.TypeSpec], [com.squareup.kotlinpoet.ParameterSpec], ... + * exposes this by implementing this interface. + */ +interface PoetSpecSupplier : Supplier + +/** + * Unfortunately, kotlin-poet spec-builders do not share a common interface, this interface simulates that. + */ +sealed interface PoetSpecBuilder, BUILDER, SPEC : PoetSpec, SUPPLIER : PoetSpecSupplier> : Builder, PoetSpecSupplier { + val builder: BUILDER + + override fun get(): SPEC = build() +} + +sealed interface AnnotatableBuilder { + + fun addAnnotation(annotationSpec: AnnotationSpec): SELF + + fun addAnnotations(annotationSpecs: Iterable): SELF + + fun addAnnotation(annotation: ClassName): SELF = addAnnotation(AnnotationSpec.builder(annotation).build()) + + fun addAnnotation(annotation: KClass<*>): SELF = addAnnotation(annotation.asClassName()) + + fun addAnnotation(annotationSupplier: AnnotationSpecSupplier): SELF = addAnnotation(annotationSupplier.get()) +} + +sealed interface TypeSpecHolderBuilder { + fun addType(typeSpec: TypeSpec): SELF + + fun addTypes(typeSpecs: Iterable): SELF +} + +sealed interface MemberSpecHolderBuilder { + fun addFunction(funSpec: FunSpec): SELF + fun addFunctions(funSpecs: Iterable): SELF + + fun addProperties(propertySpecs: Iterable): SELF + fun addProperty(propertySpec: PropertySpec): SELF + + fun addProperty(name: String, type: TypeName, vararg modifiers: KModifier) = addProperty(PropertySpec.builder(name, type, *modifiers).build()) + fun addProperty(name: String, type: KClass<*>, vararg modifiers: KModifier) = addProperty(name, type.asTypeName(), *modifiers) + fun addProperty(name: String, type: TypeName, modifiers: Iterable) = addProperty(PropertySpec.builder(name, type, modifiers).build()) + fun addProperty(name: String, type: KClass<*>, modifiers: Iterable) = addProperty(name, type.asTypeName(), modifiers) +} + +sealed interface OriginatingElementsHolderBuilder { + fun addOriginatingElement(originatingElement: Element): SELF +} + +sealed interface ContextReceivableBuilder { + fun contextReceivers(receiverTypes: Iterable): SELF + fun contextReceivers(vararg receiverTypes: TypeName): SELF +} + +sealed interface DocumentableBuilder { + fun addKdoc(format: String, vararg args: Any): SELF + fun addKdoc(block: CodeBlock): SELF +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationClassSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationClassSpec.kt new file mode 100644 index 0000000..cbd255a --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationClassSpec.kt @@ -0,0 +1,18 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinAnnotationClassSpec( + val className: ClassName, + private val spec: TypeSpec, +) : KotlinGeneratorTypeSpec, TypeSpecSupplier, KotlinAnnotationClassSpecSupplier { + + override fun spec(): KotlinAnnotationClassSpec = this + override fun get(): TypeSpec = spec + +} +interface KotlinAnnotationClassSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationSpec.kt new file mode 100644 index 0000000..0f61a69 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationSpec.kt @@ -0,0 +1,33 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.TypeName +import io.toolisticon.kotlin.generation.builder.KotlinAnnotationSpecBuilder +import io.toolisticon.kotlin.generation.poet.AnnotationSpecSupplier + +data class KotlinAnnotationSpec( + private val spec: AnnotationSpec +) : KotlinGeneratorSpec, KotlinAnnotationSpecSupplier { + + companion object { + fun of(annotations: List): List = annotations.map { KotlinAnnotationSpec(it) } + } + + val typeName: TypeName get() = spec.typeName + val members: List get() = spec.members + + override fun get(): AnnotationSpec = spec + override fun spec(): KotlinAnnotationSpec = this + + override fun toString(): String { + return "KotlinAnnotationSpec(typeName=$typeName, members=$members)" + } + +} + +interface KotlinAnnotationSpecSupplier : KotlinGeneratorSpecSupplier, AnnotationSpecSupplier { + override fun get(): AnnotationSpec = spec().get() +} + +fun KotlinAnnotationSpec.toBuilder() = KotlinAnnotationSpecBuilder.from(spec = this) diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinAnonymousClassSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinAnonymousClassSpec.kt new file mode 100644 index 0000000..387c451 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinAnonymousClassSpec.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinAnonymousClassSpec( + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinAnonymousClassSpecSupplier { + override fun spec(): KotlinAnonymousClassSpec = this + override fun get(): TypeSpec = spec +} +interface KotlinAnonymousClassSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinClassSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinClassSpec.kt new file mode 100644 index 0000000..e928f3c --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinClassSpec.kt @@ -0,0 +1,26 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinClassSpec( + val className: ClassName, + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinClassSpecSupplier { + + init { + //require(spec.is) { "Not a dataClass spec: $spec." } + } + + override fun spec(): KotlinClassSpec = this + override fun get(): TypeSpec = spec +} + +//fun KotlinDataClassSpec.toBuilder() = KotlinDataClassSpecBuilder.builder(spec = this) +//fun KotlinDataClassSpec.toFileSpec() = KotlinFileBuilder.builder(this).build() +// TODO fun KotlinDataClassSpec.toBuilder() = KotlinDataClassBuilder.from(spec = this) +// TODO fun KotlinDataClassSpec.toFileSpec() = KotlinFileSpecBuilder.builder(this).build() +interface KotlinClassSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinCompanionObjectSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinCompanionObjectSpec.kt new file mode 100644 index 0000000..813bb76 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinCompanionObjectSpec.kt @@ -0,0 +1,15 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinCompanionObjectSpec( + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinCompanionObjectSpecSupplier { + override fun spec(): KotlinCompanionObjectSpec = this + override fun get(): TypeSpec = spec +} + +interface KotlinCompanionObjectSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinConstructorPropertySpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinConstructorPropertySpec.kt new file mode 100644 index 0000000..b7636cf --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinConstructorPropertySpec.kt @@ -0,0 +1,22 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeName + +data class KotlinConstructorPropertySpec( + val property: KotlinPropertySpec, + val parameter: KotlinParameterSpec, +) : KotlinConstructorPropertySpecSupplier { + + override val name: String = property.name + val type: TypeName = property.type + override fun spec(): KotlinConstructorPropertySpec = this +} + +interface KotlinConstructorPropertySpecSupplier : KotlinGeneratorSpecSupplier { + /** + * Name of property + */ + val name: String +} + +internal fun toList(constructorProperties: Collection) : List = constructorProperties.map(KotlinConstructorPropertySpecSupplier::spec).toList() diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinDataClassSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinDataClassSpec.kt new file mode 100644 index 0000000..a930f94 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinDataClassSpec.kt @@ -0,0 +1,27 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.typeSpec.isDataClass +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinDataClassSpec( + val className: ClassName, + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinDataClassSpecSupplier { + + init { + require(spec.isDataClass) { "Not a dataClass spec: $spec." } + } + + override fun spec(): KotlinDataClassSpec = this + override fun get(): TypeSpec = spec +} + +//fun KotlinDataClassSpec.toBuilder() = KotlinDataClassSpecBuilder.builder(spec = this) +//fun KotlinDataClassSpec.toFileSpec() = KotlinFileBuilder.builder(this).build() +// TODO fun KotlinDataClassSpec.toBuilder() = KotlinDataClassBuilder.from(spec = this) +// TODO fun KotlinDataClassSpec.toFileSpec() = KotlinFileSpecBuilder.builder(this).build() +interface KotlinDataClassSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinEnumClassSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinEnumClassSpec.kt new file mode 100644 index 0000000..d80a06d --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinEnumClassSpec.kt @@ -0,0 +1,19 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinEnumClassSpec( + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinEnumClassSpecSupplier { + + init { + require(spec.isEnum) { "Not an enum spec: $spec" } + } + + override fun spec(): KotlinEnumClassSpec = this + override fun get(): TypeSpec = spec +} +interface KotlinEnumClassSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinFileSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinFileSpec.kt new file mode 100644 index 0000000..401862a --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinFileSpec.kt @@ -0,0 +1,23 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.FileSpec +import io.toolisticon.kotlin.generation.poet.FileSpecSupplier + +data class KotlinFileSpec( + private val spec: FileSpec +) : KotlinGeneratorSpec, KotlinFileSpecSupplier { + + val packageName: String = spec.packageName + val rootName: String = spec.name + val className: ClassName = ClassName(packageName, rootName) + val fqn: String = "$packageName.$rootName" + val fileName: String = "$fqn.kt" + + override fun spec(): KotlinFileSpec = this + override fun get(): FileSpec = spec +} + +interface KotlinFileSpecSupplier : KotlinGeneratorSpecSupplier, FileSpecSupplier { + override fun get(): FileSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinFunSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinFunSpec.kt new file mode 100644 index 0000000..ef5faf7 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinFunSpec.kt @@ -0,0 +1,15 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.FunSpec +import io.toolisticon.kotlin.generation.poet.FunSpecSupplier + +data class KotlinFunSpec( + private val spec: FunSpec +) : KotlinGeneratorSpec, KotlinFunSpecSupplier { + override fun spec(): KotlinFunSpec = this + override fun get(): FunSpec = spec +} + +interface KotlinFunSpecSupplier : KotlinGeneratorSpecSupplier, FunSpecSupplier { + override fun get(): FunSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinInterfaceSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinInterfaceSpec.kt new file mode 100644 index 0000000..b4ac9d1 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinInterfaceSpec.kt @@ -0,0 +1,15 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinInterfaceSpec( + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinInterfaceSpecSupplier { + override fun spec(): KotlinInterfaceSpec = this + override fun get(): TypeSpec = spec +} + +interface KotlinInterfaceSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinObjectSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinObjectSpec.kt new file mode 100644 index 0000000..94b16b4 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinObjectSpec.kt @@ -0,0 +1,16 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + + +data class KotlinObjectSpec( + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinObjectSpecSupplier { + override fun spec(): KotlinObjectSpec = this + override fun get(): TypeSpec = spec +} + +interface KotlinObjectSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinParameterSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinParameterSpec.kt new file mode 100644 index 0000000..21b2e5d --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinParameterSpec.kt @@ -0,0 +1,21 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.TypeName +import io.toolisticon.kotlin.generation.poet.ParameterSpecSupplier + +data class KotlinParameterSpec( + private val spec: ParameterSpec +) : KotlinGeneratorSpec, KotlinParameterSpecSupplier { + + val name: String get() = spec.name + + val type: TypeName get() = spec.type + + override fun spec(): KotlinParameterSpec = this + override fun get(): ParameterSpec = this.spec +} + +interface KotlinParameterSpecSupplier : KotlinGeneratorSpecSupplier, ParameterSpecSupplier { + override fun get(): ParameterSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinPropertySpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinPropertySpec.kt new file mode 100644 index 0000000..cdc0b7d --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinPropertySpec.kt @@ -0,0 +1,34 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.PropertySpec +import com.squareup.kotlinpoet.TypeName +import io.toolisticon.kotlin.generation.poet.PropertySpecSupplier + +data class KotlinPropertySpec( + private val spec: PropertySpec +) : KotlinGeneratorSpec, KotlinPropertySpecSupplier { + val name: String get() = spec.name + + val type: TypeName get() = spec.type + + val mutable: Boolean get() = spec.mutable + + override fun spec(): KotlinPropertySpec = this + override fun get(): PropertySpec = spec + //override val annotations: List get() = KotlinAnnotationSpec.of(spec.annotations) + +// override val kdoc: CodeBlock = builder.kdoc.build() +// public val modifiers: Set = builder.modifiers.toImmutableSet() +// public val typeVariables: List = builder.typeVariables.toImmutableList() +// public val initializer: CodeBlock? = builder.initializer +// public val delegated: Boolean = builder.delegated +// public val getter: FunSpec? = builder.getter +// public val setter: FunSpec? = builder.setter +// public val receiverType: TypeName? = builder.receiverType +} + +// TODO fun KotlinPropertySpec.toBuilder() = KotlinPropertyBuilder.builder(spec = this) + +interface KotlinPropertySpecSupplier : KotlinGeneratorSpecSupplier, PropertySpecSupplier { + override fun get(): PropertySpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinTypeAliasSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinTypeAliasSpec.kt new file mode 100644 index 0000000..61cacb6 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinTypeAliasSpec.kt @@ -0,0 +1,15 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeAliasSpec +import io.toolisticon.kotlin.generation.poet.TypeAliasSpecSupplier + +data class KotlinTypeAliasSpec( + private val spec: TypeAliasSpec +) : KotlinGeneratorSpec, KotlinTypeAliasSpecSupplier { + override fun spec(): KotlinTypeAliasSpec = this + override fun get(): TypeAliasSpec = spec +} + +interface KotlinTypeAliasSpecSupplier : KotlinGeneratorSpecSupplier, TypeAliasSpecSupplier { + override fun get(): TypeAliasSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/KotlinValueClassSpec.kt b/kotlin-code-generation/src/main/kotlin/spec/KotlinValueClassSpec.kt new file mode 100644 index 0000000..04819bd --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/KotlinValueClassSpec.kt @@ -0,0 +1,24 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.typeSpec.isValueClass +import io.toolisticon.kotlin.generation.poet.TypeSpecSupplier + +data class KotlinValueClassSpec( + val className: ClassName, + private val spec: TypeSpec +) : KotlinGeneratorTypeSpec, KotlinValueClassSpecSupplier { + + init { + require(spec.isValueClass) { "Not a valueClass spec: $spec." } + } + + override fun spec(): KotlinValueClassSpec = this + override fun get(): TypeSpec = spec +} + +// fun KotlinValueClassSpec.toBuilder() = KotlinValueClassBuilder.builder(spec = this) +interface KotlinValueClassSpecSupplier : KotlinGeneratorSpecSupplier, TypeSpecSupplier { + override fun get(): TypeSpec = spec().get() +} diff --git a/kotlin-code-generation/src/main/kotlin/spec/_types.kt b/kotlin-code-generation/src/main/kotlin/spec/_types.kt new file mode 100644 index 0000000..3c63c85 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/spec/_types.kt @@ -0,0 +1,22 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.TypeSpec +import io.toolisticon.kotlin.generation.poet.* + +interface KotlinGeneratorSpecSupplier { + fun spec() : GENERATOR_SPEC +} + +interface KotlinGeneratorSpec, SPEC : PoetSpec, SUPPLIER : PoetSpecSupplier> : PoetSpecSupplier, KotlinGeneratorSpecSupplier { + override fun spec(): SELF + val code : String get() = get().toString() +} + +interface KotlinGeneratorTypeSpec> : KotlinGeneratorSpec { + override fun spec(): SELF +} + + + + + diff --git a/kotlin-code-generation/src/main/kotlin/support/CodeBlockArray.kt b/kotlin-code-generation/src/main/kotlin/support/CodeBlockArray.kt new file mode 100644 index 0000000..135ac31 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/support/CodeBlockArray.kt @@ -0,0 +1,15 @@ +package io.toolisticon.kotlin.generation.support + +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.joinToCode +import io.toolisticon.kotlin.generation.Builder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildCodeBlock + +data class CodeBlockArray(val format: String, val items: Collection = emptyList()) : Builder { + + constructor(format: String, item: T) : this(format, listOf(item)) + + operator fun plus(item: T): CodeBlockArray = copy(items = items + item) + + override fun build(): CodeBlock = items.map { buildCodeBlock(format, it) }.joinToCode(prefix = "[", suffix = "]") +} diff --git a/kotlin-code-generation/src/main/kotlin/support/DeprecatedAnnotation.kt b/kotlin-code-generation/src/main/kotlin/support/DeprecatedAnnotation.kt new file mode 100644 index 0000000..f05ede1 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/support/DeprecatedAnnotation.kt @@ -0,0 +1,17 @@ +package io.toolisticon.kotlin.generation.support + +import io.toolisticon.kotlin.generation.KotlinCodeGeneration +import io.toolisticon.kotlin.generation.poet.FormatSpecifier.asCodeBlock +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpec +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier + +data class DeprecatedAnnotation(val message: String, val deprecationLevel: DeprecationLevel? = null) : KotlinAnnotationSpecSupplier { + override fun spec(): KotlinAnnotationSpec = KotlinCodeGeneration.buildAnnotation(Deprecated::class) { + if (deprecationLevel == null) { + addMember(message.asCodeBlock()) + } else { + addStringMember("message", message) + addEnumMember("deprecationLevel", deprecationLevel) + } + } +} diff --git a/kotlin-code-generation/src/main/kotlin/support/GeneratedAnnotation.kt b/kotlin-code-generation/src/main/kotlin/support/GeneratedAnnotation.kt new file mode 100644 index 0000000..f1010fc --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/support/GeneratedAnnotation.kt @@ -0,0 +1,29 @@ +package io.toolisticon.kotlin.generation.support + +import com.squareup.kotlinpoet.asTypeName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpec +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier +import jakarta.annotation.Generated +import java.time.Instant +import kotlin.reflect.KClass + +data class GeneratedAnnotation( + val value: String = KotlinCodeGeneration::class.asTypeName().toString(), + val date: Instant = Instant.now(), + val comments: List = emptyList() +) : KotlinAnnotationSpecSupplier { + + fun generator(type: KClass<*>) = copy(value = type.asTypeName().toString()) + fun date(instant: Instant) = copy(date = instant) + fun comment(comment: Pair) = copy(comments = this.comments + "${comment.first} = ${comment.second}") + + override fun spec(): KotlinAnnotationSpec = KotlinCodeGeneration.buildAnnotation(Generated::class) { + addStringMember("value", value) + addStringMember("date", date.toString()) + + if (comments.isNotEmpty()) { + addStringMember("comments", comments.joinToString(separator = "; ")) + } + } +} diff --git a/kotlin-code-generation/src/main/kotlin/support/SuppressAnnotation.kt b/kotlin-code-generation/src/main/kotlin/support/SuppressAnnotation.kt new file mode 100644 index 0000000..f5686c5 --- /dev/null +++ b/kotlin-code-generation/src/main/kotlin/support/SuppressAnnotation.kt @@ -0,0 +1,34 @@ +package io.toolisticon.kotlin.generation.support + +import com.squareup.kotlinpoet.joinToCode +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotation +import io.toolisticon.kotlin.generation.poet.FormatSpecifier.asCodeBlock +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpec +import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier + +data class SuppressAnnotation(val names: List = emptyList()) : KotlinAnnotationSpecSupplier { + companion object { + /** + * Suppress unusual class name (eg lower case) + */ + const val CLASS_NAME = "ClassName" + + /** + * Suppress redundant visibility modifiers - the public keywords used by kotlinpoet. + */ + const val REDUNDANT_VISIBILITY_MODIFIER = "RedundantVisibilityModifier" + + /** + * Suppress warnings on unused methods and types. + */ + const val UNUSED = "unused" + } + + constructor(name: String) : this(listOf(name)) + + operator fun plus(name: String) = copy(names = (names + name).distinct()) + + override fun spec(): KotlinAnnotationSpec = buildAnnotation(Suppress::class) { + addMember(names.distinct().sorted().map { it.asCodeBlock() }.joinToCode()) + } +} diff --git a/kotlin-code-generation/src/main/resources/.gitkeep b/kotlin-code-generation/src/main/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/kotlin-code-generation/src/test/kotlin/KotlinCodeGenerationTest.kt b/kotlin-code-generation/src/test/kotlin/KotlinCodeGenerationTest.kt new file mode 100644 index 0000000..04afe59 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/KotlinCodeGenerationTest.kt @@ -0,0 +1,24 @@ +package io.toolisticon.kotlin.generation + +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.name.asCodeBlock +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.name.asMemberName +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test + +internal class KotlinCodeGenerationTest { + + @Nested + inner class Name { + + @Test + fun `join members to array`() { + val m1 = AnnotationTarget.VALUE_PARAMETER.asMemberName() + val m2 = AnnotationTarget.ANNOTATION_CLASS.asMemberName() + val code = listOf(m1,m2).asCodeBlock() + + assertThat(code).hasToString("[kotlin.`annotation`.AnnotationTarget.VALUE_PARAMETER, kotlin.`annotation`.AnnotationTarget.ANNOTATION_CLASS]") + } + } + +} diff --git a/kotlin-code-generation/src/test/kotlin/TestFixtures.kt b/kotlin-code-generation/src/test/kotlin/TestFixtures.kt new file mode 100644 index 0000000..ea562e6 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/TestFixtures.kt @@ -0,0 +1,21 @@ +package io.toolisticon.kotlin.generation + +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotation +import java.time.Instant +import kotlin.reflect.KClass + +object TestFixtures { + + // a fixed instant to be used in test with + val NOW = Instant.parse( "2024-07-02T10:01:33.205357100Z") + + @Target(allowedTargets = [AnnotationTarget.VALUE_PARAMETER]) + annotation class MyAnnotation( + val name: String, + val type: KClass<*> + ) + + val myAnnotationSpec = buildAnnotation(MyAnnotation::class) + + fun KClass<*>.notDeprecated() = !this.annotations.map { it::class }.contains(Deprecated::class) +} diff --git a/kotlin-code-generation/src/test/kotlin/poet/TypeSpecBuilderTest.kt b/kotlin-code-generation/src/test/kotlin/poet/TypeSpecBuilderTest.kt new file mode 100644 index 0000000..81cf857 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/poet/TypeSpecBuilderTest.kt @@ -0,0 +1,27 @@ +package io.toolisticon.kotlin.generation.poet + +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.TypeSpec +import jakarta.annotation.Generated +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + + +internal class TypeSpecBuilderTest { + + + @Test + fun `verify builder`() { + val builder: TypeSpecBuilder = TypeSpecBuilder(TypeSpec.classBuilder(ClassName("foo", "Bar"))) + + builder.addAnnotation(Generated::class) + + assertThat(builder.build()).hasToString( + """ + @jakarta.`annotation`.Generated + public class Bar + + """.trimIndent() + ) + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinAnnotationClassTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinAnnotationClassTest.kt new file mode 100644 index 0000000..e56ec23 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinAnnotationClassTest.kt @@ -0,0 +1,34 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotationClass +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class KotlinAnnotationClassTest { + @Test + fun `build custom annotation class`() { + val className = ClassName("foo", "CustomAnnotation") + + val annotationClass: KotlinAnnotationClassSpec = buildAnnotationClass(className) { + mustBeDocumented() + retention(AnnotationRetention.SOURCE) + target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS) + target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) + repeatable() + addConstructorProperty("value", String::class) + } + + assertThat(annotationClass.code).isEqualTo(""" + @kotlin.`annotation`.Target(allowedTargets = [kotlin.`annotation`.AnnotationTarget.ANNOTATION_CLASS, kotlin.`annotation`.AnnotationTarget.CLASS, kotlin.`annotation`.AnnotationTarget.FUNCTION]) + @kotlin.`annotation`.Retention(value = kotlin.`annotation`.AnnotationRetention.SOURCE) + @kotlin.`annotation`.Repeatable + @kotlin.`annotation`.MustBeDocumented + public annotation class CustomAnnotation( + public val `value`: kotlin.String, + ) + + """.trimIndent() + ) + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinAnnotationTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinAnnotationTest.kt new file mode 100644 index 0000000..b00e2a0 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinAnnotationTest.kt @@ -0,0 +1,74 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotation +import io.toolisticon.kotlin.generation.TestFixtures.MyAnnotation +import io.toolisticon.kotlin.generation.builder.KotlinAnnotationSpecBuilder +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import kotlin.reflect.KClass + +internal class KotlinAnnotationTest { + + annotation class Foo( + val bar: String, + val x: String = "", + val type: KClass<*> = String::class + ) + + @Test + fun buildMyAnnotation() { + val annotation = buildAnnotation(MyAnnotation::class) { + addStringMember("name", "foo") + addKClassMember("type", String::class) + } + + assertThat(annotation.code).isEqualTo("""@io.toolisticon.kotlin.generation.TestFixtures.MyAnnotation(name = "foo", type = kotlin.String::class)"""); + } + + + @Test + fun `create Foo annotation`() { + val spec = KotlinAnnotationSpecBuilder.builder(Foo::class) + .addMember("bar = %S", "hello world") + .addStringMember("x", "foo") + .addKClassMember("type", Long::class) + .build() + + assertThat(spec.code).isEqualTo("""@io.toolisticon.kotlin.generation.spec.KotlinAnnotationTest.Foo(bar = "hello world", x = "foo", type = kotlin.Long::class)""") + assertThat(spec.members).hasSize(3) + + assertThat(spec).hasToString( + "KotlinAnnotationSpec(" + + "typeName=io.toolisticon.kotlin.generation.spec.KotlinAnnotationTest.Foo, " + + "members=[" + + "bar = \"hello world\", " + + "x = \"foo\", " + + "type = kotlin.Long::class]" + + ")" + ) + } + + @Test + fun `use toBuilder to add members`() { + var spec = KotlinAnnotationSpecBuilder.builder(Foo::class) + .addMember("bar", "hello") + .build() + + assertThat(spec.members).hasSize(1) + + spec = spec.toBuilder() + .addMember("type", Int::class) + .build() + + assertThat(spec.members).hasSize(2) + } + + @Test + fun `create target annotation`() { + val annotation = buildAnnotation(Target::class) { + addEnumMembers("allowedTargets", AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FILE) + } + + println(annotation.code) + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinAnonymousClassTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinAnonymousClassTest.kt new file mode 100644 index 0000000..74addd5 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinAnonymousClassTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinAnonymousClassTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinClassTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinClassTest.kt new file mode 100644 index 0000000..0e3311f --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinClassTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinClassTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinCompanionObjectTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinCompanionObjectTest.kt new file mode 100644 index 0000000..60bdb2c --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinCompanionObjectTest.kt @@ -0,0 +1,16 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Assumptions.assumeTrue +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinCompanionObjectTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinConstructorPropertyTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinConstructorPropertyTest.kt new file mode 100644 index 0000000..05f38e9 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinConstructorPropertyTest.kt @@ -0,0 +1,17 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Assumptions.assumeTrue +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinConstructorPropertyTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } + + +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinDataClassTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinDataClassTest.kt new file mode 100644 index 0000000..fac0e39 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinDataClassTest.kt @@ -0,0 +1,40 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildDataClass +import io.toolisticon.kotlin.generation.TestFixtures +import io.toolisticon.kotlin.generation.support.GeneratedAnnotation +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class KotlinDataClassTest { + + @Test + fun `create foo`() { + val className = ClassName("test", "Foo") + + val spec = buildDataClass(className) { + addAnnotation(GeneratedAnnotation(date = TestFixtures.NOW).comment("version" to "1.2")) + addConstructorProperty("x", Int::class) + addConstructorProperty("y", Long::class) { + makePrivate() + addAnnotation(TestFixtures.myAnnotationSpec) + } + } + + assertThat(spec.code.trim()).isEqualTo( + """ + @jakarta.`annotation`.Generated( + value = "io.toolisticon.kotlin.generation.KotlinCodeGeneration", + date = "2024-07-02T10:01:33.205357100Z", + comments = "version = 1.2", + ) + public data class Foo( + public val x: kotlin.Int, + @io.toolisticon.kotlin.generation.TestFixtures.MyAnnotation + private val y: kotlin.Long, + ) + """.trimIndent() + ) + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinEnumClassTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinEnumClassTest.kt new file mode 100644 index 0000000..e240bc1 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinEnumClassTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinEnumClassTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinFileTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinFileTest.kt new file mode 100644 index 0000000..5f6281b --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinFileTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinFileTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinFunTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinFunTest.kt new file mode 100644 index 0000000..fa8d7ef --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinFunTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinFunTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinInterfaceTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinInterfaceTest.kt new file mode 100644 index 0000000..49a9330 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinInterfaceTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinInterfaceTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinObjectTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinObjectTest.kt new file mode 100644 index 0000000..93f6a8c --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinObjectTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinObjectTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinParameterTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinParameterTest.kt new file mode 100644 index 0000000..750cd15 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinParameterTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinParameterTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinPropertyTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinPropertyTest.kt new file mode 100644 index 0000000..c0bbf6d --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinPropertyTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinPropertyTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinTypeAliasTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinTypeAliasTest.kt new file mode 100644 index 0000000..19816f0 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinTypeAliasTest.kt @@ -0,0 +1,14 @@ +package io.toolisticon.kotlin.generation.spec + +import io.toolisticon.kotlin.generation.TestFixtures.notDeprecated +import org.junit.jupiter.api.Assumptions.assumeFalse +import org.junit.jupiter.api.Test + +@Deprecated("not implemented yet") +internal class KotlinTypeAliasTest { + @Test + fun name() { + assumeFalse(this::class.notDeprecated()) + TODO("Not yet implemented") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/spec/KotlinValueClassTest.kt b/kotlin-code-generation/src/test/kotlin/spec/KotlinValueClassTest.kt new file mode 100644 index 0000000..c9a059b --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/spec/KotlinValueClassTest.kt @@ -0,0 +1,58 @@ +package io.toolisticon.kotlin.generation.spec + +import com.squareup.kotlinpoet.ClassName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildValueClass +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.toFileSpec +import io.toolisticon.kotlin.generation.TestFixtures +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class KotlinValueClassTest { + + @Test + fun `build foo with string value`() { + val className = ClassName("test", "Foo") + val valueClass = buildValueClass(className = className) { + addConstructorProperty("bar", String::class) { + makePrivate() + addAnnotation(TestFixtures.myAnnotationSpec) + } + } + + assertThat(toFileSpec(valueClass).code.trim()).isEqualTo( + """package test + +import io.toolisticon.kotlin.generation.TestFixtures +import kotlin.String +import kotlin.jvm.JvmInline + +@JvmInline +public value class Foo( + @TestFixtures.MyAnnotation + private val bar: String, +)""" + ) + } + + + @Test + fun `create foo value class`() { + val className = ClassName("io.acme", "Foo") + + val spec = buildValueClass(className) { + addConstructorProperty("bar", String::class) { + addAnnotation(TestFixtures.myAnnotationSpec) + } + } + + assertThat(spec.code.trim()).isEqualTo( + """ + @kotlin.jvm.JvmInline + public value class Foo( + @io.toolisticon.kotlin.generation.TestFixtures.MyAnnotation + public val bar: kotlin.String, + ) + """.trimIndent() + ) + } +} diff --git a/kotlin-code-generation/src/test/kotlin/support/CodeBlockArrayTest.kt b/kotlin-code-generation/src/test/kotlin/support/CodeBlockArrayTest.kt new file mode 100644 index 0000000..e964a57 --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/support/CodeBlockArrayTest.kt @@ -0,0 +1,17 @@ +package io.toolisticon.kotlin.generation.support + +import io.toolisticon.kotlin.generation.poet.FormatSpecifier +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CodeBlockArrayTest { + + @Test + fun `string array`() { + var array = CodeBlockArray(FormatSpecifier.STRING) + assertThat(array.build()).hasToString("[]") + array += "foo" + array += "bar" + assertThat(array.build()).hasToString("""["foo", "bar"]""") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/support/GeneratedAnnotationTest.kt b/kotlin-code-generation/src/test/kotlin/support/GeneratedAnnotationTest.kt new file mode 100644 index 0000000..0973adb --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/support/GeneratedAnnotationTest.kt @@ -0,0 +1,17 @@ +package io.toolisticon.kotlin.generation.support + +import io.toolisticon.kotlin.generation.TestFixtures +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GeneratedAnnotationTest { + + @Test + fun `generated annotation`() { + val annotation = GeneratedAnnotation( + date = TestFixtures.NOW + ).comment("version" to "1.0").spec() + + assertThat(annotation.code).isEqualTo("""@jakarta.`annotation`.Generated(value = "io.toolisticon.kotlin.generation.KotlinCodeGeneration", date = "2024-07-02T10:01:33.205357100Z", comments = "version = 1.0")""") + } +} diff --git a/kotlin-code-generation/src/test/kotlin/support/SuppressAnnotationTest.kt b/kotlin-code-generation/src/test/kotlin/support/SuppressAnnotationTest.kt new file mode 100644 index 0000000..28ddf6f --- /dev/null +++ b/kotlin-code-generation/src/test/kotlin/support/SuppressAnnotationTest.kt @@ -0,0 +1,67 @@ +package io.toolisticon.kotlin.generation.support + +import com.squareup.kotlinpoet.ClassName +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.classBuilder +import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.fileBuilder +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SuppressAnnotationTest { + private val className = ClassName("foo", "Bar") + private val typeBuilder = classBuilder(className) + private val fileBuilder = fileBuilder(className) + + @Test + fun `single unused on class`() { + val suppress = SuppressAnnotation(SuppressAnnotation.UNUSED).spec() + + val type = typeBuilder.addAnnotation(suppress).build() + + assertThat(type.code).isEqualTo( + """ + @kotlin.Suppress("unused") + public class Bar + + """.trimIndent() + ) + } + + @Test + fun `multiple on class`() { + val suppress = SuppressAnnotation(SuppressAnnotation.UNUSED) + .plus(SuppressAnnotation.REDUNDANT_VISIBILITY_MODIFIER) + .spec() + + val type = typeBuilder.addAnnotation(suppress).build() + + assertThat(type.code).isEqualTo( + """ + @kotlin.Suppress("RedundantVisibilityModifier", "unused") + public class Bar + + """.trimIndent() + ) + } + + @Test + fun `multiple on file`() { + val suppress = SuppressAnnotation(SuppressAnnotation.UNUSED) + .plus(SuppressAnnotation.REDUNDANT_VISIBILITY_MODIFIER) + .spec() + + val file = fileBuilder.addAnnotation(suppress).addType(typeBuilder.spec()).build() + + assertThat(file.code).isEqualTo( + """ + @file:Suppress("RedundantVisibilityModifier", "unused") + + package foo + + import kotlin.Suppress + + public class Bar + +""".trimIndent() + ) + } +} diff --git a/kotlin-code-generation/src/test/resources/.gitkeep b/kotlin-code-generation/src/test/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml index db1a496..ace049f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,103 +5,69 @@ io.toolisticon.maven.parent maven-parent-kotlin-base - 2024.5.0 + 2024.6.1 - BASE_GROUP_ID - BASE_ARTIFACT_ID - 0.0.1-SNAPSHOT - ${project.artifactId} - BASE_DESCRIPTION - https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/ + io.toolisticon.kotlin.generation._ + kotlin-code-generation-root + 0.0.1 - - - 5.3.1 - 3.25.3 - + pom: ${project.artifactId} + Root of kotlin-code-generation + https://github.com/toolisticon/kotlin-code-generation/ + pom - - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - - - org.jetbrains.kotlin - kotlin-reflect - - - io.github.microutils - kotlin-logging-jvm - ${kotlin-logging.version} - + + _mvn/parent + _mvn/bom + kotlin-code-generation + kotlin-code-generation-test + - - - org.mockito.kotlin - mockito-kotlin - ${mockito.version} - test - - - org.junit.jupiter - junit-jupiter - test - - - org.junit.jupiter - junit-jupiter-params - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.jetbrains.kotlin - kotlin-test-junit5 - test - - + - - clean jacoco:prepare-agent package + + + + + - - - org.jacoco - jacoco-maven-plugin - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-enforcer-plugin - - + + + + + + + + + itest + + + !skipItest + + + + _itest + + + + The Apache Software License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0.txt + repo + A business-friendly OSS license - scm:git:git@github.com:GITHUB_ORGANIZATION/GITHUB_REPOSITORY.git - scm:git:git@github.com:GITHUB_ORGANIZATION/GITHUB_REPOSITORY.git - scm:git:git@github.com:GITHUB_ORGANIZATION/GITHUB_REPOSITORY.git + scm:git:git@github.com:toolisticon/kotlin-code-generation.git + scm:git:git@github.com:toolisticon/kotlin-code-generation.git + scm:git:git@github.com:toolisticon/kotlin-code-generation.git HEAD @@ -139,4 +105,5 @@ https://holisticon.de + diff --git a/setup.sh b/setup.sh deleted file mode 100755 index a1ec87d..0000000 --- a/setup.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -GITHUB_ORGANIZATION=toolisticon -GITHUB_REPOSITORY=kotlin-lib -BASE_GROUP_ID=io.toolisticon.template -BASE_DESCRIPTION=$GITHUB_REPOSITORY -BASE_ARTIFACT_ID=$GITHUB_REPOSITORY - -case "$OSTYPE" in - darwin*) # support mac with special SED - BIN="sed -i ''" - ;; - *) # use standard SED - BIN="sed -i" - ;; -esac - -for FILE in `find . \( -name "pom.xml" -o -name "*.kt" -o -name "*.md" \) -type f` -do - $BIN "s/GITHUB_ORGANIZATION/${GITHUB_ORGANIZATION}/g" ""$FILE"" - $BIN "s/GITHUB_REPOSITORY/${GITHUB_REPOSITORY}/g" "$FILE" - $BIN "s/BASE_GROUP_ID/${BASE_GROUP_ID}/g" "$FILE" - $BIN "s/BASE_ARTIFACT_ID/${BASE_ARTIFACT_ID}/g" "$FILE" - $BIN "s/BASE_DESCRIPTION/${BASE_DESCRIPTION}/g" "$FILE" -done diff --git a/src/main/kotlin/KotlinLibTemplate.kt b/src/main/kotlin/KotlinLibTemplate.kt deleted file mode 100644 index 9370320..0000000 --- a/src/main/kotlin/KotlinLibTemplate.kt +++ /dev/null @@ -1,8 +0,0 @@ -package BASE_GROUP_ID - -object KotlinLibTemplate { - - // just a placeholder - - fun method(): Boolean = true -} diff --git a/src/test/kotlin/KotlinLibTemplateITest.kt b/src/test/kotlin/KotlinLibTemplateITest.kt deleted file mode 100644 index cc737f2..0000000 --- a/src/test/kotlin/KotlinLibTemplateITest.kt +++ /dev/null @@ -1,12 +0,0 @@ -package BASE_GROUP_ID - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class KotlinLibTemplateITest { - - @Test - fun `dummy test`() { - assertThat(1 + 1).isEqualTo(2) - } -} diff --git a/src/test/kotlin/KotlinLibTemplateTest.kt b/src/test/kotlin/KotlinLibTemplateTest.kt deleted file mode 100644 index be3536e..0000000 --- a/src/test/kotlin/KotlinLibTemplateTest.kt +++ /dev/null @@ -1,12 +0,0 @@ -package BASE_GROUP_ID - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class KotlinLibTemplateTest { - - @Test - fun `dummy test`() { - assertThat(1 + 1).isEqualTo(2) - } -}