Skip to content

Commit

Permalink
Missing top level module declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-aws committed Sep 18, 2024
1 parent f90b85b commit a45277d
Showing 1 changed file with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,24 @@ public void patchAfterTranspiling() {
}
}

private static final TokenTree EXTRA_SINGLE_CRATE_DECLARATIONS = TokenTree.of(
"""
mod standard_library_conversions;
mod standard_library_externs;
"""
);

private void patchRustAfterTranspiling() {
final MergedServicesGenerator generator = new MergedServicesGenerator(model, serviceShape, namespaces, localServiceTest);

final String extraDeclarations = generator.generatorForShape(serviceShape).topLevelModuleDeclarations().toString();
final TokenTree extraRootServiceDeclarations = generator.generatorForShape(serviceShape).topLevelModuleDeclarations();
String extraDeclarations = TokenTree.of(extraRootServiceDeclarations, EXTRA_SINGLE_CRATE_DECLARATIONS).lineSeparated().toString();
if (!awsSdkStyle) {
extraDeclarations = extraDeclarations
+ System.lineSeparator()
+ extraTopLevelDeclarationsForLocalService(serviceShape)
+ System.lineSeparator();
}
final Path implementationFromDafnyPath = libraryRoot
.resolve("runtimes")
.resolve("rust")
Expand All @@ -899,15 +913,7 @@ private void patchRustAfterTranspiling() {
}
}

private String extraDeclarationsForSDK() {
return """
mod client;
mod conversions;
mod standard_library_conversions;
""";
}

private String extraDeclarationsForLocalService() {
private String extraTopLevelDeclarationsForLocalService(ServiceShape serviceShape) {
final String configStructName = serviceShape
.expectTrait(LocalServiceTrait.class)
.getConfigId()
Expand All @@ -916,17 +922,8 @@ private String extraDeclarationsForLocalService() {

return IOUtils.evalTemplate(
"""
// (extra-declarations)
$sharedTopLevelDecls:L
/// Copied from StandardLibrary
mod standard_library_conversions;
mod standard_library_externs;
pub use client::Client;
pub use types::$configSnakeCase:L::$configStructName:L;
""",
Map.of(
"configSnakeCase",
Expand Down

0 comments on commit a45277d

Please sign in to comment.