Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support message templates in EmitEachSelector #467

Merged
merged 1 commit into from
Jun 17, 2020

Conversation

mtdowling
Copy link
Member

This commit adds support for templated messages in the EmitEachSelector
that are able to reference variables captured while shapes are matched.
This allows for very rich and descriptive error messages that generally
do as good as error messages in code-driven Smithy validators.

In order to pull this, it required that attribute value selector context
values could be parsed from a message template. Since context values are
already parsed as part of parsing selectors, this motivated me to reuse
the existing selector's parsing functionality. To do this, I created a
SimpleParser abstraction that extracts out lots of the duplicate parsing
code in Smithy into a single class. This allowed parsing of attributes
to be shared, but it was also an opportunity to trim down duplicate code
and reuse parsing logic across the IDL and selectors.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling force-pushed the emit-each-selector-templates branch 2 times, most recently from 507a7d1 to 7b6a77f Compare June 15, 2020 18:37
@mtdowling mtdowling force-pushed the emit-each-selector-templates branch from 7b6a77f to 09822e8 Compare June 16, 2020 19:14
@mtdowling mtdowling requested a review from kstich June 16, 2020 19:14
@JordonPhillips JordonPhillips self-requested a review June 16, 2020 21:10
This commit adds support for templated messages in the EmitEachSelector
that are able to reference variables captured while shapes are matched.
This allows for very rich and descriptive error messages that generally
are as good as error messages in code-driven Smithy validators.

In order to pull this, it required that attribute value selector context
values could be parsed from a message template. Since context values are
already parsed as part of parsing selectors, this motivated me to reuse
the existing selector's parsing functionality. To do this, I created a
SimpleParser abstraction that extracts out lots of the duplicate parsing
code in Smithy into a single class. This allowed parsing of attributes
to be shared, but it was also an opportunity to trim down duplicate code
and reuse parsing logic across the IDL and selectors.
@mtdowling mtdowling force-pushed the emit-each-selector-templates branch from 09822e8 to d5b2f64 Compare June 17, 2020 02:24
@mtdowling mtdowling merged commit bbb166d into master Jun 17, 2020
@mtdowling mtdowling deleted the emit-each-selector-templates branch June 23, 2020 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants