From 0d637c4a6c488b93c9d799c75a17d7fedb95abcb Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 12:41:34 +0200 Subject: [PATCH 01/18] Move things into `codegen-core` --- sa, ca work --- .../smithy/rustsdk/AwsEndpointDecorator.kt | 64 ++++--- .../rustsdk/AwsFluentClientDecorator.kt | 19 +- .../smithy/rustsdk/AwsPresigningDecorator.kt | 47 ++--- .../smithy/rustsdk/AwsReadmeDecorator.kt | 4 +- .../smithy/rustsdk/AwsRuntimeDependency.kt | 2 +- .../smithy/rustsdk/CrateLicenseDecorator.kt | 2 +- .../smithy/rustsdk/CredentialProviders.kt | 58 +++--- .../rustsdk/HttpRequestChecksumDecorator.kt | 8 +- .../rustsdk/HttpResponseChecksumDecorator.kt | 4 +- .../smithy/rustsdk/InlineAwsDependency.kt | 2 +- .../rustsdk/IntegrationTestDependencies.kt | 42 ++--- .../amazon/smithy/rustsdk/RegionDecorator.kt | 48 ++--- .../rustsdk/RetryClassifierDecorator.kt | 4 +- .../smithy/rustsdk/SdkConfigDecorator.kt | 6 +- .../amazon/smithy/rustsdk/SdkSettings.kt | 2 +- .../smithy/rustsdk/ServiceConfigDecorator.kt | 6 +- .../smithy/rustsdk/SigV4SigningDecorator.kt | 32 ++-- .../smithy/rustsdk/UserAgentDecorator.kt | 10 +- .../apigateway/ApiGatewayDecorator.kt | 6 +- .../customize/auth/DisabledAuthDecorator.kt | 2 +- .../rustsdk/customize/ec2/Ec2Decorator.kt | 2 +- .../customize/glacier/AccountIdAutofill.kt | 4 +- .../customize/glacier/ApiVersionHeader.kt | 4 +- .../customize/glacier/GlacierDecorator.kt | 2 +- .../customize/glacier/TreeHashHeader.kt | 6 +- .../customize/route53/Route53Decorator.kt | 6 +- .../rustsdk/customize/s3/S3Decorator.kt | 35 ++-- .../rustsdk/customize/sts/STSDecorator.kt | 2 +- .../EndpointConfigCustomizationTest.kt | 4 +- .../rustsdk/RegionProviderConfigTest.kt | 2 +- .../amazon/smithy/rustsdk/TestUtil.kt | 2 +- codegen-client/build.gradle.kts | 2 - .../client/smithy/ClientCodegenContext.kt | 4 +- .../client/smithy/ClientRustSettings.kt | 4 + .../codegen/client/smithy/CodegenVisitor.kt | 44 +++-- .../smithy/EventStreamSymbolProvider.kt | 19 +- .../client/smithy/RustCodegenPlugin.kt | 9 +- .../client/smithy/ServerCodegenContext.kt | 4 +- .../client/smithy/ServerRustSettings.kt | 4 + .../smithy/StreamingTraitSymbolProvider.kt | 9 +- .../customizations/AllowLintsGenerator.kt | 8 +- .../customizations/ClientCustomizations.kt | 7 +- .../customizations/ClientDocsGenerator.kt | 21 +-- .../customizations/CrateVersionGenerator.kt | 27 +-- .../customizations/DocsRsMetadataDecorator.kt | 7 +- .../customizations/EndpointPrefixGenerator.kt | 14 +- .../HttpChecksumRequiredGenerator.kt | 20 +-- .../HttpVersionListCustomization.kt | 16 +- .../IdempotencyTokenGenerator.kt | 12 +- .../ResiliencyConfigCustomization.kt | 78 ++++---- .../SmithyTypesPubUseGenerator.kt | 44 ++--- .../NoOpEventStreamSigningDecorator.kt | 14 +- .../customize/RequiredCustomizations.kt | 12 +- .../smithy/customize/RustCodegenDecorator.kt | 45 ++--- .../EndpointTraitBindingGenerator.kt | 21 +-- .../generators/NestedAccessorGenerator.kt | 63 ++++--- .../smithy/generators/PaginatorGenerator.kt | 55 +++--- .../smithy/generators/ServiceGenerator.kt | 16 +- .../generators/client/FluentClientCore.kt | 18 +- .../client/FluentClientDecorator.kt | 31 ++-- .../client/FluentClientGenerator.kt | 70 ++++---- .../generators/client/FluentClientGenerics.kt | 14 +- .../config/EventStreamSigningConfig.kt | 12 +- .../IdempotencyTokenProviderCustomization.kt | 10 +- .../config/ServiceConfigGenerator.kt | 16 +- .../protocol/ClientProtocolGenerator.kt | 93 ++++++++++ .../generators/protocol/ProtocolGenerator.kt | 170 ------------------ .../protocol/ProtocolTestGenerator.kt | 46 ++--- .../client/smithy/protocols/AwsJson.kt | 36 ++-- .../client/smithy/protocols/AwsQuery.kt | 28 +-- .../smithy/protocols/ClientProtocolLoader.kt | 33 ++++ .../client/smithy/protocols/Ec2Query.kt | 28 +-- .../protocols/HttpBoundProtocolGenerator.kt | 60 ++++--- .../client/smithy/protocols/RestJson.kt | 27 +-- .../client/smithy/protocols/RestXml.kt | 41 ++--- .../rust/codegen/client/testutil/Rust.kt | 24 +-- .../testutil/TestConfigCustomization.kt | 8 +- .../codegen/client/testutil/TestHelpers.kt | 34 ++-- .../rust/codegen/client/SymbolBuilderTest.kt | 4 +- .../ResiliencyConfigCustomizationTest.kt | 4 +- .../client/generators/EnumGeneratorTest.kt | 4 +- .../generators/GenericsGeneratorTest.kt | 4 +- .../generators/StructureGeneratorTest.kt | 10 +- .../client/generators/UnionGeneratorTest.kt | 2 +- .../http/RequestBindingGeneratorTest.kt | 8 +- .../http/ResponseBindingGeneratorTest.kt | 6 +- .../codegen/client/rustlang/RustTypesTest.kt | 2 + .../codegen/client/rustlang/RustWriterTest.kt | 2 + .../codegen/client/rustlang/WritableTest.kt | 5 +- .../smithy/EventStreamSymbolProviderTest.kt | 6 +- .../StreamingShapeSymbolProviderTest.kt | 2 +- .../smithy/generators/BuilderGeneratorTest.kt | 2 + .../generators/CombinedErrorGeneratorTest.kt | 4 +- .../generators/EndpointTraitBindingsTest.kt | 4 +- .../smithy/generators/InstantiatorTest.kt | 5 +- .../protocol/ProtocolTestGeneratorTest.kt | 15 +- .../parse/AwsQueryParserGeneratorTest.kt | 4 +- .../parse/Ec2QueryParserGeneratorTest.kt | 4 +- .../parse/JsonParserGeneratorTest.kt | 8 +- .../XmlBindingTraitParserGeneratorTest.kt | 8 +- .../AwsQuerySerializerGeneratorTest.kt | 10 +- .../Ec2QuerySerializerGeneratorTest.kt | 8 +- .../serialize/JsonSerializerGeneratorTest.kt | 8 +- .../XmlBindingTraitSerializerGeneratorTest.kt | 8 +- .../transformers/EventStreamNormalizerTest.kt | 1 + .../transformers/OperationNormalizerTest.kt | 1 + .../transformers/RecursiveShapeBoxerTest.kt | 4 +- .../RecursiveShapesIntegrationTest.kt | 5 +- .../RemoveEventStreamOperationsTest.kt | 1 + .../client/testutil/AddRustTestsDecorator.kt | 2 +- codegen-core/build.gradle.kts | 4 +- .../codegen/core}/rustlang/CargoDependency.kt | 8 +- .../rust/codegen/core}/rustlang/RustModule.kt | 2 +- .../core}/rustlang/RustReservedWords.kt | 12 +- .../rust/codegen/core}/rustlang/RustTypes.kt | 4 +- .../rust/codegen/core}/rustlang/RustWriter.kt | 8 +- .../codegen/core}/rustlang/UseDeclarations.kt | 2 +- .../rust/codegen/core}/rustlang/Writable.kt | 6 +- .../codegen/core}/smithy/CodegenDelegator.kt | 24 +-- .../codegen/core/smithy}/CodegenTarget.kt | 2 +- .../core}/smithy/CoreCodegenContext.kt | 3 +- .../codegen/core}/smithy/CoreRustSettings.kt | 2 +- .../rust/codegen/core}/smithy/RuntimeTypes.kt | 35 ++-- .../core}/smithy/SymbolMetadataProvider.kt | 8 +- .../codegen/core}/smithy/SymbolVisitor.kt | 7 +- .../smithy/customize/NamedSectionGenerator.kt | 8 +- .../customize/OperationCustomization.kt | 6 +- .../smithy/generators/BuilderGenerator.kt | 48 ++--- .../smithy/generators/CargoTomlGenerator.kt | 12 +- .../core}/smithy/generators/EnumGenerator.kt | 27 +-- .../smithy/generators/GenericsGenerator.kt | 33 ++-- .../core}/smithy/generators/Instantiator.kt | 35 ++-- .../core}/smithy/generators/LibRsGenerator.kt | 20 +-- .../smithy/generators/StructureGenerator.kt | 41 ++--- .../generators/TypeConversionGenerator.kt | 16 +- .../core}/smithy/generators/UnionGenerator.kt | 21 +-- .../error/CombinedErrorGenerator.kt | 38 ++-- .../smithy/generators/error/ErrorGenerator.kt | 26 +-- .../error/ServerCombinedErrorGenerator.kt | 24 +-- .../error/TopLevelErrorGenerator.kt | 41 +++-- .../generators/http/HttpBindingGenerator.kt | 54 +++--- .../http/RequestBindingGenerator.kt | 30 ++-- .../http/ResponseBindingGenerator.kt | 12 +- .../http/RestRequestSpecGenerator.kt | 18 +- .../protocol/MakeOperationGenerator.kt | 40 ++--- .../generators/protocol/ProtocolGenerator.kt | 88 +++++++++ .../generators/protocol/ProtocolSupport.kt | 14 ++ .../smithy/protocols/ClientProtocolLoader.kt | 29 +++ .../smithy/protocols/HttpBindingResolver.kt | 2 +- .../HttpBoundProtocolPayloadGenerator.kt | 40 ++--- .../smithy/protocols/InlineFunctionNamer.kt | 4 +- .../core}/smithy/protocols/Protocol.kt | 54 +----- .../core}/smithy/protocols/XmlNameIndex.kt | 2 +- .../parse/AwsQueryParserGenerator.kt | 8 +- .../parse/Ec2QueryParserGenerator.kt | 8 +- .../parse/EventStreamUnmarshallerGenerator.kt | 38 ++-- .../protocols/parse/JsonParserGenerator.kt | 60 +++---- .../protocols/parse/RestXmlParserGenerator.kt | 10 +- .../parse/StructuredDataParserGenerator.kt | 4 +- .../parse/XmlBindingTraitParserGenerator.kt | 60 +++---- .../serialize/AwsQuerySerializerGenerator.kt | 6 +- .../serialize/Ec2QuerySerializerGenerator.kt | 6 +- .../EventStreamErrorMarshallerGenerator.kt | 36 ++-- .../EventStreamMarshallerGenerator.kt | 38 ++-- .../serialize/JsonSerializerGenerator.kt | 50 +++--- .../serialize/QuerySerializerGenerator.kt | 52 +++--- .../protocols/serialize/SerializerUtil.kt | 6 +- .../StructuredDataSerializerGenerator.kt | 4 +- .../protocols/serialize/ValueExpression.kt | 2 +- .../XmlBindingTraitSerializerGenerator.kt | 56 +++--- .../core/smithy/traits/AllowInvalidXmlRoot.kt | 19 ++ .../core/smithy/traits}/RustBoxTrait.kt | 2 +- .../smithy/transformers/AddErrorMessage.kt | 4 +- .../transformers/EventStreamNormalizer.kt | 2 +- .../transformers/OperationNormalizer.kt | 6 +- .../transformers/RecursiveShapeBoxer.kt | 4 +- .../RemoveEventStreamOperations.kt | 4 +- .../rust/codegen/core}/util/Synthetics.kt | 3 +- .../smithy/PythonCodegenServerPlugin.kt | 2 +- .../smithy/PythonServerCodegenVisitor.kt | 6 +- .../smithy/PythonServerSymbolProvider.kt | 2 +- .../PythonServerCodegenDecorator.kt | 8 +- .../generators/PythonApplicationGenerator.kt | 4 +- .../PythonServerCombinedErrorGenerator.kt | 6 +- .../generators/PythonServerEnumGenerator.kt | 2 +- .../PythonServerOperationHandlerGenerator.kt | 2 +- .../PythonServerServiceGenerator.kt | 6 +- .../PythonServerStructureGenerator.kt | 6 +- .../PythonServerSymbolProviderTest.kt | 2 +- .../server/smithy/RustCodegenServerPlugin.kt | 13 +- .../server/smithy/ServerCargoDependency.kt | 10 +- .../server/smithy/ServerCodegenVisitor.kt | 38 ++-- .../server/smithy/ServerRuntimeType.kt | 6 +- .../AdditionalErrorsDecorator.kt | 9 +- .../ServerRequiredCustomizations.kt | 11 +- .../smithy/generators/ServerEnumGenerator.kt | 18 +- .../ServerHttpSensitivityGenerator.kt | 18 +- .../generators/ServerOperationGenerator.kt | 16 +- .../ServerOperationHandlerGenerator.kt | 20 +-- .../ServerOperationRegistryGenerator.kt | 42 ++--- .../generators/ServerServiceGenerator.kt | 22 +-- .../generators/ServerServiceGeneratorV2.kt | 22 +-- .../http/ServerRequestBindingGenerator.kt | 14 +- .../http/ServerResponseBindingGenerator.kt | 10 +- .../generators/protocol/ServerProtocol.kt | 22 +-- .../protocol/ServerProtocolGenerator.kt | 33 ++++ .../protocol/ServerProtocolTestGenerator.kt | 44 ++--- .../server/smithy/protocols/ServerAwsJson.kt | 24 +-- .../ServerHttpBoundProtocolGenerator.kt | 87 ++++----- .../smithy/protocols/ServerProtocolLoader.kt | 9 +- .../smithy/protocols/ServerRestJsonFactory.kt | 6 +- .../smithy/protocols/ServerRestXmlFactory.kt | 6 +- .../smithy/testutil/ServerTestHelpers.kt | 6 +- .../AdditionalErrorsDecoratorTest.kt | 2 +- .../ServerCombinedErrorGeneratorTest.kt | 6 +- .../smithy/protocols/EventStreamTestTools.kt | 23 ++- .../EventStreamUnmarshallerGeneratorTest.kt | 4 +- .../EventStreamMarshallerGeneratorTest.kt | 2 +- 218 files changed, 2106 insertions(+), 1857 deletions(-) create mode 100644 codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt delete mode 100644 codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolGenerator.kt create mode 100644 codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/ClientProtocolLoader.kt rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/CargoDependency.kt (96%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/RustModule.kt (95%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/RustReservedWords.kt (93%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/RustTypes.kt (99%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/RustWriter.kt (98%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/UseDeclarations.kt (95%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/rustlang/Writable.kt (94%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/CodegenDelegator.kt (89%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy}/CodegenTarget.kt (80%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/CoreCodegenContext.kt (95%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/CoreRustSettings.kt (99%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/RuntimeTypes.kt (92%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/SymbolMetadataProvider.kt (95%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/SymbolVisitor.kt (98%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/customize/NamedSectionGenerator.kt (83%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/customize/OperationCustomization.kt (91%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/BuilderGenerator.kt (86%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/CargoTomlGenerator.kt (85%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/EnumGenerator.kt (89%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/GenericsGenerator.kt (81%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/Instantiator.kt (91%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/LibRsGenerator.kt (78%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/StructureGenerator.kt (84%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/TypeConversionGenerator.kt (76%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/UnionGenerator.kt (87%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/error/CombinedErrorGenerator.kt (89%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/error/ErrorGenerator.kt (83%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/error/ServerCombinedErrorGenerator.kt (85%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/error/TopLevelErrorGenerator.kt (77%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/http/HttpBindingGenerator.kt (92%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/http/RequestBindingGenerator.kt (91%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/http/ResponseBindingGenerator.kt (69%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/http/RestRequestSpecGenerator.kt (83%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/generators/protocol/MakeOperationGenerator.kt (84%) create mode 100644 codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt create mode 100644 codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt create mode 100644 codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/HttpBindingResolver.kt (99%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt (90%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/InlineFunctionNamer.kt (94%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/Protocol.kt (50%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/XmlNameIndex.kt (97%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/AwsQueryParserGenerator.kt (88%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/Ec2QueryParserGenerator.kt (84%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt (92%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/JsonParserGenerator.kt (91%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/RestXmlParserGenerator.kt (84%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/StructuredDataParserGenerator.kt (92%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt (93%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt (83%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt (85%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt (84%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt (87%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/JsonSerializerGenerator.kt (91%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/QuerySerializerGenerator.kt (88%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/SerializerUtil.kt (87%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt (94%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/ValueExpression.kt (87%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt (91%) create mode 100644 codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/AllowInvalidXmlRoot.kt rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits}/RustBoxTrait.kt (92%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/transformers/AddErrorMessage.kt (87%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/transformers/EventStreamNormalizer.kt (98%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/transformers/OperationNormalizer.kt (95%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/transformers/RecursiveShapeBoxer.kt (96%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/smithy/transformers/RemoveEventStreamOperations.kt (94%) rename {codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client => codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core}/util/Synthetics.kt (94%) create mode 100644 codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt index 7fd4d56a83..fa101057c9 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt @@ -14,26 +14,26 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.rustlang.withBlock import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.orNull @@ -108,18 +108,24 @@ class EndpointConfigCustomization( "aws_types" to awsTypes(runtimeConfig).asType(), ) - override fun section(section: ServiceConfig): Writable = writable { - when (section) { - is ServiceConfig.ConfigStruct -> rustTemplate( - "pub (crate) endpoint_resolver: std::sync::Arc>,", - *codegenScope, - ) - is ServiceConfig.ConfigImpl -> emptySection - is ServiceConfig.BuilderStruct -> - rustTemplate("endpoint_resolver: Option>>,", *codegenScope) - ServiceConfig.BuilderImpl -> - rustTemplate( - """ + override fun section(section: ServiceConfig): Writable = + writable { + when (section) { + is ServiceConfig.ConfigStruct -> rustTemplate( + "pub (crate) endpoint_resolver: std::sync::Arc>,", + *codegenScope, + ) + + is ServiceConfig.ConfigImpl -> emptySection + is ServiceConfig.BuilderStruct -> + rustTemplate( + "endpoint_resolver: Option>>,", + *codegenScope + ) + + ServiceConfig.BuilderImpl -> + rustTemplate( + """ /// Overrides the endpoint resolver to use when making requests. /// /// When unset, the client will used a generated endpoint resolver based on the endpoint metadata @@ -147,22 +153,24 @@ class EndpointConfigCustomization( self } """, - *codegenScope, - ) - ServiceConfig.BuilderBuild -> { - val resolverGenerator = EndpointResolverGenerator(coreCodegenContext, endpointData) - rustTemplate( - """ + *codegenScope, + ) + + ServiceConfig.BuilderBuild -> { + val resolverGenerator = EndpointResolverGenerator(coreCodegenContext, endpointData) + rustTemplate( + """ endpoint_resolver: self.endpoint_resolver.unwrap_or_else(|| std::sync::Arc::new(#{EndpointShim}::from_resolver(#{Resolver}())) ), """, - *codegenScope, "Resolver" to resolverGenerator.resolver(), - ) + *codegenScope, "Resolver" to resolverGenerator.resolver(), + ) + } + + else -> emptySection } - else -> emptySection } - } } // This is an experiment in a slightly different way to create runtime types. All code MAY be refactored to use this pattern diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index 8fca907308..309a53d62e 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -8,27 +8,27 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.TitleTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.client.rustlang.Feature import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericsGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerics @@ -74,7 +74,8 @@ private class AwsClientGenerics(private val types: Types) : FluentClientGenerics override val bounds = writable { } /** Bounds for generated `send()` functions */ - override fun sendBounds(operation: Symbol, operationOutput: Symbol, operationError: RuntimeType, retryClassifier: RuntimeType): Writable = writable { } + override fun sendBounds(operation: Symbol, operationOutput: Symbol, operationError: RuntimeType, retryClassifier: RuntimeType): Writable = + writable { } override fun toGenericsGenerator(): GenericsGenerator { return GenericsGenerator() diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt index e077de8bd6..4f16d9b7de 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt @@ -18,7 +18,7 @@ import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.docs import software.amazon.smithy.rust.codegen.client.rustlang.rust @@ -26,24 +26,23 @@ import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.MakeOperationGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolPayloadGenerator import software.amazon.smithy.rust.codegen.client.util.cloneOperation import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware import software.amazon.smithy.rustsdk.traits.PresignableTrait -import kotlin.streams.toList internal enum class PayloadSigningType { EMPTY, @@ -151,11 +150,12 @@ class AwsInputPresignedMethod( "Middleware" to runtimeConfig.defaultMiddleware(), ) - override fun section(section: OperationSection): Writable = writable { - if (section is OperationSection.InputImpl && section.operationShape.hasTrait()) { - writeInputPresignedMethod(section) + override fun section(section: OperationSection): Writable = + writable { + if (section is OperationSection.InputImpl && section.operationShape.hasTrait()) { + writeInputPresignedMethod(section) + } } - } private fun RustWriter.writeInputPresignedMethod(section: OperationSection.InputImpl) { val operationError = operationShape.errorSymbol(coreCodegenContext.model, symbolProvider, coreCodegenContext.target) @@ -254,29 +254,30 @@ class AwsPresignedFluentBuilderMethod( "SdkError" to CargoDependency.SmithyHttp(runtimeConfig).asType().member("result::SdkError"), ) - override fun section(section: FluentClientSection): Writable = writable { - if (section is FluentClientSection.FluentBuilderImpl && section.operationShape.hasTrait(PresignableTrait::class.java)) { - documentPresignedMethod(hasConfigArg = false) - rustBlockTemplate( - """ + override fun section(section: FluentClientSection): Writable = + writable { + if (section is FluentClientSection.FluentBuilderImpl && section.operationShape.hasTrait(PresignableTrait::class.java)) { + documentPresignedMethod(hasConfigArg = false) + rustBlockTemplate( + """ pub async fn presigned( self, presigning_config: #{PresigningConfig}, ) -> Result<#{PresignedRequest}, #{SdkError}<#{OpError}>> """, - *codegenScope, - "OpError" to section.operationErrorType, - ) { - rustTemplate( - """ + *codegenScope, + "OpError" to section.operationErrorType, + ) { + rustTemplate( + """ let input = self.inner.build().map_err(|err| #{SdkError}::ConstructionFailure(err.into()))?; input.presigned(&self.handle.conf, presigning_config).await """, - *codegenScope, - ) + *codegenScope, + ) + } } } - } } interface PresignModelTransform { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt index fe1f1db4e5..7d14681b31 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt @@ -11,10 +11,10 @@ import org.jsoup.nodes.TextNode import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.rust.codegen.client.rustlang.raw import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.ManifestCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations import software.amazon.smithy.rust.codegen.core.util.getTrait import java.util.logging.Logger diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt index a3f9e7170b..0cefde5eda 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeCrateLocation import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt index de6f1f8dde..65076ba540 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.rust.codegen.client.rustlang.raw import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt index 4880a30fe2..ee523e7a8d 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt @@ -6,20 +6,20 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig @@ -63,18 +63,24 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati "DefaultProvider" to defaultProvider, ) - override fun section(section: ServiceConfig) = writable { - when (section) { - is ServiceConfig.ConfigStruct -> rustTemplate( - """pub(crate) credentials_provider: #{credentials}::SharedCredentialsProvider,""", - *codegenScope, - ) - is ServiceConfig.ConfigImpl -> emptySection - is ServiceConfig.BuilderStruct -> - rustTemplate("credentials_provider: Option<#{credentials}::SharedCredentialsProvider>,", *codegenScope) - ServiceConfig.BuilderImpl -> { - rustTemplate( - """ + override fun section(section: ServiceConfig) = + writable { + when (section) { + is ServiceConfig.ConfigStruct -> rustTemplate( + """pub(crate) credentials_provider: #{credentials}::SharedCredentialsProvider,""", + *codegenScope, + ) + + is ServiceConfig.ConfigImpl -> emptySection + is ServiceConfig.BuilderStruct -> + rustTemplate( + "credentials_provider: Option<#{credentials}::SharedCredentialsProvider>,", + *codegenScope + ) + + ServiceConfig.BuilderImpl -> { + rustTemplate( + """ /// Sets the credentials provider for this service pub fn credentials_provider(mut self, credentials_provider: impl #{credentials}::ProvideCredentials + 'static) -> Self { self.credentials_provider = Some(#{credentials}::SharedCredentialsProvider::new(credentials_provider)); @@ -87,15 +93,16 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati self } """, + *codegenScope, + ) + } + + ServiceConfig.BuilderBuild -> rustTemplate( + "credentials_provider: self.credentials_provider.unwrap_or_else(|| #{credentials}::SharedCredentialsProvider::new(#{DefaultProvider})),", *codegenScope, ) } - ServiceConfig.BuilderBuild -> rustTemplate( - "credentials_provider: self.credentials_provider.unwrap_or_else(|| #{credentials}::SharedCredentialsProvider::new(#{DefaultProvider})),", - *codegenScope, - ) } - } } class CredentialsProviderFeature(private val runtimeConfig: RuntimeConfig) : OperationCustomization() { @@ -117,7 +124,12 @@ class CredentialsProviderFeature(private val runtimeConfig: RuntimeConfig) : Ope class PubUseCredentials(private val runtimeConfig: RuntimeConfig) : LibRsCustomization() { override fun section(section: LibRsSection): Writable { return when (section) { - is LibRsSection.Body -> writable { rust("pub use #T::Credentials;", awsTypes(runtimeConfig).asType()) } + is LibRsSection.Body -> writable { + rust( + "pub use #T::Credentials;", + awsTypes(runtimeConfig).asType() + ) + } else -> emptySection } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt index ba21e3bec3..9debb12d98 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt @@ -8,19 +8,19 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.aws.traits.HttpChecksumTrait import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.util.expectMember import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.inputShape diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt index ecc83f0429..f368452cfc 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt @@ -8,10 +8,10 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.aws.traits.HttpChecksumTrait import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt index 30b3e33831..0f54c39fe2 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.rust.codegen.client.rustlang.InlineDependency import software.amazon.smithy.rust.codegen.client.rustlang.RustDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility object InlineAwsDependency { fun forRustFile(file: String, visibility: Visibility = Visibility.PRIVATE, vararg additionalDependency: RustDependency): InlineDependency = diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt index 4b0c479c21..6e60033b40 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt @@ -10,14 +10,14 @@ import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency.Compa import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency.Companion.TempFile import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import java.nio.file.Files import java.nio.file.Paths @@ -92,26 +92,28 @@ class IntegrationTestDependencies( } class TranscribeTestDependencies : LibRsCustomization() { - override fun section(section: LibRsSection): Writable = writable { - addDependency(AsyncStream) - addDependency(FuturesCore) - addDependency(Hound) - } + override fun section(section: LibRsSection): Writable = + writable { + addDependency(AsyncStream) + addDependency(FuturesCore) + addDependency(Hound) + } } class S3TestDependencies( private val runtimeConfig: RuntimeConfig, ) : LibRsCustomization() { - override fun section(section: LibRsSection): Writable = writable { - addDependency(AsyncStd) - addDependency(BytesUtils) - addDependency(Smol) - addDependency(TempFile) - runtimeConfig.runtimeCrate("async", scope = DependencyScope.Dev) - runtimeConfig.runtimeCrate("client", scope = DependencyScope.Dev) - runtimeConfig.runtimeCrate("http", scope = DependencyScope.Dev) - runtimeConfig.runtimeCrate("types", scope = DependencyScope.Dev) - } + override fun section(section: LibRsSection): Writable = + writable { + addDependency(AsyncStd) + addDependency(BytesUtils) + addDependency(Smol) + addDependency(TempFile) + runtimeConfig.runtimeCrate("async", scope = DependencyScope.Dev) + runtimeConfig.runtimeCrate("client", scope = DependencyScope.Dev) + runtimeConfig.runtimeCrate("http", scope = DependencyScope.Dev) + runtimeConfig.runtimeCrate("types", scope = DependencyScope.Dev) + } } private val AsyncStd = CargoDependency("async-std", CratesIo("1.12.0"), scope = DependencyScope.Dev) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index 8c4fa3d33b..a30f718f81 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -6,19 +6,19 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig @@ -104,15 +104,17 @@ class RegionProviderConfig(coreCodegenContext: CoreCodegenContext) : ConfigCusto private val region = region(coreCodegenContext.runtimeConfig) private val moduleUseName = coreCodegenContext.moduleUseName() private val codegenScope = arrayOf("Region" to region.member("Region")) - override fun section(section: ServiceConfig) = writable { - when (section) { - is ServiceConfig.ConfigStruct -> rustTemplate("pub(crate) region: Option<#{Region}>,", *codegenScope) - is ServiceConfig.ConfigImpl -> emptySection - is ServiceConfig.BuilderStruct -> - rustTemplate("region: Option<#{Region}>,", *codegenScope) - ServiceConfig.BuilderImpl -> - rustTemplate( - """ + override fun section(section: ServiceConfig) = + writable { + when (section) { + is ServiceConfig.ConfigStruct -> rustTemplate("pub(crate) region: Option<#{Region}>,", *codegenScope) + is ServiceConfig.ConfigImpl -> emptySection + is ServiceConfig.BuilderStruct -> + rustTemplate("region: Option<#{Region}>,", *codegenScope) + + ServiceConfig.BuilderImpl -> + rustTemplate( + """ /// Sets the AWS region to use when making requests. /// /// ## Examples @@ -129,14 +131,15 @@ class RegionProviderConfig(coreCodegenContext: CoreCodegenContext) : ConfigCusto self } """, + *codegenScope, + ) + + ServiceConfig.BuilderBuild -> rustTemplate( + """region: self.region,""", *codegenScope, ) - ServiceConfig.BuilderBuild -> rustTemplate( - """region: self.region,""", - *codegenScope, - ) + } } - } } class RegionConfigPlugin : OperationCustomization() { @@ -160,7 +163,12 @@ class RegionConfigPlugin : OperationCustomization() { class PubUseRegion(private val runtimeConfig: RuntimeConfig) : LibRsCustomization() { override fun section(section: LibRsSection): Writable { return when (section) { - is LibRsSection.Body -> writable { rust("pub use #T::Region;", region(runtimeConfig)) } + is LibRsSection.Body -> writable { + rust( + "pub use #T::Region;", + region(runtimeConfig) + ) + } else -> emptySection } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt index 30d3126f40..74d834e213 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt @@ -8,9 +8,9 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt index ee4f37f03d..927ea06b37 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt index bf62ecb863..bdae9bf35e 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt @@ -5,7 +5,7 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.node.ObjectNode -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.core.util.orNull import java.nio.file.Path import java.nio.file.Paths diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt index 5077a8e4bb..b469aac40a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt @@ -5,11 +5,11 @@ package software.amazon.smithy.rustsdk -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt index 9f61d1f068..b750c21cf4 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt @@ -13,13 +13,13 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.OptionalAuthTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization @@ -111,16 +111,16 @@ class SigV4SigningConfig( rustTemplate( "#{signerFn:W}", "signerFn" to - renderEventStreamSignerFn { propertiesName -> - writable { - rustTemplate( - """ + renderEventStreamSignerFn { propertiesName -> + writable { + rustTemplate( + """ #{SigV4Signer}::new($propertiesName) """, - *codegenScope, - ) - } - }, + *codegenScope, + ) + } + }, ) } } @@ -179,10 +179,16 @@ class SigV4SigningFeature( // some operations are either unsigned or optionally signed: val authSchemes = serviceIndex.getEffectiveAuthSchemes(service, operation) if (!authSchemes.containsKey(SigV4Trait.ID)) { - rustTemplate("signing_config.signing_requirements = #{sig_auth}::signer::SigningRequirements::Disabled;", *codegenScope) + rustTemplate( + "signing_config.signing_requirements = #{sig_auth}::signer::SigningRequirements::Disabled;", + *codegenScope + ) } else { if (operation.hasTrait()) { - rustTemplate("signing_config.signing_requirements = #{sig_auth}::signer::SigningRequirements::Optional;", *codegenScope) + rustTemplate( + "signing_config.signing_requirements = #{sig_auth}::signer::SigningRequirements::Optional;", + *codegenScope + ) } } rustTemplate( diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt index c3a1d5feed..9f6424c0e3 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt @@ -7,20 +7,20 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.aws.traits.ServiceTrait import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.core.util.dq diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt index 449b74b4a0..48d2f962be 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt @@ -7,11 +7,11 @@ package software.amazon.smithy.rustsdk.customize.apigateway import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt index ced0423b20..74319d312c 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt @@ -12,7 +12,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.AuthTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator private fun String.shapeId() = ShapeId.from(this) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt index c9400a4190..4486eca037 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt @@ -9,7 +9,7 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.core.util.letIf diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt index af0460cadd..a6f0b5dc21 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt @@ -7,9 +7,9 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.inputShape diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt index 9d29cd826c..a214ba65bc 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt @@ -5,9 +5,9 @@ package software.amazon.smithy.rustsdk.customize.glacier -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt index 27ba93680c..278c5da4d6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt index 54a9100550..00c003450d 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt @@ -8,14 +8,14 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.client.testutil.TokioWithTestMacros import software.amazon.smithy.rustsdk.InlineAwsDependency diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt index 4db45856d6..a2ae1e0d38 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt @@ -12,11 +12,11 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.HttpLabelTrait import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt index d64672d96d..d675b87233 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt @@ -15,22 +15,32 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.protocols.AllowInvalidXmlRoot -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolMap import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXmlFactory +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap +import software.amazon.smithy.rust.codegen.core.smithy.traits.AllowInvalidXmlRoot import software.amazon.smithy.rust.codegen.core.util.letIf import software.amazon.smithy.rustsdk.AwsRuntimeType import java.util.logging.Logger @@ -38,7 +48,7 @@ import java.util.logging.Logger /** * Top level decorator for S3 */ -class S3Decorator : RustCodegenDecorator { +class S3Decorator : RustCodegenDecorator { override val name: String = "S3" override val order: Byte = 0 private val logger: Logger = Logger.getLogger(javaClass.name) @@ -52,8 +62,8 @@ class S3Decorator : RustCodegenDecorator { override fun protocols( serviceId: ShapeId, - currentProtocols: ProtocolMap, - ): ProtocolMap = + currentProtocols: ProtocolMap, + ): ProtocolMap = currentProtocols.letIf(applies(serviceId)) { it + mapOf( RestXmlTrait.ID to RestXmlFactory { protocolConfig -> @@ -128,7 +138,12 @@ class S3(coreCodegenContext: CoreCodegenContext) : RestXml(coreCodegenContext) { class S3PubUse : LibRsCustomization() { override fun section(section: LibRsSection): Writable = when (section) { - is LibRsSection.Body -> writable { rust("pub use #T::ErrorExt;", AwsRuntimeType.S3Errors) } + is LibRsSection.Body -> writable { + rust( + "pub use #T::ErrorExt;", + AwsRuntimeType.S3Errors + ) + } else -> emptySection } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt index d3ef7f8f70..1d930249c3 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.RetryableTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.letIf diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt index 3489bc7c94..92f7009b00 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt @@ -12,13 +12,13 @@ import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customizations.AllowLintsGenerator import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt index 86a35f1a35..149d49c7af 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt @@ -6,7 +6,7 @@ package software.amazon.smithy.rustsdk import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.rustSettings import software.amazon.smithy.rust.codegen.client.testutil.validateConfigCustomizations diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt index c80a0cff3b..bbb5e324b3 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt @@ -6,7 +6,7 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.Model -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.client.smithy.RuntimeCrateLocation import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/build.gradle.kts b/codegen-client/build.gradle.kts index 10aedcab23..a836fd9100 100644 --- a/codegen-client/build.gradle.kts +++ b/codegen-client/build.gradle.kts @@ -25,9 +25,7 @@ val kotestVersion: String by project dependencies { implementation(project(":codegen-core")) implementation(kotlin("stdlib-jdk8")) - implementation("org.jsoup:jsoup:1.14.3") api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") - api("com.moandjiezana.toml:toml4j:0.7.2") implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-waiters:$smithyVersion") diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt index 1464a2e600..c4936155ab 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt @@ -8,7 +8,9 @@ package software.amazon.smithy.rust.codegen.client.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider /** * [ClientCodegenContext] contains code-generation context that is _specific_ to the [RustCodegenPlugin] plugin diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt index 0ae9d6b304..65da89276c 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt @@ -8,6 +8,10 @@ package software.amazon.smithy.rust.codegen.client.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.rust.codegen.core.smithy.CODEGEN_SETTINGS +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenConfig +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import java.util.Optional /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt index 87f1974fee..ca8bb5f5b2 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt @@ -18,21 +18,25 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.implBlock -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolLoader -import software.amazon.smithy.rust.codegen.client.smithy.transformers.AddErrorMessage -import software.amazon.smithy.rust.codegen.client.smithy.transformers.EventStreamNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RemoveEventStreamOperations +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.client.smithy.protocols.ClientProtocolLoader +import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait +import software.amazon.smithy.rust.codegen.core.smithy.transformers.AddErrorMessage +import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RemoveEventStreamOperations import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait @@ -43,8 +47,10 @@ import java.util.logging.Logger /** * Base Entrypoint for Code generation */ -class CodegenVisitor(context: PluginContext, private val codegenDecorator: RustCodegenDecorator) : - ShapeVisitor.Default() { +class CodegenVisitor( + context: PluginContext, + private val codegenDecorator: RustCodegenDecorator, +) : ShapeVisitor.Default() { private val logger = Logger.getLogger(javaClass.name) private val settings = ClientRustSettings.from(context.model, context.settings) @@ -54,8 +60,8 @@ class CodegenVisitor(context: PluginContext, private val codegenDecorator: RustC private val fileManifest = context.fileManifest private val model: Model private val codegenContext: ClientCodegenContext - private val protocolGeneratorFactory: ProtocolGeneratorFactory - private val protocolGenerator: ProtocolGenerator + private val protocolGeneratorFactory: ProtocolGeneratorFactory + private val protocolGenerator: ClientProtocolGenerator init { val symbolVisitorConfig = @@ -67,8 +73,8 @@ class CodegenVisitor(context: PluginContext, private val codegenDecorator: RustC ) val baseModel = baselineTransform(context.model) val service = settings.getService(baseModel) - val (protocol, generator) = ProtocolLoader( - codegenDecorator.protocols(service.id, ProtocolLoader.DefaultProtocols), + val (protocol, generator) = ClientProtocolLoader( + codegenDecorator.protocols(service.id, ClientProtocolLoader.DefaultProtocols), ).protocolFor(context.model, service) protocolGeneratorFactory = generator model = codegenDecorator.transformModel(service, baseModel) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt index 2f9d42819d..a1cb8e5f3c 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt @@ -10,13 +10,18 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.eventStreamErrorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.transformers.eventStreamErrors +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.WrappingSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.getTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt index 66c4061f0c..0da1667858 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt @@ -10,14 +10,17 @@ import software.amazon.smithy.build.SmithyBuildPlugin import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute.Companion.NonExhaustive -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWordSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.NonExhaustive +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.customizations.ClientCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.NoOpEventStreamSigningDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientDecorator +import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import java.util.logging.Level import java.util.logging.Logger diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt index 0ca4dae06c..9f82093085 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt @@ -8,7 +8,9 @@ package software.amazon.smithy.rust.codegen.client.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider /** * [ServerCodegenContext] contains code-generation context that is _specific_ to the [RustCodegenServerPlugin] plugin diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerRustSettings.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerRustSettings.kt index fd9984a3b4..7b414686cf 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerRustSettings.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerRustSettings.kt @@ -8,6 +8,10 @@ package software.amazon.smithy.rust.codegen.client.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.rust.codegen.core.smithy.CODEGEN_SETTINGS +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenConfig +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import java.util.Optional /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt index 88e1ba9511..cd362acccf 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt @@ -13,7 +13,14 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.Default +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolMetadataProvider +import software.amazon.smithy.rust.codegen.core.smithy.WrappingSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.setDefault import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt index 752f90100a..f96b21336e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt @@ -5,10 +5,10 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection val AllowedRustcLints = listOf( // Deprecated items should be safe to compile, so don't block the compilation. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt index 3037e97adf..e08b0f6f45 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt @@ -6,14 +6,15 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization /** * Customizations that apply only to generated clients. */ -class ClientCustomizations : RustCodegenDecorator { +class ClientCustomizations : RustCodegenDecorator { override val name: String = "ClientCustomizations" override val order: Byte = 0 diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt index 9a2503c520..adfb3b8721 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt @@ -5,11 +5,11 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.containerDocs -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.containerDocs +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection class ClientDocsGenerator : LibRsCustomization() { override fun section(section: LibRsSection): Writable { @@ -21,9 +21,10 @@ class ClientDocsGenerator : LibRsCustomization() { } } - private fun crateLayout(): Writable = writable { - containerDocs( - """ + private fun crateLayout(): Writable = + writable { + containerDocs( + """ The entry point for most customers will be [`Client`]. [`Client`] exposes one method for each API offered by the service. @@ -34,6 +35,6 @@ class ClientDocsGenerator : LibRsCustomization() { The other modules within this crate are not required for normal usage. """.trimEnd(), - ) - } + ) + } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/CrateVersionGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/CrateVersionGenerator.kt index 3de97eed5c..d3b350ed02 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/CrateVersionGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/CrateVersionGenerator.kt @@ -5,23 +5,24 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection /** * Add `PGK_VERSION` const in lib.rs to enable knowing the version of the current module */ class CrateVersionGenerator : LibRsCustomization() { - override fun section(section: LibRsSection) = writable { - if (section is LibRsSection.Body) { - rust( - """ - /// Crate version number. - pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - """, - ) + override fun section(section: LibRsSection) = + writable { + if (section is LibRsSection.Body) { + rust( + """ + /// Crate version number. + pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + """, + ) + } } - } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt index 309784c730..8a8428b9cd 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt @@ -6,9 +6,10 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.ManifestCustomizations +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations /** * See https://docs.rs/about/metadata for more information @@ -50,7 +51,7 @@ fun DocsRsMetadataSettings.asMap(): Map { * This decorator is not used by default, code generators must manually configure and include it in their builds. */ class DocsRsMetadataDecorator(private val docsRsMetadataSettings: DocsRsMetadataSettings) : - RustCodegenDecorator { + RustCodegenDecorator { override val name: String = "docsrs-metadata" override val order: Byte = 0 diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt index 892aba0505..88d9c9dc3b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt @@ -7,14 +7,14 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.EndpointTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.client.smithy.generators.EndpointTraitBindings +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection class EndpointPrefixGenerator(private val coreCodegenContext: CoreCodegenContext, private val shape: OperationShape) : OperationCustomization() { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt index 5a3ee39e58..a2da885ef2 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt @@ -8,16 +8,16 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.HttpChecksumRequiredTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.inputShape diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt index ff2c1079f9..ac6ca51611 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt @@ -7,14 +7,14 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.aws.traits.protocols.AwsProtocolTrait import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.isEventStream diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt index d0bc823a74..8049321c01 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt @@ -7,12 +7,12 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.IdempotencyTokenTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.findMemberWithTrait import software.amazon.smithy.rust.codegen.core.util.inputShape diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt index 0f45842289..6430665492 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt @@ -5,14 +5,14 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig @@ -28,19 +28,21 @@ class ResiliencyConfigCustomization(coreCodegenContext: CoreCodegenContext) : Co "TimeoutConfig" to timeoutModule.member("Config"), ) - override fun section(section: ServiceConfig) = writable { - when (section) { - is ServiceConfig.ConfigStruct -> rustTemplate( - """ + override fun section(section: ServiceConfig) = + writable { + when (section) { + is ServiceConfig.ConfigStruct -> rustTemplate( + """ retry_config: Option<#{RetryConfig}>, sleep_impl: Option>, timeout_config: Option<#{TimeoutConfig}>, """, - *codegenScope, - ) - is ServiceConfig.ConfigImpl -> { - rustTemplate( - """ + *codegenScope, + ) + + is ServiceConfig.ConfigImpl -> { + rustTemplate( + """ /// Return a reference to the retry configuration contained in this config, if any. pub fn retry_config(&self) -> Option<&#{RetryConfig}> { self.retry_config.as_ref() @@ -56,21 +58,23 @@ class ResiliencyConfigCustomization(coreCodegenContext: CoreCodegenContext) : Co self.timeout_config.as_ref() } """, - *codegenScope, - ) - } - is ServiceConfig.BuilderStruct -> - rustTemplate( - """ + *codegenScope, + ) + } + + is ServiceConfig.BuilderStruct -> + rustTemplate( + """ retry_config: Option<#{RetryConfig}>, sleep_impl: Option>, timeout_config: Option<#{TimeoutConfig}>, """, - *codegenScope, - ) - ServiceConfig.BuilderImpl -> - rustTemplate( - """ + *codegenScope, + ) + + ServiceConfig.BuilderImpl -> + rustTemplate( + """ /// Set the retry_config for the builder /// /// ## Examples @@ -211,19 +215,21 @@ class ResiliencyConfigCustomization(coreCodegenContext: CoreCodegenContext) : Co self } """, - *codegenScope, - ) - ServiceConfig.BuilderBuild -> rustTemplate( - """ + *codegenScope, + ) + + ServiceConfig.BuilderBuild -> rustTemplate( + """ retry_config: self.retry_config, sleep_impl: self.sleep_impl, timeout_config: self.timeout_config, """, - *codegenScope, - ) - else -> emptySection + *codegenScope, + ) + + else -> emptySection + } } - } } class ResiliencyReExportCustomization(private val runtimeConfig: RuntimeConfig) : LibRsCustomization() { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt index 94aa834566..f605e3a712 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt @@ -7,16 +7,16 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.core.util.hasEventStreamMember import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember @@ -70,19 +70,21 @@ internal fun pubUseTypes(runtimeConfig: RuntimeConfig, model: Model): List { - val types = pubUseTypes(runtimeConfig, section.model) - if (types.isNotEmpty()) { - docs("Re-exported types from supporting crates.") - rustBlock("pub mod types") { - types.forEach { type -> rust("pub use #T;", type) } + override fun section(section: LibRsSection) = + writable { + when (section) { + is LibRsSection.Body -> { + val types = pubUseTypes(runtimeConfig, section.model) + if (types.isNotEmpty()) { + docs("Re-exported types from supporting crates.") + rustBlock("pub mod types") { + types.forEach { type -> rust("pub use #T;", type) } + } } } - } - else -> { + + else -> { + } } } - } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt index b6280b7503..d906d83e7a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt @@ -5,21 +5,21 @@ package software.amazon.smithy.rust.codegen.client.smithy.customize -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.EventStreamSigningConfig +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.hasEventStreamOperations /** * The NoOpEventStreamSigningDecorator: * - adds a `new_event_stream_signer()` method to `config` to create an Event Stream NoOp signer */ -open class NoOpEventStreamSigningDecorator : RustCodegenDecorator { +open class NoOpEventStreamSigningDecorator : RustCodegenDecorator { override val name: String = "NoOpEventStreamSigning" override val order: Byte = Byte.MIN_VALUE diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt index d70ab9a6d3..674dcca11a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt @@ -6,10 +6,7 @@ package software.amazon.smithy.rust.codegen.client.smithy.customize import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Feature import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customizations.AllowLintsGenerator import software.amazon.smithy.rust.codegen.client.smithy.customizations.CrateVersionGenerator import software.amazon.smithy.rust.codegen.client.smithy.customizations.EndpointPrefixGenerator @@ -19,15 +16,20 @@ import software.amazon.smithy.rust.codegen.client.smithy.customizations.Idempote import software.amazon.smithy.rust.codegen.client.smithy.customizations.ResiliencyConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.customizations.ResiliencyReExportCustomization import software.amazon.smithy.rust.codegen.client.smithy.customizations.SmithyTypesPubUseGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization /** * A set of customizations that are included in all protocols. * * This exists as a convenient place to gather these modifications, these are not true customizations. */ -class RequiredCustomizations : RustCodegenDecorator { +class RequiredCustomizations : RustCodegenDecorator { override val name: String = "Required" override val order: Byte = -1 diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt index edb96225cf..1b34057dbb 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt @@ -10,12 +10,13 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.ManifestCustomizations import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolMap +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap import software.amazon.smithy.rust.codegen.core.util.deepMergeWith import java.util.ServiceLoader import java.util.logging.Logger @@ -27,7 +28,7 @@ import java.util.logging.Logger * AWS services. A different downstream customer may wish to add a different set of derive * attributes to the generated classes. */ -interface RustCodegenDecorator { +interface RustCodegenDecorator { /** * The name of this [RustCodegenDecorator], used for logging and debug information */ @@ -64,7 +65,7 @@ interface RustCodegenDecorator { fun extras(codegenContext: C, rustCrate: RustCrate) {} - fun protocols(serviceId: ShapeId, currentProtocols: ProtocolMap): ProtocolMap = + fun protocols(serviceId: ShapeId, currentProtocols: ProtocolMap): ProtocolMap = currentProtocols fun transformModel(service: ServiceShape, model: Model): Model = model @@ -77,21 +78,21 @@ interface RustCodegenDecorator { * * This makes the actual concrete codegen simpler by not needing to deal with multiple separate decorators. */ -open class CombinedCodegenDecorator(decorators: List>) : - RustCodegenDecorator { +open class CombinedCodegenDecorator(decorators: List>) : + RustCodegenDecorator { private val orderedDecorators = decorators.sortedBy { it.order } override val name: String get() = "MetaDecorator" override val order: Byte get() = 0 - fun withDecorator(decorator: RustCodegenDecorator) = CombinedCodegenDecorator(orderedDecorators + decorator) + fun withDecorator(decorator: RustCodegenDecorator) = CombinedCodegenDecorator(orderedDecorators + decorator) override fun configCustomizations( codegenContext: C, baseCustomizations: List, ): List { - return orderedDecorators.foldRight(baseCustomizations) { decorator: RustCodegenDecorator, customizations -> + return orderedDecorators.foldRight(baseCustomizations) { decorator: RustCodegenDecorator, customizations -> decorator.configCustomizations(codegenContext, customizations) } } @@ -101,7 +102,7 @@ open class CombinedCodegenDecorator(decorators: List, ): List { - return orderedDecorators.foldRight(baseCustomizations) { decorator: RustCodegenDecorator, customizations -> + return orderedDecorators.foldRight(baseCustomizations) { decorator: RustCodegenDecorator, customizations -> decorator.operationCustomizations(codegenContext, operation, customizations) } } @@ -118,7 +119,7 @@ open class CombinedCodegenDecorator(decorators: List): ProtocolMap { + override fun protocols(serviceId: ShapeId, currentProtocols: ProtocolMap): ProtocolMap { return orderedDecorators.foldRight(currentProtocols) { decorator, protocolMap -> decorator.protocols(serviceId, protocolMap) } @@ -145,17 +146,17 @@ open class CombinedCodegenDecorator(decorators: List fromClasspath( + inline fun fromClasspath( context: PluginContext, - vararg extras: RustCodegenDecorator, + vararg extras: RustCodegenDecorator, logger: Logger = Logger.getLogger("RustCodegenSPILoader"), - ): CombinedCodegenDecorator { + ): CombinedCodegenDecorator { val decorators = ServiceLoader.load( RustCodegenDecorator::class.java, context.pluginClassLoader.orElse(RustCodegenDecorator::class.java.classLoader), ) - val filteredDecorators = filterDecorators(decorators, logger).toList() + val filteredDecorators = filterDecorators(decorators, logger).toList() return CombinedCodegenDecorator(filteredDecorators + extras) } @@ -165,10 +166,10 @@ open class CombinedCodegenDecorator(decorators: List filterDecorators( - decorators: Iterable>, + inline fun filterDecorators( + decorators: Iterable>, logger: Logger = Logger.getLogger("RustCodegenSPILoader"), - ): Sequence> = + ): Sequence> = decorators.asSequence() .onEach { logger.info("Discovered Codegen Decorator: ${it.javaClass.name}") @@ -183,7 +184,7 @@ open class CombinedCodegenDecorator(decorators: List(decorators: List + it as RustCodegenDecorator } } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt index 0742725435..ad97f369ab 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt @@ -8,16 +8,17 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.EndpointTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.rustFormatString -import software.amazon.smithy.rust.codegen.client.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.OperationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.rustFormatString +import software.amazon.smithy.rust.codegen.core.smithy.isOptional import software.amazon.smithy.rust.codegen.core.util.inputShape fun EndpointTrait.prefixFormatString(): String { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/NestedAccessorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/NestedAccessorGenerator.kt index 0c6b889789..d0fabc932a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/NestedAccessorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/NestedAccessorGenerator.kt @@ -7,20 +7,20 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.makeOptional -import software.amazon.smithy.rust.codegen.client.smithy.mapRustType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.lensName +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.makeOptional +import software.amazon.smithy.rust.codegen.core.smithy.mapRustType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.lensName /** Generator for accessing nested fields through optional values **/ class NestedAccessorGenerator(private val symbolProvider: RustSymbolProvider) { @@ -65,26 +65,31 @@ class NestedAccessorGenerator(private val symbolProvider: RustSymbolProvider) { } } - private fun generateBody(path: List, reference: Boolean): Writable = writable { - val ref = if (reference) { "&" } else { "" } - if (path.isEmpty()) { - rust("Some(input)") - } else { - val head = path.first() - if (symbolProvider.toSymbol(head).isOptional()) { - rust( - """ + private fun generateBody(path: List, reference: Boolean): Writable = + writable { + val ref = if (reference) { + "&" + } else { + "" + } + if (path.isEmpty()) { + rust("Some(input)") + } else { + val head = path.first() + if (symbolProvider.toSymbol(head).isOptional()) { + rust( + """ let input = match ${ref}input.${symbolProvider.toMemberName(head)} { None => return None, Some(t) => t }; """, - ) - } else { - rust("let input = input.${symbolProvider.toMemberName(head)};") + ) + } else { + rust("let input = input.${symbolProvider.toMemberName(head)};") + } + // Note: although _this_ function is recursive, it generates a series of `if let` statements with early returns. + generateBody(path.drop(1), reference)(this) } - // Note: although _this_ function is recursive, it generates a series of `if let` statements with early returns. - generateBody(path.drop(1), reference)(this) } - } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt index b0ae733993..c5233aeb08 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt @@ -11,24 +11,26 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.traits.IdempotencyTokenTrait import software.amazon.smithy.model.traits.PaginatedTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerics -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.findMemberWithTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait @@ -217,12 +219,13 @@ class PaginatorGenerator private constructor( } /** Generate an `.items()` function to expose flattened pagination when modeled */ - private fun itemsFn(): Writable = writable { - itemsPaginator()?.also { itemPaginatorType -> - val documentedPath = - paginationInfo.itemsMemberPath.joinToString(".") { symbolProvider.toMemberName(it) } - rustTemplate( - """ + private fun itemsFn(): Writable = + writable { + itemsPaginator()?.also { itemPaginatorType -> + val documentedPath = + paginationInfo.itemsMemberPath.joinToString(".") { symbolProvider.toMemberName(it) } + rustTemplate( + """ /// Create a flattened paginator /// /// This paginator automatically flattens results using `$documentedPath`. Queries to the underlying service @@ -231,10 +234,10 @@ class PaginatorGenerator private constructor( #{ItemPaginator}(self) } """, - "ItemPaginator" to itemPaginatorType, - ) + "ItemPaginator" to itemPaginatorType, + ) + } } - } /** Generate a struct with a `items()` method that flattens the paginator **/ private fun itemsPaginator(): RuntimeType? = if (paginationInfo.itemsMemberPath.isEmpty()) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ServiceGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ServiceGenerator.kt index 219d8d08f0..8f971da3fb 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ServiceGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ServiceGenerator.kt @@ -6,16 +6,16 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import software.amazon.smithy.model.knowledge.TopDownIndex -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfigGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.TopLevelErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolTestGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.TopLevelErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.util.inputShape /** @@ -26,10 +26,10 @@ import software.amazon.smithy.rust.codegen.core.util.inputShape */ class ServiceGenerator( private val rustCrate: RustCrate, - private val protocolGenerator: ProtocolGenerator, + private val protocolGenerator: ClientProtocolGenerator, private val protocolSupport: ProtocolSupport, private val clientCodegenContext: ClientCodegenContext, - private val decorator: RustCodegenDecorator, + private val decorator: RustCodegenDecorator, ) { private val index = TopDownIndex.of(clientCodegenContext.model) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientCore.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientCore.kt index a3b812693f..fb9750119b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientCore.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientCore.kt @@ -7,15 +7,15 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.client import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asArgument -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.generators.setterName +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asArgument +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName class FluentClientCore(private val model: Model) { /** Generate and write Rust code for a builder method that sets a Vec */ diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt index ffc61c7621..f63117db71 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt @@ -7,24 +7,25 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.client import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Feature -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.customize.NamedSectionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.customize.Section -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.customize.Section +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -class FluentClientDecorator : RustCodegenDecorator { +class FluentClientDecorator : RustCodegenDecorator { override val name: String = "FluentClient" override val order: Byte = 0 diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index 1555af2c17..543d10d1ab 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -12,45 +12,45 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWords -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asArgumentType -import software.amazon.smithy.rust.codegen.client.rustlang.asOptional -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.docLink -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.normalizeHtml -import software.amazon.smithy.rust.codegen.client.rustlang.qualifiedName -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTypeParameters -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.customize.writeCustomizations -import software.amazon.smithy.rust.codegen.client.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asArgumentType +import software.amazon.smithy.rust.codegen.core.rustlang.asOptional +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.docLink +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.normalizeHtml +import software.amazon.smithy.rust.codegen.core.rustlang.qualifiedName +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.PaginatorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.builderSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.client.smithy.generators.isPaginated -import software.amazon.smithy.rust.codegen.client.smithy.generators.setterName +import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName import software.amazon.smithy.rust.codegen.client.smithy.generators.smithyHttp -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.orNull import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index e5300d1a05..f0e09372aa 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -6,13 +6,13 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.client import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator interface FluentClientGenerics { /** Declaration with defaults set */ diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt index 55f86c299a..6651503429 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt @@ -5,12 +5,12 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.config -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType open class EventStreamSigningConfig( runtimeConfig: RuntimeConfig, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt index b33ac66a13..59c983bdd4 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt @@ -5,11 +5,11 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.config -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.NamedSectionGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator /** * Add a `make_token` field to Service config. See below for the resulting generated code. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt index 68eb2c0001..1dd0aab95f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt @@ -10,14 +10,14 @@ import software.amazon.smithy.model.knowledge.OperationIndex import software.amazon.smithy.model.knowledge.TopDownIndex import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.traits.IdempotencyTokenTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.raw -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.customize.NamedSectionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.customize.Section +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.raw +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.customize.Section import software.amazon.smithy.rust.codegen.core.util.hasTrait /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt new file mode 100644 index 0000000000..a100a57050 --- /dev/null +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt @@ -0,0 +1,93 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.client.smithy.generators.protocol + +import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.docLink +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.util.inputShape + +open class ClientProtocolGenerator( + coreCodegenContext: CoreCodegenContext, + private val protocol: Protocol, + private val makeOperationGenerator: MakeOperationGenerator, + private val traitGenerator: ProtocolTraitImplGenerator, +): ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { + /** + * Render all code required for serializing requests and deserializing responses for the operation + * + * This primarily relies on two components: + * 1. [traitGenerator]: Generate implementations of the `ParseHttpResponse` trait for the operations + * 2. [makeOperationGenerator]: Generate the `make_operation()` method which is used to serialize operations + * to HTTP requests + */ + fun renderOperation( + operationWriter: RustWriter, + inputWriter: RustWriter, + operationShape: OperationShape, + customizations: List, + ) { + val inputShape = operationShape.inputShape(model) + val builderGenerator = BuilderGenerator(model, symbolProvider, operationShape.inputShape(model)) + builderGenerator.render(inputWriter) + + // impl OperationInputShape { ... } + val operationName = symbolProvider.toSymbol(operationShape).name + inputWriter.implBlock(inputShape, symbolProvider) { + writeCustomizations( + customizations, + OperationSection.InputImpl(customizations, operationShape, inputShape, protocol), + ) + makeOperationGenerator.generateMakeOperation(this, operationShape, customizations) + + // pub fn builder() -> ... { } + builderGenerator.renderConvenienceMethod(this) + } + + // pub struct Operation { ... } + val fluentBuilderName = FluentClientGenerator.clientOperationFnName(operationShape, symbolProvider) + operationWriter.rust( + """ + /// Operation shape for `$operationName`. + /// + /// This is usually constructed for you using the the fluent builder returned by + /// [`$fluentBuilderName`](${docLink("crate::client::Client::$fluentBuilderName")}). + /// + /// See [`crate::client::fluent_builders::$operationName`] for more details about the operation. + """, + ) + Attribute.Derives(setOf(RuntimeType.Clone, RuntimeType.Default, RuntimeType.Debug)).render(operationWriter) + operationWriter.rustBlock("pub struct $operationName") { + write("_private: ()") + } + operationWriter.implBlock(operationShape, symbolProvider) { + builderGenerator.renderConvenienceMethod(this) + + rust("/// Creates a new `$operationName` operation.") + rustBlock("pub fn new() -> Self") { + rust("Self { _private: () }") + } + + writeCustomizations(customizations, OperationSection.OperationImplBlock(customizations)) + } + traitGenerator.generateTraitImpls(operationWriter, operationShape, customizations) + } +} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolGenerator.kt deleted file mode 100644 index 8a788196f7..0000000000 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolGenerator.kt +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -package software.amazon.smithy.rust.codegen.client.smithy.generators.protocol - -import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.docLink -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.writeCustomizations -import software.amazon.smithy.rust.codegen.client.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.implBlock -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.core.util.inputShape - -/** - * Payload Body Generator. - * - * Used to generate payloads that will go into HTTP bodies for HTTP requests (used by clients) - * and responses (used by servers). - * - * **Note:** There is only one real implementation of this interface. The other implementation is test-only. - * All protocols use the same class. - * - * Different protocols (e.g. JSON vs. XML) need to use different functionality to generate payload bodies. - */ -interface ProtocolPayloadGenerator { - data class PayloadMetadata(val takesOwnership: Boolean) - - /** - * Code generation needs to handle whether [generatePayload] takes ownership of the input or output - * for a given operation shape. - * - * Most operations will use the HTTP payload as a reference, but for operations that will consume the entire stream - * later,they will need to take ownership and different code needs to be generated. - */ - fun payloadMetadata(operationShape: OperationShape): PayloadMetadata - - /** - * Write the payload into [writer]. - * - * [self] is the name of the variable binding for the Rust struct that is to be serialized into the payload. - * - * This should be an expression that returns bytes: - * - a `Vec` for non-streaming operations; or - * - a `ByteStream` for streaming operations. - */ - fun generatePayload(writer: RustWriter, self: String, operationShape: OperationShape) -} - -/** - * Protocol Trait implementation generator - * - * **Note:** There is only one real implementation of this interface. The other implementation is test-only. - * All protocols use the same class. - * - * Protocols implement one of two traits to enable parsing HTTP responses: - * 1. `ParseHttpResponse`: Streaming binary operations - * 2. `ParseStrictResponse`: Non-streaming operations for the body must be "strict" (as in, not lazy) where the parser - * must have the complete body to return a result. - */ -interface ProtocolTraitImplGenerator { - fun generateTraitImpls(operationWriter: RustWriter, operationShape: OperationShape, customizations: List) -} - -/** - * Class providing scaffolding for HTTP based protocols that must build an HTTP request (headers / URL) and a body. - */ -open class ProtocolGenerator( - coreCodegenContext: CoreCodegenContext, - /** - * `Protocol` contains all protocol specific information. Each smithy protocol, e.g. RestJson, RestXml, etc. will - * have their own implementation of the protocol interface which defines how an input shape becomes and http::Request - * and an output shape is build from an `http::Response`. - */ - private val protocol: Protocol, - /** - * Operations generate a `make_operation(&config)` method to build a `aws_smithy_http::Operation` that can be dispatched - * This is the serializer side of request dispatch - */ - private val makeOperationGenerator: MakeOperationGenerator, - /** - * Operations generate implementations of ParseHttpResponse or ParseStrictResponse. - * This is the deserializer side of request dispatch (parsing the response) - */ - private val traitGenerator: ProtocolTraitImplGenerator, -) { - private val symbolProvider = coreCodegenContext.symbolProvider - private val model = coreCodegenContext.model - - /** - * Render all code required for serializing requests and deserializing responses for the operation - * - * This primarily relies on two components: - * 1. [traitGenerator]: Generate implementations of the `ParseHttpResponse` trait for the operations - * 2. [makeOperationGenerator]: Generate the `make_operation()` method which is used to serialize operations - * to HTTP requests - */ - fun renderOperation( - operationWriter: RustWriter, - inputWriter: RustWriter, - operationShape: OperationShape, - customizations: List, - ) { - val inputShape = operationShape.inputShape(model) - val builderGenerator = BuilderGenerator(model, symbolProvider, operationShape.inputShape(model)) - builderGenerator.render(inputWriter) - - // impl OperationInputShape { ... } - val operationName = symbolProvider.toSymbol(operationShape).name - inputWriter.implBlock(inputShape, symbolProvider) { - writeCustomizations( - customizations, - OperationSection.InputImpl(customizations, operationShape, inputShape, protocol), - ) - makeOperationGenerator.generateMakeOperation(this, operationShape, customizations) - - // pub fn builder() -> ... { } - builderGenerator.renderConvenienceMethod(this) - } - - // pub struct Operation { ... } - val fluentBuilderName = FluentClientGenerator.clientOperationFnName(operationShape, symbolProvider) - operationWriter.rust( - """ - /// Operation shape for `$operationName`. - /// - /// This is usually constructed for you using the the fluent builder returned by - /// [`$fluentBuilderName`](${docLink("crate::client::Client::$fluentBuilderName")}). - /// - /// See [`crate::client::fluent_builders::$operationName`] for more details about the operation. - """, - ) - Attribute.Derives(setOf(RuntimeType.Clone, RuntimeType.Default, RuntimeType.Debug)).render(operationWriter) - operationWriter.rustBlock("pub struct $operationName") { - write("_private: ()") - } - operationWriter.implBlock(operationShape, symbolProvider) { - builderGenerator.renderConvenienceMethod(this) - - rust("/// Creates a new `$operationName` operation.") - rustBlock("pub fn new() -> Self") { - rust("Self { _private: () }") - } - - writeCustomizations(customizations, OperationSection.OperationImplBlock(customizations)) - } - traitGenerator.generateTraitImpls(operationWriter, operationShape, customizations) - } - - /** - * The server implementation uses this method to generate implementations of the `from_request` and `into_response` - * traits for operation input and output shapes, respectively. - */ - fun serverRenderOperation( - operationWriter: RustWriter, - operationShape: OperationShape, - ) { - traitGenerator.generateTraitImpls(operationWriter, operationShape, emptyList()) - } -} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index efc452973e..96587537ee 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -19,23 +19,24 @@ import software.amazon.smithy.protocoltests.traits.HttpRequestTestCase import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait import software.amazon.smithy.protocoltests.traits.HttpResponseTestCase import software.amazon.smithy.protocoltests.traits.HttpResponseTestsTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.Instantiator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.client.testutil.TokioTest +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.findMemberWithTrait import software.amazon.smithy.rust.codegen.core.util.getTrait @@ -47,19 +48,6 @@ import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import java.util.logging.Logger -data class ProtocolSupport( - /* Client support */ - val requestSerialization: Boolean, - val requestBodySerialization: Boolean, - val responseDeserialization: Boolean, - val errorDeserialization: Boolean, - /* Server support */ - val requestDeserialization: Boolean, - val requestBodyDeserialization: Boolean, - val responseSerialization: Boolean, - val errorSerialization: Boolean, -) - /** * Generate protocol tests for an operation */ diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt index a50da4220e..03915265b9 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt @@ -12,21 +12,26 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ToShapeId import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.generators.serializationError -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.JsonParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.JsonSerializerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.generators.serializationError +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.JsonParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serializeFunctionName import software.amazon.smithy.rust.codegen.core.util.inputShape sealed class AwsJsonVersion { @@ -41,7 +46,8 @@ sealed class AwsJsonVersion { } } -class AwsJsonFactory(private val version: AwsJsonVersion) : ProtocolGeneratorFactory { +class AwsJsonFactory(private val version: AwsJsonVersion) : + ProtocolGeneratorFactory { override fun protocol(codegenContext: ClientCodegenContext): Protocol = AwsJson(codegenContext, version) override fun buildProtocolGenerator(codegenContext: ClientCodegenContext): HttpBoundProtocolGenerator = diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt index d0f4ca0c14..ed95d63761 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt @@ -12,19 +12,23 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ToShapeId import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.AwsQueryParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.AwsQuerySerializerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.protocols.StaticHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.AwsQueryParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.AwsQuerySerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.core.util.getTrait class AwsQueryFactory : ProtocolGeneratorFactory { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/ClientProtocolLoader.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/ClientProtocolLoader.kt new file mode 100644 index 0000000000..d97f52c26e --- /dev/null +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/ClientProtocolLoader.kt @@ -0,0 +1,33 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.client.smithy.protocols + +import software.amazon.smithy.aws.traits.protocols.AwsJson1_0Trait +import software.amazon.smithy.aws.traits.protocols.AwsJson1_1Trait +import software.amazon.smithy.aws.traits.protocols.AwsQueryTrait +import software.amazon.smithy.aws.traits.protocols.Ec2QueryTrait +import software.amazon.smithy.aws.traits.protocols.RestJson1Trait +import software.amazon.smithy.aws.traits.protocols.RestXmlTrait +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolLoader +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap + +class ClientProtocolLoader(supportedProtocols: ProtocolMap) : + ProtocolLoader(supportedProtocols) { + + companion object { + val DefaultProtocols = mapOf( + AwsJson1_0Trait.ID to AwsJsonFactory(AwsJsonVersion.Json10), + AwsJson1_1Trait.ID to AwsJsonFactory(AwsJsonVersion.Json11), + AwsQueryTrait.ID to AwsQueryFactory(), + Ec2QueryTrait.ID to Ec2QueryFactory(), + RestJson1Trait.ID to RestJsonFactory(), + RestXmlTrait.ID to RestXmlFactory(), + ) + val Default = ClientProtocolLoader(DefaultProtocols) + } +} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt index 8af691bfe6..a6faa9d59f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt @@ -9,19 +9,23 @@ import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.Ec2QueryParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.Ec2QuerySerializerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.protocols.StaticHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.Ec2QueryParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.Ec2QuerySerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator class Ec2QueryFactory : ProtocolGeneratorFactory { override fun protocol(codegenContext: ClientCodegenContext): Protocol = Ec2QueryProtocol(codegenContext) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt index 1d63ce1f03..a6d689a3cb 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt @@ -9,33 +9,37 @@ import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.assignment -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.writeCustomizations -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.builderSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.ResponseBindingGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.MakeOperationGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolTraitImplGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.setterName -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.errorMessageMember -import software.amazon.smithy.rust.codegen.client.smithy.transformers.operationErrors +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.assignment +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.ResponseBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtocolPayloadGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.errorMessageMember +import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.util.UNREACHABLE import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember @@ -47,7 +51,7 @@ import software.amazon.smithy.rust.codegen.core.util.toSnakeCase class HttpBoundProtocolGenerator( coreCodegenContext: CoreCodegenContext, protocol: Protocol, -) : ProtocolGenerator( +) : ClientProtocolGenerator( coreCodegenContext, protocol, MakeOperationGenerator( diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt index 123acd4f5e..ddf71b960d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt @@ -14,18 +14,23 @@ import software.amazon.smithy.model.traits.JsonNameTrait import software.amazon.smithy.model.traits.MediaTypeTrait import software.amazon.smithy.model.traits.StreamingTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.JsonParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.JsonSerializerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.JsonParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt index 09de074078..4eefd156c8 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt @@ -6,24 +6,26 @@ package software.amazon.smithy.rust.codegen.client.smithy.protocols import software.amazon.smithy.aws.traits.protocols.RestXmlTrait -import software.amazon.smithy.model.node.Node import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.model.traits.AnnotationTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.RestXmlParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.XmlBindingTraitSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.RestXmlParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.XmlBindingTraitSerializerGenerator import software.amazon.smithy.rust.codegen.core.util.expectTrait class RestXmlFactory( @@ -102,12 +104,3 @@ open class RestXml(val coreCodegenContext: CoreCodegenContext) : Protocol { } } } - -/** - * Indicates that a service is expected to send XML where the root element name does not match the modeled member name. - */ -class AllowInvalidXmlRoot : AnnotationTrait(ID, Node.objectNode()) { - companion object { - val ID: ShapeId = ShapeId.from("smithy.api.internal#allowInvalidXmlRoot") - } -} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/Rust.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/Rust.kt index a3e21dba78..c08bd0364c 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/Rust.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/Rust.kt @@ -16,18 +16,18 @@ import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.EnumDefinition -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.raw -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenConfig -import software.amazon.smithy.rust.codegen.client.smithy.DefaultPublicModules -import software.amazon.smithy.rust.codegen.client.smithy.MaybeRenamed -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.raw +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenConfig +import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules +import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.dq diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt index f2f850e35f..1162a33ce2 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt @@ -5,10 +5,10 @@ package software.amazon.smithy.rust.codegen.client.testutil -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfigGenerator diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt index 4668052d6d..617e0e1fa9 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt @@ -10,24 +10,24 @@ import software.amazon.smithy.model.knowledge.NullableIndex import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenConfig -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeCrateLocation import software.amazon.smithy.rust.codegen.client.smithy.RustCodegenPlugin -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig -import software.amazon.smithy.rust.codegen.client.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenConfig +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeCrateLocation +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.letIf import java.io.File diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt index 96437c6140..97631dc423 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt @@ -26,8 +26,8 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.SparseTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.client.smithy.Errors import software.amazon.smithy.rust.codegen.client.smithy.Models import software.amazon.smithy.rust.codegen.client.smithy.Operations diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt index cbf7917856..a89009d87f 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt @@ -7,8 +7,8 @@ package software.amazon.smithy.rust.codegen.client.customizations import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.smithy.customizations.ResiliencyConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.rustSettings diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt index 24855a6316..daf9c2aeea 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt @@ -13,8 +13,8 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumMemberModel +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumMemberModel import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt index ea269e87df..9e6d25f9e9 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt @@ -10,8 +10,8 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator class GenericsGeneratorTest { @Test diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt index 00fac0b016..b3cd309618 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt @@ -10,16 +10,16 @@ import io.kotest.matchers.string.shouldNotContain import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.client.rustlang.docs import software.amazon.smithy.rust.codegen.client.rustlang.raw import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt index a05f219b2d..282faf3a50 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.codegen.core.SymbolProvider import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt index e17e79dde9..669305ee05 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt @@ -16,11 +16,11 @@ import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.RequestBindingGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.uriFormatString -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RequestBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.uriFormatString +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt index 03486aab4a..1e7418fa37 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt @@ -12,13 +12,13 @@ import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.ResponseBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.ResponseBindingGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt index 9f9dafc0c3..a6fb784010 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt @@ -8,6 +8,8 @@ package software.amazon.smithy.rust.codegen.client.rustlang import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.render internal class RustTypesTest { private fun forInputExpectOutput(t: Writable, expectedOutput: String) { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt index aa88fca2f3..1862aa1263 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt @@ -21,6 +21,8 @@ import software.amazon.smithy.rust.codegen.client.testutil.compileAndRun import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.shouldCompile import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.util.lookup class RustWriterTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt index 329cb463f1..72d2b5216e 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt @@ -8,8 +8,9 @@ package software.amazon.smithy.rust.codegen.client.rustlang import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.RustType internal class RustTypeParametersTest { private fun forInputExpectOutput(input: Any, expectedOutput: String) { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt index 87adb5f0f3..24aef6912c 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestSymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt index 2af307a943..3e17f8404f 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rust.codegen.client.smithy import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.MemberShape -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt index d9c98427aa..561565ceb5 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt @@ -20,6 +20,8 @@ import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.setDefault import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator internal class BuilderGeneratorTest { private val model = StructureGeneratorTest.model diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt index 099b8a452c..e92c2b3d94 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt @@ -8,8 +8,8 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.CombinedErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.CombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt index 6a9e859e5d..18e4f3090a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt @@ -10,12 +10,12 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.EndpointTrait import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt index b164a32a6a..fb5087ff03 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt @@ -17,12 +17,15 @@ import software.amazon.smithy.rust.codegen.client.rustlang.raw import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilder import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt index 03d2715307..b75c467d99 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt @@ -17,17 +17,22 @@ import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolMap import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolPayloadGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.outputShape @@ -227,8 +232,8 @@ class ProtocolTestGeneratorTest { override val order: Byte = 0 override fun protocols( serviceId: ShapeId, - currentProtocols: ProtocolMap, - ): ProtocolMap = + currentProtocols: ProtocolMap, + ): ProtocolMap = // Intentionally replace the builtin implementation of RestJson1 with our fake protocol mapOf(RestJson1Trait.ID to TestProtocolFactory(httpRequestBuilder, body, correctResponse)) diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt index 9e3258e8e2..278b946538 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt @@ -10,8 +10,8 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt index 8ad6273857..fb5ef0d349 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt @@ -10,8 +10,8 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt index dd757fefaa..3753a5f4e2 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt @@ -10,13 +10,13 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.restJsonFieldName -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt index 6cb3b5aba9..5773c7cc3b 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt @@ -11,10 +11,10 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt index e31e0ea272..4378b28473 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt @@ -11,11 +11,11 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt index ca9bb6fd6a..76bb836c15 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt @@ -10,10 +10,10 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt index 56bc924f7a..1053ba9df9 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt @@ -10,13 +10,13 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.restJsonFieldName -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt index d4ad16fb3b..c531ec2825 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt @@ -10,12 +10,12 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizerTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizerTest.kt index a24c579453..90564e81a5 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizerTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizerTest.kt @@ -11,6 +11,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticEventStreamUnionTrait +import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizerTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizerTest.kt index e211077926..0fde36acbc 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizerTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizerTest.kt @@ -15,6 +15,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.orNull internal class OperationNormalizerTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt index 4ec569e8a2..60c20f01d2 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt @@ -8,12 +8,12 @@ package software.amazon.smithy.rust.codegen.client.smithy.transformers import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.MemberShape -import software.amazon.smithy.rust.codegen.client.smithy.RustBoxTrait +import software.amazon.smithy.rust.codegen.core.smithy.traits.RustBoxTrait import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.lookup -import kotlin.streams.toList internal class RecursiveShapeBoxerTest { @Test diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt index 00574e930f..9d15eb7cea 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt @@ -11,11 +11,12 @@ import org.junit.jupiter.api.assertThrows import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperationsTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperationsTest.kt index 88301644c3..ea915eb711 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperationsTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperationsTest.kt @@ -13,6 +13,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RemoveEventStreamOperations import java.util.Optional internal class RemoveEventStreamOperationsTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt index c923aea372..7227867146 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt @@ -5,7 +5,7 @@ package software.amazon.smithy.rust.codegen.client.testutil import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator diff --git a/codegen-core/build.gradle.kts b/codegen-core/build.gradle.kts index f1c349b2ed..b5bf128d8c 100644 --- a/codegen-core/build.gradle.kts +++ b/codegen-core/build.gradle.kts @@ -25,7 +25,9 @@ val kotestVersion: String by project dependencies { implementation(kotlin("stdlib-jdk8")) - api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") + implementation("org.jsoup:jsoup:1.14.3") + api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") // TODO Why do we need this? + api("com.moandjiezana.toml:toml4j:0.7.2") implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-waiters:$smithyVersion") diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/CargoDependency.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt similarity index 96% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/CargoDependency.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt index 18aa5a3194..62361e4863 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/CargoDependency.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang import software.amazon.smithy.codegen.core.SymbolDependency import software.amazon.smithy.codegen.core.SymbolDependencyContainer -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.dq import java.nio.file.Path @@ -115,7 +115,7 @@ class InlineDependency( } } -fun CargoDependency.asType(): RuntimeType = RuntimeType(null, dependency = this, namespace = rustName) +fun CargoDependency.asType() = RuntimeType(null, dependency = this, namespace = rustName) data class Feature(val name: String, val default: Boolean, val deps: List) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustModule.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt similarity index 95% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustModule.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt index 066bbadd5e..7e81a10a9d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustModule.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang data class RustModule(val name: String, val rustMetadata: RustMetadata, val documentation: String?) { fun render(writer: RustWriter) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWords.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustReservedWords.kt similarity index 93% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWords.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustReservedWords.kt index becc7c0c1e..33f15aa89e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWords.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustReservedWords.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider import software.amazon.smithy.codegen.core.ReservedWords @@ -14,11 +14,11 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumDefinition -import software.amazon.smithy.rust.codegen.client.smithy.MaybeRenamed -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.WrappingSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.renamedFrom +import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.WrappingSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.renamedFrom import software.amazon.smithy.rust.codegen.core.util.letIf import software.amazon.smithy.rust.codegen.core.util.orNull import software.amazon.smithy.rust.codegen.core.util.toPascalCase diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypes.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypes.kt similarity index 99% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypes.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypes.kt index 60819a4c50..24344b57c7 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypes.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypes.kt @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.dq /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriter.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt similarity index 98% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriter.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt index 24d59c01ab..f733003217 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriter.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang import org.intellij.lang.annotations.Language import org.jsoup.Jsoup @@ -20,9 +20,9 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.DeprecatedTrait import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.letIf import software.amazon.smithy.rust.codegen.core.util.orNull diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarations.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/UseDeclarations.kt similarity index 95% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarations.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/UseDeclarations.kt index c2e5115098..4e409bf126 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarations.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/UseDeclarations.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang import software.amazon.smithy.codegen.core.ImportContainer import software.amazon.smithy.codegen.core.Symbol diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/Writable.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt similarity index 94% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/Writable.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt index c453fe0653..fe07dd9532 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/Writable.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.rustlang +package software.amazon.smithy.rust.codegen.core.rustlang import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.GenericsGenerator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator typealias Writable = RustWriter.() -> Unit diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt similarity index 89% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt index a2c01b4b35..232432aa60 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt @@ -3,24 +3,24 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy import software.amazon.smithy.build.FileManifest import software.amazon.smithy.codegen.core.SymbolProvider import software.amazon.smithy.codegen.core.WriterDelegator import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Feature -import software.amazon.smithy.rust.codegen.client.rustlang.InlineDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.smithy.generators.CargoTomlGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.ManifestCustomizations +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.InlineDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.smithy.generators.CargoTomlGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations /** * RustCrate abstraction. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CodegenTarget.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenTarget.kt similarity index 80% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CodegenTarget.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenTarget.kt index 5ff7fe5cf5..27ea5dcc68 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CodegenTarget.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenTarget.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy /** * Code generation mode: In some situations, codegen has different behavior for client vs. server (eg. required fields) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CoreCodegenContext.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreCodegenContext.kt similarity index 95% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CoreCodegenContext.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreCodegenContext.kt index 75c109d369..42e930ae49 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CoreCodegenContext.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreCodegenContext.kt @@ -3,12 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget /** * [CoreCodegenContext] contains code-generation context that is _common to all_ smithy-rs plugins. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CoreRustSettings.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreRustSettings.kt similarity index 99% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CoreRustSettings.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreRustSettings.kt index beac002e1b..6263f49853 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CoreRustSettings.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreRustSettings.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.Model diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypes.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt similarity index 92% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypes.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt index 66de796b83..5c652f67e0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypes.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt @@ -3,27 +3,27 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.node.Node import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyLocation -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.InlineDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Local -import software.amazon.smithy.rust.codegen.client.rustlang.RustDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustInlineTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable import software.amazon.smithy.rust.codegen.core.Version +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyLocation +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.InlineDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Local +import software.amazon.smithy.rust.codegen.core.rustlang.RustDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.util.orNull import java.util.Optional @@ -128,7 +128,12 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n /** * Get a writable for this `RuntimeType` */ - val writable = writable { rustInlineTemplate("#{this:T}", "this" to this@RuntimeType) } + val writable = writable { + rustInlineTemplate( + "#{this:T}", + "this" to this@RuntimeType + ) + } /** * Convert this [RuntimeType] into a [Symbol]. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/SymbolMetadataProvider.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt similarity index 95% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/SymbolMetadataProvider.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt index 8c7d7e70c4..8c5a56b577 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/SymbolMetadataProvider.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.codegen.core.Symbol @@ -16,9 +16,9 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumDefinition import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.StreamingTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.core.util.hasTrait /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/SymbolVisitor.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolVisitor.kt similarity index 98% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/SymbolVisitor.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolVisitor.kt index 7d749bf439..6943f0c22f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/SymbolVisitor.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolVisitor.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.codegen.core.SymbolProvider @@ -37,8 +37,9 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumDefinition import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.ErrorTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.smithy.traits.RustBoxTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.PANIC diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NamedSectionGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customize/NamedSectionGenerator.kt similarity index 83% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NamedSectionGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customize/NamedSectionGenerator.kt index 8bbbbc7f70..516bfc4284 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NamedSectionGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customize/NamedSectionGenerator.kt @@ -3,11 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.customize +package software.amazon.smithy.rust.codegen.core.smithy.customize -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.writable /** * An overrideable section for code generation. Usage: diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/OperationCustomization.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customize/OperationCustomization.kt similarity index 91% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/OperationCustomization.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customize/OperationCustomization.kt index c59b62ebda..a7dd176a9e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/OperationCustomization.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customize/OperationCustomization.kt @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.customize +package software.amazon.smithy.rust.codegen.core.smithy.customize import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol sealed class OperationSection(name: String) : Section(name) { abstract val customizations: List diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt similarity index 86% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index d9a6d8edaa..c561b04c39 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -3,35 +3,35 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWords -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asArgument -import software.amazon.smithy.rust.codegen.client.rustlang.asOptional -import software.amazon.smithy.rust.codegen.client.rustlang.conditionalBlock -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.Default -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.defaultValue -import software.amazon.smithy.rust.codegen.client.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.makeOptional -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asArgument +import software.amazon.smithy.rust.codegen.core.rustlang.asOptional +import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.Default +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.defaultValue +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.makeOptional +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.toSnakeCase diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt similarity index 85% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt index a6000ad0dc..cad51c9bf2 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt @@ -3,14 +3,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import com.moandjiezana.toml.TomlWriter -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.Feature -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.core.Version import software.amazon.smithy.rust.codegen.core.util.deepMergeWith diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EnumGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt similarity index 89% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EnumGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt index 1d5447caf3..63896d5f8e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EnumGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt @@ -3,25 +3,26 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.model.traits.EnumDefinition import software.amazon.smithy.model.traits.EnumTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.MaybeRenamed -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.util.doubleQuote import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/GenericsGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/GenericsGenerator.kt similarity index 81% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/GenericsGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/GenericsGenerator.kt index 64235ee48f..6cce15324b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/GenericsGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/GenericsGenerator.kt @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators -import software.amazon.smithy.rust.codegen.client.rustlang.rustInlineTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType data class GenericTypeArg( val typeArg: String, @@ -74,22 +74,23 @@ class GenericsGenerator(vararg genericTypeArgs: GenericTypeArg) { * // Writes "fn eat_fruit_salad()" * ``` */ - fun declaration(withAngleBrackets: Boolean = true) = writable { - // Write nothing if this generator is empty - if (typeArgs.isNotEmpty()) { - val typeArgs = typeArgs.joinToString(", ") { it.typeArg } + fun declaration(withAngleBrackets: Boolean = true) = + writable { + // Write nothing if this generator is empty + if (typeArgs.isNotEmpty()) { + val typeArgs = typeArgs.joinToString(", ") { it.typeArg } - if (withAngleBrackets) { - rustInlineTemplate("<") - } + if (withAngleBrackets) { + rustInlineTemplate("<") + } - rustInlineTemplate(typeArgs) + rustInlineTemplate(typeArgs) - if (withAngleBrackets) { - rustInlineTemplate(">") + if (withAngleBrackets) { + rustInlineTemplate(">") + } } } - } /** * Returns bounded generic type args formatted for use in a "where" clause. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/Instantiator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt similarity index 91% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/Instantiator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt index 3cf94d8b71..a869e73255 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/Instantiator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.Model @@ -29,22 +29,23 @@ import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.HttpPrefixHeadersTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.conditionalBlock -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectMember import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/LibRsGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt similarity index 78% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/LibRsGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt index 7da60fe44f..3be7198080 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/LibRsGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt @@ -3,19 +3,19 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.model.Model import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.containerDocs -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.isEmpty -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings -import software.amazon.smithy.rust.codegen.client.smithy.customize.NamedSectionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.customize.Section +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.containerDocs +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.isEmpty +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.customize.Section import software.amazon.smithy.rust.codegen.core.util.getTrait sealed class LibRsSection(name: String) : Section(name) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/StructureGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt similarity index 84% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/StructureGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt index c1b93c7243..b2342fd4c0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/StructureGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.codegen.core.SymbolProvider @@ -13,25 +13,26 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.SensitiveTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asDeref -import software.amazon.smithy.rust.codegen.client.rustlang.asRef -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.isCopy -import software.amazon.smithy.rust.codegen.client.rustlang.isDeref -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.canUseDefault -import software.amazon.smithy.rust.codegen.client.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.ErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.renamedFrom -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ErrorGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asDeref +import software.amazon.smithy.rust.codegen.core.rustlang.asRef +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.isCopy +import software.amazon.smithy.rust.codegen.core.rustlang.isDeref +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.canUseDefault +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.renamedFrom +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/TypeConversionGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/TypeConversionGenerator.kt similarity index 76% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/TypeConversionGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/TypeConversionGenerator.kt index 9ae2f63f5e..dd46fcba42 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/TypeConversionGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/TypeConversionGenerator.kt @@ -3,20 +3,20 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.BlobShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.TimestampShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.rustType /* * Utility class used to force casting a non primitive type into one overriden by a new symbol provider, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/UnionGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/UnionGenerator.kt similarity index 87% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/UnionGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/UnionGenerator.kt index 388dc2e14d..5075430ed3 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/UnionGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/UnionGenerator.kt @@ -3,21 +3,22 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators +package software.amazon.smithy.rust.codegen.core.smithy.generators import software.amazon.smithy.codegen.core.SymbolProvider import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.UnionShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.client.smithy.renamedFrom +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.renamedFrom import software.amazon.smithy.rust.codegen.core.util.toSnakeCase fun CodegenTarget.renderUnknownVariant() = when (this) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/CombinedErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt similarity index 89% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/CombinedErrorGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt index 86f1c37fd2..9e65ceac9b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/CombinedErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.error +package software.amazon.smithy.rust.codegen.core.smithy.generators.error import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model @@ -12,24 +12,24 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.RetryableTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.customize.Section -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.transformers.eventStreamErrors -import software.amazon.smithy.rust.codegen.client.smithy.transformers.operationErrors +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.customize.Section +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors +import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.toSnakeCase diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt similarity index 83% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt index 748e0bff8a..669786b0fc 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt @@ -3,23 +3,23 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.error +package software.amazon.smithy.rust.codegen.core.smithy.generators.error import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.RetryableTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType.Companion.StdError -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.transformers.errorMessageMember +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.Companion.StdError +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.transformers.errorMessageMember import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.letIf diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServerCombinedErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ServerCombinedErrorGenerator.kt similarity index 85% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServerCombinedErrorGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ServerCombinedErrorGenerator.kt index 77196149a3..de6c09a5ac 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServerCombinedErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ServerCombinedErrorGenerator.kt @@ -3,22 +3,22 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.error +package software.amazon.smithy.rust.codegen.core.smithy.generators.error import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.util.toSnakeCase /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/TopLevelErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt similarity index 77% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/TopLevelErrorGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt index db7c3a6e63..e1630bbfeb 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/TopLevelErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt @@ -3,29 +3,28 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.error +package software.amazon.smithy.rust.codegen.core.smithy.generators.error import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.deprecatedShape -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.transformers.allErrors -import software.amazon.smithy.rust.codegen.client.smithy.transformers.eventStreamErrors +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors /** * Each service defines its own "top-level" error combining all possible errors that a service can emit. @@ -126,8 +125,8 @@ class TopLevelErrorGenerator(private val coreCodegenContext: CoreCodegenContext, private fun RustWriter.renderDefinition() { rust("/// All possible error types for this service.") RustMetadata( - additionalAttributes = listOf(Attribute.NonExhaustive), - visibility = Visibility.PUBLIC, + additionalAttributes = listOf(software.amazon.smithy.rust.codegen.core.rustlang.Attribute.NonExhaustive), + visibility = software.amazon.smithy.rust.codegen.core.rustlang.Visibility.PUBLIC, ).withDerives(RuntimeType.Debug).render(this) rustBlock("enum Error") { allErrors.forEach { error -> diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt similarity index 92% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/HttpBindingGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 2de37bbf81..549ca8d9ca 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.http +package software.amazon.smithy.rust.codegen.core.smithy.generators.http import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.knowledge.HttpBinding @@ -21,32 +21,32 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.MediaTypeTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asOptional -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.autoDeref -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError -import software.amazon.smithy.rust.codegen.client.smithy.generators.redactIfNecessary -import software.amazon.smithy.rust.codegen.client.smithy.makeOptional -import software.amazon.smithy.rust.codegen.client.smithy.mapRustType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingDescriptor -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.EventStreamUnmarshallerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asOptional +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.redactIfNecessary +import software.amazon.smithy.rust.codegen.core.smithy.makeOptional +import software.amazon.smithy.rust.codegen.core.smithy.mapRustType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.UNREACHABLE import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/RequestBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt similarity index 91% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/RequestBindingGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt index 84e3f77213..c58d758e94 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/RequestBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.http +package software.amazon.smithy.rust.codegen.core.smithy.generators.http import software.amazon.smithy.model.knowledge.HttpBinding import software.amazon.smithy.model.knowledge.HttpBindingIndex @@ -13,20 +13,20 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.traits.HttpTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.autoDeref -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationBuildError -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.OperationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectMember import software.amazon.smithy.rust.codegen.core.util.inputShape diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/ResponseBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt similarity index 69% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/ResponseBindingGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt index 7eeeb2b5c5..1f97d09cce 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/ResponseBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt @@ -3,14 +3,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.http +package software.amazon.smithy.rust.codegen.core.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingDescriptor -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol class ResponseBindingGenerator( protocol: Protocol, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/RestRequestSpecGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt similarity index 83% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/RestRequestSpecGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt index ce02937301..df401f7636 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/http/RestRequestSpecGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt @@ -3,17 +3,17 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.http +package software.amazon.smithy.rust.codegen.core.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver /** * [RestRequestSpecGenerator] generates a restJson1 or restXml specific `RequestSpec`. Both protocols are routed the same. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/MakeOperationGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt similarity index 84% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/MakeOperationGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt index a18be2d44a..4f0c65c510 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/MakeOperationGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt @@ -3,30 +3,30 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.generators.protocol +package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol import software.amazon.smithy.aws.traits.ServiceTrait import software.amazon.smithy.model.shapes.BlobShape import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.writeCustomizations -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.RequestBindingGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RequestBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.findStreamingMember import software.amazon.smithy.rust.codegen.core.util.getTrait diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt new file mode 100644 index 0000000000..b521e64d37 --- /dev/null +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt @@ -0,0 +1,88 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol + +import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization + +/** + * Payload Body Generator. + * + * Used to generate payloads that will go into HTTP bodies for HTTP requests (used by clients) + * and responses (used by servers). + * + * **Note:** There is only one real implementation of this interface. The other implementation is test-only. + * All protocols use the same class. + * + * Different protocols (e.g. JSON vs. XML) need to use different functionality to generate payload bodies. + */ +interface ProtocolPayloadGenerator { + data class PayloadMetadata(val takesOwnership: Boolean) + + /** + * Code generation needs to handle whether [generatePayload] takes ownership of the input or output + * for a given operation shape. + * + * Most operations will use the HTTP payload as a reference, but for operations that will consume the entire stream + * later,they will need to take ownership and different code needs to be generated. + */ + fun payloadMetadata(operationShape: OperationShape): PayloadMetadata + + /** + * Write the payload into [writer]. + * + * [self] is the name of the variable binding for the Rust struct that is to be serialized into the payload. + * + * This should be an expression that returns bytes: + * - a `Vec` for non-streaming operations; or + * - a `ByteStream` for streaming operations. + */ + fun generatePayload(writer: RustWriter, self: String, operationShape: OperationShape) +} + +/** + * Protocol Trait implementation generator + * + * **Note:** There is only one real implementation of this interface. The other implementation is test-only. + * All protocols use the same class. + * + * Protocols implement one of two traits to enable parsing HTTP responses: + * 1. `ParseHttpResponse`: Streaming binary operations + * 2. `ParseStrictResponse`: Non-streaming operations for the body must be "strict" (as in, not lazy) where the parser + * must have the complete body to return a result. + */ +interface ProtocolTraitImplGenerator { + fun generateTraitImpls(operationWriter: RustWriter, operationShape: OperationShape, customizations: List) +} + +/** + * Class providing scaffolding for HTTP based protocols that must build an HTTP request (headers / URL) and a body. + */ +abstract class ProtocolGenerator( + coreCodegenContext: CoreCodegenContext, + /** + * `Protocol` contains all protocol specific information. Each smithy protocol, e.g. RestJson, RestXml, etc. will + * have their own implementation of the protocol interface which defines how an input shape becomes and http::Request + * and an output shape is build from an `http::Response`. + */ + private val protocol: Protocol, + /** + * Operations generate a `make_operation(&config)` method to build a `aws_smithy_http::Operation` that can be dispatched + * This is the serializer side of request dispatch + */ + private val makeOperationGenerator: MakeOperationGenerator, + /** + * Operations generate implementations of ParseHttpResponse or ParseStrictResponse. + * This is the deserializer side of request dispatch (parsing the response) + */ + private val traitGenerator: ProtocolTraitImplGenerator, +) { + protected val symbolProvider = coreCodegenContext.symbolProvider + protected val model = coreCodegenContext.model +} diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt new file mode 100644 index 0000000000..cc984ec9cd --- /dev/null +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt @@ -0,0 +1,14 @@ +package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol + +data class ProtocolSupport( + /* Client support */ + val requestSerialization: Boolean, + val requestBodySerialization: Boolean, + val responseDeserialization: Boolean, + val errorDeserialization: Boolean, + /* Server support */ + val requestDeserialization: Boolean, + val requestBodyDeserialization: Boolean, + val responseSerialization: Boolean, + val errorSerialization: Boolean, +) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt new file mode 100644 index 0000000000..e9b050ad1c --- /dev/null +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt @@ -0,0 +1,29 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.core.smithy.protocols + +import software.amazon.smithy.codegen.core.CodegenException +import software.amazon.smithy.model.Model +import software.amazon.smithy.model.knowledge.ServiceIndex +import software.amazon.smithy.model.shapes.ServiceShape +import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.model.traits.Trait +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext + +open class ProtocolLoader(private val supportedProtocols: ProtocolMap) { + fun protocolFor( + model: Model, + serviceShape: ServiceShape, + ): Pair> { + val protocols: MutableMap = ServiceIndex.of(model).getProtocols(serviceShape) + val matchingProtocols = + protocols.keys.mapNotNull { protocolId -> supportedProtocols[protocolId]?.let { protocolId to it } } + if (matchingProtocols.isEmpty()) { + throw CodegenException("No matching protocol — service offers: ${protocols.keys}. We offer: ${supportedProtocols.keys}") + } + return matchingProtocols.first() + } +} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBindingResolver.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBindingResolver.kt similarity index 99% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBindingResolver.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBindingResolver.kt index 4615048126..cf14e07e2e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBindingResolver.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBindingResolver.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols +package software.amazon.smithy.rust.codegen.core.smithy.protocols import software.amazon.smithy.model.Model import software.amazon.smithy.model.knowledge.HttpBinding diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt similarity index 90% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt index c8f7e855ba..111ebc6b7f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols +package software.amazon.smithy.rust.codegen.core.smithy.protocols import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.shapes.BlobShape @@ -14,25 +14,25 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.HttpMessageType -import software.amazon.smithy.rust.codegen.client.smithy.generators.operationBuildError -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolPayloadGenerator -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.EventStreamErrorMarshallerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.EventStreamMarshallerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolPayloadGenerator +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.EventStreamErrorMarshallerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.EventStreamMarshallerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.UNREACHABLE import software.amazon.smithy.rust.codegen.core.util.expectMember diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamer.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/InlineFunctionNamer.kt similarity index 94% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamer.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/InlineFunctionNamer.kt index 16d1c28668..6b21fd2115 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamer.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/InlineFunctionNamer.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols +package software.amazon.smithy.rust.codegen.core.smithy.protocols import software.amazon.smithy.model.shapes.DocumentShape import software.amazon.smithy.model.shapes.ListShape @@ -15,7 +15,7 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.toSnakeCase diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Protocol.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt similarity index 50% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Protocol.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt index 1be6d8ec11..75a0f44a6a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Protocol.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt @@ -3,29 +3,17 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols +package software.amazon.smithy.rust.codegen.core.smithy.protocols -import software.amazon.smithy.aws.traits.protocols.AwsJson1_0Trait -import software.amazon.smithy.aws.traits.protocols.AwsJson1_1Trait -import software.amazon.smithy.aws.traits.protocols.AwsQueryTrait -import software.amazon.smithy.aws.traits.protocols.Ec2QueryTrait -import software.amazon.smithy.aws.traits.protocols.RestJson1Trait -import software.amazon.smithy.aws.traits.protocols.RestXmlTrait -import software.amazon.smithy.codegen.core.CodegenException -import software.amazon.smithy.model.Model -import software.amazon.smithy.model.knowledge.ServiceIndex import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.model.traits.Trait -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator /** * Describes a protocol to the [HttpBoundProtocolGenerator]. @@ -75,37 +63,11 @@ interface Protocol { fun parseEventStreamGenericError(operationShape: OperationShape): RuntimeType } -typealias ProtocolMap = Map> +typealias ProtocolMap = Map> -interface ProtocolGeneratorFactory { +interface ProtocolGeneratorFactory { fun protocol(codegenContext: C): Protocol fun buildProtocolGenerator(codegenContext: C): T fun support(): ProtocolSupport } -open class ProtocolLoader(private val supportedProtocols: ProtocolMap) { - fun protocolFor( - model: Model, - serviceShape: ServiceShape, - ): Pair> { - val protocols: MutableMap = ServiceIndex.of(model).getProtocols(serviceShape) - val matchingProtocols = - protocols.keys.mapNotNull { protocolId -> supportedProtocols[protocolId]?.let { protocolId to it } } - if (matchingProtocols.isEmpty()) { - throw CodegenException("No matching protocol — service offers: ${protocols.keys}. We offer: ${supportedProtocols.keys}") - } - return matchingProtocols.first() - } - - companion object { - val DefaultProtocols = mapOf( - AwsJson1_0Trait.ID to AwsJsonFactory(AwsJsonVersion.Json10), - AwsJson1_1Trait.ID to AwsJsonFactory(AwsJsonVersion.Json11), - AwsQueryTrait.ID to AwsQueryFactory(), - Ec2QueryTrait.ID to Ec2QueryFactory(), - RestJson1Trait.ID to RestJsonFactory(), - RestXmlTrait.ID to RestXmlFactory(), - ) - val Default = ProtocolLoader(DefaultProtocols) - } -} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/XmlNameIndex.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/XmlNameIndex.kt similarity index 97% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/XmlNameIndex.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/XmlNameIndex.kt index a153ba7c65..e3f1be1ff7 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/XmlNameIndex.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/XmlNameIndex.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols +package software.amazon.smithy.rust.codegen.core.smithy.protocols import software.amazon.smithy.model.Model import software.amazon.smithy.model.knowledge.KnowledgeIndex diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt similarity index 88% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt index 3649cd0938..0eb6dbf0f2 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt @@ -3,11 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType /** * The AWS query protocol's responses are identical to REST XML's, except that they are wrapped diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt similarity index 84% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt index 1cb756c6cc..d24832a49a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt @@ -3,11 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType /** * The EC2 query protocol's responses are identical to REST XML's, except that they are wrapped diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt similarity index 92% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt index 2036ca246d..6205a5a37a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model @@ -22,24 +22,24 @@ import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EventHeaderTrait import software.amazon.smithy.model.traits.EventPayloadTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.eventStreamErrorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.client.smithy.transformers.eventStreamErrors +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticEventStreamUnionTrait import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt similarity index 91% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index 2fbf75ba8d..017183a713 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.model.shapes.BlobShape import software.amazon.smithy.model.shapes.BooleanShape @@ -20,33 +20,33 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.SparseTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.canUseDefault -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.TypeConversionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.builderSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.setterName -import software.amazon.smithy.rust.codegen.client.smithy.isRustBoxed -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.deserializeFunctionName +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.canUseDefault +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.TypeConversionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName +import software.amazon.smithy.rust.codegen.core.smithy.isRustBoxed +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.deserializeFunctionName import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.hasTrait @@ -370,7 +370,7 @@ class JsonParserGenerator( *codegenScope, ) { startObjectOrNull { - rust("let mut map = #T::new();", RustType.HashMap.RuntimeType) + rust("let mut map = #T::new();", software.amazon.smithy.rust.codegen.core.rustlang.RustType.HashMap.RuntimeType) objectKeyLoop(hasMembers = true) { withBlock("let key =", "?;") { deserializeStringInner(keyTarget, "key") @@ -409,7 +409,7 @@ class JsonParserGenerator( *codegenScope, ) { startObjectOrNull { - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rustTemplate("let mut builder = #{Shape}::builder();", *codegenScope, "Shape" to symbol) deserializeStructInner(shape.members()) withBlock("Ok(Some(builder.build()", "))") { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/RestXmlParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt similarity index 84% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/RestXmlParserGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt index b718071c52..0126f38969 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/RestXmlParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.AllowInvalidXmlRoot +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.traits.AllowInvalidXmlRoot import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/StructuredDataParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/StructuredDataParserGenerator.kt similarity index 92% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/StructuredDataParserGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/StructuredDataParserGenerator.kt index 7b1a6f491c..2bd6c923e0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/StructuredDataParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/StructuredDataParserGenerator.kt @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType interface StructuredDataParserGenerator { /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt similarity index 93% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt index 051631d672..95ee3af53c 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse +package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.aws.traits.customizations.S3UnwrappedXmlOutputTrait import software.amazon.smithy.codegen.core.CodegenException @@ -24,33 +24,33 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.TimestampFormatTrait import software.amazon.smithy.model.traits.XmlFlattenedTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.conditionalBlock -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.builderSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.setterName -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.isRustBoxed -import software.amazon.smithy.rust.codegen.client.smithy.protocols.XmlMemberIndex -import software.amazon.smithy.rust.codegen.client.smithy.protocols.XmlNameIndex -import software.amazon.smithy.rust.codegen.client.smithy.protocols.deserializeFunctionName +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.isRustBoxed +import software.amazon.smithy.rust.codegen.core.smithy.protocols.XmlMemberIndex +import software.amazon.smithy.rust.codegen.core.smithy.protocols.XmlNameIndex +import software.amazon.smithy.rust.codegen.core.smithy.protocols.deserializeFunctionName import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectMember @@ -467,7 +467,7 @@ class XmlBindingTraitParserGenerator( "pub fn $fnName(decoder: &mut #{ScopedDecoder}) -> Result<#{Shape}, #{XmlError}>", *codegenScope, "Shape" to symbol, ) { - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rustTemplate("let mut builder = #{Shape}::builder();", *codegenScope, "Shape" to symbol) val members = shape.xmlMembers() if (members.isNotEmpty()) { @@ -534,7 +534,7 @@ class XmlBindingTraitParserGenerator( *codegenScope, "Map" to symbolProvider.toSymbol(target), ) { - rust("let mut out = #T::new();", RustType.HashMap.RuntimeType) + rust("let mut out = #T::new();", software.amazon.smithy.rust.codegen.core.rustlang.RustType.HashMap.RuntimeType) parseLoop(Ctx(tag = "decoder", accum = null)) { ctx -> rustBlock("s if ${XmlName("entry").matchExpression("s")} => ") { rust("#T(&mut ${ctx.tag}, &mut out)?;", mapEntryParser(target, ctx)) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt similarity index 83% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt index 25961611e4..b84955ad37 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt @@ -3,15 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.XmlFlattenedTrait import software.amazon.smithy.model.traits.XmlNameTrait -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.getTrait class AwsQuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) : QuerySerializerGenerator(coreCodegenContext) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt similarity index 85% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt index f340ee05c9..9d3ec14f41 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt @@ -3,15 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.aws.traits.protocols.Ec2QueryNameTrait import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.XmlNameTrait -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.utils.StringUtils diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt similarity index 84% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt index de02c7561b..a9c8269fad 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model @@ -13,23 +13,23 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EventHeaderTrait import software.amazon.smithy.model.traits.EventPayloadTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.eventStreamErrorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.unknownVariantError -import software.amazon.smithy.rust.codegen.client.smithy.rustType -import software.amazon.smithy.rust.codegen.client.smithy.transformers.eventStreamErrors +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.unknownVariantError +import software.amazon.smithy.rust.codegen.core.smithy.rustType +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticEventStreamUnionTrait import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt similarity index 87% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt index 2b3e461646..136af9f316 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model @@ -21,24 +21,24 @@ import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EventHeaderTrait import software.amazon.smithy.model.traits.EventPayloadTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.unknownVariantError -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.unknownVariantError +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.toPascalCase diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt similarity index 91% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt index 650b079ef1..63b4e2efd7 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.model.shapes.BlobShape import software.amazon.smithy.model.shapes.BooleanShape @@ -21,30 +21,30 @@ import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.TimestampFormatTrait.Format.EPOCH_SECONDS -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.customize.NamedSectionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.customize.Section -import software.amazon.smithy.rust.codegen.client.smithy.generators.TypeConversionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.serializationError -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serializeFunctionName -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.customize.Section +import software.amazon.smithy.rust.codegen.core.smithy.generators.TypeConversionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.serializationError +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serializeFunctionName +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/QuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt similarity index 88% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/QuerySerializerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt index 4d59e38773..1e73a67a2c 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/QuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.model.shapes.BlobShape import software.amazon.smithy.model.shapes.BooleanShape @@ -20,26 +20,26 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.TimestampFormatTrait import software.amazon.smithy.model.traits.XmlNameTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.serializationError -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serializeFunctionName -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.serializationError +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serializeFunctionName +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait @@ -155,7 +155,7 @@ abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) val fnName = symbolProvider.serializeFunctionName(context.shape) val structureSymbol = symbolProvider.toSymbol(context.shape) val structureSerializer = RuntimeType.forInlineFun(fnName, querySerModule) { writer -> - Attribute.AllowUnusedMut.render(writer) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(writer) writer.rustBlockTemplate( "pub fn $fnName(mut writer: #{QueryValueWriter}, input: &#{Input}) -> Result<(), #{Error}>", "Input" to structureSymbol, @@ -248,7 +248,7 @@ abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) private fun RustWriter.structWriter(context: MemberContext, inner: RustWriter.(String) -> Unit) { val prefix = context.shape.queryKeyName() safeName("scope").also { scopeName -> - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rust("let mut $scopeName = ${context.writerExpression}.prefix(${prefix.dq()});") inner(scopeName) } @@ -265,7 +265,7 @@ abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) rust("let mut $listName = ${context.writerExpression}.start_list($flat, $memberOverride);") rustBlock("for $itemName in ${context.valueExpression.asRef()}") { val entryName = safeName("entry") - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rust("let mut $entryName = $listName.entry();") val targetShape = model.expectShape(context.shape.member.target) serializeMemberValue( @@ -292,7 +292,7 @@ abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) else -> keyName } val entryName = safeName("entry") - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rust("let mut $entryName = $mapName.entry($keyExpression);") serializeMember(MemberContext(entryName, ValueExpression.Reference(valueName), context.shape.value)) } @@ -304,7 +304,7 @@ abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) val fnName = symbolProvider.serializeFunctionName(context.shape) val unionSymbol = symbolProvider.toSymbol(context.shape) val unionSerializer = RuntimeType.forInlineFun(fnName, querySerModule) { writer -> - Attribute.AllowUnusedMut.render(writer) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(writer) writer.rustBlockTemplate( "pub fn $fnName(mut writer: #{QueryValueWriter}, input: &#{Input}) -> Result<(), #{Error}>", "Input" to unionSymbol, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/SerializerUtil.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/SerializerUtil.kt similarity index 87% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/SerializerUtil.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/SerializerUtil.kt index 323e1ad93d..a780218e89 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/SerializerUtil.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/SerializerUtil.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.BooleanShape @@ -12,8 +12,8 @@ import software.amazon.smithy.model.shapes.FloatShape import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.NumberShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock class SerializerUtil(private val model: Model) { fun RustWriter.ignoreZeroValues(shape: MemberShape, value: ValueExpression, inner: RustWriter.() -> Unit) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt similarity index 94% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt index dc18a21ebc..962b9c8720 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/StructuredDataSerializerGenerator.kt @@ -3,13 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType interface StructuredDataSerializerGenerator { /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/ValueExpression.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/ValueExpression.kt similarity index 87% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/ValueExpression.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/ValueExpression.kt index 2d259c05b6..4d7a2ce3e5 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/ValueExpression.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/ValueExpression.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize sealed class ValueExpression { abstract val name: String diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt similarity index 91% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt index e4270443eb..a265d5f0b6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize +package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.shapes.BlobShape @@ -23,32 +23,32 @@ import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.TimestampFormatTrait import software.amazon.smithy.model.traits.XmlFlattenedTrait import software.amazon.smithy.model.traits.XmlNamespaceTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.autoDeref -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.stripOuter -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant -import software.amazon.smithy.rust.codegen.client.smithy.generators.serializationError -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.XmlMemberIndex -import software.amazon.smithy.rust.codegen.client.smithy.protocols.XmlNameIndex -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serializeFunctionName -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.serializationError +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.XmlMemberIndex +import software.amazon.smithy.rust.codegen.core.smithy.protocols.XmlNameIndex +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serializeFunctionName +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait @@ -276,7 +276,7 @@ class XmlBindingTraitSerializerGenerator( } } } - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rust("let mut scope = ${ctx.elementWriter}.finish();") val scopeCtx = Ctx.Scope("scope", ctx.input) members.dataMembers.forEach { member -> diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/AllowInvalidXmlRoot.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/AllowInvalidXmlRoot.kt new file mode 100644 index 0000000000..7bc3fdacbe --- /dev/null +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/AllowInvalidXmlRoot.kt @@ -0,0 +1,19 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.core.smithy.traits + +import software.amazon.smithy.model.node.Node +import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.model.traits.AnnotationTrait + +/** + * Indicates that a service is expected to send XML where the root element name does not match the modeled member name. + */ +class AllowInvalidXmlRoot : AnnotationTrait(ID, Node.objectNode()) { + companion object { + val ID: ShapeId = ShapeId.from("smithy.api.internal#allowInvalidXmlRoot") + } +} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustBoxTrait.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/RustBoxTrait.kt similarity index 92% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustBoxTrait.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/RustBoxTrait.kt index 206de88725..2d5a313401 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustBoxTrait.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/traits/RustBoxTrait.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy +package software.amazon.smithy.rust.codegen.core.smithy.traits import software.amazon.smithy.model.node.Node import software.amazon.smithy.model.shapes.ShapeId diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/AddErrorMessage.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/AddErrorMessage.kt similarity index 87% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/AddErrorMessage.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/AddErrorMessage.kt index bfb4163afd..b95c64e9f1 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/AddErrorMessage.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/AddErrorMessage.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.transformers +package software.amazon.smithy.rust.codegen.core.smithy.transformers import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape @@ -15,6 +15,8 @@ import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.orNull import java.util.logging.Logger +// TODO This file should be in the client module, since the transformer is only used by the client generator. +// However, this extension function is used by the server too, so this should probably be moved to `Smithy.kt`. fun StructureShape.errorMessageMember(): MemberShape? = this.getMember("message").or { this.getMember("Message") }.orNull() /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizer.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/EventStreamNormalizer.kt similarity index 98% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizer.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/EventStreamNormalizer.kt index 4195891a34..508ea0fab6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/EventStreamNormalizer.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/EventStreamNormalizer.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.transformers +package software.amazon.smithy.rust.codegen.core.smithy.transformers import software.amazon.smithy.model.Model import software.amazon.smithy.model.knowledge.OperationIndex diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizer.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt similarity index 95% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizer.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt index 1fae090fd9..ced062f1dd 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/OperationNormalizer.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.transformers +package software.amazon.smithy.rust.codegen.core.smithy.transformers import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape @@ -11,7 +11,7 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.util.rename +import software.amazon.smithy.rust.codegen.core.util.rename import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.orNull @@ -56,7 +56,7 @@ object OperationNormalizer { // Generate or modify the input and output of the given `Operation` to be a unique shape listOf(syntheticInputShape(model, operation), syntheticOutputShape(model, operation)) } - val shapeConflict = newShapes.firstOrNull() { shape -> model.getShape(shape.id).isPresent } + val shapeConflict = newShapes.firstOrNull { shape -> model.getShape(shape.id).isPresent } check( shapeConflict == null, ) { "shape $shapeConflict conflicted with an existing shape in the model (${model.getShape(shapeConflict!!.id)}. This is a bug." } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxer.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapeBoxer.kt similarity index 96% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxer.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapeBoxer.kt index f14c0e9908..4b47801a8d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxer.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapeBoxer.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.transformers +package software.amazon.smithy.rust.codegen.core.smithy.transformers import software.amazon.smithy.codegen.core.TopologicalIndex import software.amazon.smithy.model.Model @@ -13,7 +13,7 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.SetShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.smithy.RustBoxTrait +import software.amazon.smithy.rust.codegen.core.smithy.traits.RustBoxTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait object RecursiveShapeBoxer { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperations.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RemoveEventStreamOperations.kt similarity index 94% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperations.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RemoveEventStreamOperations.kt index aa48d9f0a0..934385125b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RemoveEventStreamOperations.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RemoveEventStreamOperations.kt @@ -3,13 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.smithy.transformers +package software.amazon.smithy.rust.codegen.core.smithy.transformers import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.core.util.findStreamingMember import software.amazon.smithy.rust.codegen.core.util.orNull import java.util.logging.Logger diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/util/Synthetics.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Synthetics.kt similarity index 94% rename from codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/util/Synthetics.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Synthetics.kt index 1f2c99cac5..f0746701e3 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/util/Synthetics.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Synthetics.kt @@ -3,14 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.client.util +package software.amazon.smithy.rust.codegen.core.util import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.ToShapeId -import software.amazon.smithy.rust.codegen.core.util.orNull /** * Clones an entire operation and its input/output shapes under a new name. diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt index 82fa706d7c..5b677f7ec3 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt @@ -17,7 +17,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitor import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.server.python.smithy.customizations.DECORATORS import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerSymbolVisitor import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonStreamingShapeMetadataProvider diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt index 24d2931180..51d1527967 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt @@ -19,9 +19,9 @@ import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerEnumGenerator import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerServiceGenerator diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index ba298b536e..9c511dba53 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.SymbolMetadataProvider diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt index 9ab914f01b..0bdf3c6b33 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt @@ -11,13 +11,13 @@ import software.amazon.smithy.rust.codegen.client.rustlang.docs import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.ManifestCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection +import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerRuntimeType import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerModuleGenerator diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt index 55cff80bc4..b13fc98227 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt @@ -7,13 +7,13 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.Errors import software.amazon.smithy.rust.codegen.client.smithy.Inputs import software.amazon.smithy.rust.codegen.client.smithy.Outputs diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt index 014e434701..32755b8007 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt @@ -16,9 +16,9 @@ import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.ServerCombinedErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency /** diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt index 68aa315390..0fc2111301 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.EnumTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt index c624cb1385..4c641ce0d8 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt @@ -11,7 +11,7 @@ import software.amazon.smithy.rust.codegen.client.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt index 3798148cfd..ed9a6d4b93 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt @@ -8,10 +8,10 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerServiceGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt index 03e512d12a..a7aa871874 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt @@ -10,16 +10,16 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.rustlang.Writable import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.client.rustlang.rust import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.client.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency diff --git a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt index 15f4021237..33dd903c73 100644 --- a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt +++ b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.client.smithy.rustType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.server.smithy.testutil.ServerTestSymbolVisitorConfig diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt index 061d8b1c86..c05000c1d0 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt @@ -10,17 +10,18 @@ import software.amazon.smithy.build.SmithyBuildPlugin import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWordSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.BaseSymbolMetadataProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider import software.amazon.smithy.rust.codegen.client.smithy.EventStreamSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.StreamingShapeMetadataProvider import software.amazon.smithy.rust.codegen.client.smithy.StreamingShapeSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitor -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import java.util.logging.Level import java.util.logging.Logger @@ -42,7 +43,7 @@ class RustCodegenServerPlugin : SmithyBuildPlugin { // - location (e.g. the mutate section of an operation) // - context (e.g. the of the operation) // - writer: The active RustWriter at the given location - val codegenDecorator: CombinedCodegenDecorator = + val codegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath(context, ServerRequiredCustomizations()) // ServerCodegenVisitor is the main driver of code generation that traverses the model and generates code diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCargoDependency.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCargoDependency.kt index 012c78a912..6058519abf 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCargoDependency.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCargoDependency.kt @@ -4,11 +4,11 @@ */ package software.amazon.smithy.rust.codegen.server.smithy -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.InlineDependency -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.InlineDependency +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig /** * Object used *exclusively* in the runtime of the server, for separation concerns. diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt index 2f8dcc7eb7..81acb53e77 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt @@ -17,31 +17,31 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.smithy.CoreRustSettings -import software.amazon.smithy.rust.codegen.client.smithy.DefaultPublicModules -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerRustSettings -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.implBlock -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory -import software.amazon.smithy.rust.codegen.client.smithy.transformers.EventStreamNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RecursiveShapeBoxer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RemoveEventStreamOperations +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RemoveEventStreamOperations +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.runCommand import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerEnumGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerServiceGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerProtocolLoader import java.util.logging.Logger @@ -51,7 +51,7 @@ import java.util.logging.Logger */ open class ServerCodegenVisitor( context: PluginContext, - private val codegenDecorator: RustCodegenDecorator, + private val codegenDecorator: RustCodegenDecorator, ) : ShapeVisitor.Default() { protected val logger = Logger.getLogger(javaClass.name) @@ -62,8 +62,8 @@ open class ServerCodegenVisitor( private val fileManifest = context.fileManifest protected var model: Model protected var codegenContext: ServerCodegenContext - protected var protocolGeneratorFactory: ProtocolGeneratorFactory - protected var protocolGenerator: ProtocolGenerator + protected var protocolGeneratorFactory: ProtocolGeneratorFactory + protected var protocolGenerator: ServerProtocolGenerator init { val symbolVisitorConfig = diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerRuntimeType.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerRuntimeType.kt index 3ae6c62822..4b7f18ba89 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerRuntimeType.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerRuntimeType.kt @@ -5,9 +5,9 @@ package software.amazon.smithy.rust.codegen.server.smithy -import software.amazon.smithy.rust.codegen.client.rustlang.InlineDependency -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.InlineDependency +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType /** * Object used *exclusively* in the runtime of the server, for separation concerns. diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt index b4033fe7a1..acdda0745e 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt @@ -13,10 +13,11 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.RequiredTrait import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.allErrors +import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator /** * Add at least one error to all operations in the model. @@ -32,7 +33,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.transformers.allErrors * mkdir -p "$D" && echo "$C" > "$D/$F" * ``` */ -class AddInternalServerErrorToInfallibleOperationsDecorator : RustCodegenDecorator { +class AddInternalServerErrorToInfallibleOperationsDecorator : RustCodegenDecorator { override val name: String = "AddInternalServerErrorToInfallibleOperations" override val order: Byte = 0 @@ -61,7 +62,7 @@ class AddInternalServerErrorToInfallibleOperationsDecorator : RustCodegenDecorat * mkdir -p "$D" && echo "$C" > "$D/$F" * ``` */ -class AddInternalServerErrorToAllOperationsDecorator : RustCodegenDecorator { +class AddInternalServerErrorToAllOperationsDecorator : RustCodegenDecorator { override val name: String = "AddInternalServerErrorToAllOperations" override val order: Byte = 0 diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt index b6ab91fe56..e83ca6d04b 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt @@ -5,15 +5,16 @@ package software.amazon.smithy.rust.codegen.server.smithy.customizations -import software.amazon.smithy.rust.codegen.client.rustlang.Feature -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customizations.AllowLintsGenerator import software.amazon.smithy.rust.codegen.client.smithy.customizations.CrateVersionGenerator import software.amazon.smithy.rust.codegen.client.smithy.customizations.SmithyTypesPubUseGenerator import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator /** * A set of customizations that are included in all protocols. @@ -22,7 +23,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.LibRsCustomi * * See [RequiredCustomizations] from the `rust-codegen` subproject for the client version of this decorator. */ -class ServerRequiredCustomizations : RustCodegenDecorator { +class ServerRequiredCustomizations : RustCodegenDecorator { override val name: String = "ServerRequired" override val order: Byte = -1 diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt index 6ace15f028..ad420c759e 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt @@ -7,15 +7,15 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.EnumTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.server.smithy.ServerRuntimeType diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt index 4135ce384a..5c37efd34f 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt @@ -22,15 +22,15 @@ import software.amazon.smithy.model.traits.HttpResponseCodeTrait import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.SensitiveTrait import software.amazon.smithy.model.traits.Trait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt index d638a3976f..419777324a 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt @@ -6,14 +6,14 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.util.toPascalCase import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt index 9e07d4bc48..d81724a428 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt @@ -6,16 +6,16 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.transformers.operationErrors +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt index e755695377..3c9c9d2fe6 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt @@ -7,27 +7,27 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWords -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.Errors -import software.amazon.smithy.rust.codegen.client.smithy.Inputs -import software.amazon.smithy.rust.codegen.client.smithy.Outputs -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.Errors +import software.amazon.smithy.rust.codegen.core.smithy.Inputs +import software.amazon.smithy.rust.codegen.core.smithy.Outputs +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt index 99c59ff51b..700545a42a 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt @@ -7,17 +7,17 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.knowledge.TopDownIndex import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.DefaultPublicModules -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolTestGenerator /** @@ -28,7 +28,7 @@ import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.Ser */ open class ServerServiceGenerator( private val rustCrate: RustCrate, - private val protocolGenerator: ProtocolGenerator, + private val protocolGenerator: ServerProtocolGenerator, private val protocolSupport: ProtocolSupport, private val protocol: ServerProtocol, private val coreCodegenContext: CoreCodegenContext, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt index 64f09b7536..04abeb6f38 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt @@ -6,17 +6,17 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.knowledge.TopDownIndex -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWords -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.documentShape -import software.amazon.smithy.rust.codegen.client.rustlang.join -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.documentShape +import software.amazon.smithy.rust.codegen.core.rustlang.join +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.util.toPascalCase import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt index 401901c48a..9ce26f4986 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt @@ -6,13 +6,13 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.HttpBindingGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.HttpMessageType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingDescriptor -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol class ServerRequestBindingGenerator( protocol: Protocol, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt index 09e4bb65d8..afe8e620c4 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt @@ -7,11 +7,11 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.HttpBindingGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.HttpMessageType -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol class ServerResponseBindingGenerator( protocol: Protocol, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt index 5c55e2c2b3..4893b05fd3 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt @@ -7,21 +7,21 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.protocol import software.amazon.smithy.model.knowledge.TopDownIndex import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.RestRequestSpecGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJson import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJsonVersion -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RestRequestSpecGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.ServerRuntimeType import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerAwsJsonSerializerGenerator diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt new file mode 100644 index 0000000000..3ce46c7f6b --- /dev/null +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt @@ -0,0 +1,33 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.server.smithy.generators.protocol + +import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol + +open class ServerProtocolGenerator( + coreCodegenContext: CoreCodegenContext, + protocol: Protocol, + makeOperationGenerator: MakeOperationGenerator, + private val traitGenerator: ProtocolTraitImplGenerator, +): ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { + /** + * The server implementation uses this method to generate implementations of the `from_request` and `into_response` + * traits for operation input and output shapes, respectively. + */ + fun renderOperation( + operationWriter: RustWriter, + operationShape: OperationShape, + ) { + traitGenerator.generateTraitImpls(operationWriter, operationShape, emptyList()) + } +} diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 237b38aa44..83887daf03 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -23,27 +23,27 @@ import software.amazon.smithy.protocoltests.traits.HttpRequestTestCase import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait import software.amazon.smithy.protocoltests.traits.HttpResponseTestCase import software.amazon.smithy.protocoltests.traits.HttpResponseTestsTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWords -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.Instantiator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.transformers.allErrors import software.amazon.smithy.rust.codegen.client.testutil.TokioTest +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember @@ -68,7 +68,7 @@ private const val PROTOCOL_TEST_HELPER_MODULE_NAME = "protocol_test_helper" class ServerProtocolTestGenerator( private val coreCodegenContext: CoreCodegenContext, private val protocolSupport: ProtocolSupport, - private val protocolGenerator: ProtocolGenerator, + private val protocolGenerator: ServerProtocolGenerator, ) { private val logger = Logger.getLogger(javaClass.name) @@ -145,7 +145,7 @@ class ServerProtocolTestGenerator( renderTestHelper(writer) for (operation in operations) { - protocolGenerator.serverRenderOperation(writer, operation) + protocolGenerator.renderOperation(writer, operation) renderOperationTestCases(operation, writer) } } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt index c93caca67f..847cb02e94 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt @@ -6,21 +6,21 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols import software.amazon.smithy.model.traits.ErrorTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJsonVersion -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.client.smithy.protocols.awsJsonFieldName -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.JsonCustomization -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.JsonSection -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.JsonSerializerGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.StructuredDataSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonCustomization +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonSection +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerAwsJsonProtocol import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt index ce26142120..bc294218fe 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt @@ -24,44 +24,44 @@ import software.amazon.smithy.model.traits.HttpErrorTrait import software.amazon.smithy.model.traits.HttpPayloadTrait import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.MediaTypeTrait -import software.amazon.smithy.rust.codegen.client.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.conditionalBlock -import software.amazon.smithy.rust.codegen.client.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.extractSymbolFromOption -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.TypeConversionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.builderSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.http.HttpMessageType -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.MakeOperationGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolTraitImplGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.setterName -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBindingDescriptor -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolPayloadGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.client.smithy.toOptional -import software.amazon.smithy.rust.codegen.client.smithy.transformers.operationErrors -import software.amazon.smithy.rust.codegen.client.smithy.wrapOptional +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.extractSymbolFromOption +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.TypeConversionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtocolPayloadGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.toOptional +import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors +import software.amazon.smithy.rust.codegen.core.smithy.wrapOptional import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait @@ -79,9 +79,10 @@ import software.amazon.smithy.rust.codegen.server.smithy.ServerRuntimeType import software.amazon.smithy.rust.codegen.server.smithy.generators.http.ServerRequestBindingGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.http.ServerResponseBindingGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import java.util.logging.Logger -/* +/** * Implement operations' input parsing and output serialization. Protocols can plug their own implementations * and overrides by creating a protocol factory inheriting from this class and feeding it to the [ServerProtocolLoader]. * See `ServerRestJsonFactory.kt` for more info. @@ -89,7 +90,7 @@ import java.util.logging.Logger class ServerHttpBoundProtocolGenerator( codegenContext: ServerCodegenContext, protocol: ServerProtocol, -) : ProtocolGenerator( +) : ServerProtocolGenerator( codegenContext, protocol, MakeOperationGenerator( @@ -535,7 +536,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( val bindings = httpBindingResolver.errorResponseBindings(it) - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rustTemplate("let mut builder = #{http}::Response::builder();", *codegenScope) serverRenderResponseHeaders(operationShape, variantShape) @@ -571,7 +572,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( operationShape: OperationShape, bindings: List, ) { - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rustTemplate("let mut builder = #{http}::Response::builder();", *codegenScope) serverRenderResponseHeaders(operationShape) bindings.find { it.location == HttpLocation.RESPONSE_CODE } @@ -738,7 +739,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( ) { val httpBindingGenerator = ServerRequestBindingGenerator(protocol, codegenContext, operationShape) val structuredDataParser = protocol.structuredDataParser(operationShape) - Attribute.AllowUnusedMut.render(this) + software.amazon.smithy.rust.codegen.core.rustlang.Attribute.AllowUnusedMut.render(this) rust("let mut input = #T::default();", inputShape.builderSymbol(symbolProvider)) val parser = structuredDataParser.serverInputParser(operationShape) val noInputs = model.expectShape(operationShape.inputShape).expectTrait().originalId == null @@ -992,7 +993,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( rustTemplate( "let mut query_params: #{HashMap} = #{HashMap}::new();", - "HashMap" to RustType.HashMap.RuntimeType, + "HashMap" to software.amazon.smithy.rust.codegen.core.rustlang.RustType.HashMap.RuntimeType, ) } val (queryBindingsTargettingCollection, queryBindingsTargettingSimple) = diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerProtocolLoader.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerProtocolLoader.kt index 827230f2cc..4fb304b499 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerProtocolLoader.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerProtocolLoader.kt @@ -11,11 +11,12 @@ import software.amazon.smithy.aws.traits.protocols.RestJson1Trait import software.amazon.smithy.aws.traits.protocols.RestXmlTrait import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJsonVersion -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolLoader -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolMap +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolLoader +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator -class ServerProtocolLoader(supportedProtocols: ProtocolMap) : - ProtocolLoader(supportedProtocols) { +class ServerProtocolLoader(supportedProtocols: ProtocolMap) : + ProtocolLoader(supportedProtocols) { companion object { val DefaultProtocols = mapOf( diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt index 88b299a643..aa49a6c877 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt @@ -6,10 +6,10 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerRestJsonProtocol /** diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt index 6adf59900e..80d12b87c5 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt @@ -6,10 +6,10 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ProtocolSupport -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerRestXmlProtocol /* diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt index e6e930e631..136894afe3 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt @@ -10,12 +10,12 @@ import software.amazon.smithy.model.knowledge.NullableIndex import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenConfig import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerRustSettings -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.server.smithy.RustCodegenServerPlugin diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt index a1d1a7d7a8..5e6bc2a6da 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt @@ -9,7 +9,7 @@ import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt index bbd64783cb..e9176df8a6 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt @@ -8,9 +8,9 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.ServerCombinedErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt index 868a2898e4..4141840f26 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt @@ -18,16 +18,16 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.CombinedErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.error.ServerCombinedErrorGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.implBlock -import software.amazon.smithy.rust.codegen.client.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.CombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJson import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJsonVersion import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsQueryProtocol @@ -35,8 +35,8 @@ import software.amazon.smithy.rust.codegen.client.smithy.protocols.Ec2QueryProto import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml -import software.amazon.smithy.rust.codegen.client.smithy.transformers.EventStreamNormalizer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.TestWriterDelegator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel @@ -47,7 +47,6 @@ import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider import java.util.stream.Stream -import kotlin.streams.toList private fun fillInBaseModel( protocolName: String, diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt index b10b3f4f61..5c0692d724 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt @@ -9,8 +9,8 @@ import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.generators.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.EventStreamUnmarshallerGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt index 97c57d4615..2bbdba75b7 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt @@ -11,7 +11,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.EventStreamMarshallerGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest From 8bdb97b9f5f2c13f0e052e5b2df657fe41e6f8ef Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 18:36:32 +0200 Subject: [PATCH 02/18] server-unit-tests work --- .../server/smithy/ServerCodegenVisitorTest.kt | 3 +- .../ServerCombinedErrorGeneratorTest.kt | 2 +- .../generators/ServerEnumGeneratorTest.kt | 2 +- .../ServerHttpSensitivityGeneratorTest.kt | 8 ++--- .../ServerOperationRegistryGeneratorTest.kt | 2 +- .../smithy/protocols/EventStreamTestTools.kt | 33 ++++++++++--------- .../EventStreamUnmarshallerGeneratorTest.kt | 8 ++--- .../EventStreamMarshallerGeneratorTest.kt | 12 +++---- .../customize/CombinedCodegenDecoratorTest.kt | 10 +++--- 9 files changed, 42 insertions(+), 38 deletions(-) diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitorTest.kt index bbbdf07ba5..3b496f1d28 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitorTest.kt @@ -13,6 +13,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodeg import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import kotlin.io.path.createDirectory import kotlin.io.path.writeText @@ -48,7 +49,7 @@ class ServerCodegenVisitorTest { val (ctx, testDir) = generatePluginContext(model) testDir.resolve("src").createDirectory() testDir.resolve("src/main.rs").writeText("fn main() {}") - val codegenDecorator: CombinedCodegenDecorator = + val codegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath(ctx, ServerRequiredCustomizations()) val visitor = ServerCodegenVisitor(ctx, codegenDecorator) val baselineModel = visitor.baselineTransformInternalTest(model) diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt index e9176df8a6..5b9b65ce3b 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt @@ -7,7 +7,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer @@ -16,6 +15,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilder import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGeneratorTest.kt index 1f972cb316..85f4b2e3f3 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGeneratorTest.kt @@ -8,10 +8,10 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import io.kotest.matchers.string.shouldNotContain import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StringShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt index 7d3db149da..5a58af7c8d 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt @@ -12,10 +12,10 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.traits.HttpHeaderTrait import software.amazon.smithy.model.traits.HttpResponseCodeTrait import software.amazon.smithy.model.traits.HttpTrait -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGeneratorTest.kt index ebf9b67ab6..3f3de45222 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGeneratorTest.kt @@ -9,8 +9,8 @@ import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test import software.amazon.smithy.model.knowledge.TopDownIndex import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerProtocolLoader diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt index 4141840f26..e3492261df 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.smithy.protocols +package software.amazon.smithy.rust.codegen.server.smithy.protocols import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments @@ -16,37 +16,38 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.ErrorTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.CombinedErrorGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock -import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJson import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJsonVersion import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsQueryProtocol import software.amazon.smithy.rust.codegen.client.smithy.protocols.Ec2QueryProtocol -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml -import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.TestWriterDelegator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilder import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.CombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider import java.util.stream.Stream +import kotlin.streams.toList private fun fillInBaseModel( protocolName: String, diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt index 5c0692d724..62d1a87415 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt @@ -8,16 +8,16 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols.parse import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.client.smithy.protocols.parse.EventStreamUnmarshallerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings import software.amazon.smithy.rust.codegen.client.testutil.unitTest -import software.amazon.smithy.rust.codegen.smithy.protocols.EventStreamTestModels -import software.amazon.smithy.rust.codegen.smithy.protocols.EventStreamTestTools +import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels +import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestTools class EventStreamUnmarshallerGeneratorTest { @ParameterizedTest diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt index 2bbdba75b7..237866ef05 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt @@ -8,18 +8,18 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols.serialize import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.protocols.serialize.EventStreamMarshallerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.EventStreamMarshallerGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.util.dq -import software.amazon.smithy.rust.codegen.smithy.protocols.EventStreamTestModels -import software.amazon.smithy.rust.codegen.smithy.protocols.EventStreamTestTools +import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels +import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestTools class EventStreamMarshallerGeneratorTest { @ParameterizedTest diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/CombinedCodegenDecoratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/CombinedCodegenDecoratorTest.kt index 3d6affbbc2..8277de48af 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/CombinedCodegenDecoratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/CombinedCodegenDecoratorTest.kt @@ -12,15 +12,17 @@ import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator internal class CombinedCodegenDecoratorTest { - private val clientDecorator: RustCodegenDecorator = RequiredCustomizations() - private val serverDecorator: RustCodegenDecorator = ServerRequiredCustomizations() + private val clientDecorator: RustCodegenDecorator = RequiredCustomizations() + private val serverDecorator: RustCodegenDecorator = ServerRequiredCustomizations() @Test fun filterClientDecorators() { - val filteredDecorators = CombinedCodegenDecorator.filterDecorators( + val filteredDecorators = CombinedCodegenDecorator.filterDecorators( listOf(clientDecorator, serverDecorator), ).toList() @@ -29,7 +31,7 @@ internal class CombinedCodegenDecoratorTest { @Test fun filterServerDecorators() { - val filteredDecorators = CombinedCodegenDecorator.filterDecorators( + val filteredDecorators = CombinedCodegenDecorator.filterDecorators( listOf(clientDecorator, serverDecorator), ).toList() From a0da58e3b9f869a886f9f8ae6ab4403f28899fc0 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 19:16:06 +0200 Subject: [PATCH 03/18] client-unit-tests work --- .../rust/codegen/client/SymbolBuilderTest.kt | 14 ++--- .../HttpVersionListGeneratorTest.kt | 23 ++++---- .../SmithyTypesPubUseGeneratorTest.kt | 2 +- .../client/generators/EnumGeneratorTest.kt | 4 +- .../generators/GenericsGeneratorTest.kt | 6 +- .../generators/StructureGeneratorTest.kt | 20 +++---- .../client/generators/UnionGeneratorTest.kt | 4 +- .../http/RequestBindingGeneratorTest.kt | 10 ++-- .../http/ResponseBindingGeneratorTest.kt | 20 +++---- .../client/rustlang/InlineDependencyTest.kt | 7 ++- .../RustReservedWordSymbolProviderTest.kt | 7 ++- .../codegen/client/rustlang/RustTypesTest.kt | 3 + .../codegen/client/rustlang/RustWriterTest.kt | 11 +++- .../client/rustlang/UseDeclarationsTest.kt | 1 + .../codegen/client/rustlang/WritableTest.kt | 10 +++- .../client/smithy/CodegenDelegatorTest.kt | 7 ++- .../smithy/EventStreamSymbolProviderTest.kt | 2 + .../codegen/client/smithy/RuntimeTypesTest.kt | 11 +++- .../StreamingShapeSymbolProviderTest.kt | 2 + .../smithy/generators/BuilderGeneratorTest.kt | 15 ++--- .../generators/CargoTomlGeneratorTest.kt | 4 +- .../generators/CombinedErrorGeneratorTest.kt | 6 +- .../generators/EndpointTraitBindingsTest.kt | 19 ++++--- .../smithy/generators/InstantiatorTest.kt | 12 ++-- .../config/ServiceConfigGeneratorTest.kt | 10 ++-- .../protocol/ProtocolTestGeneratorTest.kt | 56 ++++++++++--------- .../protocols/InlineFunctionNamerTest.kt | 2 + .../parse/AwsQueryParserGeneratorTest.kt | 9 +-- .../parse/Ec2QueryParserGeneratorTest.kt | 9 +-- .../parse/JsonParserGeneratorTest.kt | 7 ++- .../XmlBindingTraitParserGeneratorTest.kt | 13 +++-- .../AwsQuerySerializerGeneratorTest.kt | 13 +++-- .../Ec2QuerySerializerGeneratorTest.kt | 11 ++-- .../serialize/JsonSerializerGeneratorTest.kt | 15 ++--- .../XmlBindingTraitSerializerGeneratorTest.kt | 15 ++--- .../transformers/RecursiveShapeBoxerTest.kt | 1 + .../RecursiveShapesIntegrationTest.kt | 6 +- .../client/testutil/AddRustTestsDecorator.kt | 10 ++-- .../codegen/client/util/SyntheticsTest.kt | 2 + .../codegen/core/smithy/CodegenDelegator.kt | 2 +- 40 files changed, 228 insertions(+), 173 deletions(-) diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt index 97631dc423..640cfc46fa 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/SymbolBuilderTest.kt @@ -26,15 +26,15 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.SparseTrait -import software.amazon.smithy.rust.codegen.core.rustlang.RustType -import software.amazon.smithy.rust.codegen.core.rustlang.render -import software.amazon.smithy.rust.codegen.client.smithy.Errors -import software.amazon.smithy.rust.codegen.client.smithy.Models -import software.amazon.smithy.rust.codegen.client.smithy.Operations -import software.amazon.smithy.rust.codegen.client.smithy.isOptional -import software.amazon.smithy.rust.codegen.client.smithy.rustType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.smithy.Errors +import software.amazon.smithy.rust.codegen.core.smithy.Models +import software.amazon.smithy.rust.codegen.core.smithy.Operations +import software.amazon.smithy.rust.codegen.core.smithy.isOptional +import software.amazon.smithy.rust.codegen.core.smithy.rustType class SymbolBuilderTest { private fun Symbol.referenceClosure(): List { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt index ef5188e9bf..d36fdac071 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt @@ -6,23 +6,24 @@ package software.amazon.smithy.rust.codegen.client.customizations import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.client.testutil.AddRustTestsDecorator import software.amazon.smithy.rust.codegen.client.testutil.TokioTest import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.runCommand // If any of these tests fail, and you want to understand why, run them with logging: @@ -58,7 +59,7 @@ internal class HttpVersionListGeneratorTest { """.asSmithyModel() val (ctx, testDir) = generatePluginContext(model) val moduleName = ctx.settings.expectStringMember("module").value.replace('-', '_') - val combinedCodegenDecorator: CombinedCodegenDecorator = + val combinedCodegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath(ctx, RequiredCustomizations()) .withDecorator( AddRustTestsDecorator("validate_defaults") { @@ -114,7 +115,7 @@ internal class HttpVersionListGeneratorTest { """.asSmithyModel() val (ctx, testDir) = generatePluginContext(model) val moduleName = ctx.settings.expectStringMember("module").value.replace('-', '_') - val combinedCodegenDecorator: CombinedCodegenDecorator = + val combinedCodegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath(ctx, RequiredCustomizations()) .withDecorator( AddRustTestsDecorator("validate_http") { @@ -184,9 +185,9 @@ internal class HttpVersionListGeneratorTest { val (ctx, testDir) = generatePluginContext(model, addModuleToEventStreamAllowList = true) val moduleName = ctx.settings.expectStringMember("module").value.replace('-', '_') - val combinedCodegenDecorator: CombinedCodegenDecorator = + val combinedCodegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath(ctx, RequiredCustomizations()) - .withDecorator(object : AddRustTestsDecorator("validate_eventstream_http", { + .withDecorator(object : AddRustTestsDecorator("validate_eventstream_http", { TokioTest.render(this) rust( """ diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt index f499693c9a..a20694d81f 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rust.codegen.client.customizations import org.junit.jupiter.api.Test import software.amazon.smithy.model.Model -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customizations.pubUseTypes import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt index daf9c2aeea..1d4da7cc09 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt @@ -11,8 +11,8 @@ import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.EnumTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumMemberModel import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt index 9e6d25f9e9..ceb71e3e2a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt @@ -7,9 +7,9 @@ package software.amazon.smithy.rust.codegen.client.generators import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt index b3cd309618..7f9b771a09 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/StructureGeneratorTest.kt @@ -10,21 +10,21 @@ import io.kotest.matchers.string.shouldNotContain import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.core.rustlang.Attribute -import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.raw -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.raw +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.lookup class StructureGeneratorTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt index 282faf3a50..4a259a4a36 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt @@ -8,8 +8,8 @@ package software.amazon.smithy.rust.codegen.client.generators import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test import software.amazon.smithy.codegen.core.SymbolProvider -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt index 669305ee05..756c5786ff 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt @@ -11,11 +11,11 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.HttpTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RequestBindingGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.http.uriFormatString import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt index 1e7418fa37..f0eaefd6da 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt @@ -8,17 +8,7 @@ package software.amazon.smithy.rust.codegen.client.generators.http import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.generators.http.ResponseBindingGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpLocation -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -26,6 +16,16 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.ResponseBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.outputShape class ResponseBindingGeneratorTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/InlineDependencyTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/InlineDependencyTest.kt index 972bfbd924..52103a35de 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/InlineDependencyTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/InlineDependencyTest.kt @@ -9,9 +9,14 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.InlineDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock internal class InlineDependencyTest { - fun makeDep(name: String) = InlineDependency(name, RustModule.private("module")) { + private fun makeDep(name: String) = InlineDependency(name, RustModule.private("module")) { it.rustBlock("fn foo()") {} } diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWordSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWordSymbolProviderTest.kt index ba0849d1c1..36904eab7d 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWordSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustReservedWordSymbolProviderTest.kt @@ -11,10 +11,11 @@ import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.traits.EnumDefinition -import software.amazon.smithy.rust.codegen.client.smithy.MaybeRenamed -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.core.util.PANIC import software.amazon.smithy.rust.codegen.core.util.orNull import software.amazon.smithy.rust.codegen.core.util.toPascalCase diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt index a6fb784010..b9f36e3560 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustTypesTest.kt @@ -9,7 +9,10 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.render +import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate internal class RustTypesTest { private fun forInputExpectOutput(t: Writable, expectedOutput: String) { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt index 1862aa1263..2996c04b15 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt @@ -15,14 +15,23 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.SetShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndRun import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.shouldCompile import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.rustlang.Attribute +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.isEmpty +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.util.lookup class RustWriterTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarationsTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarationsTest.kt index da53e8a05f..0d88defcad 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarationsTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/UseDeclarationsTest.kt @@ -8,6 +8,7 @@ package software.amazon.smithy.rust.codegen.client.rustlang import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.testutil.shouldCompile +import software.amazon.smithy.rust.codegen.core.rustlang.UseDeclarations class UseDeclarationsTest { private fun useDecl() = UseDeclarations("test") diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt index 72d2b5216e..14b67f7503 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt @@ -7,10 +7,16 @@ package software.amazon.smithy.rust.codegen.client.rustlang import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.join +import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator -import software.amazon.smithy.rust.codegen.core.rustlang.RustType internal class RustTypeParametersTest { private fun forInputExpectOutput(input: Any, expectedOutput: String) { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegatorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegatorTest.kt index f2de828082..c2e47b6993 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegatorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenDelegatorTest.kt @@ -7,9 +7,10 @@ package software.amazon.smithy.rust.codegen.client.smithy import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope.Compile +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope.Compile +import software.amazon.smithy.rust.codegen.core.smithy.mergeDependencyFeatures class CodegenDelegatorTest { @Test diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt index 24aef6912c..706dd5075a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt @@ -16,6 +16,8 @@ import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNor import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestSymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.core.smithy.rustType class EventStreamSymbolProviderTest { @Test diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypesTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypesTest.kt index d85bd0e973..074a2f83ed 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypesTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RuntimeTypesTest.kt @@ -11,9 +11,14 @@ import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import software.amazon.smithy.model.node.Node -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyLocation -import software.amazon.smithy.rust.codegen.client.rustlang.Local +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyLocation +import software.amazon.smithy.rust.codegen.core.rustlang.Local +import software.amazon.smithy.rust.codegen.core.smithy.CrateVersionMap +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeCrateLocation +import software.amazon.smithy.rust.codegen.core.smithy.crateLocation +import software.amazon.smithy.rust.codegen.core.smithy.defaultRuntimeCrateVersion import java.util.Optional class RuntimeTypesTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt index 3e17f8404f..a4f9a37669 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt @@ -11,6 +11,8 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.Default +import software.amazon.smithy.rust.codegen.core.smithy.defaultValue import software.amazon.smithy.rust.codegen.core.util.lookup internal class StreamingShapeSymbolProviderTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt index 561565ceb5..f51b343145 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt @@ -11,17 +11,18 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.traits.EnumDefinition import software.amazon.smithy.rust.codegen.client.generators.StructureGeneratorTest -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.smithy.Default -import software.amazon.smithy.rust.codegen.client.smithy.MaybeRenamed -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig -import software.amazon.smithy.rust.codegen.client.smithy.setDefault +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.smithy.Default +import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.setDefault import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock internal class BuilderGeneratorTest { private val model = StructureGeneratorTest.model diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGeneratorTest.kt index 39492f974e..c31aecfaf5 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CargoTomlGeneratorTest.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.Version +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo class CargoTomlGeneratorTest { private val CargoMetadata: CargoDependency = CargoDependency("cargo_metadata", CratesIo("0.15.0")) diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt index e92c2b3d94..92f44feb44 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/CombinedErrorGeneratorTest.kt @@ -7,15 +7,15 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.CombinedErrorGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilder import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.CombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.lookup class CombinedErrorGeneratorTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt index 18e4f3090a..2db9557b77 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt @@ -9,17 +9,12 @@ import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.EndpointTrait -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.TokioTest @@ -28,6 +23,14 @@ import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.Visibility +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.runCommand import kotlin.io.path.ExperimentalPathApi @@ -144,7 +147,7 @@ internal class EndpointTraitBindingsTest { """.asSmithyModel() val (ctx, testDir) = generatePluginContext(model) val moduleName = ctx.settings.expectStringMember("module").value.replace('-', '_') - val codegenDecorator = object : RustCodegenDecorator { + val codegenDecorator = object : RustCodegenDecorator { override val name: String = "add tests" override val order: Byte = 0 @@ -176,7 +179,7 @@ internal class EndpointTraitBindingsTest { override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } - val combinedCodegenDecorator: CombinedCodegenDecorator = + val combinedCodegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath(ctx, RequiredCustomizations()).withDecorator(codegenDecorator) val visitor = CodegenVisitor(ctx, combinedCodegenDecorator) visitor.execute() diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt index fb5087ff03..6d47fff4ca 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/InstantiatorTest.kt @@ -12,20 +12,20 @@ import software.amazon.smithy.model.shapes.BlobShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.raw -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilder import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.raw +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt index 2f7fbf656d..3afcc7d08a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt @@ -8,16 +8,16 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.config import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.customize.NamedSectionGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator import software.amazon.smithy.rust.codegen.core.util.lookup internal class ServiceConfigGeneratorTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt index b75c467d99..07bb78c078 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt @@ -11,27 +11,28 @@ import org.junit.jupiter.api.assertThrows import software.amazon.smithy.aws.traits.protocols.RestJson1Trait import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.escape -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolPayloadGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.dq @@ -97,7 +98,7 @@ private class TestProtocolGenerator( httpRequestBuilder: String, body: String, correctResponse: String, -) : ProtocolGenerator( +) : ClientProtocolGenerator( coreCodegenContext, protocol, TestProtocolMakeOperationGenerator(coreCodegenContext, protocol, body, httpRequestBuilder), @@ -108,12 +109,12 @@ private class TestProtocolFactory( private val httpRequestBuilder: String, private val body: String, private val correctResponse: String, -) : ProtocolGeneratorFactory { +) : ProtocolGeneratorFactory { override fun protocol(codegenContext: ClientCodegenContext): Protocol { return RestJson(codegenContext) } - override fun buildProtocolGenerator(codegenContext: ClientCodegenContext): ProtocolGenerator { + override fun buildProtocolGenerator(codegenContext: ClientCodegenContext): ClientProtocolGenerator { return TestProtocolGenerator( codegenContext, protocol(codegenContext), @@ -225,21 +226,22 @@ class ProtocolTestGeneratorTest { correctResponse: String = """Ok(crate::output::SayHelloOutput::builder().value("hey there!").build())""", ): Path { val (pluginContext, testDir) = generatePluginContext(model) + val codegenDecorator = object : RustCodegenDecorator { + override val name: String = "mock" + override val order: Byte = 0 + override fun protocols( + serviceId: ShapeId, + currentProtocols: ProtocolMap, + ): ProtocolMap = + // Intentionally replace the builtin implementation of RestJson1 with our fake protocol + mapOf(RestJson1Trait.ID to TestProtocolFactory(httpRequestBuilder, body, correctResponse)) + + override fun supportsCodegenContext(clazz: Class): Boolean = + clazz.isAssignableFrom(ClientCodegenContext::class.java) + } val visitor = CodegenVisitor( pluginContext, - object : RustCodegenDecorator { - override val name: String = "mock" - override val order: Byte = 0 - override fun protocols( - serviceId: ShapeId, - currentProtocols: ProtocolMap, - ): ProtocolMap = - // Intentionally replace the builtin implementation of RestJson1 with our fake protocol - mapOf(RestJson1Trait.ID to TestProtocolFactory(httpRequestBuilder, body, correctResponse)) - - override fun supportsCodegenContext(clazz: Class): Boolean = - clazz.isAssignableFrom(ClientCodegenContext::class.java) - }, + codegenDecorator, ) visitor.execute() println("file:///$testDir/src/operation.rs") diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamerTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamerTest.kt index 996d445340..623b4d1ac4 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamerTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/InlineFunctionNamerTest.kt @@ -10,6 +10,8 @@ import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.protocols.deserializeFunctionName +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serializeFunctionName import software.amazon.smithy.rust.codegen.core.util.lookup class InlineFunctionNamerTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt index 278b946538..638e4bc59d 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/AwsQueryParserGeneratorTest.kt @@ -8,10 +8,6 @@ package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel @@ -20,6 +16,11 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.AwsQueryParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt index fb5ef0d349..aac9f12ed7 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/Ec2QueryParserGeneratorTest.kt @@ -8,10 +8,6 @@ package software.amazon.smithy.rust.codegen.client.smithy.protocols.parse import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel @@ -20,6 +16,11 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.Ec2QueryParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt index 3753a5f4e2..b0bd2b0422 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt @@ -9,11 +9,11 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.restJsonFieldName import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer @@ -24,6 +24,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.JsonParserGenerator import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt index 5773c7cc3b..b5dea3f9fe 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/XmlBindingTraitParserGeneratorTest.kt @@ -9,12 +9,6 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel @@ -23,6 +17,13 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.XmlBindingTraitParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt index 4378b28473..400d4c6b80 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/AwsQuerySerializerGeneratorTest.kt @@ -10,12 +10,6 @@ import org.junit.jupiter.params.provider.CsvSource import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -23,6 +17,13 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.AwsQuerySerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt index 76bb836c15..512fcd9aa5 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/Ec2QuerySerializerGeneratorTest.kt @@ -9,11 +9,6 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -21,6 +16,12 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.Ec2QuerySerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt index 1053ba9df9..be3341700a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt @@ -9,14 +9,7 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.restJsonFieldName -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -24,6 +17,14 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt index c531ec2825..e352da919a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/serialize/XmlBindingTraitSerializerGeneratorTest.kt @@ -9,13 +9,6 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpTraitHttpBindingResolver -import software.amazon.smithy.rust.codegen.client.smithy.protocols.ProtocolContentTypes -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -23,6 +16,14 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes +import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.XmlBindingTraitSerializerGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt index 60c20f01d2..f6e37612c9 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt @@ -14,6 +14,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveSha import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.lookup +import kotlin.streams.toList internal class RecursiveShapeBoxerTest { @Test diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt index 9d15eb7cea..67b73e77c3 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapesIntegrationTest.kt @@ -10,12 +10,12 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.lookup diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt index 7227867146..53d3194edc 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt @@ -4,15 +4,15 @@ */ package software.amazon.smithy.rust.codegen.client.testutil -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -open class AddRustTestsDecorator( +open class AddRustTestsDecorator( private val testsFileName: String, private val testWritable: Writable, -) : RustCodegenDecorator { +) : RustCodegenDecorator { override val name: String = "add tests" override val order: Byte = 0 diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/util/SyntheticsTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/util/SyntheticsTest.kt index a2058bc83c..1feaf49662 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/util/SyntheticsTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/util/SyntheticsTest.kt @@ -11,7 +11,9 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.util.cloneOperation import software.amazon.smithy.rust.codegen.core.util.orNull +import software.amazon.smithy.rust.codegen.core.util.rename class SyntheticsTest { @Test diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt index 232432aa60..1dd4201f46 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenDelegator.kt @@ -203,7 +203,7 @@ private fun CargoDependency.mergeWith(other: CargoDependency): CargoDependency { ) } -internal fun mergeDependencyFeatures(cargoDependencies: List): List = +fun mergeDependencyFeatures(cargoDependencies: List): List = cargoDependencies.groupBy { it.key } .mapValues { group -> group.value.reduce { acc, next -> acc.mergeWith(next) } } .values From 0ff4694caaf3f98f7d0e4a6e992fd1de8d2a32d8 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 19:39:24 +0200 Subject: [PATCH 04/18] sdk works --- .../smithy/rustsdk/AwsCodegenDecorator.kt | 3 +- .../smithy/rustsdk/AwsEndpointDecorator.kt | 37 +++++++++--------- .../rustsdk/AwsFluentClientDecorator.kt | 34 ++++++++++------- .../smithy/rustsdk/AwsPresigningDecorator.kt | 38 ++++++++++--------- .../smithy/rustsdk/AwsReadmeDecorator.kt | 7 ++-- .../smithy/rustsdk/AwsRuntimeDependency.kt | 10 ++--- .../smithy/rustsdk/CrateLicenseDecorator.kt | 9 +++-- .../smithy/rustsdk/CredentialProviders.kt | 31 ++++++++------- .../rustsdk/HttpRequestChecksumDecorator.kt | 23 +++++------ .../rustsdk/HttpResponseChecksumDecorator.kt | 13 ++++--- .../smithy/rustsdk/InlineAwsDependency.kt | 4 +- .../rustsdk/IntegrationTestDependencies.kt | 19 +++++----- .../amazon/smithy/rustsdk/RegionDecorator.kt | 23 +++++------ .../rustsdk/RetryClassifierDecorator.kt | 19 +++++----- .../smithy/rustsdk/SdkConfigDecorator.kt | 19 +++++----- .../smithy/rustsdk/ServiceConfigDecorator.kt | 11 +++--- .../smithy/rustsdk/SigV4SigningDecorator.kt | 23 +++++------ .../smithy/rustsdk/UserAgentDecorator.kt | 25 ++++++------ .../apigateway/ApiGatewayDecorator.kt | 15 ++++---- .../customize/auth/DisabledAuthDecorator.kt | 5 ++- .../rustsdk/customize/ec2/Ec2Decorator.kt | 5 ++- .../customize/glacier/AccountIdAutofill.kt | 6 +-- .../customize/glacier/ApiVersionHeader.kt | 8 ++-- .../customize/glacier/GlacierDecorator.kt | 7 ++-- .../customize/glacier/TreeHashHeader.kt | 14 +++---- .../customize/route53/Route53Decorator.kt | 15 ++++---- .../rustsdk/customize/s3/S3Decorator.kt | 23 ++++------- .../rustsdk/customize/sts/STSDecorator.kt | 5 ++- 28 files changed, 237 insertions(+), 214 deletions(-) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt index f63e7078d8..aec623d221 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt @@ -9,6 +9,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customizations.DocsRsMetadataDecorator import software.amazon.smithy.rust.codegen.client.smithy.customizations.DocsRsMetadataSettings import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rustsdk.customize.apigateway.ApiGatewayDecorator import software.amazon.smithy.rustsdk.customize.auth.DisabledAuthDecorator import software.amazon.smithy.rustsdk.customize.ec2.Ec2Decorator @@ -48,7 +49,7 @@ val DECORATORS = listOf( DocsRsMetadataDecorator(DocsRsMetadataSettings(targets = listOf("x86_64-unknown-linux-gnu"), allFeatures = true)), ) -class AwsCodegenDecorator : CombinedCodegenDecorator(DECORATORS) { +class AwsCodegenDecorator : CombinedCodegenDecorator(DECORATORS) { override val name: String = "AwsSdkCodegenDecorator" override val order: Byte = -1 } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt index fa101057c9..42593f180a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt @@ -11,35 +11,36 @@ import software.amazon.smithy.model.node.Node import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.node.StringNode import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.client.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.orNull import kotlin.io.path.readText -class AwsEndpointDecorator : RustCodegenDecorator { +class AwsEndpointDecorator : RustCodegenDecorator { override val name: String = "AwsEndpoint" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index 309a53d62e..c12f4a95ed 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -9,21 +9,21 @@ import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.TitleTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope -import software.amazon.smithy.rust.codegen.client.rustlang.Feature -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator @@ -33,6 +33,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.client.Fluen import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerics import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientSection +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware @@ -74,7 +75,12 @@ private class AwsClientGenerics(private val types: Types) : FluentClientGenerics override val bounds = writable { } /** Bounds for generated `send()` functions */ - override fun sendBounds(operation: Symbol, operationOutput: Symbol, operationError: RuntimeType, retryClassifier: RuntimeType): Writable = + override fun sendBounds( + operation: Symbol, + operationOutput: Symbol, + operationError: RuntimeType, + retryClassifier: RuntimeType, + ): Writable = writable { } override fun toGenericsGenerator(): GenericsGenerator { @@ -82,7 +88,7 @@ private class AwsClientGenerics(private val types: Types) : FluentClientGenerics } } -class AwsFluentClientDecorator : RustCodegenDecorator { +class AwsFluentClientDecorator : RustCodegenDecorator { override val name: String = "FluentClient" // Must run after the AwsPresigningDecorator so that the presignable trait is correctly added to operations @@ -122,6 +128,7 @@ class AwsFluentClientDecorator : RustCodegenDecorator { Attribute.DocInline.render(this) rust("pub use client::Client;") } + else -> emptySection } } @@ -263,6 +270,7 @@ private class AwsFluentClientDocs(private val coreCodegenContext: CoreCodegenCon ) } } + else -> emptySection } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt index 4f16d9b7de..7eebb3b1c3 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt @@ -16,33 +16,35 @@ import software.amazon.smithy.model.shapes.ToShapeId import software.amazon.smithy.model.traits.HttpQueryTrait import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientSection +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator -import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolPayloadGenerator -import software.amazon.smithy.rust.codegen.client.util.cloneOperation +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtocolPayloadGenerator +import software.amazon.smithy.rust.codegen.core.util.cloneOperation import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware import software.amazon.smithy.rustsdk.traits.PresignableTrait +import kotlin.streams.toList internal enum class PayloadSigningType { EMPTY, @@ -84,7 +86,7 @@ internal val PRESIGNABLE_OPERATIONS by lazy { class AwsPresigningDecorator internal constructor( private val presignableOperations: Map = PRESIGNABLE_OPERATIONS, -) : RustCodegenDecorator { +) : RustCodegenDecorator { companion object { const val ORDER: Byte = 0 } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt index 7d14681b31..5217f65112 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt @@ -9,11 +9,12 @@ import org.jsoup.Jsoup import org.jsoup.nodes.Element import org.jsoup.nodes.TextNode import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.client.rustlang.raw +import software.amazon.smithy.rust.codegen.core.rustlang.raw import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations import software.amazon.smithy.rust.codegen.core.util.getTrait import java.util.logging.Logger @@ -26,7 +27,7 @@ private const val SPACE_SIGIL = "[[smithy-rs-nbsp]]" /** * Generates a README.md for each service crate for display on crates.io. */ -class AwsReadmeDecorator : RustCodegenDecorator { +class AwsReadmeDecorator : RustCodegenDecorator { override val name: String = "AwsReadmeDecorator" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt index 0cefde5eda..eb87bf56dd 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeDependency.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.codegen.core.CodegenException -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Visibility -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeCrateLocation -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.crateLocation +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeCrateLocation +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.crateLocation import java.io.File import java.nio.file.Path diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt index 65076ba540..d1d6067a4a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt @@ -5,13 +5,14 @@ package software.amazon.smithy.rustsdk -import software.amazon.smithy.rust.codegen.client.rustlang.raw import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.raw +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -class CrateLicenseDecorator : RustCodegenDecorator { +class CrateLicenseDecorator : RustCodegenDecorator { override val name: String = "CrateLicense" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt index ee523e7a8d..e6539d2a98 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt @@ -6,24 +6,25 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig -class CredentialsProviderDecorator : RustCodegenDecorator { +class CredentialsProviderDecorator : RustCodegenDecorator { override val name: String = "CredentialsProvider" override val order: Byte = 0 @@ -75,7 +76,7 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati is ServiceConfig.BuilderStruct -> rustTemplate( "credentials_provider: Option<#{credentials}::SharedCredentialsProvider>,", - *codegenScope + *codegenScope, ) ServiceConfig.BuilderImpl -> { @@ -116,6 +117,7 @@ class CredentialsProviderFeature(private val runtimeConfig: RuntimeConfig) : Ope setProvider(runtimeConfig), ) } + else -> emptySection } } @@ -127,9 +129,10 @@ class PubUseCredentials(private val runtimeConfig: RuntimeConfig) : LibRsCustomi is LibRsSection.Body -> writable { rust( "pub use #T::Credentials;", - awsTypes(runtimeConfig).asType() + awsTypes(runtimeConfig).asType(), ) } + else -> emptySection } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt index 9debb12d98..d73b543f01 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt @@ -7,19 +7,20 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.aws.traits.HttpChecksumTrait import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.util.expectMember import software.amazon.smithy.rust.codegen.core.util.getTrait @@ -41,7 +42,7 @@ fun RuntimeConfig.awsInlineableBodyWithChecksum() = RuntimeType.forInlineDepende ), ) -class HttpRequestChecksumDecorator : RustCodegenDecorator { +class HttpRequestChecksumDecorator : RustCodegenDecorator { override val name: String = "HttpRequestChecksum" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt index f368452cfc..2aa3e931d0 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt @@ -8,13 +8,14 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.aws.traits.HttpChecksumTrait import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.expectMember import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.inputShape @@ -28,7 +29,7 @@ private fun HttpChecksumTrait.requestValidationModeMember( return operationShape.inputShape(codegenContext.model).expectMember(requestValidationModeMember) } -class HttpResponseChecksumDecorator : RustCodegenDecorator { +class HttpResponseChecksumDecorator : RustCodegenDecorator { override val name: String = "HttpResponseChecksum" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt index 0f54c39fe2..98c5ab0e99 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/InlineAwsDependency.kt @@ -5,8 +5,8 @@ package software.amazon.smithy.rustsdk -import software.amazon.smithy.rust.codegen.client.rustlang.InlineDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustDependency +import software.amazon.smithy.rust.codegen.core.rustlang.InlineDependency +import software.amazon.smithy.rust.codegen.core.rustlang.RustDependency import software.amazon.smithy.rust.codegen.core.rustlang.Visibility object InlineAwsDependency { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt index 6e60033b40..1a2356ae3b 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt @@ -5,23 +5,24 @@ package software.amazon.smithy.rustsdk -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency.Companion.BytesUtils -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency.Companion.TempFile -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.rustlang.DependencyScope +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.BytesUtils +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.TempFile +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import java.nio.file.Files import java.nio.file.Paths -class IntegrationTestDecorator : RustCodegenDecorator { +class IntegrationTestDecorator : RustCodegenDecorator { override val name: String = "IntegrationTest" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index a30f718f81..c66ad83264 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -6,21 +6,22 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig /* Example Generated Code */ /* @@ -70,7 +71,7 @@ fn test_1() { } */ -class RegionDecorator : RustCodegenDecorator { +class RegionDecorator : RustCodegenDecorator { override val name: String = "Region" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt index 74d834e213..88d9f1e3d6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt @@ -6,18 +6,19 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection -class RetryClassifierDecorator : RustCodegenDecorator { +class RetryClassifierDecorator : RustCodegenDecorator { override val name: String = "RetryPolicy" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt index 927ea06b37..64b7522603 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt @@ -5,18 +5,19 @@ package software.amazon.smithy.rustsdk -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate /** * Adds functionality for constructing `::Config` objects from `aws_types::SdkConfig`s @@ -24,7 +25,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.config.Servi * - `From<&aws_types::SdkConfig> for ::config::Builder`: Enabling customization * - `pub fn new(&aws_types::SdkConfig) -> ::Config`: Direct construction without customization */ -class SdkConfigDecorator : RustCodegenDecorator { +class SdkConfigDecorator : RustCodegenDecorator { override val name: String = "SdkConfig" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt index b469aac40a..a0b270eda6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt @@ -5,16 +5,17 @@ package software.amazon.smithy.rustsdk -import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -class ServiceConfigDecorator : RustCodegenDecorator { +class ServiceConfigDecorator : RustCodegenDecorator { override val name: String = "ServiceConfigGenerator" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt index b750c21cf4..8a9330f6fa 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt @@ -13,20 +13,21 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.OptionalAuthTrait -import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.EventStreamSigningConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasEventStreamOperations @@ -42,7 +43,7 @@ import software.amazon.smithy.rust.codegen.core.util.letIf * - sets a default `OperationSigningConfig` A future enhancement will customize this for specific services that need * different behavior. */ -class SigV4SigningDecorator : RustCodegenDecorator { +class SigV4SigningDecorator : RustCodegenDecorator { override val name: String = "SigV4Signing" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt index 9f6424c0e3..d363b6463c 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt @@ -7,29 +7,30 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.aws.traits.ServiceTrait import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait /** * Inserts a UserAgent configuration into the operation */ -class UserAgentDecorator : RustCodegenDecorator { +class UserAgentDecorator : RustCodegenDecorator { override val name: String = "UserAgent" override val order: Byte = 10 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt index 48d2f962be..0f6c837caf 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt @@ -7,18 +7,19 @@ package software.amazon.smithy.rustsdk.customize.apigateway import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.letIf -class ApiGatewayDecorator : RustCodegenDecorator { +class ApiGatewayDecorator : RustCodegenDecorator { override val name: String = "ApiGateway" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt index 74319d312c..20b0fb6eaa 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt @@ -12,13 +12,14 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.AuthTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext private fun String.shapeId() = ShapeId.from(this) // / STS (and possibly other services) need to have auth manually set to [] -class DisabledAuthDecorator : RustCodegenDecorator { +class DisabledAuthDecorator : RustCodegenDecorator { override val name: String = "OptionalAuth" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt index 4486eca037..b3729f7134 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt @@ -9,11 +9,12 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.util.letIf -class Ec2Decorator : RustCodegenDecorator { +class Ec2Decorator : RustCodegenDecorator { override val name: String = "Ec2" override val order: Byte = 0 private val ec2 = ShapeId.from("com.amazonaws.ec2#AmazonEC2") diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt index a6f0b5dc21..a101742512 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt @@ -8,10 +8,10 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.inputShape class AccountIdAutofill() : OperationCustomization() { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt index a214ba65bc..8bc2d3b061 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/ApiVersionHeader.kt @@ -6,11 +6,11 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.dq class ApiVersionHeader( diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt index 278c5da4d6..32c47020ab 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt @@ -8,13 +8,14 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization val Glacier: ShapeId = ShapeId.from("com.amazonaws.glacier#Glacier") -class GlacierDecorator : RustCodegenDecorator { +class GlacierDecorator : RustCodegenDecorator { override val name: String = "Glacier" override val order: Byte = 0 diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt index 00c003450d..f762ffe2e4 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/TreeHashHeader.kt @@ -7,16 +7,16 @@ package software.amazon.smithy.rustsdk.customize.glacier import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.client.testutil.TokioWithTestMacros +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError -import software.amazon.smithy.rust.codegen.client.testutil.TokioWithTestMacros import software.amazon.smithy.rustsdk.InlineAwsDependency val TreeHashDependencies = listOf( diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt index a2ae1e0d38..5b495f472a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt @@ -12,15 +12,16 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.HttpLabelTrait import software.amazon.smithy.model.transform.ModelTransformer +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationCustomization -import software.amazon.smithy.rust.codegen.client.smithy.customize.OperationSection -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.letIf @@ -29,7 +30,7 @@ import java.util.logging.Logger val Route53: ShapeId = ShapeId.from("com.amazonaws.route53#AWSDnsV20130401") -class Route53Decorator : RustCodegenDecorator { +class Route53Decorator : RustCodegenDecorator { override val name: String = "Route53" override val order: Byte = 0 private val logger: Logger = Logger.getLogger(javaClass.name) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt index d675b87233..2754b7d23f 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt @@ -13,32 +13,23 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.protocols.AllowInvalidXmlRoot import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXmlFactory import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap import software.amazon.smithy.rust.codegen.core.smithy.traits.AllowInvalidXmlRoot import software.amazon.smithy.rust.codegen.core.util.letIf @@ -62,8 +53,8 @@ class S3Decorator : RustCodegenDecorator, - ): ProtocolMap = + currentProtocols: ProtocolMap, + ): ProtocolMap = currentProtocols.letIf(applies(serviceId)) { it + mapOf( RestXmlTrait.ID to RestXmlFactory { protocolConfig -> diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt index 1d930249c3..bc1232e569 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/sts/STSDecorator.kt @@ -13,13 +13,14 @@ import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.RetryableTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.letIf import java.util.logging.Logger -class STSDecorator : RustCodegenDecorator { +class STSDecorator : RustCodegenDecorator { override val name: String = "STS" override val order: Byte = 0 private val logger: Logger = Logger.getLogger(javaClass.name) From ddaef4055eb841cff27b0cf468233f61de3e83a8 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 19:52:15 +0200 Subject: [PATCH 05/18] codegen-server-test:python works --- .../smithy/PythonCodegenServerPlugin.kt | 13 ++++++------ .../smithy/PythonServerCargoDependency.kt | 6 +++--- .../smithy/PythonServerCodegenVisitor.kt | 11 +++++----- .../python/smithy/PythonServerRuntimeType.kt | 4 ++-- .../smithy/PythonServerSymbolProvider.kt | 18 ++++++++-------- .../PythonServerCodegenDecorator.kt | 21 ++++++++++--------- .../generators/PythonApplicationGenerator.kt | 16 +++++++------- .../PythonServerCombinedErrorGenerator.kt | 16 +++++++------- .../generators/PythonServerEnumGenerator.kt | 18 ++++++++-------- .../generators/PythonServerModuleGenerator.kt | 12 +++++------ .../PythonServerOperationHandlerGenerator.kt | 10 ++++----- .../PythonServerServiceGenerator.kt | 12 +++++------ .../PythonServerStructureGenerator.kt | 16 +++++++------- .../PythonServerSymbolProviderTest.kt | 1 + 14 files changed, 88 insertions(+), 86 deletions(-) diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt index 5b677f7ec3..3a235ec5be 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt @@ -10,18 +10,17 @@ import software.amazon.smithy.build.SmithyBuildPlugin import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustReservedWordSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.BaseSymbolMetadataProvider import software.amazon.smithy.rust.codegen.client.smithy.EventStreamSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitor -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.server.python.smithy.customizations.DECORATORS -import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerSymbolVisitor -import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonStreamingShapeMetadataProvider import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import java.util.logging.Level import java.util.logging.Logger @@ -44,7 +43,7 @@ class PythonCodegenServerPlugin : SmithyBuildPlugin { // - location (e.g. the mutate section of an operation) // - context (e.g. the of the operation) // - writer: The active RustWriter at the given location - val codegenDecorator: CombinedCodegenDecorator = + val codegenDecorator: CombinedCodegenDecorator = CombinedCodegenDecorator.fromClasspath( context, CombinedCodegenDecorator(DECORATORS + ServerRequiredCustomizations()), diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt index d92482f324..6fd3b430c2 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt @@ -5,9 +5,9 @@ package software.amazon.smithy.rust.codegen.server.python.smithy -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.CratesIo -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig /** * Object used *exclusively* in the runtime of the Python server, for separation concerns. diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt index 51d1527967..a3a5159d16 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt @@ -14,13 +14,13 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait -import software.amazon.smithy.rust.codegen.client.smithy.DefaultPublicModules -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerEnumGenerator @@ -28,6 +28,7 @@ import software.amazon.smithy.rust.codegen.server.python.smithy.generators.Pytho import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerStructureGenerator import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenVisitor import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerProtocolLoader /** @@ -39,7 +40,7 @@ import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerProtoco */ class PythonServerCodegenVisitor( context: PluginContext, - codegenDecorator: RustCodegenDecorator, + codegenDecorator: RustCodegenDecorator, ) : ServerCodegenVisitor(context, codegenDecorator) { init { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerRuntimeType.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerRuntimeType.kt index 4863a4f04f..0452dacdf1 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerRuntimeType.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerRuntimeType.kt @@ -5,8 +5,8 @@ package software.amazon.smithy.rust.codegen.server.python.smithy -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType /** * Object used *exclusively* in the runtime of the Python server, for separation concerns. diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index 9c511dba53..6c3d9a600a 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.server.python.smithy.generators +package software.amazon.smithy.rust.codegen.server.python.smithy import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model @@ -16,12 +16,12 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolMetadataProvider -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitor -import software.amazon.smithy.rust.codegen.client.smithy.SymbolVisitorConfig -import software.amazon.smithy.rust.codegen.client.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolMetadataProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember @@ -42,8 +42,8 @@ import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerRunt */ class PythonServerSymbolVisitor( private val model: Model, - private val serviceShape: ServiceShape?, - private val config: SymbolVisitorConfig, + serviceShape: ServiceShape?, + config: SymbolVisitorConfig, ) : SymbolVisitor(model, serviceShape, config) { private val runtimeConfig = config().runtimeConfig diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt index 0bdf3c6b33..bae39fd434 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt @@ -6,15 +6,15 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.customizations import software.amazon.smithy.model.neighbor.Walker -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.docs -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.docs +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations @@ -22,6 +22,7 @@ import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerRuntimeType import software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerModuleGenerator import software.amazon.smithy.rust.codegen.server.smithy.customizations.AddInternalServerErrorToAllOperationsDecorator +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator /** * Configure the [lib] section of `Cargo.toml`. @@ -30,7 +31,7 @@ import software.amazon.smithy.rust.codegen.server.smithy.customizations.AddInter * name = "$CRATE_NAME" * crate-type = ["cdylib"] */ -class CdylibManifestDecorator : RustCodegenDecorator { +class CdylibManifestDecorator : RustCodegenDecorator { override val name: String = "CdylibDecorator" override val order: Byte = 0 @@ -70,7 +71,7 @@ class PubUsePythonTypes(private val codegenContext: ServerCodegenContext) : LibR /** * Render the Python shared library module export. */ -class PythonExportModuleDecorator : RustCodegenDecorator { +class PythonExportModuleDecorator : RustCodegenDecorator { override val name: String = "PythonExportModuleDecorator" override val order: Byte = 0 @@ -87,7 +88,7 @@ class PythonExportModuleDecorator : RustCodegenDecorator { /** * Decorator applying the customization from [PubUsePythonTypes] class. */ -class PubUsePythonTypesDecorator : RustCodegenDecorator { +class PubUsePythonTypesDecorator : RustCodegenDecorator { override val name: String = "PubUsePythonTypesDecorator" override val order: Byte = 0 diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt index b13fc98227..9401d528bb 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt @@ -8,15 +8,15 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.rust.codegen.core.rustlang.RustType -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.Errors -import software.amazon.smithy.rust.codegen.client.smithy.Inputs -import software.amazon.smithy.rust.codegen.client.smithy.Outputs +import software.amazon.smithy.rust.codegen.core.smithy.Errors +import software.amazon.smithy.rust.codegen.core.smithy.Inputs +import software.amazon.smithy.rust.codegen.core.smithy.Outputs import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt index 32755b8007..53d4713aa0 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt @@ -8,15 +8,15 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.Model import software.amazon.smithy.model.knowledge.OperationIndex import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt index 0fc2111301..b804d12bbb 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt @@ -9,15 +9,15 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerEnumGenerator diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt index cf9631047d..51da95f4bf 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt @@ -10,13 +10,13 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ResourceShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt index 4c641ce0d8..7423b20ce7 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt @@ -6,11 +6,11 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt index ed9a6d4b93..e21872a99f 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt @@ -6,14 +6,14 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.client.rustlang.RustModule -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerServiceGenerator import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol +import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator /** * PythonServerServiceGenerator @@ -23,9 +23,9 @@ import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.Ser */ class PythonServerServiceGenerator( private val rustCrate: RustCrate, - protocolGenerator: ProtocolGenerator, + protocolGenerator: ServerProtocolGenerator, protocolSupport: ProtocolSupport, - private val protocol: ServerProtocol, + protocol: ServerProtocol, private val context: CoreCodegenContext, ) : ServerServiceGenerator(rustCrate, protocolGenerator, protocolSupport, protocol, context) { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt index a7aa871874..faea82110b 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt @@ -11,16 +11,16 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute -import software.amazon.smithy.rust.codegen.client.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.client.rustlang.Writable -import software.amazon.smithy.rust.codegen.client.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.render -import software.amazon.smithy.rust.codegen.client.rustlang.rust -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.client.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator -import software.amazon.smithy.rust.codegen.client.smithy.rustType +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency diff --git a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt index 33dd903c73..0d23b15240 100644 --- a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt +++ b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt @@ -11,6 +11,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.client.smithy.rustType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerSymbolVisitor import software.amazon.smithy.rust.codegen.server.smithy.testutil.ServerTestSymbolVisitorConfig internal class PythonServerSymbolProviderTest { From 9d6ad32bf2888764674b08e500f4226b7b0cb718 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 19:53:04 +0200 Subject: [PATCH 06/18] ./gradlew ktlintFormat --- .../smithy/rustsdk/AwsEndpointDecorator.kt | 2 +- .../rustsdk/AwsFluentClientDecorator.kt | 14 ++++++------- .../smithy/rustsdk/AwsReadmeDecorator.kt | 6 +++--- .../amazon/smithy/rustsdk/RegionDecorator.kt | 2 +- .../smithy/rustsdk/SigV4SigningDecorator.kt | 20 +++++++++---------- .../rustsdk/customize/s3/S3Decorator.kt | 2 +- .../EndpointConfigCustomizationTest.kt | 4 ++-- .../rustsdk/RegionProviderConfigTest.kt | 2 +- .../amazon/smithy/rustsdk/TestUtil.kt | 2 +- .../smithy/EventStreamSymbolProvider.kt | 4 ++-- .../client/smithy/RustCodegenPlugin.kt | 6 +++--- .../customizations/ClientCustomizations.kt | 2 +- .../customizations/DocsRsMetadataDecorator.kt | 2 +- .../customizations/EndpointPrefixGenerator.kt | 2 +- .../ResiliencyConfigCustomization.kt | 4 ++-- .../client/FluentClientDecorator.kt | 6 +++--- .../client/FluentClientGenerator.kt | 8 ++++---- .../protocol/ClientProtocolGenerator.kt | 2 +- .../protocol/ProtocolTestGenerator.kt | 4 ++-- .../testutil/TestConfigCustomization.kt | 6 +++--- .../ResiliencyConfigCustomizationTest.kt | 4 ++-- .../SmithyTypesPubUseGeneratorTest.kt | 2 +- .../client/generators/EnumGeneratorTest.kt | 6 +++--- .../client/generators/UnionGeneratorTest.kt | 6 +++--- .../http/RequestBindingGeneratorTest.kt | 18 ++++++++--------- .../codegen/client/rustlang/RustWriterTest.kt | 2 +- .../codegen/client/rustlang/WritableTest.kt | 2 +- .../smithy/EventStreamSymbolProviderTest.kt | 6 +++--- .../StreamingShapeSymbolProviderTest.kt | 2 +- .../smithy/generators/BuilderGeneratorTest.kt | 6 +++--- .../protocol/ProtocolTestGeneratorTest.kt | 2 -- .../parse/JsonParserGeneratorTest.kt | 14 ++++++------- .../transformers/RecursiveShapeBoxerTest.kt | 2 +- .../rust/codegen/core/smithy/RuntimeTypes.kt | 2 +- .../smithy/generators/CargoTomlGenerator.kt | 2 +- .../core/smithy/generators/EnumGenerator.kt | 2 +- .../smithy/generators/StructureGenerator.kt | 4 ++-- .../error/CombinedErrorGenerator.kt | 2 +- .../smithy/generators/error/ErrorGenerator.kt | 2 +- .../generators/http/HttpBindingGenerator.kt | 2 +- .../generators/protocol/ProtocolGenerator.kt | 2 +- .../smithy/protocols/ClientProtocolLoader.kt | 2 +- .../HttpBoundProtocolPayloadGenerator.kt | 2 +- .../codegen/core/smithy/protocols/Protocol.kt | 1 - .../parse/EventStreamUnmarshallerGenerator.kt | 4 ++-- .../protocols/parse/JsonParserGenerator.kt | 2 +- .../parse/XmlBindingTraitParserGenerator.kt | 2 +- .../EventStreamErrorMarshallerGenerator.kt | 4 ++-- .../EventStreamMarshallerGenerator.kt | 2 +- .../transformers/OperationNormalizer.kt | 2 +- .../smithy/PythonServerSymbolProvider.kt | 1 - .../PythonServerSymbolProviderTest.kt | 2 +- .../server/smithy/RustCodegenServerPlugin.kt | 8 ++++---- .../server/smithy/ServerCodegenVisitor.kt | 12 +++++------ .../AdditionalErrorsDecorator.kt | 2 +- .../smithy/generators/ServerEnumGenerator.kt | 2 +- .../ServerOperationHandlerGenerator.kt | 2 +- .../ServerOperationRegistryGenerator.kt | 2 +- .../protocol/ServerProtocolGenerator.kt | 3 +-- .../protocol/ServerProtocolTestGenerator.kt | 1 - .../server/smithy/protocols/ServerAwsJson.kt | 2 +- .../ServerHttpBoundProtocolGenerator.kt | 5 ++--- .../smithy/protocols/ServerRestJsonFactory.kt | 2 +- .../smithy/protocols/ServerRestXmlFactory.kt | 2 +- .../smithy/testutil/ServerTestHelpers.kt | 6 +++--- .../AdditionalErrorsDecoratorTest.kt | 2 +- .../ServerCombinedErrorGeneratorTest.kt | 6 +++--- .../ServerHttpSensitivityGeneratorTest.kt | 8 ++++---- .../EventStreamUnmarshallerGeneratorTest.kt | 8 ++++---- .../EventStreamMarshallerGeneratorTest.kt | 8 ++++---- 70 files changed, 144 insertions(+), 151 deletions(-) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt index 42593f180a..49cab7d426 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt @@ -121,7 +121,7 @@ class EndpointConfigCustomization( is ServiceConfig.BuilderStruct -> rustTemplate( "endpoint_resolver: Option>>,", - *codegenScope + *codegenScope, ) ServiceConfig.BuilderImpl -> diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index c12f4a95ed..78b3b7b231 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -8,6 +8,13 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.TitleTrait +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator +import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerics +import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientSection +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope @@ -19,21 +26,14 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerics -import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt index 5217f65112..606cf0c7a8 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt @@ -9,12 +9,12 @@ import org.jsoup.Jsoup import org.jsoup.nodes.Element import org.jsoup.nodes.TextNode import software.amazon.smithy.model.traits.DocumentationTrait -import software.amazon.smithy.rust.codegen.core.rustlang.raw import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.rustlang.raw +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations import software.amazon.smithy.rust.codegen.core.util.getTrait import java.util.logging.Logger diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index c66ad83264..7f63226084 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -167,7 +167,7 @@ class PubUseRegion(private val runtimeConfig: RuntimeConfig) : LibRsCustomizatio is LibRsSection.Body -> writable { rust( "pub use #T::Region;", - region(runtimeConfig) + region(runtimeConfig), ) } else -> emptySection diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt index 8a9330f6fa..99454c5a59 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt @@ -112,16 +112,16 @@ class SigV4SigningConfig( rustTemplate( "#{signerFn:W}", "signerFn" to - renderEventStreamSignerFn { propertiesName -> - writable { - rustTemplate( - """ + renderEventStreamSignerFn { propertiesName -> + writable { + rustTemplate( + """ #{SigV4Signer}::new($propertiesName) """, - *codegenScope, - ) - } - }, + *codegenScope, + ) + } + }, ) } } @@ -182,13 +182,13 @@ class SigV4SigningFeature( if (!authSchemes.containsKey(SigV4Trait.ID)) { rustTemplate( "signing_config.signing_requirements = #{sig_auth}::signer::SigningRequirements::Disabled;", - *codegenScope + *codegenScope, ) } else { if (operation.hasTrait()) { rustTemplate( "signing_config.signing_requirements = #{sig_auth}::signer::SigningRequirements::Optional;", - *codegenScope + *codegenScope, ) } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt index 2754b7d23f..ace7fdf698 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt @@ -132,7 +132,7 @@ class S3PubUse : LibRsCustomization() { is LibRsSection.Body -> writable { rust( "pub use #T::ErrorExt;", - AwsRuntimeType.S3Errors + AwsRuntimeType.S3Errors, ) } else -> emptySection diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt index 92f7009b00..ce7ffff675 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt @@ -12,18 +12,18 @@ import software.amazon.smithy.rust.codegen.client.rustlang.asType import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customizations.AllowLintsGenerator import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext import software.amazon.smithy.rust.codegen.client.testutil.stubConfigCustomization import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.util.runCommand internal class EndpointConfigCustomizationTest { diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt index 149d49c7af..c71ddb6383 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/RegionProviderConfigTest.kt @@ -6,10 +6,10 @@ package software.amazon.smithy.rustsdk import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.rustSettings import software.amazon.smithy.rust.codegen.client.testutil.validateConfigCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings internal class RegionProviderConfigTest { @Test diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt index bbb5e324b3..8ed38448e8 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.Model -import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.client.smithy.RuntimeCrateLocation import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import java.io.File // In aws-sdk-codegen, the working dir when gradle runs tests is actually `./aws`. So, to find the smithy runtime, we need diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt index a1cb8e5f3c..6802d444c4 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt @@ -10,8 +10,6 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol -import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.render @@ -21,9 +19,11 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.WrappingSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.isEventStream import software.amazon.smithy.rust.codegen.core.util.isInputEventStream diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt index 0da1667858..9a30b3cafe 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/RustCodegenPlugin.kt @@ -10,15 +10,15 @@ import software.amazon.smithy.build.SmithyBuildPlugin import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.NonExhaustive -import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.customizations.ClientCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.NoOpEventStreamSigningDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientDecorator +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.NonExhaustive +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import java.util.logging.Level diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt index e08b0f6f45..c52c69f951 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt @@ -6,9 +6,9 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt index 8a8428b9cd..45335f0dd4 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt @@ -6,9 +6,9 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt index 88d9c9dc3b..f9fb5eba20 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt @@ -7,9 +7,9 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.EndpointTrait -import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.client.smithy.generators.EndpointTraitBindings import software.amazon.smithy.rust.codegen.core.rustlang.Writable +import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt index 6430665492..33bc3fd2c1 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt @@ -5,6 +5,8 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable @@ -13,8 +15,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig class ResiliencyConfigCustomization(coreCodegenContext: CoreCodegenContext) : ConfigCustomization() { private val retryConfig = smithyTypesRetry(coreCodegenContext.runtimeConfig) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt index f63117db71..cd7cc9c5af 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt @@ -7,6 +7,9 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.client import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Feature import software.amazon.smithy.rust.codegen.core.rustlang.Writable @@ -14,13 +17,10 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator -import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.customize.Section import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index 543d10d1ab..865056c085 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -13,6 +13,9 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.generators.PaginatorGenerator +import software.amazon.smithy.rust.codegen.client.smithy.generators.isPaginated +import software.amazon.smithy.rust.codegen.client.smithy.generators.smithyHttp import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords @@ -35,21 +38,18 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator -import software.amazon.smithy.rust.codegen.client.smithy.generators.PaginatorGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.smithy.generators.isPaginated import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName -import software.amazon.smithy.rust.codegen.client.smithy.generators.smithyHttp import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.orNull diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt index a100a57050..53792dac02 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt @@ -30,7 +30,7 @@ open class ClientProtocolGenerator( private val protocol: Protocol, private val makeOperationGenerator: MakeOperationGenerator, private val traitGenerator: ProtocolTraitImplGenerator, -): ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { +) : ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { /** * Render all code required for serializing requests and deserializing responses for the operation * diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index 96587537ee..3bf540de52 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -19,6 +19,7 @@ import software.amazon.smithy.protocoltests.traits.HttpRequestTestCase import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait import software.amazon.smithy.protocoltests.traits.HttpResponseTestCase import software.amazon.smithy.protocoltests.traits.HttpResponseTestsTrait +import software.amazon.smithy.rust.codegen.client.testutil.TokioTest import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata @@ -30,12 +31,11 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol -import software.amazon.smithy.rust.codegen.client.testutil.TokioTest import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.findMemberWithTrait diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt index 1162a33ce2..d91ea1f6d6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt @@ -5,13 +5,13 @@ package software.amazon.smithy.rust.codegen.client.testutil +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig +import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfigGenerator import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig -import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfigGenerator /** * Test helper to produce a valid config customization to test that a [ConfigCustomization] can be used in conjunction diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt index a89009d87f..fcae33df06 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ResiliencyConfigCustomizationTest.kt @@ -7,13 +7,13 @@ package software.amazon.smithy.rust.codegen.client.customizations import org.junit.jupiter.api.Test import software.amazon.smithy.rust.codegen.client.smithy.customizations.ResiliencyConfigCustomization -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.rustSettings import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.validateConfigCustomizations +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer internal class ResiliencyConfigCustomizationTest { private val baseModel = """ diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt index a20694d81f..6450e40c74 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/SmithyTypesPubUseGeneratorTest.kt @@ -7,10 +7,10 @@ package software.amazon.smithy.rust.codegen.client.customizations import org.junit.jupiter.api.Test import software.amazon.smithy.model.Model -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.smithy.customizations.pubUseTypes import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType class SmithyTypesPubUseGeneratorTest { private fun emptyModel() = modelWithMember() diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt index 1d4da7cc09..031600f1aa 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/EnumGeneratorTest.kt @@ -11,13 +11,13 @@ import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.traits.EnumTrait +import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest +import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumMemberModel -import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel -import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest -import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.orNull diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt index 4a259a4a36..f770df48bc 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/UnionGeneratorTest.kt @@ -8,12 +8,12 @@ package software.amazon.smithy.rust.codegen.client.generators import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test import software.amazon.smithy.codegen.core.SymbolProvider -import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.rust -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.util.lookup class UnionGeneratorTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt index 756c5786ff..e2bbad162b 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/RequestBindingGeneratorTest.kt @@ -11,16 +11,7 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.HttpTrait -import software.amazon.smithy.rust.codegen.core.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.rust -import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RequestBindingGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.http.uriFormatString -import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel @@ -29,6 +20,15 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RequestBindingGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.http.uriFormatString +import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt index 2996c04b15..a09066cc82 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/RustWriterTest.kt @@ -15,7 +15,6 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.SetShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndRun import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -32,6 +31,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.lookup class RustWriterTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt index 14b67f7503..c6051a9bb6 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt @@ -7,7 +7,6 @@ package software.amazon.smithy.rust.codegen.client.rustlang import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.join @@ -15,6 +14,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt index 706dd5075a..4f9fd82238 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProviderTest.kt @@ -10,14 +10,14 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.core.rustlang.RustType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestSymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor import software.amazon.smithy.rust.codegen.core.smithy.rustType +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer class EventStreamSymbolProviderTest { @Test diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt index a4f9a37669..584e097565 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingShapeSymbolProviderTest.kt @@ -8,11 +8,11 @@ package software.amazon.smithy.rust.codegen.client.smithy import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.MemberShape -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.Default import software.amazon.smithy.rust.codegen.core.smithy.defaultValue +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.lookup internal class StreamingShapeSymbolProviderTest { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt index f51b343145..a941f7218d 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/BuilderGeneratorTest.kt @@ -11,18 +11,18 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.traits.EnumDefinition import software.amazon.smithy.rust.codegen.client.generators.StructureGeneratorTest +import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest +import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.Default import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig -import software.amazon.smithy.rust.codegen.core.smithy.setDefault -import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest -import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock +import software.amazon.smithy.rust.codegen.core.smithy.setDefault internal class BuilderGeneratorTest { private val model = StructureGeneratorTest.model diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt index 07bb78c078..b7db2929a3 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt @@ -13,8 +13,6 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt index b0bd2b0422..ad94eb2105 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/parse/JsonParserGeneratorTest.kt @@ -9,14 +9,7 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.core.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator -import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver -import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.client.smithy.protocols.restJsonFieldName -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer -import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest @@ -24,7 +17,14 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator +import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator +import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver +import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolContentTypes import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.JsonParserGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer +import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt index f6e37612c9..2327b3fa0c 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/RecursiveShapeBoxerTest.kt @@ -8,8 +8,8 @@ package software.amazon.smithy.rust.codegen.client.smithy.transformers import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.MemberShape -import software.amazon.smithy.rust.codegen.core.smithy.traits.RustBoxTrait import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.smithy.traits.RustBoxTrait import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt index 5c652f67e0..781014bd85 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeTypes.kt @@ -131,7 +131,7 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n val writable = writable { rustInlineTemplate( "#{this:T}", - "this" to this@RuntimeType + "this" to this@RuntimeType, ) } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt index cad51c9bf2..cceced878b 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators import com.moandjiezana.toml.TomlWriter +import software.amazon.smithy.rust.codegen.core.Version import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.Feature import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings -import software.amazon.smithy.rust.codegen.core.Version import software.amazon.smithy.rust.codegen.core.util.deepMergeWith /** diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt index 63896d5f8e..f2b25032b5 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt @@ -18,11 +18,11 @@ import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.MaybeRenamed import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.util.doubleQuote import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.getTrait diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt index b2342fd4c0..f8610d2e46 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt @@ -13,8 +13,6 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.SensitiveTrait -import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ErrorGenerator import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asDeref @@ -30,6 +28,8 @@ import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.canUseDefault +import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ErrorGenerator import software.amazon.smithy.rust.codegen.core.smithy.isOptional import software.amazon.smithy.rust.codegen.core.smithy.renamedFrom import software.amazon.smithy.rust.codegen.core.smithy.rustType diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt index 9e65ceac9b..9c973ff092 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt @@ -24,10 +24,10 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.customize.Section -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt index 669786b0fc..2955b5c248 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt @@ -13,11 +13,11 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.Companion.StdError import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.isOptional import software.amazon.smithy.rust.codegen.core.smithy.transformers.errorMessageMember import software.amazon.smithy.rust.codegen.core.util.dq diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 549ca8d9ca..4eb1e760cd 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -35,9 +35,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.smithy.generators.redactIfNecessary import software.amazon.smithy.rust.codegen.core.smithy.makeOptional diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt index b521e64d37..a8871bfc83 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt @@ -6,10 +6,10 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization +import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol /** * Payload Body Generator. diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt index e9b050ad1c..719468e71c 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.Trait import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -open class ProtocolLoader(private val supportedProtocols: ProtocolMap) { +open class ProtocolLoader(private val supportedProtocols: ProtocolMap) { fun protocolFor( model: Model, serviceShape: ServiceShape, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt index 111ebc6b7f..388d119f4e 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt @@ -23,9 +23,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolPayloadGenerator diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt index 75a0f44a6a..0296b9c066 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt @@ -70,4 +70,3 @@ interface ProtocolGeneratorFactory { fun buildProtocolGenerator(codegenContext: C): T fun support(): ProtocolSupport } - diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt index 6205a5a37a..97d6bb1c83 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt @@ -31,16 +31,16 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol -import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticEventStreamUnionTrait +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index 017183a713..5196454e07 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -33,10 +33,10 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.canUseDefault -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.TypeConversionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt index 95ee3af53c..39b35b7299 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt @@ -38,9 +38,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt index a9c8269fad..3d06da554c 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt @@ -21,16 +21,16 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.error.eventStreamErrorSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant import software.amazon.smithy.rust.codegen.core.smithy.generators.unknownVariantError import software.amazon.smithy.rust.codegen.core.smithy.rustType -import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticEventStreamUnionTrait +import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamErrors import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt index 136af9f316..133f2b9bb6 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt @@ -30,10 +30,10 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant import software.amazon.smithy.rust.codegen.core.smithy.generators.unknownVariantError diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt index ced062f1dd..1a00d431ae 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt @@ -11,10 +11,10 @@ import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.core.util.rename import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait import software.amazon.smithy.rust.codegen.core.util.orNull +import software.amazon.smithy.rust.codegen.core.util.rename import java.util.Optional import kotlin.streams.toList diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index 6c3d9a600a..1e6f2b7ea8 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -27,7 +27,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTra import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.isStreaming -import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerRuntimeType /** * Symbol visitor allowing that recursively replace symbols in nested shapes. diff --git a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt index 0d23b15240..9108b3b092 100644 --- a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt +++ b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt @@ -8,9 +8,9 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.client.smithy.rustType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerSymbolVisitor import software.amazon.smithy.rust.codegen.server.smithy.testutil.ServerTestSymbolVisitorConfig diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt index c05000c1d0..42c81072c7 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt @@ -10,16 +10,16 @@ import software.amazon.smithy.build.SmithyBuildPlugin import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider import software.amazon.smithy.rust.codegen.client.smithy.EventStreamSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.StreamingShapeMetadataProvider import software.amazon.smithy.rust.codegen.client.smithy.StreamingShapeSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor -import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator +import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator import java.util.logging.Level diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt index 81acb53e77..9d0d760a1d 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt @@ -17,10 +17,15 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerRustSettings import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator @@ -30,11 +35,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamN import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer import software.amazon.smithy.rust.codegen.core.smithy.transformers.RemoveEventStreamOperations -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules -import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.runCommand diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt index acdda0745e..7230f7e81a 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt @@ -13,9 +13,9 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.RequiredTrait import software.amazon.smithy.model.transform.ModelTransformer -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt index ad420c759e..323a40ebf0 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerEnumGenerator.kt @@ -11,10 +11,10 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.EnumGenerator import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.server.smithy.ServerRuntimeType diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt index d81724a428..fa7a3d0577 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt @@ -11,9 +11,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt index 3c9c9d2fe6..1d6f21f828 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt @@ -21,12 +21,12 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.Errors import software.amazon.smithy.rust.codegen.core.smithy.Inputs import software.amazon.smithy.rust.codegen.core.smithy.Outputs import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.inputShape diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt index 3ce46c7f6b..ba21287f41 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.protocol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator @@ -19,7 +18,7 @@ open class ServerProtocolGenerator( protocol: Protocol, makeOperationGenerator: MakeOperationGenerator, private val traitGenerator: ProtocolTraitImplGenerator, -): ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { +) : ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { /** * The server implementation uses this method to generate implementations of the `from_request` and `into_response` * traits for operation input and output shapes, respectively. diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 83887daf03..ef5b24bac1 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -41,7 +41,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors import software.amazon.smithy.rust.codegen.core.util.dq diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt index 847cb02e94..c24f6afc55 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt @@ -9,12 +9,12 @@ import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.protocols.AwsJsonVersion import software.amazon.smithy.rust.codegen.client.smithy.protocols.awsJsonFieldName -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.JsonCustomization diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt index bc294218fe..5df9709e48 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt @@ -41,17 +41,16 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.extractSymbolFromOption -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.TypeConversionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName import software.amazon.smithy.rust.codegen.core.smithy.isOptional @@ -60,9 +59,9 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtoc import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator import software.amazon.smithy.rust.codegen.core.smithy.toOptional +import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.smithy.wrapOptional -import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.findStreamingMember diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt index aa49a6c877..39f1e9947d 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt @@ -6,8 +6,8 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestJson +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerRestJsonProtocol diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt index 80d12b87c5..96e6b06a0f 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestXmlFactory.kt @@ -6,8 +6,8 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.client.smithy.protocols.RestXml +import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerRestXmlProtocol diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt index 136894afe3..8972fd0296 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt @@ -10,14 +10,14 @@ import software.amazon.smithy.model.knowledge.NullableIndex import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig -import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenConfig import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.ServerRustSettings -import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider +import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig import software.amazon.smithy.rust.codegen.server.smithy.RustCodegenServerPlugin // These are the settings we default to if the user does not override them in their `smithy-build.json`. diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt index 5e6bc2a6da..0727a2154a 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecoratorTest.kt @@ -9,8 +9,8 @@ import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.lookup class AdditionalErrorsDecoratorTest { diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt index 5b9b65ce3b..1406573d89 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerCombinedErrorGeneratorTest.kt @@ -7,15 +7,15 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilder import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.rustlang.RustModule +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.generators.error.ServerCombinedErrorGenerator +import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt index 5a58af7c8d..cd069a27fa 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt @@ -12,15 +12,15 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.traits.HttpHeaderTrait import software.amazon.smithy.model.traits.HttpResponseCodeTrait import software.amazon.smithy.model.traits.HttpTrait -import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.core.rustlang.asType -import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt index 62d1a87415..793e1df961 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt @@ -8,14 +8,14 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols.parse import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.core.rustlang.rust -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget +import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestTools diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt index 237866ef05..e52a8bef98 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt @@ -8,15 +8,15 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols.serialize import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig +import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest +import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings +import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.EventStreamMarshallerGenerator -import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig -import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest -import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings -import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestTools From a21fe4d563c7dd51b8f28041272e87a4a217b308 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 20:03:21 +0200 Subject: [PATCH 07/18] Address TODOs --- .../smithy/rust/codegen/client/smithy/CodegenVisitor.kt | 2 +- .../smithy/protocols/HttpBoundProtocolGenerator.kt | 2 +- .../client}/smithy/transformers/AddErrorMessage.kt | 9 ++------- codegen-core/build.gradle.kts | 2 +- .../core/smithy/generators/error/ErrorGenerator.kt | 2 +- .../amazon/smithy/rust/codegen/core/util/Smithy.kt | 2 ++ 6 files changed, 8 insertions(+), 11 deletions(-) rename {codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core => codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client}/smithy/transformers/AddErrorMessage.kt (77%) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt index ca8bb5f5b2..e14cd6f8bf 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt @@ -32,7 +32,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait -import software.amazon.smithy.rust.codegen.core.smithy.transformers.AddErrorMessage +import software.amazon.smithy.rust.codegen.client.smithy.transformers.AddErrorMessage import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt index a6d689a3cb..b4e0d6476d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt @@ -38,10 +38,10 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtoc import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator -import software.amazon.smithy.rust.codegen.core.smithy.transformers.errorMessageMember import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors import software.amazon.smithy.rust.codegen.core.util.UNREACHABLE import software.amazon.smithy.rust.codegen.core.util.dq +import software.amazon.smithy.rust.codegen.core.util.errorMessageMember import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.isStreaming diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/AddErrorMessage.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/AddErrorMessage.kt similarity index 77% rename from codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/AddErrorMessage.kt rename to codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/AddErrorMessage.kt index b95c64e9f1..7e69ce6995 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/AddErrorMessage.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/transformers/AddErrorMessage.kt @@ -3,22 +3,17 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.core.smithy.transformers +package software.amazon.smithy.rust.codegen.client.smithy.transformers import software.amazon.smithy.model.Model -import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.transform.ModelTransformer +import software.amazon.smithy.rust.codegen.core.util.errorMessageMember import software.amazon.smithy.rust.codegen.core.util.hasTrait -import software.amazon.smithy.rust.codegen.core.util.orNull import java.util.logging.Logger -// TODO This file should be in the client module, since the transformer is only used by the client generator. -// However, this extension function is used by the server too, so this should probably be moved to `Smithy.kt`. -fun StructureShape.errorMessageMember(): MemberShape? = this.getMember("message").or { this.getMember("Message") }.orNull() - /** * Ensure that all errors have error messages. * diff --git a/codegen-core/build.gradle.kts b/codegen-core/build.gradle.kts index b5bf128d8c..4cb3e06fea 100644 --- a/codegen-core/build.gradle.kts +++ b/codegen-core/build.gradle.kts @@ -26,7 +26,7 @@ val kotestVersion: String by project dependencies { implementation(kotlin("stdlib-jdk8")) implementation("org.jsoup:jsoup:1.14.3") - api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") // TODO Why do we need this? + api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") api("com.moandjiezana.toml:toml4j:0.7.2") implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt index 2955b5c248..8f9382b5ac 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/ErrorGenerator.kt @@ -19,8 +19,8 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.Companion.StdError import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.isOptional -import software.amazon.smithy.rust.codegen.core.smithy.transformers.errorMessageMember import software.amazon.smithy.rust.codegen.core.util.dq +import software.amazon.smithy.rust.codegen.core.util.errorMessageMember import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.letIf diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt index e7b7894478..60db4a4e14 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt @@ -41,6 +41,8 @@ fun StructureShape.expectMember(member: String): MemberShape = fun UnionShape.expectMember(member: String): MemberShape = this.getMember(member).orElseThrow { CodegenException("$member did not exist on $this") } +fun StructureShape.errorMessageMember(): MemberShape? = this.getMember("message").or { this.getMember("Message") }.orNull() + fun StructureShape.hasStreamingMember(model: Model) = this.findStreamingMember(model) != null fun UnionShape.hasStreamingMember(model: Model) = this.findMemberWithTrait(model) != null fun MemberShape.isStreaming(model: Model) = this.getMemberTrait(model, StreamingTrait::class.java).isPresent From ba76e98b1c1dbf6f101e2e46d0b2efc16bb1b37c Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 20:03:53 +0200 Subject: [PATCH 08/18] ./gradlew ktlintFormat --- .../amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt index e14cd6f8bf..9369629a6e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt @@ -21,6 +21,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDe import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.ClientProtocolLoader +import software.amazon.smithy.rust.codegen.client.smithy.transformers.AddErrorMessage import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider @@ -32,7 +33,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrait -import software.amazon.smithy.rust.codegen.client.smithy.transformers.AddErrorMessage import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer From a359e97a509129bafa5b65cb2e04afd0a01aff31 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 20:05:53 +0200 Subject: [PATCH 09/18] Copyright header --- .../core/smithy/generators/protocol/ProtocolSupport.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt index cc984ec9cd..c66dae4ce5 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolSupport.kt @@ -1,3 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol data class ProtocolSupport( From 953ae533c7818b684fa21677c9cf1d4ffeda75d6 Mon Sep 17 00:00:00 2001 From: david-perez Date: Thu, 22 Sep 2022 20:25:55 +0200 Subject: [PATCH 10/18] Move more things into `codegen-core` This moves most things from `codegen-client` that should be in `codegen-core` into `codegen-core`. This is a continuation of the efforts started in #1697, #1730. From 6ea6f54d0ba8775eebf62287593495fec16f3820 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 12:50:00 +0200 Subject: [PATCH 11/18] Fix Python Server unit tests --- .../python/smithy/generators/PythonServerSymbolProviderTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt index 9108b3b092..e2ca3e8d29 100644 --- a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt +++ b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerSymbolProviderTest.kt @@ -8,9 +8,9 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.client.smithy.rustType import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.core.rustlang.RustType +import software.amazon.smithy.rust.codegen.core.smithy.rustType import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerSymbolVisitor import software.amazon.smithy.rust.codegen.server.smithy.testutil.ServerTestSymbolVisitorConfig From 74a5278ec98b2a8932f54af525273b14c3f9ce58 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 12:54:31 +0200 Subject: [PATCH 12/18] Fix AWS SDK Kotlin unit tests --- .../smithy/rustsdk/EndpointConfigCustomizationTest.kt | 11 ++++++----- .../kotlin/software/amazon/smithy/rustsdk/TestUtil.kt | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt index ce7ffff675..3c965df357 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt @@ -7,22 +7,23 @@ package software.amazon.smithy.rustsdk import org.junit.jupiter.api.Test import software.amazon.smithy.model.node.ObjectNode -import software.amazon.smithy.rust.codegen.client.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.client.rustlang.asType -import software.amazon.smithy.rust.codegen.client.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.CodegenVisitor -import software.amazon.smithy.rust.codegen.client.smithy.RustCrate import software.amazon.smithy.rust.codegen.client.smithy.customizations.AllowLintsGenerator import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.RequiredCustomizations import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization +import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.generatePluginContext import software.amazon.smithy.rust.codegen.client.testutil.stubConfigCustomization import software.amazon.smithy.rust.codegen.client.testutil.unitTest +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.util.runCommand @@ -127,7 +128,7 @@ internal class EndpointConfigCustomizationTest { private fun validateEndpointCustomizationForService(service: String, test: ((RustCrate) -> Unit)? = null) { val (context, testDir) = generatePluginContext(model, service = service, runtimeConfig = AwsTestRuntimeConfig) - val codegenDecorator = object : RustCodegenDecorator { + val codegenDecorator = object : RustCodegenDecorator { override val name: String = "tests and config" override val order: Byte = 0 override fun configCustomizations( diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt index 8ed38448e8..61d6558a1c 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.Model -import software.amazon.smithy.rust.codegen.client.smithy.RuntimeCrateLocation import software.amazon.smithy.rust.codegen.client.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.client.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.client.testutil.testCodegenContext import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeCrateLocation import java.io.File // In aws-sdk-codegen, the working dir when gradle runs tests is actually `./aws`. So, to find the smithy runtime, we need From 0876167a0ed066c4db281e23ee9fa797ce98c191 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 13:21:10 +0200 Subject: [PATCH 13/18] Rename protocol loader in `codegen-core` from `ClientProtocolLoader` to `ProtocolLoader` --- .../protocols/{ClientProtocolLoader.kt => ProtocolLoader.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/{ClientProtocolLoader.kt => ProtocolLoader.kt} (100%) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ProtocolLoader.kt similarity index 100% rename from codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ClientProtocolLoader.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ProtocolLoader.kt From d6385d96267cd8e564fbc2037c318560afe64ad6 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 13:33:11 +0200 Subject: [PATCH 14/18] Move `GenericsGenerator` into `rustlang` and rename it to `RustGenerics` --- .../rustsdk/AwsFluentClientDecorator.kt | 12 ++++----- .../client/FluentClientGenerator.kt | 14 +++++----- .../generators/client/FluentClientGenerics.kt | 10 +++---- ...csGeneratorTest.kt => RustGenericsTest.kt} | 26 +++++++++---------- .../codegen/client/rustlang/WritableTest.kt | 10 +++---- .../RustGenerics.kt} | 11 +++----- .../rust/codegen/core/rustlang/Writable.kt | 3 +-- 7 files changed, 40 insertions(+), 46 deletions(-) rename codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/{GenericsGeneratorTest.kt => RustGenericsTest.kt} (84%) rename codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/{smithy/generators/GenericsGenerator.kt => rustlang/RustGenerics.kt} (88%) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index 78b3b7b231..2026781b03 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -19,6 +19,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.rustlang.RustGenerics import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asType @@ -30,8 +32,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.core.util.expectTrait @@ -83,9 +83,7 @@ private class AwsClientGenerics(private val types: Types) : FluentClientGenerics ): Writable = writable { } - override fun toGenericsGenerator(): GenericsGenerator { - return GenericsGenerator() - } + override fun toRustGenerics() = RustGenerics() } class AwsFluentClientDecorator : RustCodegenDecorator { @@ -283,8 +281,8 @@ private fun renderCustomizableOperationSendMethod( ) { val smithyHttp = CargoDependency.SmithyHttp(runtimeConfig).asType() - val operationGenerics = GenericsGenerator(GenericTypeArg("O"), GenericTypeArg("Retry")) - val handleGenerics = generics.toGenericsGenerator() + val operationGenerics = RustGenerics(GenericTypeArg("O"), GenericTypeArg("Retry")) + val handleGenerics = generics.toRustGenerics() val combinedGenerics = operationGenerics + handleGenerics val codegenScope = arrayOf( diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index 865056c085..8615129766 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -17,6 +17,8 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.PaginatorGen import software.amazon.smithy.rust.codegen.client.smithy.generators.isPaginated import software.amazon.smithy.rust.codegen.client.smithy.generators.smithyHttp import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.rustlang.RustGenerics import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustType @@ -45,8 +47,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations import software.amazon.smithy.rust.codegen.core.smithy.expectRustMetadata -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName @@ -326,7 +326,7 @@ class FluentClientGenerator( "customizable_op_type_params" to rustTypeParameters( symbolProvider.toSymbol(operation), retryClassifier, - generics.toGenericsGenerator(), + generics.toRustGenerics(), ), ) PaginatorGenerator.paginatorType(codegenContext, generics, operation, retryClassifier)?.also { paginatorType -> @@ -377,8 +377,8 @@ private fun renderCustomizableOperationModule( ) { val smithyHttp = CargoDependency.SmithyHttp(runtimeConfig).asType() - val operationGenerics = GenericsGenerator(GenericTypeArg("O"), GenericTypeArg("Retry")) - val handleGenerics = generics.toGenericsGenerator() + val operationGenerics = RustGenerics(GenericTypeArg("O"), GenericTypeArg("Retry")) + val handleGenerics = generics.toRustGenerics() val combinedGenerics = operationGenerics + handleGenerics val codegenScope = arrayOf( @@ -469,8 +469,8 @@ private fun renderCustomizableOperationSend( val smithyHttp = CargoDependency.SmithyHttp(runtimeConfig).asType() val smithyClient = CargoDependency.SmithyClient(runtimeConfig).asType() - val operationGenerics = GenericsGenerator(GenericTypeArg("O"), GenericTypeArg("Retry")) - val handleGenerics = generics.toGenericsGenerator() + val operationGenerics = RustGenerics(GenericTypeArg("O"), GenericTypeArg("Retry")) + val handleGenerics = generics.toRustGenerics() val combinedGenerics = operationGenerics + handleGenerics val codegenScope = arrayOf( diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index f0e09372aa..f855156820 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -6,13 +6,13 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.client import software.amazon.smithy.codegen.core.Symbol +import software.amazon.smithy.rust.codegen.core.rustlang.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.rustlang.RustGenerics import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator interface FluentClientGenerics { /** Declaration with defaults set */ @@ -30,8 +30,8 @@ interface FluentClientGenerics { /** Bounds for generated `send()` functions */ fun sendBounds(operation: Symbol, output: Symbol, error: RuntimeType, retryClassifier: RuntimeType): Writable - /** Convert this `FluentClientGenerics` into the more general `GenericsGenerator` */ - fun toGenericsGenerator(): GenericsGenerator + /** Convert this `FluentClientGenerics` into the more general `RustGenerics` */ + fun toRustGenerics(): RustGenerics } data class FlexibleClientGenerics( @@ -89,7 +89,7 @@ data class FlexibleClientGenerics( ) } - override fun toGenericsGenerator(): GenericsGenerator = GenericsGenerator( + override fun toRustGenerics(): RustGenerics = RustGenerics( GenericTypeArg("C", client.member("bounds::SmithyConnector")), GenericTypeArg("M", client.member("bounds::SmithyMiddleware")), GenericTypeArg("R", client.member("retry::NewRequestPolicy")), diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/RustGenericsTest.kt similarity index 84% rename from codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt rename to codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/RustGenericsTest.kt index ceb71e3e2a..73fd5500e9 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/GenericsGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/RustGenericsTest.kt @@ -7,16 +7,16 @@ package software.amazon.smithy.rust.codegen.client.generators import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test +import software.amazon.smithy.rust.codegen.core.rustlang.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.rustlang.RustGenerics import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator -class GenericsGeneratorTest { +class RustGenericsTest { @Test fun `declaration is correct for no args`() { - val gg = GenericsGenerator() + val gg = RustGenerics() val writer = RustWriter.forModule("model") writer.rustTemplate("A#{decl:W}B", "decl" to gg.declaration()) @@ -25,7 +25,7 @@ class GenericsGeneratorTest { @Test fun `declaration is correct for 1 arg`() { - val gg = GenericsGenerator(GenericTypeArg("T")) + val gg = RustGenerics(GenericTypeArg("T")) val writer = RustWriter.forModule("model") writer.rustTemplate("#{decl:W}", "decl" to gg.declaration()) @@ -34,7 +34,7 @@ class GenericsGeneratorTest { @Test fun `declaration is correct for several args`() { - val gg = GenericsGenerator(GenericTypeArg("T"), GenericTypeArg("U"), GenericTypeArg("V")) + val gg = RustGenerics(GenericTypeArg("T"), GenericTypeArg("U"), GenericTypeArg("V")) val writer = RustWriter.forModule("model") writer.rustTemplate("#{decl:W}", "decl" to gg.declaration()) @@ -43,7 +43,7 @@ class GenericsGeneratorTest { @Test fun `bounds is correct for no args`() { - val gg = GenericsGenerator() + val gg = RustGenerics() val writer = RustWriter.forModule("model") writer.rustTemplate("A#{bounds:W}B", "bounds" to gg.bounds()) @@ -52,7 +52,7 @@ class GenericsGeneratorTest { @Test fun `bounds is correct for 1 arg`() { - val gg = GenericsGenerator(GenericTypeArg("T", testRT("Test"))) + val gg = RustGenerics(GenericTypeArg("T", testRT("Test"))) val writer = RustWriter.forModule("model") writer.rustTemplate("#{bounds:W}", "bounds" to gg.bounds()) @@ -61,7 +61,7 @@ class GenericsGeneratorTest { @Test fun `bounds is correct for several args`() { - val gg = GenericsGenerator( + val gg = RustGenerics( GenericTypeArg("A", testRT("Apple")), GenericTypeArg("PL", testRT("Plum")), GenericTypeArg("PE", testRT("Pear")), @@ -78,7 +78,7 @@ class GenericsGeneratorTest { @Test fun `bounds skips arg with no bounds`() { - val gg = GenericsGenerator( + val gg = RustGenerics( GenericTypeArg("A", testRT("Apple")), GenericTypeArg("PL"), GenericTypeArg("PE", testRT("Pear")), @@ -94,7 +94,7 @@ class GenericsGeneratorTest { @Test fun `bounds generates nothing if all args are skipped`() { - val gg = GenericsGenerator( + val gg = RustGenerics( GenericTypeArg("A"), GenericTypeArg("PL"), GenericTypeArg("PE"), @@ -107,10 +107,10 @@ class GenericsGeneratorTest { @Test fun `Adding GenericGenerators works`() { - val ggA = GenericsGenerator( + val ggA = RustGenerics( GenericTypeArg("A", testRT("Apple")), ) - val ggB = GenericsGenerator( + val ggB = RustGenerics( GenericTypeArg("B", testRT("Banana")), ) RustWriter.forModule("model").let { writer -> diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt index c6051a9bb6..f770d5be61 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/rustlang/WritableTest.kt @@ -7,6 +7,8 @@ package software.amazon.smithy.rust.codegen.client.rustlang import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Test +import software.amazon.smithy.rust.codegen.core.rustlang.GenericTypeArg +import software.amazon.smithy.rust.codegen.core.rustlang.RustGenerics import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.join @@ -15,8 +17,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericTypeArg -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator internal class RustTypeParametersTest { private fun forInputExpectOutput(input: Any, expectedOutput: String) { @@ -51,8 +51,8 @@ internal class RustTypeParametersTest { } @Test - fun `rustTypeParameters accepts GenericsGenerator`() { - forInputExpectOutput(GenericsGenerator(GenericTypeArg("A"), GenericTypeArg("B")), "''") + fun `rustTypeParameters accepts RustGenerics`() { + forInputExpectOutput(RustGenerics(GenericTypeArg("A"), GenericTypeArg("B")), "''") } @Test @@ -63,7 +63,7 @@ internal class RustTypeParametersTest { RustType.Unit, RuntimeType("String", namespace = "std::string", dependency = null), "T", - GenericsGenerator(GenericTypeArg("A"), GenericTypeArg("B")), + RustGenerics(GenericTypeArg("A"), GenericTypeArg("B")), ) writer.rustInlineTemplate("'") writer.rustInlineTemplate("#{tps:W}", "tps" to tps) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/GenericsGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustGenerics.kt similarity index 88% rename from codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/GenericsGenerator.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustGenerics.kt index 6cce15324b..b5de87b76c 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/GenericsGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustGenerics.kt @@ -3,11 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.rust.codegen.core.smithy.generators +package software.amazon.smithy.rust.codegen.core.rustlang -import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate -import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType data class GenericTypeArg( @@ -54,7 +51,7 @@ data class GenericTypeArg( * // } * ``` */ -class GenericsGenerator(vararg genericTypeArgs: GenericTypeArg) { +class RustGenerics(vararg genericTypeArgs: GenericTypeArg) { private val typeArgs: List init { @@ -148,7 +145,7 @@ class GenericsGenerator(vararg genericTypeArgs: GenericTypeArg) { * // Writes "fn eat_fruit()" * */ - operator fun plus(operationGenerics: GenericsGenerator): GenericsGenerator { - return GenericsGenerator(*(typeArgs + operationGenerics.typeArgs).toTypedArray()) + operator fun plus(operationGenerics: RustGenerics): RustGenerics { + return RustGenerics(*(typeArgs + operationGenerics.typeArgs).toTypedArray()) } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt index fe07dd9532..f1ed5ad944 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/Writable.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.core.rustlang import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.GenericsGenerator typealias Writable = RustWriter.() -> Unit @@ -103,7 +102,7 @@ fun rustTypeParameters( when (typeParameter) { is Symbol, is RuntimeType, is RustType -> rustInlineTemplate("#{it}", "it" to typeParameter) is String -> rustInlineTemplate(typeParameter) - is GenericsGenerator -> rustInlineTemplate( + is RustGenerics -> rustInlineTemplate( "#{gg:W}", "gg" to typeParameter.declaration(withAngleBrackets = false), ) From 90d250dbb5ef6781050f623c14d58e124d819d28 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 13:37:46 +0200 Subject: [PATCH 15/18] Rename `CoreCodegenContext` as `CodegenContext`, since it's now in the `codegen-core` module --- .../smithy/rustsdk/AwsEndpointDecorator.kt | 18 +++--- .../rustsdk/AwsFluentClientDecorator.kt | 16 +++--- .../smithy/rustsdk/AwsPresigningDecorator.kt | 19 +++---- .../smithy/rustsdk/AwsReadmeDecorator.kt | 4 +- .../smithy/rustsdk/CrateLicenseDecorator.kt | 4 +- .../smithy/rustsdk/CredentialProviders.kt | 4 +- .../rustsdk/HttpRequestChecksumDecorator.kt | 4 +- .../rustsdk/HttpResponseChecksumDecorator.kt | 4 +- .../rustsdk/IntegrationTestDependencies.kt | 4 +- .../amazon/smithy/rustsdk/RegionDecorator.kt | 10 ++-- .../rustsdk/RetryClassifierDecorator.kt | 4 +- .../smithy/rustsdk/SdkConfigDecorator.kt | 4 +- .../smithy/rustsdk/ServiceConfigDecorator.kt | 4 +- .../smithy/rustsdk/SigV4SigningDecorator.kt | 6 +- .../smithy/rustsdk/UserAgentDecorator.kt | 4 +- .../apigateway/ApiGatewayDecorator.kt | 8 +-- .../customize/auth/DisabledAuthDecorator.kt | 4 +- .../rustsdk/customize/ec2/Ec2Decorator.kt | 4 +- .../customize/glacier/GlacierDecorator.kt | 6 +- .../customize/route53/Route53Decorator.kt | 4 +- .../rustsdk/customize/s3/S3Decorator.kt | 8 +-- .../rustsdk/customize/sts/STSDecorator.kt | 4 +- .../EndpointConfigCustomizationTest.kt | 4 +- .../client/smithy/ClientCodegenContext.kt | 6 +- .../client/smithy/ServerCodegenContext.kt | 6 +- .../customizations/ClientCustomizations.kt | 4 +- .../customizations/DocsRsMetadataDecorator.kt | 4 +- .../customizations/EndpointPrefixGenerator.kt | 10 ++-- .../HttpChecksumRequiredGenerator.kt | 10 ++-- .../HttpVersionListCustomization.kt | 10 ++-- .../IdempotencyTokenGenerator.kt | 8 +-- .../ResiliencyConfigCustomization.kt | 12 ++-- .../NoOpEventStreamSigningDecorator.kt | 8 +-- .../customize/RequiredCustomizations.kt | 4 +- .../smithy/customize/RustCodegenDecorator.kt | 16 +++--- .../smithy/generators/PaginatorGenerator.kt | 12 ++-- .../client/FluentClientDecorator.kt | 10 ++-- .../config/ServiceConfigGenerator.kt | 6 +- .../protocol/ClientProtocolGenerator.kt | 6 +- .../protocol/ProtocolTestGenerator.kt | 50 ++++++++--------- .../client/smithy/protocols/AwsJson.kt | 26 ++++----- .../client/smithy/protocols/AwsQuery.kt | 12 ++-- .../client/smithy/protocols/Ec2Query.kt | 12 ++-- .../protocols/HttpBoundProtocolGenerator.kt | 34 +++++------ .../client/smithy/protocols/RestJson.kt | 12 ++-- .../client/smithy/protocols/RestXml.kt | 14 ++--- .../codegen/client/testutil/TestHelpers.kt | 4 +- .../http/ResponseBindingGeneratorTest.kt | 8 +-- .../generators/EndpointTraitBindingsTest.kt | 4 +- .../protocol/ProtocolTestGeneratorTest.kt | 26 ++++----- .../client/testutil/AddRustTestsDecorator.kt | 6 +- ...oreCodegenContext.kt => CodegenContext.kt} | 4 +- .../error/TopLevelErrorGenerator.kt | 24 ++++---- .../generators/http/HttpBindingGenerator.kt | 14 ++--- .../http/RequestBindingGenerator.kt | 12 ++-- .../http/ResponseBindingGenerator.kt | 6 +- .../protocol/MakeOperationGenerator.kt | 20 +++---- .../generators/protocol/ProtocolGenerator.kt | 8 +-- .../HttpBoundProtocolPayloadGenerator.kt | 12 ++-- .../codegen/core/smithy/protocols/Protocol.kt | 4 +- .../core/smithy/protocols/ProtocolLoader.kt | 4 +- .../parse/AwsQueryParserGenerator.kt | 8 +-- .../parse/Ec2QueryParserGenerator.kt | 8 +-- .../protocols/parse/JsonParserGenerator.kt | 14 ++--- .../protocols/parse/RestXmlParserGenerator.kt | 6 +- .../parse/XmlBindingTraitParserGenerator.kt | 15 +++-- .../serialize/AwsQuerySerializerGenerator.kt | 4 +- .../serialize/Ec2QuerySerializerGenerator.kt | 4 +- .../serialize/JsonSerializerGenerator.kt | 12 ++-- .../serialize/QuerySerializerGenerator.kt | 14 ++--- .../XmlBindingTraitSerializerGenerator.kt | 15 +++-- .../PythonServerCodegenDecorator.kt | 8 +-- .../generators/PythonApplicationGenerator.kt | 14 ++--- .../PythonServerOperationHandlerGenerator.kt | 10 ++-- .../PythonServerServiceGenerator.kt | 4 +- .../AdditionalErrorsDecorator.kt | 6 +- .../ServerRequiredCustomizations.kt | 4 +- .../generators/ServerOperationGenerator.kt | 10 ++-- .../ServerOperationHandlerGenerator.kt | 14 ++--- .../ServerOperationRegistryGenerator.kt | 16 +++--- .../generators/ServerServiceGenerator.kt | 18 +++--- .../generators/ServerServiceGeneratorV2.kt | 16 +++--- .../http/ServerRequestBindingGenerator.kt | 6 +- .../http/ServerResponseBindingGenerator.kt | 6 +- .../generators/protocol/ServerProtocol.kt | 56 +++++++++---------- .../protocol/ServerProtocolGenerator.kt | 6 +- .../protocol/ServerProtocolTestGenerator.kt | 56 +++++++++---------- .../server/smithy/protocols/ServerAwsJson.kt | 6 +- .../smithy/protocols/EventStreamTestTools.kt | 5 +- .../EventStreamUnmarshallerGeneratorTest.kt | 4 +- .../EventStreamMarshallerGeneratorTest.kt | 4 +- 91 files changed, 481 insertions(+), 487 deletions(-) rename codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/{CoreCodegenContext.kt => CodegenContext.kt} (95%) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt index 49cab7d426..af3ae09c6a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt @@ -27,7 +27,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -85,22 +85,22 @@ class AwsEndpointDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } class EndpointConfigCustomization( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val endpointData: ObjectNode, ) : ConfigCustomization() { - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig private val resolveAwsEndpoint = runtimeConfig.awsEndpoint().asType().copy(name = "ResolveAwsEndpoint") private val smithyEndpointResolver = CargoDependency.SmithyHttp(runtimeConfig).asType().member("endpoint::ResolveEndpoint") private val placeholderEndpointParams = runtimeConfig.awsEndpoint().asType().member("Params") private val endpointShim = runtimeConfig.awsEndpoint().asType().member("EndpointShim") - private val moduleUseName = coreCodegenContext.moduleUseName() + private val moduleUseName = codegenContext.moduleUseName() private val codegenScope = arrayOf( "SmithyResolver" to smithyEndpointResolver, "PlaceholderParams" to placeholderEndpointParams, @@ -158,7 +158,7 @@ class EndpointConfigCustomization( ) ServiceConfig.BuilderBuild -> { - val resolverGenerator = EndpointResolverGenerator(coreCodegenContext, endpointData) + val resolverGenerator = EndpointResolverGenerator(codegenContext, endpointData) rustTemplate( """ endpoint_resolver: self.endpoint_resolver.unwrap_or_else(|| @@ -217,9 +217,9 @@ class PubUseEndpoint(private val runtimeConfig: RuntimeConfig) : LibRsCustomizat } } -class EndpointResolverGenerator(coreCodegenContext: CoreCodegenContext, private val endpointData: ObjectNode) { - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val endpointPrefix = coreCodegenContext.serviceShape.expectTrait().endpointPrefix +class EndpointResolverGenerator(codegenContext: CodegenContext, private val endpointData: ObjectNode) { + private val runtimeConfig = codegenContext.runtimeConfig + private val endpointPrefix = codegenContext.serviceShape.expectTrait().endpointPrefix private val awsEndpoint = runtimeConfig.awsEndpoint().asType() private val awsTypes = runtimeConfig.awsTypes().asType() private val codegenScope = diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index 2026781b03..387c115a05 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -28,7 +28,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate @@ -132,7 +132,7 @@ class AwsFluentClientDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } @@ -209,17 +209,17 @@ private class AwsFluentClientExtensions(types: Types) { } } -private class AwsFluentClientDocs(private val coreCodegenContext: CoreCodegenContext) : FluentClientCustomization() { - private val serviceName = coreCodegenContext.serviceShape.expectTrait().value - private val serviceShape = coreCodegenContext.serviceShape - private val crateName = coreCodegenContext.moduleUseName() +private class AwsFluentClientDocs(private val codegenContext: CodegenContext) : FluentClientCustomization() { + private val serviceName = codegenContext.serviceShape.expectTrait().value + private val serviceShape = codegenContext.serviceShape + private val crateName = codegenContext.moduleUseName() private val codegenScope = - arrayOf("aws_config" to coreCodegenContext.runtimeConfig.awsConfig().copy(scope = DependencyScope.Dev).asType()) + arrayOf("aws_config" to codegenContext.runtimeConfig.awsConfig().copy(scope = DependencyScope.Dev).asType()) // If no `aws-config` version is provided, assume that docs referencing `aws-config` cannot be given. // Also, STS and SSO must NOT reference `aws-config` since that would create a circular dependency. private fun suppressUsageDocs(): Boolean = - SdkSettings.from(coreCodegenContext.settings).awsConfigVersion == null || + SdkSettings.from(codegenContext.settings).awsConfigVersion == null || setOf( ShapeId.from("com.amazonaws.sts#AWSSecurityTokenServiceV20110615"), ShapeId.from("com.amazonaws.sso#SWBPortalService"), diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt index 7eebb3b1c3..3a2e4d5ed1 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt @@ -32,7 +32,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -44,7 +44,6 @@ import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware import software.amazon.smithy.rustsdk.traits.PresignableTrait -import kotlin.streams.toList internal enum class PayloadSigningType { EMPTY, @@ -118,7 +117,7 @@ class AwsPresigningDecorator internal constructor( return presignableTransforms.fold(intermediate) { m, t -> t.transform(m) } } - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) private fun addSyntheticOperations(model: Model): Model { @@ -134,11 +133,11 @@ class AwsPresigningDecorator internal constructor( } class AwsInputPresignedMethod( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val operationShape: OperationShape, ) : OperationCustomization() { - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val symbolProvider = coreCodegenContext.symbolProvider + private val runtimeConfig = codegenContext.runtimeConfig + private val symbolProvider = codegenContext.symbolProvider private val codegenScope = arrayOf( "Error" to AwsRuntimeType.Presigning.member("config::Error"), @@ -160,11 +159,11 @@ class AwsInputPresignedMethod( } private fun RustWriter.writeInputPresignedMethod(section: OperationSection.InputImpl) { - val operationError = operationShape.errorSymbol(coreCodegenContext.model, symbolProvider, coreCodegenContext.target) + val operationError = operationShape.errorSymbol(codegenContext.model, symbolProvider, codegenContext.target) val presignableOp = PRESIGNABLE_OPERATIONS.getValue(operationShape.id) val makeOperationOp = if (presignableOp.hasModelTransforms()) { - coreCodegenContext.model.expectShape(syntheticShapeId(operationShape.id), OperationShape::class.java) + codegenContext.model.expectShape(syntheticShapeId(operationShape.id), OperationShape::class.java) } else { section.operationShape } @@ -172,9 +171,9 @@ class AwsInputPresignedMethod( val protocol = section.protocol MakeOperationGenerator( - coreCodegenContext, + codegenContext, protocol, - HttpBoundProtocolPayloadGenerator(coreCodegenContext, protocol), + HttpBoundProtocolPayloadGenerator(codegenContext, protocol), // Prefixed with underscore to avoid colliding with modeled functions functionName = makeOperationFn, public = false, diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt index 606cf0c7a8..05175db3d6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.raw -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations import software.amazon.smithy.rust.codegen.core.util.getTrait @@ -31,7 +31,7 @@ class AwsReadmeDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) override fun crateManifestCustomizations(codegenContext: ClientCodegenContext): ManifestCustomizations = diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt index d1d6067a4a..2f5baf4c0d 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CrateLicenseDecorator.kt @@ -9,7 +9,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.raw -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate class CrateLicenseDecorator : RustCodegenDecorator { @@ -24,6 +24,6 @@ class CrateLicenseDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt index e6539d2a98..47e74d3ad0 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt @@ -16,7 +16,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -50,7 +50,7 @@ class CredentialsProviderDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt index d73b543f01..a14c9843cb 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt @@ -16,7 +16,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -54,7 +54,7 @@ class HttpRequestChecksumDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt index 2aa3e931d0..c695c5c407 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDe import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.expectMember @@ -41,7 +41,7 @@ class HttpResponseChecksumDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt index 1a2356ae3b..76d42c8255 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection @@ -52,7 +52,7 @@ class IntegrationTestDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index 7f63226084..3a6aaf40a6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -97,13 +97,13 @@ class RegionDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } -class RegionProviderConfig(coreCodegenContext: CoreCodegenContext) : ConfigCustomization() { - private val region = region(coreCodegenContext.runtimeConfig) - private val moduleUseName = coreCodegenContext.moduleUseName() +class RegionProviderConfig(codegenContext: CodegenContext) : ConfigCustomization() { + private val region = region(codegenContext.runtimeConfig) + private val moduleUseName = codegenContext.moduleUseName() private val codegenScope = arrayOf("Region" to region.member("Region")) override fun section(section: ServiceConfig) = writable { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt index 88d9f1e3d6..4d1aa4973d 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt @@ -12,7 +12,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.Cli import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -30,7 +30,7 @@ class RetryClassifierDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt index 64b7522603..4d0489ef67 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RustCrate @@ -69,7 +69,7 @@ class SdkConfigDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt index a0b270eda6..e8729060e8 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/ServiceConfigDecorator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.Cli import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext class ServiceConfigDecorator : RustCodegenDecorator { override val name: String = "ServiceConfigGenerator" @@ -24,7 +24,7 @@ class ServiceConfigDecorator : RustCodegenDecorator, ): List = baseCustomizations + SharedConfigDocsCustomization() - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt index 99454c5a59..97b8813bfb 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt @@ -23,7 +23,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -47,7 +47,7 @@ class SigV4SigningDecorator : RustCodegenDecorator() + private fun applies(codegenContext: CodegenContext): Boolean = codegenContext.serviceShape.hasTrait() override fun configCustomizations( codegenContext: ClientCodegenContext, @@ -77,7 +77,7 @@ class SigV4SigningDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt index d363b6463c..f18c9cd06b 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt @@ -17,7 +17,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -58,7 +58,7 @@ class UserAgentDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt index 0f6c837caf..23d489a5ce 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/apigateway/ApiGatewayDecorator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.Cli import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -23,8 +23,8 @@ class ApiGatewayDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt index 20b0fb6eaa..57acccd6a5 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/auth/DisabledAuthDecorator.kt @@ -14,7 +14,7 @@ import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext private fun String.shapeId() = ShapeId.from(this) @@ -49,6 +49,6 @@ class DisabledAuthDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt index b3729f7134..630ac0af02 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/ec2/Ec2Decorator.kt @@ -11,7 +11,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.util.letIf class Ec2Decorator : RustCodegenDecorator { @@ -31,6 +31,6 @@ class Ec2Decorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt index 32c47020ab..166ca7e3b1 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/GlacierDecorator.kt @@ -10,7 +10,7 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization val Glacier: ShapeId = ShapeId.from("com.amazonaws.glacier#Glacier") @@ -19,7 +19,7 @@ class GlacierDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt index 5b495f472a..adff13cf80 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt @@ -18,7 +18,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.Cli import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -61,7 +61,7 @@ class Route53Decorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) private fun isResourceId(shape: Shape): Boolean { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt index ace7fdf698..e99ef76e54 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/s3/S3Decorator.kt @@ -26,7 +26,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection @@ -81,7 +81,7 @@ class S3Decorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) private fun isInInvalidXmlRootAllowList(shape: Shape): Boolean { @@ -89,8 +89,8 @@ class S3Decorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt index 3c965df357..11dd45f2bb 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointConfigCustomizationTest.kt @@ -22,7 +22,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.util.runCommand @@ -152,7 +152,7 @@ internal class EndpointConfigCustomizationTest { } } - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } val customization = CombinedCodegenDecorator(listOf(RequiredCustomizations(), codegenDecorator)) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt index c4936155ab..e2d49cd0fe 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt @@ -9,14 +9,14 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider /** * [ClientCodegenContext] contains code-generation context that is _specific_ to the [RustCodegenPlugin] plugin * from the `rust-codegen` subproject. * - * It inherits from [CoreCodegenContext], which contains code-generation context that is common to _all_ smithy-rs plugins. + * It inherits from [CodegenContext], which contains code-generation context that is common to _all_ smithy-rs plugins. */ data class ClientCodegenContext( override val model: Model, @@ -24,6 +24,6 @@ data class ClientCodegenContext( override val serviceShape: ServiceShape, override val protocol: ShapeId, override val settings: ClientRustSettings, -) : CoreCodegenContext( +) : CodegenContext( model, symbolProvider, serviceShape, protocol, settings, CodegenTarget.CLIENT, ) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt index 9f82093085..e78b986b42 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt @@ -9,14 +9,14 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider /** * [ServerCodegenContext] contains code-generation context that is _specific_ to the [RustCodegenServerPlugin] plugin * from the `rust-codegen-server` subproject. * - * It inherits from [CoreCodegenContext], which contains code-generation context that is common to _all_ smithy-rs plugins. + * It inherits from [CodegenContext], which contains code-generation context that is common to _all_ smithy-rs plugins. * * This class has to live in the `codegen` subproject because it is referenced in common generators to both client * and server (like [JsonParserGenerator]). @@ -27,6 +27,6 @@ data class ServerCodegenContext( override val serviceShape: ServiceShape, override val protocol: ShapeId, override val settings: ServerRustSettings, -) : CoreCodegenContext( +) : CodegenContext( model, symbolProvider, serviceShape, protocol, settings, CodegenTarget.SERVER, ) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt index c52c69f951..6ff57e85ab 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientCustomizations.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization /** @@ -23,6 +23,6 @@ class ClientCustomizations : RustCodegenDecorator, ): List = baseCustomizations + ClientDocsGenerator() - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt index 45335f0dd4..7809ccffbd 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/DocsRsMetadataDecorator.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rust.codegen.client.smithy.customizations import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations /** @@ -59,6 +59,6 @@ class DocsRsMetadataDecorator(private val docsRsMetadataSettings: DocsRsMetadata return docsRsMetadataSettings.asMap() } - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt index f9fb5eba20..110ca580c6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/EndpointPrefixGenerator.kt @@ -12,19 +12,19 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection -class EndpointPrefixGenerator(private val coreCodegenContext: CoreCodegenContext, private val shape: OperationShape) : +class EndpointPrefixGenerator(private val codegenContext: CodegenContext, private val shape: OperationShape) : OperationCustomization() { override fun section(section: OperationSection): Writable = when (section) { is OperationSection.MutateRequest -> writable { shape.getTrait(EndpointTrait::class.java).map { epTrait -> val endpointTraitBindings = EndpointTraitBindings( - coreCodegenContext.model, - coreCodegenContext.symbolProvider, - coreCodegenContext.runtimeConfig, + codegenContext.model, + codegenContext.symbolProvider, + codegenContext.runtimeConfig, shape, epTrait, ) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt index a2da885ef2..75feb396f0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -23,14 +23,14 @@ import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.inputShape class HttpChecksumRequiredGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val operationShape: OperationShape, ) : OperationCustomization() { override fun section(section: OperationSection): Writable { if (!operationShape.hasTrait()) { return emptySection } - if (operationShape.inputShape(coreCodegenContext.model).hasStreamingMember(coreCodegenContext.model)) { + if (operationShape.inputShape(codegenContext.model).hasStreamingMember(codegenContext.model)) { throw CodegenException("HttpChecksum required cannot be applied to a streaming shape") } return when (section) { @@ -52,8 +52,8 @@ class HttpChecksumRequiredGenerator( """, "md5" to CargoDependency.Md5.asType(), "http" to CargoDependency.Http.asType(), - "base64_encode" to RuntimeType.Base64Encode(coreCodegenContext.runtimeConfig), - "BuildError" to coreCodegenContext.runtimeConfig.operationBuildError(), + "base64_encode" to RuntimeType.Base64Encode(codegenContext.runtimeConfig), + "BuildError" to codegenContext.runtimeConfig.operationBuildError(), ) } else -> emptySection diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt index ac6ca51611..8550adcefa 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpVersionListCustomization.kt @@ -10,7 +10,7 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization @@ -24,19 +24,19 @@ private fun RuntimeConfig.defaultHttpVersionList(): RuntimeType = this.httpVersionModule().member("DEFAULT_HTTP_VERSION_LIST") class HttpVersionListCustomization( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val operationShape: OperationShape, ) : OperationCustomization() { - private val defaultHttpVersions = coreCodegenContext.runtimeConfig.defaultHttpVersionList().fullyQualifiedName() + private val defaultHttpVersions = codegenContext.runtimeConfig.defaultHttpVersionList().fullyQualifiedName() override fun section(section: OperationSection): Writable { - val awsProtocolTrait = coreCodegenContext.serviceShape.getTrait() + val awsProtocolTrait = codegenContext.serviceShape.getTrait() val supportedHttpProtocolVersions = if (awsProtocolTrait == null) { // No protocol trait was defined, use default http versions "$defaultHttpVersions.clone()" } else { // Figure out whether we're dealing with an EventStream operation and fetch the corresponding list of desired HTTP versions - val versionList = if (operationShape.isEventStream(coreCodegenContext.model)) awsProtocolTrait.eventStreamHttp else awsProtocolTrait.http + val versionList = if (operationShape.isEventStream(codegenContext.model)) awsProtocolTrait.eventStreamHttp else awsProtocolTrait.http if (versionList.isEmpty()) { // If no desired versions are specified, go with the default "$defaultHttpVersions.clone()" diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt index 8049321c01..049b92a25d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt @@ -10,16 +10,16 @@ import software.amazon.smithy.model.traits.IdempotencyTokenTrait import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.util.findMemberWithTrait import software.amazon.smithy.rust.codegen.core.util.inputShape -class IdempotencyTokenGenerator(coreCodegenContext: CoreCodegenContext, private val operationShape: OperationShape) : +class IdempotencyTokenGenerator(codegenContext: CodegenContext, private val operationShape: OperationShape) : OperationCustomization() { - private val model = coreCodegenContext.model - private val symbolProvider = coreCodegenContext.symbolProvider + private val model = codegenContext.model + private val symbolProvider = codegenContext.symbolProvider private val idempotencyTokenMember = operationShape.inputShape(model).findMemberWithTrait(model) override fun section(section: OperationSection): Writable { if (idempotencyTokenMember == null) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt index 33bc3fd2c1..8e6439fe2f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt @@ -10,17 +10,17 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.config.Servi import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection -class ResiliencyConfigCustomization(coreCodegenContext: CoreCodegenContext) : ConfigCustomization() { - private val retryConfig = smithyTypesRetry(coreCodegenContext.runtimeConfig) - private val sleepModule = smithyAsyncRtSleep(coreCodegenContext.runtimeConfig) - private val timeoutModule = smithyTypesTimeout(coreCodegenContext.runtimeConfig) - private val moduleUseName = coreCodegenContext.moduleUseName() +class ResiliencyConfigCustomization(codegenContext: CodegenContext) : ConfigCustomization() { + private val retryConfig = smithyTypesRetry(codegenContext.runtimeConfig) + private val sleepModule = smithyAsyncRtSleep(codegenContext.runtimeConfig) + private val timeoutModule = smithyTypesTimeout(codegenContext.runtimeConfig) + private val moduleUseName = codegenContext.moduleUseName() private val codegenScope = arrayOf( "AsyncSleep" to sleepModule.member("AsyncSleep"), "RetryConfig" to retryConfig.member("RetryConfig"), diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt index d906d83e7a..f4cfce3898 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt @@ -10,7 +10,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.config.Event import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.hasEventStreamOperations @@ -19,11 +19,11 @@ import software.amazon.smithy.rust.codegen.core.util.hasEventStreamOperations * The NoOpEventStreamSigningDecorator: * - adds a `new_event_stream_signer()` method to `config` to create an Event Stream NoOp signer */ -open class NoOpEventStreamSigningDecorator : RustCodegenDecorator { +open class NoOpEventStreamSigningDecorator : RustCodegenDecorator { override val name: String = "NoOpEventStreamSigning" override val order: Byte = Byte.MIN_VALUE - private fun applies(codegenContext: CoreCodegenContext, baseCustomizations: List): Boolean = + private fun applies(codegenContext: CodegenContext, baseCustomizations: List): Boolean = codegenContext.serviceShape.hasEventStreamOperations(codegenContext.model) && // and if there is no other `EventStreamSigningConfig`, apply this one !baseCustomizations.any { it is EventStreamSigningConfig } @@ -41,7 +41,7 @@ open class NoOpEventStreamSigningDecorator : RustCode ) } - override fun supportsCodegenContext(clazz: Class) = true + override fun supportsCodegenContext(clazz: Class) = true } class NoOpEventStreamSigningConfig( diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt index 674dcca11a..4163378239 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt @@ -19,7 +19,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.customizations.SmithyTy import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Feature -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization @@ -64,6 +64,6 @@ class RequiredCustomizations : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt index 1b34057dbb..2b22ed040b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RustCodegenDecorator.kt @@ -11,7 +11,7 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization @@ -28,7 +28,7 @@ import java.util.logging.Logger * AWS services. A different downstream customer may wish to add a different set of derive * attributes to the generated classes. */ -interface RustCodegenDecorator { +interface RustCodegenDecorator { /** * The name of this [RustCodegenDecorator], used for logging and debug information */ @@ -70,7 +70,7 @@ interface RustCodegenDecorator { fun transformModel(service: ServiceShape, model: Model): Model = model - fun supportsCodegenContext(clazz: Class): Boolean + fun supportsCodegenContext(clazz: Class): Boolean } /** @@ -78,7 +78,7 @@ interface RustCodegenDecorator { * * This makes the actual concrete codegen simpler by not needing to deal with multiple separate decorators. */ -open class CombinedCodegenDecorator(decorators: List>) : +open class CombinedCodegenDecorator(decorators: List>) : RustCodegenDecorator { private val orderedDecorators = decorators.sortedBy { it.order } override val name: String @@ -141,12 +141,12 @@ open class CombinedCodegenDecorator(decorators: List< } } - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = // `CombinedCodegenDecorator` can work with all types of codegen context. - CoreCodegenContext::class.java.isAssignableFrom(clazz) + CodegenContext::class.java.isAssignableFrom(clazz) companion object { - inline fun fromClasspath( + inline fun fromClasspath( context: PluginContext, vararg extras: RustCodegenDecorator, logger: Logger = Logger.getLogger("RustCodegenSPILoader"), @@ -166,7 +166,7 @@ open class CombinedCodegenDecorator(decorators: List< * non-public-API declarations. * See https://kotlinlang.org/docs/inline-functions.html#restrictions-for-public-api-inline-functions. */ - inline fun filterDecorators( + inline fun filterDecorators( decorators: Iterable>, logger: Logger = Logger.getLogger("RustCodegenSPILoader"), ): Sequence> = diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt index c5233aeb08..1c69e6b6e0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt @@ -25,7 +25,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol @@ -54,16 +54,16 @@ class PaginatorGenerator private constructor( ) { companion object { fun paginatorType( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, generics: FluentClientGenerics, operationShape: OperationShape, retryClassifier: RuntimeType, ): RuntimeType? { - return if (operationShape.isPaginated(coreCodegenContext.model)) { + return if (operationShape.isPaginated(codegenContext.model)) { PaginatorGenerator( - coreCodegenContext.model, - coreCodegenContext.symbolProvider, - coreCodegenContext.serviceShape, + codegenContext.model, + codegenContext.symbolProvider, + codegenContext.serviceShape, operationShape, generics, retryClassifier, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt index cd7cc9c5af..6666357a75 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt @@ -17,7 +17,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator @@ -63,7 +63,7 @@ class FluentClientDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } @@ -80,9 +80,9 @@ sealed class FluentClientSection(name: String) : Section(name) { abstract class FluentClientCustomization : NamedSectionGenerator() -class GenericFluentClient(coreCodegenContext: CoreCodegenContext) : FluentClientCustomization() { - private val moduleUseName = coreCodegenContext.moduleUseName() - private val clientDep = CargoDependency.SmithyClient(coreCodegenContext.runtimeConfig) +class GenericFluentClient(codegenContext: CodegenContext) : FluentClientCustomization() { + private val moduleUseName = codegenContext.moduleUseName() + private val clientDep = CargoDependency.SmithyClient(codegenContext.runtimeConfig) private val codegenScope = arrayOf("client" to clientDep.asType()) override fun section(section: FluentClientSection): Writable { return when (section) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt index 1dd0aab95f..926eef9793 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.raw import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator import software.amazon.smithy.rust.codegen.core.smithy.customize.Section import software.amazon.smithy.rust.codegen.core.util.hasTrait @@ -111,9 +111,9 @@ typealias ConfigCustomization = NamedSectionGenerator class ServiceConfigGenerator(private val customizations: List = listOf()) { companion object { - fun withBaseBehavior(coreCodegenContext: CoreCodegenContext, extraCustomizations: List): ServiceConfigGenerator { + fun withBaseBehavior(codegenContext: CodegenContext, extraCustomizations: List): ServiceConfigGenerator { val baseFeatures = mutableListOf() - if (coreCodegenContext.serviceShape.needsIdempotencyToken(coreCodegenContext.model)) { + if (codegenContext.serviceShape.needsIdempotencyToken(codegenContext.model)) { baseFeatures.add(IdempotencyTokenProviderCustomization()) } return ServiceConfigGenerator(baseFeatures + extraCustomizations) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt index 53792dac02..9b66e01187 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt @@ -12,7 +12,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.docLink import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -26,11 +26,11 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.util.inputShape open class ClientProtocolGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val protocol: Protocol, private val makeOperationGenerator: MakeOperationGenerator, private val traitGenerator: ProtocolTraitImplGenerator, -) : ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { +) : ProtocolGenerator(codegenContext, protocol, makeOperationGenerator, traitGenerator) { /** * Render all code required for serializing requests and deserializing responses for the operation * diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index 3bf540de52..1b70377521 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -32,7 +32,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol @@ -52,24 +52,24 @@ import java.util.logging.Logger * Generate protocol tests for an operation */ class ProtocolTestGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val protocolSupport: ProtocolSupport, private val operationShape: OperationShape, private val writer: RustWriter, ) { private val logger = Logger.getLogger(javaClass.name) - private val inputShape = operationShape.inputShape(coreCodegenContext.model) - private val outputShape = operationShape.outputShape(coreCodegenContext.model) - private val operationSymbol = coreCodegenContext.symbolProvider.toSymbol(operationShape) - private val operationIndex = OperationIndex.of(coreCodegenContext.model) + private val inputShape = operationShape.inputShape(codegenContext.model) + private val outputShape = operationShape.outputShape(codegenContext.model) + private val operationSymbol = codegenContext.symbolProvider.toSymbol(operationShape) + private val operationIndex = OperationIndex.of(codegenContext.model) - private val instantiator = with(coreCodegenContext) { + private val instantiator = with(codegenContext) { Instantiator(symbolProvider, model, runtimeConfig, CodegenTarget.CLIENT) } private val codegenScope = arrayOf( - "SmithyHttp" to CargoDependency.SmithyHttp(coreCodegenContext.runtimeConfig).asType(), + "SmithyHttp" to CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType(), "Http" to CargoDependency.Http.asType(), "AssertEq" to CargoDependency.PrettyAssertions.asType().member("assert_eq!"), ) @@ -126,7 +126,7 @@ class ProtocolTestGenerator( private fun List.filterMatching(): List { return if (RunOnly.isNullOrEmpty()) { this.filter { testCase -> - testCase.testCase.protocol == coreCodegenContext.protocol && + testCase.testCase.protocol == codegenContext.protocol && !DisableTests.contains(testCase.testCase.id) } } else { @@ -170,7 +170,7 @@ class ProtocolTestGenerator( rust("/* test case disabled for this protocol (not yet supported) */") return } - val customToken = if (inputShape.findMemberWithTrait(coreCodegenContext.model) != null) { + val customToken = if (inputShape.findMemberWithTrait(codegenContext.model) != null) { """.make_token("00000000-0000-4000-8000-000000000000")""" } else "" rust( @@ -236,7 +236,7 @@ class ProtocolTestGenerator( } private fun expectFail(testCase: HttpMessageTestCase): Boolean = ExpectFail.find { - it.id == testCase.id && it.action == testCase.action() && it.service == coreCodegenContext.serviceShape.id.toString() + it.id == testCase.id && it.action == testCase.action() && it.service == codegenContext.serviceShape.id.toString() } != null private fun RustWriter.renderHttpResponseTestCase( @@ -265,11 +265,11 @@ class ProtocolTestGenerator( .body(#T::from(${testCase.body.orNull()?.dq()?.replace("#", "##") ?: "vec![]"})) .unwrap(); """, - RuntimeType.sdkBody(runtimeConfig = coreCodegenContext.runtimeConfig), + RuntimeType.sdkBody(runtimeConfig = codegenContext.runtimeConfig), ) write( "let mut op_response = #T::new(http_response);", - RuntimeType.operationModule(coreCodegenContext.runtimeConfig).member("Response"), + RuntimeType.operationModule(codegenContext.runtimeConfig).member("Response"), ) rustTemplate( """ @@ -284,12 +284,12 @@ class ProtocolTestGenerator( """, "op" to operationSymbol, "bytes" to RuntimeType.Bytes, - "parse_http_response" to CargoDependency.SmithyHttp(coreCodegenContext.runtimeConfig).asType() + "parse_http_response" to CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType() .member("response::ParseHttpResponse"), ) if (expectedShape.hasTrait()) { - val errorSymbol = operationShape.errorSymbol(coreCodegenContext.model, coreCodegenContext.symbolProvider, coreCodegenContext.target) - val errorVariant = coreCodegenContext.symbolProvider.toSymbol(expectedShape).name + val errorSymbol = operationShape.errorSymbol(codegenContext.model, codegenContext.symbolProvider, codegenContext.target) + val errorVariant = codegenContext.symbolProvider.toSymbol(expectedShape).name rust("""let parsed = parsed.expect_err("should be error response");""") rustBlock("if let #TKind::$errorVariant(actual_error) = parsed.kind", errorSymbol) { rustTemplate("#{AssertEq}(expected_output, actual_error);", *codegenScope) @@ -300,8 +300,8 @@ class ProtocolTestGenerator( } else { rust("let parsed = parsed.unwrap();") outputShape.members().forEach { member -> - val memberName = coreCodegenContext.symbolProvider.toMemberName(member) - if (member.isStreaming(coreCodegenContext.model)) { + val memberName = codegenContext.symbolProvider.toMemberName(member) + if (member.isStreaming(codegenContext.model)) { rustTemplate( """ #{AssertEq}( @@ -312,10 +312,10 @@ class ProtocolTestGenerator( *codegenScope, ) } else { - when (coreCodegenContext.model.expectShape(member.target)) { + when (codegenContext.model.expectShape(member.target)) { is DoubleShape, is FloatShape -> { addUseImports( - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "FloatEquals").toSymbol(), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "FloatEquals").toSymbol(), ) rust( """ @@ -349,8 +349,8 @@ class ProtocolTestGenerator( "#T(&body, ${ rustWriter.escape(body).dq() }, #T::from(${(mediaType ?: "unknown").dq()}))", - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "validate_body"), - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "MediaType"), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "validate_body"), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "MediaType"), ) } } @@ -391,7 +391,7 @@ class ProtocolTestGenerator( assertOk(rustWriter) { write( "#T($actualExpression, $variableName)", - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "validate_headers"), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "validate_headers"), ) } } @@ -445,7 +445,7 @@ class ProtocolTestGenerator( assertOk(rustWriter) { write( "#T($actualExpression, $expectedVariableName)", - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, checkFunction), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, checkFunction), ) } } @@ -455,7 +455,7 @@ class ProtocolTestGenerator( * for pretty prettying protocol test helper results */ private fun assertOk(rustWriter: RustWriter, inner: RustWriter.() -> Unit) { - rustWriter.write("#T(", RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "assert_ok")) + rustWriter.write("#T(", RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "assert_ok")) inner(rustWriter) rustWriter.write(");") } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt index 03915265b9..ae2d8e058e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsJson.kt @@ -18,7 +18,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.generators.serializationError @@ -104,12 +104,12 @@ class AwsJsonHttpBindingResolver( * customizes wraps [JsonSerializerGenerator] to add this functionality. */ class AwsJsonSerializerGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, httpBindingResolver: HttpBindingResolver, private val jsonSerializerGenerator: JsonSerializerGenerator = - JsonSerializerGenerator(coreCodegenContext, httpBindingResolver, ::awsJsonFieldName), + JsonSerializerGenerator(codegenContext, httpBindingResolver, ::awsJsonFieldName), ) : StructuredDataSerializerGenerator by jsonSerializerGenerator { - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "Error" to runtimeConfig.serializationError(), "SdkBody" to RuntimeType.sdkBody(runtimeConfig), @@ -118,12 +118,12 @@ class AwsJsonSerializerGenerator( override fun operationInputSerializer(operationShape: OperationShape): RuntimeType { var serializer = jsonSerializerGenerator.operationInputSerializer(operationShape) if (serializer == null) { - val inputShape = operationShape.inputShape(coreCodegenContext.model) - val fnName = coreCodegenContext.symbolProvider.serializeFunctionName(operationShape) + val inputShape = operationShape.inputShape(codegenContext.model) + val fnName = codegenContext.symbolProvider.serializeFunctionName(operationShape) serializer = RuntimeType.forInlineFun(fnName, RustModule.private("operation_ser")) { it.rustBlockTemplate( "pub fn $fnName(_input: &#{target}) -> Result<#{SdkBody}, #{Error}>", - *codegenScope, "target" to coreCodegenContext.symbolProvider.toSymbol(inputShape), + *codegenScope, "target" to codegenContext.symbolProvider.toSymbol(inputShape), ) { rustTemplate("""Ok(#{SdkBody}::from("{}"))""", *codegenScope) } @@ -134,10 +134,10 @@ class AwsJsonSerializerGenerator( } open class AwsJson( - val coreCodegenContext: CoreCodegenContext, + val codegenContext: CodegenContext, val awsJsonVersion: AwsJsonVersion, ) : Protocol { - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig private val errorScope = arrayOf( "Bytes" to RuntimeType.Bytes, "Error" to RuntimeType.GenericError(runtimeConfig), @@ -151,18 +151,18 @@ open class AwsJson( val version: AwsJsonVersion get() = awsJsonVersion override val httpBindingResolver: HttpBindingResolver = - AwsJsonHttpBindingResolver(coreCodegenContext.model, awsJsonVersion) + AwsJsonHttpBindingResolver(codegenContext.model, awsJsonVersion) override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.EPOCH_SECONDS override fun additionalRequestHeaders(operationShape: OperationShape): List> = - listOf("x-amz-target" to "${coreCodegenContext.serviceShape.id.name}.${operationShape.id.name}") + listOf("x-amz-target" to "${codegenContext.serviceShape.id.name}.${operationShape.id.name}") override fun structuredDataParser(operationShape: OperationShape): StructuredDataParserGenerator = - JsonParserGenerator(coreCodegenContext, httpBindingResolver, ::awsJsonFieldName) + JsonParserGenerator(codegenContext, httpBindingResolver, ::awsJsonFieldName) override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator = - AwsJsonSerializerGenerator(coreCodegenContext, httpBindingResolver) + AwsJsonSerializerGenerator(codegenContext, httpBindingResolver) override fun parseHttpGenericError(operationShape: OperationShape): RuntimeType = RuntimeType.forInlineFun("parse_http_generic_error", jsonDeserModule) { writer -> diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt index ed95d63761..4a95ea1269 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQuery.kt @@ -18,7 +18,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver @@ -67,8 +67,8 @@ class AwsQueryBindingResolver(private val model: Model) : } } -class AwsQueryProtocol(private val coreCodegenContext: CoreCodegenContext) : Protocol { - private val runtimeConfig = coreCodegenContext.runtimeConfig +class AwsQueryProtocol(private val codegenContext: CodegenContext) : Protocol { + private val runtimeConfig = codegenContext.runtimeConfig private val awsQueryErrors: RuntimeType = RuntimeType.wrappedXmlErrors(runtimeConfig) private val errorScope = arrayOf( "Bytes" to RuntimeType.Bytes, @@ -79,15 +79,15 @@ class AwsQueryProtocol(private val coreCodegenContext: CoreCodegenContext) : Pro ) private val xmlDeserModule = RustModule.private("xml_deser") - override val httpBindingResolver: HttpBindingResolver = AwsQueryBindingResolver(coreCodegenContext.model) + override val httpBindingResolver: HttpBindingResolver = AwsQueryBindingResolver(codegenContext.model) override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.DATE_TIME override fun structuredDataParser(operationShape: OperationShape): StructuredDataParserGenerator = - AwsQueryParserGenerator(coreCodegenContext, awsQueryErrors) + AwsQueryParserGenerator(codegenContext, awsQueryErrors) override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator = - AwsQuerySerializerGenerator(coreCodegenContext) + AwsQuerySerializerGenerator(codegenContext) override fun parseHttpGenericError(operationShape: OperationShape): RuntimeType = RuntimeType.forInlineFun("parse_http_generic_error", xmlDeserModule) { writer -> diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt index a6faa9d59f..cd19cf2336 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/Ec2Query.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver @@ -49,8 +49,8 @@ class Ec2QueryFactory : ProtocolGeneratorFactory diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt index b4e0d6476d..55e4fe5182 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt @@ -21,7 +21,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -49,28 +49,28 @@ import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.core.util.toSnakeCase class HttpBoundProtocolGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, protocol: Protocol, ) : ClientProtocolGenerator( - coreCodegenContext, + codegenContext, protocol, MakeOperationGenerator( - coreCodegenContext, + codegenContext, protocol, - HttpBoundProtocolPayloadGenerator(coreCodegenContext, protocol), + HttpBoundProtocolPayloadGenerator(codegenContext, protocol), public = true, includeDefaultPayloadHeaders = true, ), - HttpBoundProtocolTraitImplGenerator(coreCodegenContext, protocol), + HttpBoundProtocolTraitImplGenerator(codegenContext, protocol), ) class HttpBoundProtocolTraitImplGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val protocol: Protocol, ) : ProtocolTraitImplGenerator { - private val symbolProvider = coreCodegenContext.symbolProvider - private val model = coreCodegenContext.model - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val symbolProvider = codegenContext.symbolProvider + private val model = codegenContext.model + private val runtimeConfig = codegenContext.runtimeConfig private val httpBindingResolver = protocol.httpBindingResolver private val operationDeserModule = RustModule.private("operation_deser") @@ -125,7 +125,7 @@ class HttpBoundProtocolTraitImplGenerator( }""", *codegenScope, "O" to outputSymbol, - "E" to operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target), + "E" to operationShape.errorSymbol(model, symbolProvider, codegenContext.target), "parse_error" to parseError(operationShape), "parse_response" to parseResponse(operationShape, customizations), ) @@ -156,7 +156,7 @@ class HttpBoundProtocolTraitImplGenerator( } """, "O" to outputSymbol, - "E" to operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target), + "E" to operationShape.errorSymbol(model, symbolProvider, codegenContext.target), "parse_streaming_response" to parseStreamingResponse(operationShape, customizations), "parse_error" to parseError(operationShape), *codegenScope, @@ -167,7 +167,7 @@ class HttpBoundProtocolTraitImplGenerator( val fnName = "parse_${operationShape.id.name.toSnakeCase()}_error" val outputShape = operationShape.outputShape(model) val outputSymbol = symbolProvider.toSymbol(outputShape) - val errorSymbol = operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target) + val errorSymbol = operationShape.errorSymbol(model, symbolProvider, codegenContext.target) return RuntimeType.forInlineFun(fnName, operationDeserModule) { Attribute.Custom("allow(clippy::unnecessary_wraps)").render(it) it.rustBlockTemplate( @@ -241,7 +241,7 @@ class HttpBoundProtocolTraitImplGenerator( val fnName = "parse_${operationShape.id.name.toSnakeCase()}" val outputShape = operationShape.outputShape(model) val outputSymbol = symbolProvider.toSymbol(outputShape) - val errorSymbol = operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target) + val errorSymbol = operationShape.errorSymbol(model, symbolProvider, codegenContext.target) return RuntimeType.forInlineFun(fnName, operationDeserModule) { Attribute.Custom("allow(clippy::unnecessary_wraps)").render(it) it.rustBlockTemplate( @@ -270,7 +270,7 @@ class HttpBoundProtocolTraitImplGenerator( val fnName = "parse_${operationShape.id.name.toSnakeCase()}_response" val outputShape = operationShape.outputShape(model) val outputSymbol = symbolProvider.toSymbol(outputShape) - val errorSymbol = operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target) + val errorSymbol = operationShape.errorSymbol(model, symbolProvider, codegenContext.target) return RuntimeType.forInlineFun(fnName, operationDeserModule) { Attribute.Custom("allow(clippy::unnecessary_wraps)").render(it) it.rustBlockTemplate( @@ -299,7 +299,7 @@ class HttpBoundProtocolTraitImplGenerator( errorSymbol: RuntimeType, customizations: List, ) { - val httpBindingGenerator = ResponseBindingGenerator(protocol, coreCodegenContext, operationShape) + val httpBindingGenerator = ResponseBindingGenerator(protocol, codegenContext, operationShape) val structuredDataParser = protocol.structuredDataParser(operationShape) Attribute.AllowUnusedMut.render(this) rust("let mut output = #T::default();", outputShape.builderSymbol(symbolProvider)) @@ -352,7 +352,7 @@ class HttpBoundProtocolTraitImplGenerator( httpBindingGenerator: ResponseBindingGenerator, structuredDataParser: StructuredDataParserGenerator, ): Writable? { - val errorSymbol = operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target) + val errorSymbol = operationShape.errorSymbol(model, symbolProvider, codegenContext.target) val member = binding.member return when (binding.location) { HttpLocation.HEADER -> writable { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt index ddf71b960d..02f880d1b8 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJson.kt @@ -19,7 +19,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver @@ -90,8 +90,8 @@ class RestJsonHttpBindingResolver( } } -open class RestJson(val coreCodegenContext: CoreCodegenContext) : Protocol { - private val runtimeConfig = coreCodegenContext.runtimeConfig +open class RestJson(val codegenContext: CodegenContext) : Protocol { + private val runtimeConfig = codegenContext.runtimeConfig private val errorScope = arrayOf( "Bytes" to RuntimeType.Bytes, "Error" to RuntimeType.GenericError(runtimeConfig), @@ -103,7 +103,7 @@ open class RestJson(val coreCodegenContext: CoreCodegenContext) : Protocol { private val jsonDeserModule = RustModule.private("json_deser") override val httpBindingResolver: HttpBindingResolver = - RestJsonHttpBindingResolver(coreCodegenContext.model, ProtocolContentTypes("application/json", "application/json", "application/vnd.amazon.eventstream")) + RestJsonHttpBindingResolver(codegenContext.model, ProtocolContentTypes("application/json", "application/json", "application/vnd.amazon.eventstream")) override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.EPOCH_SECONDS @@ -115,10 +115,10 @@ open class RestJson(val coreCodegenContext: CoreCodegenContext) : Protocol { listOf("x-amzn-errortype" to errorShape.id.name) override fun structuredDataParser(operationShape: OperationShape): StructuredDataParserGenerator = - JsonParserGenerator(coreCodegenContext, httpBindingResolver, ::restJsonFieldName) + JsonParserGenerator(codegenContext, httpBindingResolver, ::restJsonFieldName) override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator = - JsonSerializerGenerator(coreCodegenContext, httpBindingResolver, ::restJsonFieldName) + JsonSerializerGenerator(codegenContext, httpBindingResolver, ::restJsonFieldName) override fun parseHttpGenericError(operationShape: OperationShape): RuntimeType = RuntimeType.forInlineFun("parse_http_generic_error", jsonDeserModule) { writer -> diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt index 4eefd156c8..cb3a82674a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXml.kt @@ -14,7 +14,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver @@ -53,9 +53,9 @@ class RestXmlFactory( } } -open class RestXml(val coreCodegenContext: CoreCodegenContext) : Protocol { - private val restXml = coreCodegenContext.serviceShape.expectTrait() - private val runtimeConfig = coreCodegenContext.runtimeConfig +open class RestXml(val codegenContext: CodegenContext) : Protocol { + private val restXml = codegenContext.serviceShape.expectTrait() + private val runtimeConfig = codegenContext.runtimeConfig private val errorScope = arrayOf( "Bytes" to RuntimeType.Bytes, "Error" to RuntimeType.GenericError(runtimeConfig), @@ -71,17 +71,17 @@ open class RestXml(val coreCodegenContext: CoreCodegenContext) : Protocol { } override val httpBindingResolver: HttpBindingResolver = - HttpTraitHttpBindingResolver(coreCodegenContext.model, ProtocolContentTypes("application/xml", "application/xml", "application/vnd.amazon.eventstream")) + HttpTraitHttpBindingResolver(codegenContext.model, ProtocolContentTypes("application/xml", "application/xml", "application/vnd.amazon.eventstream")) override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.DATE_TIME override fun structuredDataParser(operationShape: OperationShape): StructuredDataParserGenerator { - return RestXmlParserGenerator(coreCodegenContext, restXmlErrors) + return RestXmlParserGenerator(codegenContext, restXmlErrors) } override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator { - return XmlBindingTraitSerializerGenerator(coreCodegenContext, httpBindingResolver) + return XmlBindingTraitSerializerGenerator(codegenContext, httpBindingResolver) } override fun parseHttpGenericError(operationShape: OperationShape): RuntimeType = diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt index 617e0e1fa9..697c088362 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt @@ -19,7 +19,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenConfig -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeCrateLocation @@ -77,7 +77,7 @@ fun testCodegenContext( serviceShape: ServiceShape? = null, settings: CoreRustSettings = testRustSettings(), codegenTarget: CodegenTarget = CodegenTarget.CLIENT, -): CoreCodegenContext = CoreCodegenContext( +): CodegenContext = CodegenContext( model, testSymbolProvider(model), serviceShape diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt index f0eaefd6da..dd7af8de69 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/generators/http/ResponseBindingGeneratorTest.kt @@ -20,7 +20,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.http.ResponseBindingGenerator import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpLocation import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpTraitHttpBindingResolver @@ -70,7 +70,7 @@ class ResponseBindingGeneratorTest { private val model = OperationNormalizer.transform(baseModel) private val operationShape = model.expectShape(ShapeId.from("smithy.example#PutObject"), OperationShape::class.java) private val symbolProvider = testSymbolProvider(model) - private val testCoreCodegenContext: CoreCodegenContext = testCodegenContext(model) + private val testCodegenContext: CodegenContext = testCodegenContext(model) private fun RustWriter.renderOperation() { operationShape.outputShape(model).renderWithModelBuilder(model, symbolProvider, this) @@ -80,8 +80,8 @@ class ResponseBindingGeneratorTest { .filter { it.location == HttpLocation.HEADER } bindings.forEach { binding -> val runtimeType = ResponseBindingGenerator( - RestJson(testCoreCodegenContext), - testCoreCodegenContext, + RestJson(testCodegenContext), + testCodegenContext, operationShape, ).generateDeserializeHeaderFn(binding) // little hack to force these functions to be generated diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt index 2db9557b77..920faba4b9 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingsTest.kt @@ -27,7 +27,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError @@ -176,7 +176,7 @@ internal class EndpointTraitBindingsTest { } } - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } val combinedCodegenDecorator: CombinedCodegenDecorator = diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt index b7db2929a3..ef56310688 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt @@ -21,7 +21,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol @@ -48,10 +48,10 @@ private class TestProtocolPayloadGenerator(private val body: String) : ProtocolP } private class TestProtocolTraitImplGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val correctResponse: String, ) : ProtocolTraitImplGenerator { - private val symbolProvider = coreCodegenContext.symbolProvider + private val symbolProvider = codegenContext.symbolProvider override fun generateTraitImpls(operationWriter: RustWriter, operationShape: OperationShape, customizations: List) { operationWriter.rustTemplate( @@ -62,9 +62,9 @@ private class TestProtocolTraitImplGenerator( ${operationWriter.escape(correctResponse)} } }""", - "parse_strict" to RuntimeType.parseStrictResponse(coreCodegenContext.runtimeConfig), - "output" to symbolProvider.toSymbol(operationShape.outputShape(coreCodegenContext.model)), - "error" to operationShape.errorSymbol(coreCodegenContext.model, symbolProvider, coreCodegenContext.target), + "parse_strict" to RuntimeType.parseStrictResponse(codegenContext.runtimeConfig), + "output" to symbolProvider.toSymbol(operationShape.outputShape(codegenContext.model)), + "error" to operationShape.errorSymbol(codegenContext.model, symbolProvider, codegenContext.target), "response" to RuntimeType.Http("Response"), "bytes" to RuntimeType.Bytes, ) @@ -72,12 +72,12 @@ private class TestProtocolTraitImplGenerator( } private class TestProtocolMakeOperationGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, protocol: Protocol, body: String, private val httpRequestBuilder: String, ) : MakeOperationGenerator( - coreCodegenContext, + codegenContext, protocol, TestProtocolPayloadGenerator(body), public = true, @@ -91,16 +91,16 @@ private class TestProtocolMakeOperationGenerator( // A stubbed test protocol to do enable testing intentionally broken protocols private class TestProtocolGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, protocol: Protocol, httpRequestBuilder: String, body: String, correctResponse: String, ) : ClientProtocolGenerator( - coreCodegenContext, + codegenContext, protocol, - TestProtocolMakeOperationGenerator(coreCodegenContext, protocol, body, httpRequestBuilder), - TestProtocolTraitImplGenerator(coreCodegenContext, correctResponse), + TestProtocolMakeOperationGenerator(codegenContext, protocol, body, httpRequestBuilder), + TestProtocolTraitImplGenerator(codegenContext, correctResponse), ) private class TestProtocolFactory( @@ -234,7 +234,7 @@ class ProtocolTestGeneratorTest { // Intentionally replace the builtin implementation of RestJson1 with our fake protocol mapOf(RestJson1Trait.ID to TestProtocolFactory(httpRequestBuilder, body, correctResponse)) - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ClientCodegenContext::class.java) } val visitor = CodegenVisitor( diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt index 53d3194edc..0bb1a6c7ce 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/testutil/AddRustTestsDecorator.kt @@ -6,10 +6,10 @@ package software.amazon.smithy.rust.codegen.client.testutil import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -open class AddRustTestsDecorator( +open class AddRustTestsDecorator( private val testsFileName: String, private val testWritable: Writable, ) : RustCodegenDecorator { @@ -23,5 +23,5 @@ open class AddRustTestsDecorator( } // Don't allow this class to be discovered on the classpath; always return false - override fun supportsCodegenContext(clazz: Class): Boolean = false + override fun supportsCodegenContext(clazz: Class): Boolean = false } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreCodegenContext.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenContext.kt similarity index 95% rename from codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreCodegenContext.kt rename to codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenContext.kt index 42e930ae49..743eb63ebc 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreCodegenContext.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CodegenContext.kt @@ -10,14 +10,14 @@ import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId /** - * [CoreCodegenContext] contains code-generation context that is _common to all_ smithy-rs plugins. + * [CodegenContext] contains code-generation context that is _common to all_ smithy-rs plugins. * * Code-generation context is pervasive read-only global data that gets passed around to the generators. * * If your data is specific to the `rust-codegen` client plugin, put it in [ClientCodegenContext] instead. * If your data is specific to the `rust-server-codegen` server plugin, put it in [ServerCodegenContext] instead. */ -open class CoreCodegenContext( +open class CodegenContext( /** * The smithy model. * diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt index e1630bbfeb..71ad2eaa41 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt @@ -20,7 +20,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors @@ -41,15 +41,15 @@ import software.amazon.smithy.rust.codegen.core.smithy.transformers.eventStreamE * } * ``` */ -class TopLevelErrorGenerator(private val coreCodegenContext: CoreCodegenContext, private val operations: List) { - private val symbolProvider = coreCodegenContext.symbolProvider - private val model = coreCodegenContext.model +class TopLevelErrorGenerator(private val codegenContext: CodegenContext, private val operations: List) { + private val symbolProvider = codegenContext.symbolProvider + private val model = codegenContext.model - private val allErrors = operations.flatMap { it.allErrors(model) }.map { it.id }.distinctBy { it.getName(coreCodegenContext.serviceShape) } - .map { coreCodegenContext.model.expectShape(it, StructureShape::class.java) } - .sortedBy { it.id.getName(coreCodegenContext.serviceShape) } + private val allErrors = operations.flatMap { it.allErrors(model) }.map { it.id }.distinctBy { it.getName(codegenContext.serviceShape) } + .map { codegenContext.model.expectShape(it, StructureShape::class.java) } + .sortedBy { it.id.getName(codegenContext.serviceShape) } - private val sdkError = CargoDependency.SmithyHttp(coreCodegenContext.runtimeConfig).asType().member("result::SdkError") + private val sdkError = CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType().member("result::SdkError") fun render(crate: RustCrate) { crate.withModule(RustModule.default("error_meta", visibility = Visibility.PRIVATE)) { writer -> writer.renderDefinition() @@ -57,10 +57,10 @@ class TopLevelErrorGenerator(private val coreCodegenContext: CoreCodegenContext, // Every operation error can be converted into service::Error operations.forEach { operationShape -> // operation errors - writer.renderImplFrom(operationShape.errorSymbol(model, symbolProvider, coreCodegenContext.target), operationShape.errors) + writer.renderImplFrom(operationShape.errorSymbol(model, symbolProvider, codegenContext.target), operationShape.errors) } // event stream errors - operations.map { it.eventStreamErrors(coreCodegenContext.model) } + operations.map { it.eventStreamErrors(codegenContext.model) } .flatMap { it.entries } .associate { it.key to it.value } .forEach { (unionShape, errors) -> @@ -68,7 +68,7 @@ class TopLevelErrorGenerator(private val coreCodegenContext: CoreCodegenContext, unionShape.eventStreamErrorSymbol( model, symbolProvider, - coreCodegenContext.target, + codegenContext.target, ), errors.map { it.id }, ) @@ -92,7 +92,7 @@ class TopLevelErrorGenerator(private val coreCodegenContext: CoreCodegenContext, } private fun RustWriter.renderImplFrom(symbol: RuntimeType, errors: List) { - if (errors.isNotEmpty() || CodegenTarget.CLIENT == coreCodegenContext.target) { + if (errors.isNotEmpty() || CodegenTarget.CLIENT == codegenContext.target) { rustBlock( "impl From<#T<#T, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static", sdkError, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 907f3513c6..8f9731a6de 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -36,7 +36,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.smithy.makeOptional @@ -88,14 +88,14 @@ enum class HttpMessageType { */ class HttpBindingGenerator( private val protocol: Protocol, - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val operationShape: OperationShape, ) { - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val symbolProvider = coreCodegenContext.symbolProvider - private val target = coreCodegenContext.target - private val model = coreCodegenContext.model - private val service = coreCodegenContext.serviceShape + private val runtimeConfig = codegenContext.runtimeConfig + private val symbolProvider = codegenContext.symbolProvider + private val target = codegenContext.target + private val model = codegenContext.model + private val service = codegenContext.serviceShape private val index = HttpBindingIndex.of(model) private val headerUtil = CargoDependency.SmithyHttp(runtimeConfig).asType().member("header") private val defaultTimestampFormat = TimestampFormatTrait.Format.EPOCH_SECONDS diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt index c58d758e94..9a55d74a48 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt @@ -21,7 +21,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.OperationBuildError import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError @@ -53,16 +53,16 @@ fun SmithyPattern.rustFormatString(prefix: String, separator: String): String { * headers & URL based on the HTTP trait implementation. */ class RequestBindingGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val protocol: Protocol, private val operationShape: OperationShape, ) { - private val model = coreCodegenContext.model + private val model = codegenContext.model private val inputShape = operationShape.inputShape(model) - private val symbolProvider = coreCodegenContext.symbolProvider - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val symbolProvider = codegenContext.symbolProvider + private val runtimeConfig = codegenContext.runtimeConfig private val httpTrait = protocol.httpBindingResolver.httpTrait(operationShape) - private val httpBindingGenerator = HttpBindingGenerator(protocol, coreCodegenContext, operationShape) + private val httpBindingGenerator = HttpBindingGenerator(protocol, codegenContext, operationShape) private val index = HttpBindingIndex.of(model) private val Encoder = CargoDependency.SmithyTypes(runtimeConfig).asType().member("primitive::Encoder") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt index 1f97d09cce..1de4cd2897 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/ResponseBindingGenerator.kt @@ -7,17 +7,17 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol class ResponseBindingGenerator( protocol: Protocol, - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, operationShape: OperationShape, ) { - private val httpBindingGenerator = HttpBindingGenerator(protocol, coreCodegenContext, operationShape) + private val httpBindingGenerator = HttpBindingGenerator(protocol, codegenContext, operationShape) fun generateDeserializeHeaderFn(binding: HttpBindingDescriptor): RuntimeType = httpBindingGenerator.generateDeserializeHeaderFn(binding) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt index 4f0c65c510..cda444132c 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt @@ -18,7 +18,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection @@ -35,7 +35,7 @@ import software.amazon.smithy.rust.codegen.core.util.letIf /** Generates the `make_operation` function on input structs */ open class MakeOperationGenerator( - protected val coreCodegenContext: CoreCodegenContext, + protected val codegenContext: CodegenContext, private val protocol: Protocol, private val bodyGenerator: ProtocolPayloadGenerator, private val public: Boolean, @@ -43,25 +43,25 @@ open class MakeOperationGenerator( private val includeDefaultPayloadHeaders: Boolean, private val functionName: String = "make_operation", ) { - protected val model = coreCodegenContext.model - protected val runtimeConfig = coreCodegenContext.runtimeConfig - protected val symbolProvider = coreCodegenContext.symbolProvider + protected val model = codegenContext.model + protected val runtimeConfig = codegenContext.runtimeConfig + protected val symbolProvider = codegenContext.symbolProvider protected val httpBindingResolver = protocol.httpBindingResolver private val defaultClassifier = CargoDependency.SmithyHttp(runtimeConfig) .asType().member("retry::DefaultResponseRetryClassifier") private val sdkId = - coreCodegenContext.serviceShape.getTrait()?.sdkId?.lowercase()?.replace(" ", "") - ?: coreCodegenContext.serviceShape.id.getName(coreCodegenContext.serviceShape) + codegenContext.serviceShape.getTrait()?.sdkId?.lowercase()?.replace(" ", "") + ?: codegenContext.serviceShape.id.getName(codegenContext.serviceShape) private val codegenScope = arrayOf( "config" to RuntimeType.Config, "header_util" to CargoDependency.SmithyHttp(runtimeConfig).asType().member("header"), "http" to RuntimeType.http, "HttpRequestBuilder" to RuntimeType.HttpRequestBuilder, - "OpBuildError" to coreCodegenContext.runtimeConfig.operationBuildError(), + "OpBuildError" to codegenContext.runtimeConfig.operationBuildError(), "operation" to RuntimeType.operationModule(runtimeConfig), - "SdkBody" to RuntimeType.sdkBody(coreCodegenContext.runtimeConfig), + "SdkBody" to RuntimeType.sdkBody(codegenContext.runtimeConfig), ) fun generateMakeOperation( @@ -162,7 +162,7 @@ open class MakeOperationGenerator( open fun createHttpRequest(writer: RustWriter, operationShape: OperationShape) { val httpBindingGenerator = RequestBindingGenerator( - coreCodegenContext, + codegenContext, protocol, operationShape, ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt index a8871bfc83..025df135a3 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol @@ -65,7 +65,7 @@ interface ProtocolTraitImplGenerator { * Class providing scaffolding for HTTP based protocols that must build an HTTP request (headers / URL) and a body. */ abstract class ProtocolGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, /** * `Protocol` contains all protocol specific information. Each smithy protocol, e.g. RestJson, RestXml, etc. will * have their own implementation of the protocol interface which defines how an input shape becomes and http::Request @@ -83,6 +83,6 @@ abstract class ProtocolGenerator( */ private val traitGenerator: ProtocolTraitImplGenerator, ) { - protected val symbolProvider = coreCodegenContext.symbolProvider - protected val model = coreCodegenContext.model + protected val symbolProvider = codegenContext.symbolProvider + protected val model = codegenContext.model } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt index 388d119f4e..9ec69d6d89 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt @@ -24,7 +24,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError @@ -46,14 +46,14 @@ import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.core.util.toSnakeCase class HttpBoundProtocolPayloadGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val protocol: Protocol, private val httpMessageType: HttpMessageType = HttpMessageType.REQUEST, ) : ProtocolPayloadGenerator { - private val symbolProvider = coreCodegenContext.symbolProvider - private val model = coreCodegenContext.model - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val target = coreCodegenContext.target + private val symbolProvider = codegenContext.symbolProvider + private val model = codegenContext.model + private val runtimeConfig = codegenContext.runtimeConfig + private val target = codegenContext.target private val httpBindingResolver = protocol.httpBindingResolver private val operationSerModule = RustModule.private("operation_ser") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt index 0296b9c066..c5d93ae3b0 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Protocol.kt @@ -9,7 +9,7 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.StructuredDataParserGenerator @@ -65,7 +65,7 @@ interface Protocol { typealias ProtocolMap = Map> -interface ProtocolGeneratorFactory { +interface ProtocolGeneratorFactory { fun protocol(codegenContext: C): Protocol fun buildProtocolGenerator(codegenContext: C): T fun support(): ProtocolSupport diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ProtocolLoader.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ProtocolLoader.kt index 719468e71c..5bf333ab8d 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ProtocolLoader.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/ProtocolLoader.kt @@ -11,9 +11,9 @@ import software.amazon.smithy.model.knowledge.ServiceIndex import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.Trait -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext -open class ProtocolLoader(private val supportedProtocols: ProtocolMap) { +open class ProtocolLoader(private val supportedProtocols: ProtocolMap) { fun protocolFor( model: Model, serviceShape: ServiceShape, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt index 0eb6dbf0f2..cb0569c22d 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/AwsQueryParserGenerator.kt @@ -6,7 +6,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType /** @@ -25,14 +25,14 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType * of the response parsing, but it overrides [operationParser] to add the protocol differences. */ class AwsQueryParserGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, xmlErrors: RuntimeType, private val xmlBindingTraitParserGenerator: XmlBindingTraitParserGenerator = XmlBindingTraitParserGenerator( - coreCodegenContext, + codegenContext, xmlErrors, ) { context, inner -> - val operationName = coreCodegenContext.symbolProvider.toSymbol(context.shape).name + val operationName = codegenContext.symbolProvider.toSymbol(context.shape).name val responseWrapperName = operationName + "Response" val resultWrapperName = operationName + "Result" rustTemplate( diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt index d24832a49a..c33e257377 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/Ec2QueryParserGenerator.kt @@ -6,7 +6,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType /** @@ -23,14 +23,14 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType * of the response parsing, but it overrides [operationParser] to add the protocol differences. */ class Ec2QueryParserGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, xmlErrors: RuntimeType, private val xmlBindingTraitParserGenerator: XmlBindingTraitParserGenerator = XmlBindingTraitParserGenerator( - coreCodegenContext, + codegenContext, xmlErrors, ) { context, inner -> - val operationName = coreCodegenContext.symbolProvider.toSymbol(context.shape).name + val operationName = codegenContext.symbolProvider.toSymbol(context.shape).name val responseWrapperName = operationName + "Response" rustTemplate( """ diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index 5196454e07..01e1b8266d 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -20,10 +20,8 @@ import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.SparseTrait import software.amazon.smithy.model.traits.TimestampFormatTrait -import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.escape @@ -34,7 +32,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.canUseDefault import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator @@ -55,15 +53,15 @@ import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.utils.StringUtils class JsonParserGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val httpBindingResolver: HttpBindingResolver, /** Function that maps a MemberShape into a JSON field name */ private val jsonName: (MemberShape) -> String, ) : StructuredDataParserGenerator { - private val model = coreCodegenContext.model - private val symbolProvider = coreCodegenContext.symbolProvider - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val target = coreCodegenContext.target + private val model = codegenContext.model + private val symbolProvider = codegenContext.symbolProvider + private val runtimeConfig = codegenContext.runtimeConfig + private val target = codegenContext.target private val smithyJson = CargoDependency.smithyJson(runtimeConfig).asType() private val jsonDeserModule = RustModule.private("json_deser") private val typeConversionGenerator = TypeConversionGenerator(model, symbolProvider, runtimeConfig) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt index 0126f38969..ed41cfd85a 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/RestXmlParserGenerator.kt @@ -6,7 +6,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.protocols.parse import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.traits.AllowInvalidXmlRoot import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticOutputTrait @@ -15,11 +15,11 @@ import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.orNull class RestXmlParserGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, xmlErrors: RuntimeType, private val xmlBindingTraitParserGenerator: XmlBindingTraitParserGenerator = XmlBindingTraitParserGenerator( - coreCodegenContext, + codegenContext, xmlErrors, ) { context, inner -> val shapeName = context.outputShapeName diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt index 39b35b7299..47aba4ea89 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt @@ -27,7 +27,6 @@ import software.amazon.smithy.model.traits.XmlFlattenedTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustModule -import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock @@ -39,7 +38,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator @@ -69,7 +68,7 @@ data class OperationWrapperContext( ) class XmlBindingTraitParserGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val xmlErrors: RuntimeType, private val writeOperationWrapper: RustWriter.(OperationWrapperContext, OperationInnerWriteable) -> Unit, ) : StructuredDataParserGenerator { @@ -95,12 +94,12 @@ class XmlBindingTraitParserGenerator( */ data class Ctx(val tag: String, val accum: String?) - private val symbolProvider = coreCodegenContext.symbolProvider - private val smithyXml = CargoDependency.smithyXml(coreCodegenContext.runtimeConfig).asType() + private val symbolProvider = codegenContext.symbolProvider + private val smithyXml = CargoDependency.smithyXml(codegenContext.runtimeConfig).asType() private val xmlError = smithyXml.member("decode::XmlError") private val scopedDecoder = smithyXml.member("decode::ScopedDecoder") - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig // The symbols we want all the time private val codegenScope = arrayOf( @@ -112,10 +111,10 @@ class XmlBindingTraitParserGenerator( "ScopedDecoder" to scopedDecoder, "aws_smithy_types" to CargoDependency.SmithyTypes(runtimeConfig).asType(), ) - private val model = coreCodegenContext.model + private val model = codegenContext.model private val index = HttpBindingIndex.of(model) private val xmlIndex = XmlNameIndex.of(model) - private val target = coreCodegenContext.target + private val target = codegenContext.target private val xmlDeserModule = RustModule.private("xml_deser") /** diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt index b84955ad37..8e84f5b0b2 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/AwsQuerySerializerGenerator.kt @@ -10,11 +10,11 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.XmlFlattenedTrait import software.amazon.smithy.model.traits.XmlNameTrait -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.getTrait -class AwsQuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) : QuerySerializerGenerator(coreCodegenContext) { +class AwsQuerySerializerGenerator(codegenContext: CodegenContext) : QuerySerializerGenerator(codegenContext) { override val protocolName: String get() = "AWS Query" override fun MemberShape.queryKeyName(prioritizedFallback: String?): String = diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt index 9d3ec14f41..ed3a83c667 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/Ec2QuerySerializerGenerator.kt @@ -10,12 +10,12 @@ import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.XmlNameTrait -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.utils.StringUtils -class Ec2QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) : QuerySerializerGenerator(coreCodegenContext) { +class Ec2QuerySerializerGenerator(codegenContext: CodegenContext) : QuerySerializerGenerator(codegenContext) { override val protocolName: String get() = "EC2 Query" override fun MemberShape.queryKeyName(prioritizedFallback: String?): String = diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt index 63b4e2efd7..e9501ecddd 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt @@ -31,7 +31,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.customize.NamedSectionGenerator @@ -66,7 +66,7 @@ sealed class JsonSection(name: String) : Section(name) { typealias JsonCustomization = NamedSectionGenerator class JsonSerializerGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val httpBindingResolver: HttpBindingResolver, /** Function that maps a MemberShape into a JSON field name */ private val jsonName: (MemberShape) -> String, @@ -146,10 +146,10 @@ class JsonSerializerGenerator( val shape: StructureShape, ) - private val model = coreCodegenContext.model - private val symbolProvider = coreCodegenContext.symbolProvider - private val target = coreCodegenContext.target - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val model = codegenContext.model + private val symbolProvider = codegenContext.symbolProvider + private val target = codegenContext.target + private val runtimeConfig = codegenContext.runtimeConfig private val smithyTypes = CargoDependency.SmithyTypes(runtimeConfig).asType() private val smithyJson = CargoDependency.smithyJson(runtimeConfig).asType() private val codegenScope = arrayOf( diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt index 1e73a67a2c..518da051a3 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt @@ -31,7 +31,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator @@ -46,7 +46,7 @@ import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rust.codegen.core.util.inputShape import software.amazon.smithy.rust.codegen.core.util.orNull -abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) : StructuredDataSerializerGenerator { +abstract class QuerySerializerGenerator(codegenContext: CodegenContext) : StructuredDataSerializerGenerator { protected data class Context( /** Expression that yields a QueryValueWriter */ val writerExpression: String, @@ -87,11 +87,11 @@ abstract class QuerySerializerGenerator(coreCodegenContext: CoreCodegenContext) } } - protected val model = coreCodegenContext.model - protected val symbolProvider = coreCodegenContext.symbolProvider - protected val runtimeConfig = coreCodegenContext.runtimeConfig - private val target = coreCodegenContext.target - private val serviceShape = coreCodegenContext.serviceShape + protected val model = codegenContext.model + protected val symbolProvider = codegenContext.symbolProvider + protected val runtimeConfig = codegenContext.runtimeConfig + private val target = codegenContext.target + private val serviceShape = codegenContext.serviceShape private val serializerError = runtimeConfig.serializationError() private val smithyTypes = CargoDependency.SmithyTypes(runtimeConfig).asType() private val smithyQuery = CargoDependency.smithyQuery(runtimeConfig).asType() diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt index a265d5f0b6..8f83d8fe6a 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt @@ -23,7 +23,6 @@ import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.TimestampFormatTrait import software.amazon.smithy.model.traits.XmlFlattenedTrait import software.amazon.smithy.model.traits.XmlNamespaceTrait -import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustType @@ -37,7 +36,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.renderUnknownVariant @@ -57,14 +56,14 @@ import software.amazon.smithy.rust.codegen.core.util.letIf import software.amazon.smithy.rust.codegen.core.util.outputShape class XmlBindingTraitSerializerGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val httpBindingResolver: HttpBindingResolver, ) : StructuredDataSerializerGenerator { - private val symbolProvider = coreCodegenContext.symbolProvider - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val model = coreCodegenContext.model + private val symbolProvider = codegenContext.symbolProvider + private val runtimeConfig = codegenContext.runtimeConfig + private val model = codegenContext.model private val smithyXml = CargoDependency.smithyXml(runtimeConfig).asType() - private val target = coreCodegenContext.target + private val target = codegenContext.target private val codegenScope = arrayOf( "XmlWriter" to smithyXml.member("encode::XmlWriter"), @@ -76,7 +75,7 @@ class XmlBindingTraitSerializerGenerator( private val xmlSerModule = RustModule.private("xml_ser") private val xmlIndex = XmlNameIndex.of(model) - private val rootNamespace = coreCodegenContext.serviceShape.getTrait() + private val rootNamespace = codegenContext.serviceShape.getTrait() private val util = SerializerUtil(model) sealed class Ctx { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt index bae39fd434..9718d88f04 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection @@ -46,7 +46,7 @@ class CdylibManifestDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ServerCodegenContext::class.java) } @@ -81,7 +81,7 @@ class PythonExportModuleDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ServerCodegenContext::class.java) } @@ -99,7 +99,7 @@ class PubUsePythonTypesDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ServerCodegenContext::class.java) } diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt index 345b74957b..1f3e3e197a 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.Errors import software.amazon.smithy.rust.codegen.core.smithy.Inputs import software.amazon.smithy.rust.codegen.core.smithy.Outputs @@ -61,14 +61,14 @@ import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency * that abstracts the processes / event loops / workers lifecycles. */ class PythonApplicationGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val operations: List, ) { - private val symbolProvider = coreCodegenContext.symbolProvider - private val libName = "lib${coreCodegenContext.settings.moduleName.toSnakeCase()}" - private val runtimeConfig = coreCodegenContext.runtimeConfig - private val model = coreCodegenContext.model - private val protocol = coreCodegenContext.protocol + private val symbolProvider = codegenContext.symbolProvider + private val libName = "lib${codegenContext.settings.moduleName.toSnakeCase()}" + private val runtimeConfig = codegenContext.runtimeConfig + private val model = codegenContext.model + private val protocol = codegenContext.protocol private val codegenScope = arrayOf( "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(runtimeConfig).asType(), diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt index 60a91b222a..6f814d7ee3 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt @@ -11,7 +11,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency @@ -32,11 +32,11 @@ import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerOperat * To call a Python coroutine, the same happens, but scheduled in a `tokio::Future`. */ class PythonServerOperationHandlerGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val operations: List, -) : ServerOperationHandlerGenerator(coreCodegenContext, operations) { - private val symbolProvider = coreCodegenContext.symbolProvider - private val runtimeConfig = coreCodegenContext.runtimeConfig +) : ServerOperationHandlerGenerator(codegenContext, operations) { + private val symbolProvider = codegenContext.symbolProvider + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(runtimeConfig).asType(), diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt index e21872a99f..ce1bf6a36f 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerServiceGenerator.kt @@ -8,7 +8,7 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerServiceGenerator @@ -26,7 +26,7 @@ class PythonServerServiceGenerator( protocolGenerator: ServerProtocolGenerator, protocolSupport: ProtocolSupport, protocol: ServerProtocol, - private val context: CoreCodegenContext, + private val context: CodegenContext, ) : ServerServiceGenerator(rustCrate, protocolGenerator, protocolSupport, protocol, context) { override fun renderCombinedErrors(writer: RustWriter, operation: OperationShape) { diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt index 7230f7e81a..2d8ff6ed54 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/AdditionalErrorsDecorator.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.model.traits.RequiredTrait import software.amazon.smithy.model.transform.ModelTransformer import software.amazon.smithy.rust.codegen.client.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator @@ -40,7 +40,7 @@ class AddInternalServerErrorToInfallibleOperationsDecorator : RustCodegenDecorat override fun transformModel(service: ServiceShape, model: Model): Model = addErrorShapeToModelOperations(service, model) { shape -> shape.allErrors(model).isEmpty() } - override fun supportsCodegenContext(clazz: Class): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ServerCodegenContext::class.java) } @@ -69,7 +69,7 @@ class AddInternalServerErrorToAllOperationsDecorator : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ServerCodegenContext::class.java) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt index e83ca6d04b..4cd48a05c4 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt @@ -11,7 +11,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.customizations.CrateVer import software.amazon.smithy.rust.codegen.client.smithy.customizations.SmithyTypesPubUseGenerator import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.core.rustlang.Feature -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator @@ -38,6 +38,6 @@ class ServerRequiredCustomizations : RustCodegenDecorator): Boolean = + override fun supportsCodegenContext(clazz: Class): Boolean = clazz.isAssignableFrom(ServerCodegenContext::class.java) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt index 419777324a..9c56f374cb 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt @@ -13,22 +13,22 @@ import software.amazon.smithy.rust.codegen.core.rustlang.documentShape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.util.toPascalCase import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency class ServerOperationGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val operation: OperationShape, ) { - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), ) - private val symbolProvider = coreCodegenContext.symbolProvider - private val model = coreCodegenContext.model + private val symbolProvider = codegenContext.symbolProvider + private val model = codegenContext.model private val operationName = symbolProvider.toSymbol(operation).name.toPascalCase() private val operationId = operation.id diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt index fa7a3d0577..f58b75256b 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt @@ -12,7 +12,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors @@ -28,15 +28,15 @@ import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerHttpBou * ServerOperationHandlerGenerator */ open class ServerOperationHandlerGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val operations: List, ) { private val serverCrate = "aws_smithy_http_server" - private val service = coreCodegenContext.serviceShape - private val model = coreCodegenContext.model - private val protocol = coreCodegenContext.protocol - private val symbolProvider = coreCodegenContext.symbolProvider - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val service = codegenContext.serviceShape + private val model = codegenContext.model + private val protocol = codegenContext.protocol + private val symbolProvider = codegenContext.symbolProvider + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "AsyncTrait" to ServerCargoDependency.AsyncTrait.asType(), "Tower" to ServerCargoDependency.Tower.asType(), diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt index 1d6f21f828..eb62473b1d 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt @@ -22,7 +22,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.Errors import software.amazon.smithy.rust.codegen.core.smithy.Inputs import software.amazon.smithy.rust.codegen.core.smithy.Outputs @@ -48,16 +48,16 @@ import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.Ser * [`tower::Service`]: https://docs.rs/tower/latest/tower/trait.Service.html */ class ServerOperationRegistryGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val protocol: ServerProtocol, private val operations: List, ) { - private val crateName = coreCodegenContext.settings.moduleName - private val model = coreCodegenContext.model - private val symbolProvider = coreCodegenContext.symbolProvider - private val serviceName = coreCodegenContext.serviceShape.toShapeId().name + private val crateName = codegenContext.settings.moduleName + private val model = codegenContext.model + private val symbolProvider = codegenContext.symbolProvider + private val serviceName = codegenContext.serviceShape.toShapeId().name private val operationNames = operations.map { RustReservedWords.escapeIfNeeded(symbolProvider.toSymbol(it).name.toSnakeCase()) } - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "Router" to ServerRuntimeType.Router(runtimeConfig), "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), @@ -320,7 +320,7 @@ ${operationImplementationStubs(operations)} } val sensitivityGens = operations.map { - ServerHttpSensitivityGenerator(model, it, coreCodegenContext.runtimeConfig) + ServerHttpSensitivityGenerator(model, it, codegenContext.runtimeConfig) } withBlockTemplate( diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt index 700545a42a..a9670d013b 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt @@ -12,7 +12,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Visibility -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport @@ -31,10 +31,10 @@ open class ServerServiceGenerator( private val protocolGenerator: ServerProtocolGenerator, private val protocolSupport: ProtocolSupport, private val protocol: ServerProtocol, - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, ) { - private val index = TopDownIndex.of(coreCodegenContext.model) - protected val operations = index.getContainedOperations(coreCodegenContext.serviceShape).sortedBy { it.id } + private val index = TopDownIndex.of(codegenContext.model) + protected val operations = index.getContainedOperations(codegenContext.serviceShape).sortedBy { it.id } /** * Render Service Specific code. Code will end up in different files via [useShapeWriter]. See `SymbolVisitor.kt` @@ -42,7 +42,7 @@ open class ServerServiceGenerator( */ fun render() { rustCrate.withModule(DefaultPublicModules["operation"]!!) { writer -> - ServerProtocolTestGenerator(coreCodegenContext, protocolSupport, protocolGenerator).render(writer) + ServerProtocolTestGenerator(codegenContext, protocolSupport, protocolGenerator).render(writer) } for (operation in operations) { @@ -81,7 +81,7 @@ open class ServerServiceGenerator( ), ) { writer -> for (operation in operations) { - ServerOperationGenerator(coreCodegenContext, operation).render(writer) + ServerOperationGenerator(codegenContext, operation).render(writer) } } @@ -91,7 +91,7 @@ open class ServerServiceGenerator( ) { writer -> val serverProtocol = ServerProtocol.fromCoreProtocol(protocol) ServerServiceGeneratorV2( - coreCodegenContext, + codegenContext, serverProtocol, ).render(writer) } @@ -109,11 +109,11 @@ open class ServerServiceGenerator( // Render operations handler. open fun renderOperationHandler(writer: RustWriter, operations: List) { - ServerOperationHandlerGenerator(coreCodegenContext, operations).render(writer) + ServerOperationHandlerGenerator(codegenContext, operations).render(writer) } // Render operations registry. private fun renderOperationRegistry(writer: RustWriter, operations: List) { - ServerOperationRegistryGenerator(coreCodegenContext, protocol, operations).render(writer) + ServerOperationRegistryGenerator(codegenContext, protocol, operations).render(writer) } } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt index 04abeb6f38..9486b47488 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt @@ -16,17 +16,17 @@ import software.amazon.smithy.rust.codegen.core.rustlang.join import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.util.toPascalCase import software.amazon.smithy.rust.codegen.core.util.toSnakeCase import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol class ServerServiceGeneratorV2( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, private val protocol: ServerProtocol, ) { - private val runtimeConfig = coreCodegenContext.runtimeConfig + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "Bytes" to CargoDependency.Bytes.asType(), @@ -36,16 +36,16 @@ class ServerServiceGeneratorV2( ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), "Tower" to CargoDependency.Tower.asType(), ) - private val model = coreCodegenContext.model - private val symbolProvider = coreCodegenContext.symbolProvider + private val model = codegenContext.model + private val symbolProvider = codegenContext.symbolProvider - private val service = coreCodegenContext.serviceShape + private val service = codegenContext.serviceShape private val serviceName = service.id.name.toPascalCase() private val builderName = "${serviceName}Builder" /** Calculate all `operationShape`s contained within the `ServiceShape`. */ - private val index = TopDownIndex.of(coreCodegenContext.model) - private val operations = index.getContainedOperations(coreCodegenContext.serviceShape).sortedBy { it.id } + private val index = TopDownIndex.of(codegenContext.model) + private val operations = index.getContainedOperations(codegenContext.serviceShape).sortedBy { it.id } /** The sequence of builder generics: `Op1`, ..., `OpN`. */ private val builderOps = (1..operations.size).map { "Op$it" } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt index 9ce26f4986..55ff0fbe73 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType @@ -16,10 +16,10 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol class ServerRequestBindingGenerator( protocol: Protocol, - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, operationShape: OperationShape, ) { - private val httpBindingGenerator = HttpBindingGenerator(protocol, coreCodegenContext, operationShape) + private val httpBindingGenerator = HttpBindingGenerator(protocol, codegenContext, operationShape) fun generateDeserializeHeaderFn(binding: HttpBindingDescriptor): RuntimeType = httpBindingGenerator.generateDeserializeHeaderFn(binding) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt index afe8e620c4..1967e4304c 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType @@ -15,10 +15,10 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol class ServerResponseBindingGenerator( protocol: Protocol, - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, operationShape: OperationShape, ) { - private val httpBindingGenerator = HttpBindingGenerator(protocol, coreCodegenContext, operationShape) + private val httpBindingGenerator = HttpBindingGenerator(protocol, codegenContext, operationShape) fun generateAddHeadersFn(shape: Shape): RuntimeType? = httpBindingGenerator.generateAddHeadersFn(shape, HttpMessageType.RESPONSE) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt index 4893b05fd3..a85b59c24f 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt @@ -16,7 +16,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.http.RestRequestSpecGenerator @@ -26,9 +26,9 @@ import software.amazon.smithy.rust.codegen.server.smithy.ServerCargoDependency import software.amazon.smithy.rust.codegen.server.smithy.ServerRuntimeType import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerAwsJsonSerializerGenerator -private fun allOperations(coreCodegenContext: CoreCodegenContext): List { - val index = TopDownIndex.of(coreCodegenContext.model) - return index.getContainedOperations(coreCodegenContext.serviceShape).sortedBy { it.id } +private fun allOperations(codegenContext: CodegenContext): List { + val index = TopDownIndex.of(codegenContext.model) + return index.getContainedOperations(codegenContext.serviceShape).sortedBy { it.id } } interface ServerProtocol : Protocol { @@ -79,21 +79,21 @@ interface ServerProtocol : Protocol { } class ServerAwsJsonProtocol( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, awsJsonVersion: AwsJsonVersion, -) : AwsJson(coreCodegenContext, awsJsonVersion), ServerProtocol { - private val runtimeConfig = coreCodegenContext.runtimeConfig +) : AwsJson(codegenContext, awsJsonVersion), ServerProtocol { + private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), ) - private val symbolProvider = coreCodegenContext.symbolProvider - private val service = coreCodegenContext.serviceShape + private val symbolProvider = codegenContext.symbolProvider + private val service = codegenContext.serviceShape override fun structuredDataSerializer(operationShape: OperationShape): StructuredDataSerializerGenerator = - ServerAwsJsonSerializerGenerator(coreCodegenContext, httpBindingResolver, awsJsonVersion) + ServerAwsJsonSerializerGenerator(codegenContext, httpBindingResolver, awsJsonVersion) companion object { - fun fromCoreProtocol(awsJson: AwsJson): ServerAwsJsonProtocol = ServerAwsJsonProtocol(awsJson.coreCodegenContext, awsJson.version) + fun fromCoreProtocol(awsJson: AwsJson): ServerAwsJsonProtocol = ServerAwsJsonProtocol(awsJson.codegenContext, awsJson.version) } override fun markerStruct(): RuntimeType { @@ -110,7 +110,7 @@ class ServerAwsJsonProtocol( override fun routerType() = RuntimeType("AwsJsonRouter", ServerCargoDependency.SmithyHttpServer(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http_server::proto::aws_json::router") override fun routerConstruction(operationValues: Iterable): Writable = writable { - val allOperationShapes = allOperations(coreCodegenContext) + val allOperationShapes = allOperations(codegenContext) // TODO(https://github.com/awslabs/smithy-rs/issues/1724#issue-1367509999): This causes a panic: "symbol // visitor should not be invoked in service shapes" @@ -163,22 +163,22 @@ private fun restRouterType(runtimeConfig: RuntimeConfig) = RuntimeType("RestRout private fun restRouterConstruction( protocol: ServerProtocol, operationValues: Iterable, - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, ): Writable = writable { - val operations = allOperations(coreCodegenContext) + val operations = allOperations(codegenContext) // TODO(https://github.com/awslabs/smithy-rs/issues/1724#issue-1367509999): This causes a panic: "symbol visitor // should not be invoked in service shapes" // val serviceName = symbolProvider.toSymbol(service).name - val serviceName = coreCodegenContext.serviceShape.id.name + val serviceName = codegenContext.serviceShape.id.name val pairs = writable { for ((operationShape, operationValue) in operations.zip(operationValues)) { - val operationName = coreCodegenContext.symbolProvider.toSymbol(operationShape).name + val operationName = codegenContext.symbolProvider.toSymbol(operationShape).name val key = protocol.serverRouterRequestSpec( operationShape, operationName, serviceName, - ServerCargoDependency.SmithyHttpServer(coreCodegenContext.runtimeConfig).asType().member("routing::request_spec"), + ServerCargoDependency.SmithyHttpServer(codegenContext.runtimeConfig).asType().member("routing::request_spec"), ) rustTemplate( """ @@ -189,7 +189,7 @@ private fun restRouterConstruction( """, "Key" to key, "OperationValue" to operationValue, - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(coreCodegenContext.runtimeConfig).asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(codegenContext.runtimeConfig).asType(), ) } } @@ -203,19 +203,19 @@ private fun restRouterConstruction( } class ServerRestJsonProtocol( - coreCodegenContext: CoreCodegenContext, -) : RestJson(coreCodegenContext), ServerProtocol { - val runtimeConfig = coreCodegenContext.runtimeConfig + codegenContext: CodegenContext, +) : RestJson(codegenContext), ServerProtocol { + val runtimeConfig = codegenContext.runtimeConfig companion object { - fun fromCoreProtocol(restJson: RestJson): ServerRestJsonProtocol = ServerRestJsonProtocol(restJson.coreCodegenContext) + fun fromCoreProtocol(restJson: RestJson): ServerRestJsonProtocol = ServerRestJsonProtocol(restJson.codegenContext) } override fun markerStruct() = ServerRuntimeType.Protocol("AwsRestJson1", "rest_json_1", runtimeConfig) override fun routerType() = restRouterType(runtimeConfig) - override fun routerConstruction(operationValues: Iterable): Writable = restRouterConstruction(this, operationValues, coreCodegenContext) + override fun routerConstruction(operationValues: Iterable): Writable = restRouterConstruction(this, operationValues, codegenContext) override fun serverRouterRequestSpec( operationShape: OperationShape, @@ -230,13 +230,13 @@ class ServerRestJsonProtocol( } class ServerRestXmlProtocol( - coreCodegenContext: CoreCodegenContext, -) : RestXml(coreCodegenContext), ServerProtocol { - val runtimeConfig = coreCodegenContext.runtimeConfig + codegenContext: CodegenContext, +) : RestXml(codegenContext), ServerProtocol { + val runtimeConfig = codegenContext.runtimeConfig companion object { fun fromCoreProtocol(restXml: RestXml): ServerRestXmlProtocol { - return ServerRestXmlProtocol(restXml.coreCodegenContext) + return ServerRestXmlProtocol(restXml.codegenContext) } } @@ -244,7 +244,7 @@ class ServerRestXmlProtocol( override fun routerType() = restRouterType(runtimeConfig) - override fun routerConstruction(operationValues: Iterable): Writable = restRouterConstruction(this, operationValues, coreCodegenContext) + override fun routerConstruction(operationValues: Iterable): Writable = restRouterConstruction(this, operationValues, codegenContext) override fun serverRouterRequestSpec( operationShape: OperationShape, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt index ba21287f41..f46ade2f66 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt @@ -7,18 +7,18 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.protocol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.MakeOperationGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol open class ServerProtocolGenerator( - coreCodegenContext: CoreCodegenContext, + codegenContext: CodegenContext, protocol: Protocol, makeOperationGenerator: MakeOperationGenerator, private val traitGenerator: ProtocolTraitImplGenerator, -) : ProtocolGenerator(coreCodegenContext, protocol, makeOperationGenerator, traitGenerator) { +) : ProtocolGenerator(codegenContext, protocol, makeOperationGenerator, traitGenerator) { /** * The server implementation uses this method to generate implementations of the `from_request` and `into_response` * traits for operation input and output shapes, respectively. diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index ef5b24bac1..e0ae5072a6 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -38,7 +38,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport @@ -65,18 +65,18 @@ private const val PROTOCOL_TEST_HELPER_MODULE_NAME = "protocol_test_helper" * Generate protocol tests for an operation */ class ServerProtocolTestGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val protocolSupport: ProtocolSupport, private val protocolGenerator: ServerProtocolGenerator, ) { private val logger = Logger.getLogger(javaClass.name) - private val model = coreCodegenContext.model - private val symbolProvider = coreCodegenContext.symbolProvider - private val operationIndex = OperationIndex.of(coreCodegenContext.model) + private val model = codegenContext.model + private val symbolProvider = codegenContext.symbolProvider + private val operationIndex = OperationIndex.of(codegenContext.model) - private val serviceName = coreCodegenContext.serviceShape.id.name.toPascalCase() - private val operations = TopDownIndex.of(coreCodegenContext.model).getContainedOperations(coreCodegenContext.serviceShape).sortedBy { it.id } + private val serviceName = codegenContext.serviceShape.id.name.toPascalCase() + private val operations = TopDownIndex.of(codegenContext.model).getContainedOperations(codegenContext.serviceShape).sortedBy { it.id } private val operationInputOutputTypes = operations.associateWith { val inputSymbol = symbolProvider.toSymbol(it.inputShape(model)) @@ -96,20 +96,20 @@ class ServerProtocolTestGenerator( inputT to outputT } - private val instantiator = with(coreCodegenContext) { + private val instantiator = with(codegenContext) { Instantiator(symbolProvider, model, runtimeConfig, CodegenTarget.SERVER) } private val codegenScope = arrayOf( "Bytes" to RuntimeType.Bytes, - "SmithyHttp" to CargoDependency.SmithyHttp(coreCodegenContext.runtimeConfig).asType(), + "SmithyHttp" to CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType(), "Http" to CargoDependency.Http.asType(), "Hyper" to CargoDependency.Hyper.asType(), "Tokio" to ServerCargoDependency.TokioDev.asType(), "Tower" to CargoDependency.Tower.asType(), - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(coreCodegenContext.runtimeConfig).asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(codegenContext.runtimeConfig).asType(), "AssertEq" to CargoDependency.PrettyAssertions.asType().member("assert_eq!"), - "Router" to ServerRuntimeType.Router(coreCodegenContext.runtimeConfig), + "Router" to ServerRuntimeType.Router(codegenContext.runtimeConfig), ) sealed class TestCase { @@ -225,7 +225,7 @@ class ServerProtocolTestGenerator( } private fun renderOperationTestCases(operationShape: OperationShape, writer: RustWriter) { - val outputShape = operationShape.outputShape(coreCodegenContext.model) + val outputShape = operationShape.outputShape(codegenContext.model) val operationSymbol = symbolProvider.toSymbol(operationShape) val requestTests = operationShape.getTrait() @@ -280,7 +280,7 @@ class ServerProtocolTestGenerator( private fun List.filterMatching(): List { return if (RunOnly.isNullOrEmpty()) { this.filter { testCase -> - testCase.protocol == coreCodegenContext.protocol && + testCase.protocol == codegenContext.protocol && !DisableTests.contains(testCase.id) } } else { @@ -294,7 +294,7 @@ class ServerProtocolTestGenerator( private fun List.fixBroken(): List = this.map { when (it) { is TestCase.RequestTest -> { - val howToFixIt = BrokenRequestTests[Pair(coreCodegenContext.serviceShape.id.toString(), it.id)] + val howToFixIt = BrokenRequestTests[Pair(codegenContext.serviceShape.id.toString(), it.id)] if (howToFixIt == null) { it } else { @@ -303,7 +303,7 @@ class ServerProtocolTestGenerator( } } is TestCase.ResponseTest -> { - val howToFixIt = BrokenResponseTests[Pair(coreCodegenContext.serviceShape.id.toString(), it.id)] + val howToFixIt = BrokenResponseTests[Pair(codegenContext.serviceShape.id.toString(), it.id)] if (howToFixIt == null) { it } else { @@ -388,7 +388,7 @@ class ServerProtocolTestGenerator( } private fun expectFail(testCase: TestCase): Boolean = ExpectFail.find { - it.id == testCase.id && it.testType == testCase.testType && it.service == coreCodegenContext.serviceShape.id.toString() + it.id == testCase.id && it.testType == testCase.testType && it.service == codegenContext.serviceShape.id.toString() } != null /** @@ -509,8 +509,8 @@ class ServerProtocolTestGenerator( /** Returns the body of the request test. */ private fun checkRequestHandler(operationShape: OperationShape, httpRequestTestCase: HttpRequestTestCase) = writable { - val inputShape = operationShape.inputShape(coreCodegenContext.model) - val outputShape = operationShape.outputShape(coreCodegenContext.model) + val inputShape = operationShape.inputShape(codegenContext.model) + val outputShape = operationShape.outputShape(codegenContext.model) // Construct expected request. withBlock("let expected = ", ";") { @@ -583,8 +583,8 @@ class ServerProtocolTestGenerator( // A streaming shape does not implement `PartialEq`, so we have to iterate over the input shape's members // and handle the equality assertion separately. for (member in inputShape.members()) { - val memberName = coreCodegenContext.symbolProvider.toMemberName(member) - if (member.isStreaming(coreCodegenContext.model)) { + val memberName = codegenContext.symbolProvider.toMemberName(member) + if (member.isStreaming(codegenContext.model)) { rustWriter.rustTemplate( """ #{AssertEq}( @@ -612,11 +612,11 @@ class ServerProtocolTestGenerator( // TODO(https://github.com/awslabs/smithy-rs/issues/1147) Handle the case of nested floating point members. if (hasFloatingPointMembers) { for (member in inputShape.members()) { - val memberName = coreCodegenContext.symbolProvider.toMemberName(member) - when (coreCodegenContext.model.expectShape(member.target)) { + val memberName = codegenContext.symbolProvider.toMemberName(member) + when (codegenContext.model.expectShape(member.target)) { is DoubleShape, is FloatShape -> { rustWriter.addUseImports( - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "FloatEquals") + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "FloatEquals") .toSymbol(), ) rustWriter.rust( @@ -710,8 +710,8 @@ class ServerProtocolTestGenerator( "#T(&body, ${ rustWriter.escape(body).dq() }, #T::from(${(mediaType ?: "unknown").dq()}))", - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "validate_body"), - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "MediaType"), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "validate_body"), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "MediaType"), ) } } @@ -764,7 +764,7 @@ class ServerProtocolTestGenerator( assertOk(rustWriter) { write( "#T($actualExpression, $variableName)", - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "validate_headers"), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "validate_headers"), ) } } @@ -785,7 +785,7 @@ class ServerProtocolTestGenerator( assertOk(rustWriter) { write( "#T($actualExpression, $expectedVariableName)", - RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, checkFunction), + RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, checkFunction), ) } } @@ -795,7 +795,7 @@ class ServerProtocolTestGenerator( * for pretty prettying protocol test helper results */ private fun assertOk(rustWriter: RustWriter, inner: RustWriter.() -> Unit) { - rustWriter.write("#T(", RuntimeType.ProtocolTestHelper(coreCodegenContext.runtimeConfig, "assert_ok")) + rustWriter.write("#T(", RuntimeType.ProtocolTestHelper(codegenContext.runtimeConfig, "assert_ok")) inner(rustWriter) rustWriter.write(");") } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt index c24f6afc55..66587f6c9b 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerAwsJson.kt @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingResolver import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory @@ -81,12 +81,12 @@ class ServerAwsJsonError(private val awsJsonVersion: AwsJsonVersion) : JsonCusto * https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_0-protocol.html#operation-error-serialization */ class ServerAwsJsonSerializerGenerator( - private val coreCodegenContext: CoreCodegenContext, + private val codegenContext: CodegenContext, private val httpBindingResolver: HttpBindingResolver, private val awsJsonVersion: AwsJsonVersion, private val jsonSerializerGenerator: JsonSerializerGenerator = JsonSerializerGenerator( - coreCodegenContext, + codegenContext, httpBindingResolver, ::awsJsonFieldName, customizations = listOf(ServerAwsJsonError(awsJsonVersion)), diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt index e3492261df..ae1820883a 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt @@ -30,7 +30,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator @@ -47,7 +47,6 @@ import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider import java.util.stream.Stream -import kotlin.streams.toList private fun fillInBaseModel( protocolName: String, @@ -136,7 +135,7 @@ object EventStreamTestModels { val validSomeError: String, val validUnmodeledError: String, val target: CodegenTarget = CodegenTarget.CLIENT, - val protocolBuilder: (CoreCodegenContext) -> Protocol, + val protocolBuilder: (CodegenContext) -> Protocol, ) { override fun toString(): String = protocolShapeId } diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt index 793e1df961..79ff16d78d 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt @@ -14,7 +14,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestTools @@ -25,7 +25,7 @@ class EventStreamUnmarshallerGeneratorTest { fun test(testCase: EventStreamTestModels.TestCase) { val test = EventStreamTestTools.generateTestProject(testCase) - val codegenContext = CoreCodegenContext( + val codegenContext = CodegenContext( test.model, test.symbolProvider, test.serviceShape, diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt index e52a8bef98..9fbbe47f50 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt @@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.EventStreamMarshallerGenerator import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels @@ -27,7 +27,7 @@ class EventStreamMarshallerGeneratorTest { fun test(testCase: EventStreamTestModels.TestCase) { val test = EventStreamTestTools.generateTestProject(testCase) - val codegenContext = CoreCodegenContext( + val codegenContext = CodegenContext( test.model, test.symbolProvider, test.serviceShape, From 66acea3f9a55f86cb8ca0ea2835c30f159be169a Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 14:40:01 +0200 Subject: [PATCH 16/18] ./gradlew ktlintFormat --- .../smithy/rust/codegen/client/smithy/ClientCodegenContext.kt | 2 +- .../smithy/rust/codegen/client/smithy/ServerCodegenContext.kt | 2 +- .../rust/codegen/client/smithy/generators/PaginatorGenerator.kt | 2 +- .../client/smithy/generators/protocol/ProtocolTestGenerator.kt | 2 +- .../amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt | 2 +- .../core/smithy/generators/error/TopLevelErrorGenerator.kt | 2 +- .../codegen/core/smithy/generators/http/HttpBindingGenerator.kt | 2 +- .../core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt | 2 +- .../codegen/core/smithy/protocols/parse/JsonParserGenerator.kt | 2 +- .../smithy/protocols/parse/XmlBindingTraitParserGenerator.kt | 2 +- .../server/smithy/generators/ServerOperationHandlerGenerator.kt | 2 +- .../smithy/generators/ServerOperationRegistryGenerator.kt | 2 +- .../smithy/generators/protocol/ServerProtocolTestGenerator.kt | 2 +- .../codegen/server/smithy/protocols/EventStreamTestTools.kt | 2 +- .../protocols/parse/EventStreamUnmarshallerGeneratorTest.kt | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt index e2d49cd0fe..03eeeb24a0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenContext.kt @@ -8,8 +8,8 @@ package software.amazon.smithy.rust.codegen.client.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt index e78b986b42..ffa48f68fd 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ServerCodegenContext.kt @@ -8,8 +8,8 @@ package software.amazon.smithy.rust.codegen.client.smithy import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt index 1c69e6b6e0..8e3df9d58f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt @@ -24,8 +24,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index 1b70377521..52fb86d933 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -31,8 +31,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt index 697c088362..1f6e8e40d8 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt @@ -17,9 +17,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asType +import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CoreCodegenConfig -import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeCrateLocation diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt index 71ad2eaa41..4253622fff 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt @@ -19,8 +19,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.documentShape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 8f9731a6de..e76ed60ac9 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -35,8 +35,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter import software.amazon.smithy.rust.codegen.core.rustlang.withBlock -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError import software.amazon.smithy.rust.codegen.core.smithy.makeOptional diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt index 9ec69d6d89..b7bf02f8f5 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt @@ -23,8 +23,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpMessageType import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuildError diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index 01e1b8266d..5169242add 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -31,8 +31,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.canUseDefault import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt index 47aba4ea89..92ab1a4971 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt @@ -37,8 +37,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.UnionGenerator diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt index f58b75256b..38e1a11409 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt @@ -11,8 +11,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.error.errorSymbol import software.amazon.smithy.rust.codegen.core.smithy.transformers.operationErrors diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt index eb62473b1d..ed9edff366 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt @@ -21,8 +21,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.withBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.Errors import software.amazon.smithy.rust.codegen.core.smithy.Inputs import software.amazon.smithy.rust.codegen.core.smithy.Outputs diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index e0ae5072a6..08ecdc9795 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -37,8 +37,8 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt index ae1820883a..3f27803d4a 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt @@ -29,8 +29,8 @@ import software.amazon.smithy.rust.codegen.client.testutil.renderWithModelBuilde import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGenerator diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt index 79ff16d78d..bce3bfab2d 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/parse/EventStreamUnmarshallerGeneratorTest.kt @@ -13,8 +13,8 @@ import software.amazon.smithy.rust.codegen.client.testutil.compileAndTest import software.amazon.smithy.rust.codegen.client.testutil.testRustSettings import software.amazon.smithy.rust.codegen.client.testutil.unitTest import software.amazon.smithy.rust.codegen.core.rustlang.rust -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestModels import software.amazon.smithy.rust.codegen.server.smithy.protocols.EventStreamTestTools From c34dc467c415847b1f8c7691839b4a3c9b3261b8 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 23 Sep 2022 18:34:50 +0200 Subject: [PATCH 17/18] import `kotlin.streams.toList` --- .../software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt | 1 + .../rust/codegen/server/smithy/protocols/EventStreamTestTools.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt index 3a2e4d5ed1..a65cb4fcae 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt @@ -44,6 +44,7 @@ import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware import software.amazon.smithy.rustsdk.traits.PresignableTrait +import kotlin.streams.toList internal enum class PayloadSigningType { EMPTY, diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt index 3f27803d4a..6a7227c658 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/EventStreamTestTools.kt @@ -47,6 +47,7 @@ import software.amazon.smithy.rust.codegen.core.util.lookup import software.amazon.smithy.rust.codegen.core.util.outputShape import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymbolProvider import java.util.stream.Stream +import kotlin.streams.toList private fun fillInBaseModel( protocolName: String, From 36c3cdfc0e6481f2019a3d7d7cc060c14c6a742b Mon Sep 17 00:00:00 2001 From: david-perez Date: Mon, 26 Sep 2022 12:26:50 +0200 Subject: [PATCH 18/18] ./gradlew ktlintFormat --- .../amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt index 4ea787a009..0e66b6ba3d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/CodegenVisitor.kt @@ -22,6 +22,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceGener import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.client.smithy.protocols.ClientProtocolLoader import software.amazon.smithy.rust.codegen.client.smithy.transformers.AddErrorMessage +import software.amazon.smithy.rust.codegen.client.smithy.transformers.RemoveEventStreamOperations import software.amazon.smithy.rust.codegen.core.smithy.DefaultPublicModules import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider @@ -36,7 +37,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.traits.SyntheticInputTrai import software.amazon.smithy.rust.codegen.core.smithy.transformers.EventStreamNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.core.smithy.transformers.RecursiveShapeBoxer -import software.amazon.smithy.rust.codegen.client.smithy.transformers.RemoveEventStreamOperations import software.amazon.smithy.rust.codegen.core.util.CommandFailed import software.amazon.smithy.rust.codegen.core.util.getTrait import software.amazon.smithy.rust.codegen.core.util.hasTrait