-
Notifications
You must be signed in to change notification settings - Fork 226
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
Conversation
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
75a6649
to
a0794b7
Compare
JordonPhillips
approved these changes
Feb 26, 2022
smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/SmithyIntegration.java
Outdated
Show resolved
Hide resolved
smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/SmithyIntegration.java
Outdated
Show resolved
Hide resolved
bf43985
to
084bd5a
Compare
JordonPhillips
approved these changes
Mar 2, 2022
...degen-core/src/main/java/software/amazon/smithy/codegen/core/IntegrationTopologicalSort.java
Outdated
Show resolved
Hide resolved
...n-core/src/test/java/software/amazon/smithy/codegen/core/IntegrationTopologicalSortTest.java
Outdated
Show resolved
Hide resolved
084bd5a
to
17e8212
Compare
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.
17e8212
to
4fecd79
Compare
kstich
approved these changes
Mar 2, 2022
...degen-core/src/main/java/software/amazon/smithy/codegen/core/IntegrationTopologicalSort.java
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 sucha 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.