-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor step3codegen
package (mainly TypeGenerator
)
#72
Conversation
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/KotlinPoetPatterns.kt
Show resolved
Hide resolved
f936b32
to
8616eb8
Compare
8616eb8
to
e42b191
Compare
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step2intermediate/MoreTypes.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor stuff. Also, you need to get rebased.
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/KotlinPoetExtensions.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/types/TypeGenerator.kt
Show resolved
Hide resolved
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step2intermediate/MoreTypes.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/expressions/Expressions.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/KotlinPoetExtensions.kt
Outdated
Show resolved
Hide resolved
...in/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/types/setters/ListTypeGenerator.kt
Outdated
Show resolved
Hide resolved
e42b191
to
598affc
Compare
598affc
to
7435731
Compare
Yes, I just turned all |
0aae79d
to
e8c2697
Compare
e8c2697
to
896cde2
Compare
# Conflicts: # src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/resources/ResourceGenerator.kt
Task
Related to #24.
Description
Note
I could do much more here, but I've already proved to myself that these big-bang refactorings turn into never-ending rabbit holes (with lots of merge conflicts). We need to keep these PRs small and focused.
Main changes
1.
Refactor
TypeGenerator
:SetterGenerator
interface so that:pulumi-kotlin/src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/types/setters/BasicGenerator.kt
Lines 10 to 11 in f936b32
2.
Add comments to some methods that return
TypeName
orFunSpec
. Example:pulumi-kotlin/src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/KotlinPoetPatterns.kt
Lines 24 to 32 in f936b32
3.
Create
KotlinPoetExtensions.kt
files with extension methods that could increase readability (e.g.addImports
) and reduce noise in generators' code. Example:pulumi-kotlin/src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step3codegen/KotlinPoetExtensions.kt
Lines 11 to 16 in f936b32
4.
Add new methods and rename existing methods in
MoreTypes
. For example:pulumi-kotlin/src/main/kotlin/com/virtuslab/pulumikotlin/codegen/step2intermediate/MoreTypes.kt
Lines 12 to 22 in 8616eb8
We can use
something::class.asTypeName()
, but I'm not sure this will be possible in the future (#41), so I'd prefer having all these "hardcoded" cases inMoreTypes
for now.(Edit) Clarification from: #72 (comment)
I turned all
ClassName(package, name)
intoType::class.asClassName()
, but I'd still prefer to keep them all (MemberName
andClassName
factory methods, likeapplySuspendExtensionMethod
) in this class (MoreTypes
) to ease potential refactorings and have opportunity to give them good names.(
MoreTypes
should probably be named differently and placed instep3codegen
package.)Merging this PR
I created
main-2022-10-16-all-pr-merge
branch and cherry-picked existing PRs there to minimize the risk of conflicts, so this can be merged only after these are merged:UseCharacteristic
class and improve things aroundNamingFlags
#70Supress
inSchemaModel.PropertyType
withSerialName
(per value) #68