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 interface for codegen integration and settings #1109

Merged
merged 5 commits into from
Mar 3, 2022

Conversation

mtdowling
Copy link
Member

Codegen integrations typically all follow a similar format -- they
provide hooks for modifying the code generator and are discovered using
SPI. This commit adds a base interface for codegen integrations and
settings objects. The integration object is as minimal as possible
whill still providing some utility and conformity across
implementations, and the settings object just provides a minimal
getService method. Each Java implementation of Smithy codegen has such
a method in their settings object, and so does the Kotlin based Rust
generator.

The integration interface is very simimlar to both TypeScript and Go
integrations, though not exactly the same as either. The TypeScript
generator passes the entire PluginContext to preprocessModel, but that
is never actually needed and makes it harder to mock (Go does not
require the full context, only the Model so it can take this change).

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 requested a review from a team as a code owner February 26, 2022 00:42
@mtdowling mtdowling force-pushed the add-base-codegen-integration branch 2 times, most recently from 75a6649 to a0794b7 Compare February 26, 2022 00:51
@JordonPhillips JordonPhillips self-requested a review February 28, 2022 18:16
@mtdowling mtdowling force-pushed the add-base-codegen-integration branch 3 times, most recently from bf43985 to 084bd5a Compare March 2, 2022 07:37
@mtdowling mtdowling force-pushed the add-base-codegen-integration branch from 084bd5a to 17e8212 Compare March 2, 2022 17:00
Codegen integrations typically all follow a similar format -- they
provide hooks for modifying the code generator and are discovered using
SPI. This commit adds a base interface for codegen integrations and
settings objects. The integration object is as minimal as possible
whill still providing some utility and conformity across
implementations, and the settings object just provides a minimal
`getService` method. Each Java implementation of Smithy codegen has such
a method in their settings object, and so does the Kotlin based Rust
generator.

The integration interface is very simimlar to both TypeScript and Go
integrations, though not exactly the same as either. The TypeScript
generator passes the entire PluginContext to preprocessModel, but that
is never actually needed and makes it harder to mock (Go does not
require the full context, only the Model so it can take this change).
SmithyIntegrations now support relative and priority based ordering, and
a default topological sort implementaiton is provided to sort
integrations.
@mtdowling mtdowling force-pushed the add-base-codegen-integration branch from 17e8212 to 4fecd79 Compare March 2, 2022 18:57
@mtdowling mtdowling merged commit b664e7f into main Mar 3, 2022
@mtdowling mtdowling deleted the add-base-codegen-integration 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