-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
step3codegen
package (mainly TypeGenerator
)
- Loading branch information
Showing
15 changed files
with
635 additions
and
392 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
47 changes: 35 additions & 12 deletions
47
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step2intermediate/MoreTypes.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
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
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/KotlinPoetExtensions.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,39 @@ | ||
package com.virtuslab.pulumikotlin.codegen.step3codegen | ||
|
||
import com.squareup.kotlinpoet.CodeBlock | ||
import com.squareup.kotlinpoet.FileSpec | ||
import com.squareup.kotlinpoet.FunSpec | ||
import com.squareup.kotlinpoet.MemberName | ||
import com.squareup.kotlinpoet.PropertySpec | ||
import com.squareup.kotlinpoet.TypeSpec | ||
import com.virtuslab.pulumikotlin.codegen.expressions.Code | ||
|
||
object KotlinPoetExtensions { | ||
fun FileSpec.Builder.addTypes(vararg typeSpecs: TypeSpec) = | ||
addTypes(typeSpecs.toList()) | ||
|
||
fun TypeSpec.Builder.addFunctions(vararg funSpecs: FunSpec) = | ||
addFunctions(funSpecs.toList()) | ||
|
||
fun TypeSpec.Builder.addProperties(vararg propertySpecs: PropertySpec) = | ||
addProperties(propertySpecs.toList()) | ||
|
||
fun FileSpec.Builder.addImport(memberName: MemberName) = | ||
addImport(memberName.packageName, memberName.simpleName) | ||
|
||
fun FileSpec.Builder.addImports(vararg memberNames: MemberName): FileSpec.Builder { | ||
memberNames.forEach { | ||
addImport(it) | ||
} | ||
return this | ||
} | ||
|
||
fun FileSpec.Builder.addTypes(types: Iterable<TypeSpec>): FileSpec.Builder { | ||
types.forEach { addType(it) } | ||
return this | ||
} | ||
|
||
fun CodeBlock.Builder.add(code: Code): CodeBlock.Builder { | ||
return this.add(code.toCodeBlock().toKotlinPoetCodeBlock()) | ||
} | ||
} |
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
Oops, something went wrong.