-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor - move to poet package
- Loading branch information
1 parent
444dbc0
commit 47ef360
Showing
21 changed files
with
131 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.toolisticon.kotlin.generation | ||
|
||
import java.util.function.Supplier | ||
|
||
fun interface Builder<P : Any> { | ||
fun build(): P | ||
} | ||
|
||
interface BuilderSupplier<P : Any, B : Any> : Builder<P>, Supplier<B> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
kotlin-code-generation/src/main/kotlin/builder/poet/_adapter.kt
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
kotlin-code-generation/src/main/kotlin/poet/AnnotatableBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.Annotatable | ||
import com.squareup.kotlinpoet.AnnotationSpec | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
|
||
sealed interface AnnotatableBuilder<SELF : AnnotatableBuilder<SELF, S, B>, S : Annotatable, B : Annotatable.Builder<B>> | ||
: BuilderSupplier<S, B>, Annotatable.Builder<SELF> { | ||
override val annotations: MutableList<AnnotationSpec> get() = get().annotations | ||
|
||
fun addAnnotation(builder: AnnotationSpecBuilder): SELF = addAnnotation(builder.build()) | ||
} |
5 changes: 3 additions & 2 deletions
5
...lin/builder/poet/AnnotationSpecBuilder.kt → ...main/kotlin/poet/AnnotationSpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...n/kotlin/builder/poet/CodeBlockBuilder.kt → .../src/main/kotlin/poet/CodeBlockBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
kotlin-code-generation/src/main/kotlin/poet/ContextReceivableBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.ContextReceivable | ||
import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi | ||
import com.squareup.kotlinpoet.TypeName | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
|
||
@ExperimentalKotlinPoetApi | ||
sealed interface ContextReceivableBuilder<SELF : ContextReceivableBuilder<SELF, S, B>, S : ContextReceivable, B : ContextReceivable.Builder<B>> | ||
: BuilderSupplier<S, B>, ContextReceivable.Builder<SELF> { | ||
override val contextReceiverTypes: MutableList<TypeName> get() = get().contextReceiverTypes | ||
} |
12 changes: 12 additions & 0 deletions
12
kotlin-code-generation/src/main/kotlin/poet/DocumentableBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.CodeBlock | ||
import com.squareup.kotlinpoet.Documentable | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
|
||
sealed interface DocumentableBuilder<SELF : DocumentableBuilder<SELF, S, B>, S : Documentable, B : Documentable.Builder<B>> | ||
: BuilderSupplier<S, B>, Documentable.Builder<SELF> { | ||
override val kdoc: CodeBlock.Builder get() = get().kdoc | ||
|
||
fun addKdoc(builder: CodeBlockBuilder): SELF = addKdoc(builder.build()) | ||
} |
5 changes: 3 additions & 2 deletions
5
...in/kotlin/builder/poet/FileSpecBuilder.kt → ...n/src/main/kotlin/poet/FileSpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...ain/kotlin/builder/poet/FunSpecBuilder.kt → ...on/src/main/kotlin/poet/FunSpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
kotlin-code-generation/src/main/kotlin/poet/MemberSpecHolderBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi | ||
import com.squareup.kotlinpoet.FunSpec | ||
import com.squareup.kotlinpoet.MemberSpecHolder | ||
import com.squareup.kotlinpoet.PropertySpec | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
|
||
sealed interface MemberSpecHolderBuilder<SELF : MemberSpecHolderBuilder<SELF, S, B>, S : MemberSpecHolder, B : MemberSpecHolder.Builder<B>> | ||
: BuilderSupplier<S, B>, MemberSpecHolder.Builder<SELF> { | ||
override fun addProperty(propertySpec: PropertySpec): SELF | ||
|
||
@OptIn(ExperimentalKotlinPoetApi::class) | ||
fun addProperty(builder: PropertySpecBuilder): SELF = addProperty(builder.build()) | ||
|
||
override fun addFunction(funSpec: FunSpec): SELF | ||
|
||
@OptIn(ExperimentalKotlinPoetApi::class) | ||
fun addFunction(builder: FunSpecBuilder): SELF = addFunction(builder.build()) | ||
} |
10 changes: 10 additions & 0 deletions
10
kotlin-code-generation/src/main/kotlin/poet/OriginatingElementsHolderBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.OriginatingElementsHolder | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
import javax.lang.model.element.Element | ||
|
||
sealed interface OriginatingElementsHolderBuilder<SELF : OriginatingElementsHolderBuilder<SELF, S, B>, S : OriginatingElementsHolder, B : OriginatingElementsHolder.Builder<B>> | ||
: BuilderSupplier<S, B>, OriginatingElementsHolder.Builder<SELF> { | ||
override val originatingElements: MutableList<Element> get() = get().originatingElements | ||
} |
5 changes: 3 additions & 2 deletions
5
...tlin/builder/poet/ParameterSpecBuilder.kt → .../main/kotlin/poet/ParameterSpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
...otlin/builder/poet/PropertySpecBuilder.kt → ...c/main/kotlin/poet/PropertySpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
kotlin-code-generation/src/main/kotlin/poet/TaggableBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.Taggable | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
import kotlin.reflect.KClass | ||
|
||
sealed interface TaggableBuilder<SELF : TaggableBuilder<SELF, S, B>, S : Taggable, B : Taggable.Builder<B>> | ||
: BuilderSupplier<S, B>, Taggable.Builder<SELF> { | ||
override val tags: MutableMap<KClass<*>, Any> get() = get().tags | ||
} |
5 changes: 3 additions & 2 deletions
5
...tlin/builder/poet/TypeAliasSpecBuilder.kt → .../main/kotlin/poet/TypeAliasSpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...in/kotlin/builder/poet/TypeSpecBuilder.kt → ...n/src/main/kotlin/poet/TypeSpecBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
kotlin-code-generation/src/main/kotlin/poet/TypeSpecHolderBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.toolisticon.kotlin.generation.poet | ||
|
||
import com.squareup.kotlinpoet.* | ||
import io.toolisticon.kotlin.generation.BuilderSupplier | ||
|
||
sealed interface TypeSpecHolderBuilder<SELF : TypeSpecHolderBuilder<SELF, S, B>, S : TypeSpecHolder, B : TypeSpecHolder.Builder<B>> | ||
: BuilderSupplier<S, B>, TypeSpecHolder.Builder<SELF> { | ||
override fun addType(typeSpec: TypeSpec): SELF | ||
|
||
@OptIn(ExperimentalKotlinPoetApi::class) | ||
fun addType(builder: TypeSpecBuilder): SELF = addType(builder.build()) | ||
} |
3 changes: 2 additions & 1 deletion
3
...builder/poet/AnnotationSpecBuilderTest.kt → .../kotlin/poet/AnnotationSpecBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...otlin/builder/poet/TypeSpecBuilderTest.kt → ...c/test/kotlin/poet/TypeSpecBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters