-
Notifications
You must be signed in to change notification settings - Fork 55
refactor(codegen): restructure protocol codegen to use structured parser generators #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
A new generated diff is ready to view: __generated-main...__generated-refactor-protocol-codegen |
|
A new generated diff is ready to view: __generated-main...__generated-refactor-protocol-codegen |
| } | ||
| .write("") | ||
|
|
||
| if (op.errors.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Now that we're attaching metadata in all cases, I think we could simplify this code by moving the metadata/throwing to a single place:
writer.withBlock("val ex = when (errorDetails.code) {", "}") {
op.errors.forEach { err ->
val errSymbol = ctx.symbolProvider.toSymbol(ctx.model.expectShape(err))
val errDeserializerSymbol = buildSymbol {
name = "${errSymbol.name}Deserializer"
namespace = "${ctx.settings.pkg.name}.transform"
}
write("#S -> #T.deserialize(context, wrappedResponse)", getErrorCode(ctx, err), errDeserializerSymbol)
}
write("else -> #T(errorDetails.message)", exceptionBaseSymbol)
}
writer.write("#T(ex, wrappedResponse, errorDetails)", AwsRuntimeTypes.Http.setAseErrorMetadata)
writer.write("throw ex")| } | ||
| .write("") | ||
|
|
||
| if (op.errors.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Duplicated code with AwsHttpBindingProtocolGenerator.kt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the improvements you suggested I'm going to leave some duplication here since the S3 error codegen is handling a few S3 specific behaviors
|
SonarCloud Quality Gate failed.
|
|
A new generated diff is ready to view: __generated-main...__generated-refactor-protocol-codegen |
kggilmer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving all the red








Issue #
Related to: smithy-lang/smithy-kotlin#579
closes #449
Description of changes
Refactored protocols to be implemented using the new
StructuredDataSerializerGeneratorandStructuredDataParserGenerator)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.