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 custom codegen hook before shape generation #1469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,26 @@ public void run() {

LOGGER.fine("All setup done. Beginning code generation");

LOGGER.finest(() -> "Performing custom codegen for "
+ directedCodegen.getClass().getName() + " before shape codegen");
CustomizeDirective<C, S> customizeDirective = new CustomizeDirective<>(context, serviceShape);
directedCodegen.customizeBeforeShapeGeneration(customizeDirective);

LOGGER.finest(() -> "Generating shapes for service " + serviceShape.getId());
generateShapesInService(context, serviceShape);

LOGGER.finest(() -> "Generating service " + serviceShape.getId());
directedCodegen.generateService(new GenerateServiceDirective<>(context, serviceShape));

CustomizeDirective<C, S> postProcess = new CustomizeDirective<>(context, serviceShape);

LOGGER.finest(() -> "Performing custom codegen for "
+ directedCodegen.getClass().getName() + " before integrations");
directedCodegen.customizeBeforeIntegrations(postProcess);
directedCodegen.customizeBeforeIntegrations(customizeDirective);

applyIntegrationCustomizations(context, integrations);

LOGGER.finest(() -> "Performing custom codegen for "
+ directedCodegen.getClass().getName() + " after integrations");
directedCodegen.customizeAfterIntegrations(postProcess);
directedCodegen.customizeAfterIntegrations(customizeDirective);

LOGGER.finest(() -> "Directed codegen finished for " + directedCodegen.getClass().getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ default void generateResource(GenerateResourceDirective<C, S> directive) {
*/
void generateIntEnumShape(GenerateIntEnumDirective<C, S> directive);

/**
* Performs any necessary code generation before all shapes are generated,
* using the created codegen context object.
*
* @param directive Directive to perform.
*/
default void customizeBeforeShapeGeneration(CustomizeDirective<C, S> directive) {
// Does nothing by default.
}

/**
* Performs any necessary code generation after all shapes are generated,
* using the created codegen context object before integrations perform
Expand Down