-
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.
- Loading branch information
1 parent
f694e04
commit b077abf
Showing
56 changed files
with
865 additions
and
1,133 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
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
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
59 changes: 0 additions & 59 deletions
59
kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationBuilder.kt
This file was deleted.
Oops, something went wrong.
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
41 changes: 41 additions & 0 deletions
41
kotlin-code-generation/src/main/kotlin/builder/KotlinAnnotationSpecBuilder.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,41 @@ | ||
package io.toolisticon.kotlin.generation.builder | ||
|
||
import com.squareup.kotlinpoet.AnnotationSpec | ||
import com.squareup.kotlinpoet.ClassName | ||
import com.squareup.kotlinpoet.CodeBlock | ||
import com.squareup.kotlinpoet.ParameterizedTypeName | ||
import io.toolisticon.kotlin.generation.Builder | ||
import io.toolisticon.kotlin.generation.poet.AnnotationSpecBuilder | ||
import io.toolisticon.kotlin.generation.spec.AnnotationSpecSupplier | ||
import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpec | ||
import kotlin.reflect.KClass | ||
|
||
class KotlinAnnotationSpecBuilder internal constructor( | ||
private val delegate: AnnotationSpecBuilder | ||
) : Builder<KotlinAnnotationSpec>, AnnotationSpecSupplier { | ||
companion object { | ||
fun builder(type: ClassName): KotlinAnnotationSpecBuilder = KotlinAnnotationSpecBuilder(AnnotationSpecBuilder.builder(type)) | ||
fun builder(type: ParameterizedTypeName): KotlinAnnotationSpecBuilder = KotlinAnnotationSpecBuilder(AnnotationSpecBuilder.Companion.builder(type)) | ||
fun builder(type: KClass<out Annotation>): KotlinAnnotationSpecBuilder = KotlinAnnotationSpecBuilder(AnnotationSpecBuilder.builder(type)) | ||
} | ||
|
||
operator fun invoke(block: AnnotationSpecBuilder.() -> Unit): KotlinAnnotationSpecBuilder = apply { | ||
delegate.block() | ||
} | ||
|
||
fun addMember(format: String, vararg args: Any): KotlinAnnotationSpecBuilder = apply { | ||
delegate.addMember(format, *args) | ||
} | ||
|
||
fun addMember(codeBlock: CodeBlock): KotlinAnnotationSpecBuilder = apply { | ||
delegate.addMember(codeBlock) | ||
} | ||
|
||
fun addKClassMember(name: String, klass: KClass<*>) = addMember("$name = %T::class", klass) | ||
|
||
fun addStringMember(name: String, value: String) = addMember("$name = %S", value) | ||
|
||
|
||
override fun build(): KotlinAnnotationSpec = KotlinAnnotationSpec(spec = delegate.build()) | ||
override fun get(): AnnotationSpec = build().get() | ||
} |
19 changes: 11 additions & 8 deletions
19
kotlin-code-generation/src/main/kotlin/builder/KotlinAnonymousClassBuilder.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 |
---|---|---|
@@ -1,22 +1,25 @@ | ||
package io.toolisticon.kotlin.generation.builder | ||
|
||
import com.squareup.kotlinpoet.TypeSpec | ||
import io.toolisticon.kotlin.generation.Builder | ||
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.Supressions.CLASS_NAME | ||
import io.toolisticon.kotlin.generation.builder.bak.BAK_KotlinPoetTypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.builder.bak.ToKotlinPoetTypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.poet.TypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.spec.KotlinAnonymousClassSpec | ||
import io.toolisticon.kotlin.generation.spec.TypeSpecSupplier | ||
|
||
@Deprecated("Not implemented yet!") | ||
class KotlinAnonymousClassBuilder internal constructor(delegate: TypeSpec.Builder) : KotlinPoetTypeSpecBuilder<KotlinAnonymousClassSpec>( | ||
delegate = delegate | ||
), TypeSpecSupplier { | ||
@Deprecated("not implemented yet") | ||
class KotlinAnonymousClassBuilder internal constructor( | ||
private val delegate: TypeSpecBuilder | ||
) : Builder<KotlinAnonymousClassSpec>, TypeSpecSupplier { | ||
|
||
|
||
@Suppress(CLASS_NAME) | ||
object builder : ToKotlinPoetTypeSpecBuilder<KotlinAnonymousClassSpec, KotlinAnonymousClassBuilder> { | ||
override fun invoke(spec: KotlinAnonymousClassSpec, kind: TypeSpec.Kind, name: String?): KotlinAnonymousClassBuilder = KotlinAnonymousClassBuilder(spec.get().toBuilder(kind,name)) | ||
override fun build(): KotlinAnonymousClassSpec { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun build(): KotlinAnonymousClassSpec { | ||
override fun get(): TypeSpec { | ||
TODO("Not yet implemented") | ||
} | ||
} |
24 changes: 16 additions & 8 deletions
24
kotlin-code-generation/src/main/kotlin/builder/KotlinClassBuilder.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
package io.toolisticon.kotlin.generation.builder | ||
|
||
import com.squareup.kotlinpoet.ClassName | ||
import com.squareup.kotlinpoet.TypeSpec | ||
import io.toolisticon.kotlin.generation.Builder | ||
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.Supressions.CLASS_NAME | ||
import io.toolisticon.kotlin.generation.builder.bak.BAK_KotlinPoetTypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.builder.bak.ToKotlinPoetTypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.poet.TypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.spec.KotlinClassSpec | ||
import io.toolisticon.kotlin.generation.spec.TypeSpecSupplier | ||
|
||
@Deprecated("Not implemented yet!") | ||
class KotlinClassBuilder internal constructor(delegate: TypeSpec.Builder) : KotlinPoetTypeSpecBuilder<KotlinClassSpec>( | ||
delegate = delegate | ||
), TypeSpecSupplier { | ||
class KotlinClassBuilder internal constructor( | ||
private val delegate: TypeSpecBuilder | ||
) : Builder<KotlinClassSpec>, TypeSpecSupplier { | ||
|
||
|
||
@Suppress(CLASS_NAME) | ||
object builder : ToKotlinPoetTypeSpecBuilder<KotlinClassSpec, KotlinClassBuilder> { | ||
override fun invoke(spec: KotlinClassSpec, kind: TypeSpec.Kind, name: String?): KotlinClassBuilder = KotlinClassBuilder(spec.get().toBuilder(kind,name)) | ||
companion object { | ||
fun builder(className: ClassName) = KotlinClassBuilder( | ||
delegate = TypeSpecBuilder.classBuilder(className) | ||
) | ||
} | ||
|
||
operator fun invoke(block: TypeSpecBuilder.() -> Unit): KotlinClassBuilder = apply { | ||
delegate.block() | ||
} | ||
|
||
override fun build(): KotlinClassSpec = KotlinClassSpec(spec = delegate.build()) | ||
override fun get(): TypeSpec = build().get() | ||
} |
22 changes: 14 additions & 8 deletions
22
kotlin-code-generation/src/main/kotlin/builder/KotlinCompanionObjectBuilder.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 |
---|---|---|
@@ -1,20 +1,26 @@ | ||
package io.toolisticon.kotlin.generation.builder | ||
|
||
import com.squareup.kotlinpoet.TypeSpec | ||
import io.toolisticon.kotlin.generation.Builder | ||
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.Supressions.CLASS_NAME | ||
import io.toolisticon.kotlin.generation.builder.bak.ToKotlinPoetTypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.poet.TypeSpecBuilder | ||
import io.toolisticon.kotlin.generation.spec.KotlinCompanionObjectSpec | ||
import io.toolisticon.kotlin.generation.spec.TypeSpecSupplier | ||
|
||
@Deprecated("Not implemented yet!") | ||
class KotlinCompanionObjectBuilder internal constructor(delegate: TypeSpec.Builder) : KotlinPoetTypeSpecBuilder<KotlinCompanionObjectSpec>( | ||
delegate = delegate | ||
), TypeSpecSupplier { | ||
class KotlinCompanionObjectBuilder internal constructor( | ||
private val delegate: TypeSpecBuilder | ||
) : Builder<KotlinCompanionObjectSpec>, TypeSpecSupplier { | ||
|
||
|
||
@Suppress(CLASS_NAME) | ||
object builder : ToKotlinPoetTypeSpecBuilder<KotlinCompanionObjectSpec, KotlinCompanionObjectBuilder> { | ||
override fun invoke(spec: KotlinCompanionObjectSpec, kind: TypeSpec.Kind, name: String?): KotlinCompanionObjectBuilder = KotlinCompanionObjectBuilder(spec.get().toBuilder(kind,name)) | ||
companion object { | ||
fun builder(name: String? = null) = KotlinCompanionObjectBuilder( | ||
delegate = TypeSpecBuilder.companionObjectBuilder(name) | ||
) | ||
} | ||
operator fun invoke(block: TypeSpecBuilder.() -> Unit): KotlinCompanionObjectBuilder = apply { | ||
delegate.block() | ||
} | ||
|
||
override fun build(): KotlinCompanionObjectSpec = KotlinCompanionObjectSpec(spec = delegate.build()) | ||
override fun get(): TypeSpec = build().get() | ||
} |
Oops, something went wrong.