Skip to content
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

Add DirectedCodegen to make codegen simpler #1167

Merged
merged 4 commits into from
Apr 7, 2022
Merged

Conversation

mtdowling
Copy link
Member

DirectedCodegen is an attempt to make using all the different pieces of
smithy-codegen-core easier. It wires integrations together with your
generator, automatically calls all the methods of integrations in the
appropriate order, executes the methods of the directed code generator,
and provides well-defined methods that help guide new code generation
projects. The goal is to point people in the right direction using
methods rather than just provide a blank slate and expect everything to
built from the ground up.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling force-pushed the directed-codegen-draft branch 10 times, most recently from c09aa2d to eed6306 Compare April 2, 2022 07:33
DirectedCodegen is an attempt to make using all the different pieces of
smithy-codegen-core easier. It wires integrations together with your
generator, automatically calls all the methods of integrations in the
appropriate order, executes the methods of the directed code generator,
and provides well-defined methods that help guide new code generation
projects. The goal is to point people in the right direction using
methods rather than just provide a blank slate and expect everything to
built from the ground up.
@mtdowling mtdowling force-pushed the directed-codegen-draft branch from eed6306 to d50a9d7 Compare April 2, 2022 07:36
@mtdowling mtdowling marked this pull request as ready for review April 4, 2022 04:39
@mtdowling mtdowling requested a review from a team as a code owner April 4, 2022 04:39
@mtdowling mtdowling force-pushed the directed-codegen-draft branch from a4291ed to c907513 Compare April 4, 2022 04:46
CodegenContext did not previously have a writerDelegator(), but this
will almost certainly be implemented in every SmithyIntegration and
has been so far in Smithy code generators that have similar abstractions.
By Adding a SymbolWriter generic to CodegenContext, we can also simplify
the generics needed to implement DirectedCodegen. This provides a big
simplification and helps standardize generators, but it does furhter
lock-in the design decisions made in SymbolWriter. To account for this
and the variance that can occur across languages to generate
documentation, the abstract writeDocs methods was removed from
SymbolWriter. The impact of this is likely just the removal of an
`@Override` annotation in implementations.
@mtdowling mtdowling force-pushed the directed-codegen-draft branch from c907513 to cf16839 Compare April 4, 2022 04:51
@mtdowling mtdowling requested a review from JordonPhillips April 6, 2022 20:43
@mtdowling mtdowling force-pushed the directed-codegen-draft branch from 70566e0 to 3d7e566 Compare April 6, 2022 21:37
We will be added proper enum shapes in Smithy IDL 2.0, and we want code
generators to explicitly pay attention to doing this codegen step.
Adding a new required directive method later would be a breaking change
unless se give it a default implementation, but a default implementation
won't force implementers to notice enums need codegen.

The solution in this commit is to support both string shape and enum
shape codegen from the same directive. Generators need to ask the
directive what kind of shape is being generated to know how to perform
enum codegen. Generators that perform this transformation in advance can
just assume they're only given enum shapes during code generation.

Add Directive suffix to directive classes

This helps to make their relationship and intent more clear, in
particular classes like "Customize" that seemed overly ambiguous.
@mtdowling mtdowling force-pushed the directed-codegen-draft branch from 2e0d704 to 8e8a410 Compare April 6, 2022 22:01
@mtdowling mtdowling merged commit ced203e into main Apr 7, 2022
@mtdowling mtdowling deleted the directed-codegen-draft branch April 8, 2022 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants