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

Migrate to Smithy's DirectedCodegen pattern #1675

Open
4 tasks
jdisanti opened this issue Aug 26, 2022 · 1 comment
Open
4 tasks

Migrate to Smithy's DirectedCodegen pattern #1675

jdisanti opened this issue Aug 26, 2022 · 1 comment
Labels
refactoring Changes that do not affect our users, mostly focused on maintainability tracking Meta-issues to track overall progress

Comments

@jdisanti
Copy link
Collaborator

Smithy now provides a DirectedCodegen interface that essentially replaces the need to write a CodegenVisitor, and standardizes the patterns that the newer Smithy code generators have established.

I spent some time investigating what it would take to refactor our code generator to use the DirectedCodegen approach, and discovered this list of smaller refactors we can do that will make the transition a lot easier:

  • Use NodeMapper.deserialize to parse -RustSettings instead of manual parsing:
S deserialized = new NodeMapper().deserialize(settingsNode, settingsType);

This method of parsing is required to use DirectedCodegen since the CodegenDirector does the parsing.

  • Replace OperationNormalizer with ModelTransformer.createDedicatedInputAndOutput
  • Refactor existing codegen to write its file entries into a Smithy FileManifest
  • Eliminate direct use of RustSymbolProvider; only the SymbolProvider interface may be used in codegen

Additionally, we would need to break the Client/Server inheritance model for the RustSettings and CodegenContext classes since the types for these need to be known at compile time. The best way to do this would probably be to keep them, but they go into their respective client/server modules, and then have a ClientDirectedCodegen and a ServerDirectedCodegen. Essentially, the server codegen would need to become its own Smithy plugin, and the shared code between client and server would need to go into a core module.

Once all of these refactors are done, it looks like it should be possible to migrate, but it will still be a considerable amount of work.

@jdisanti jdisanti added the tracking Meta-issues to track overall progress label Aug 26, 2022
@jdisanti
Copy link
Collaborator Author

Replacing the OperationNormalizer is blocked on smithy-lang/smithy#1373

@jdisanti jdisanti added the refactoring Changes that do not affect our users, mostly focused on maintainability label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Changes that do not affect our users, mostly focused on maintainability tracking Meta-issues to track overall progress
Projects
None yet
Development

No branches or pull requests

1 participant