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

Trait code generation #2074

Merged
merged 88 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
aa569cf
Break annotation processor out into separate class with tests
hpmellema Dec 13, 2023
e886463
Initial Setup with annotation processor
hpmellema Dec 13, 2023
293bd51
Add integrations
hpmellema Dec 14, 2023
ffb18a3
Update tests
hpmellema Dec 14, 2023
e6497b1
Refactor to simplify project structure
hpmellema Dec 14, 2023
f544dd9
Add documentation to public shapes
hpmellema Dec 14, 2023
91a1c37
Add additional javadocs on integrations
hpmellema Dec 15, 2023
62925be
Remove unnecessary use of node mapper
hpmellema Jan 18, 2024
d14280b
Simplify enum generator to a single effectively sealed class and add …
hpmellema Jan 24, 2024
1d91ad4
Add javadocs for common generators
hpmellema Jan 24, 2024
7b75f1b
Add internal annotation
hpmellema Jan 24, 2024
a7d733b
Simplify provider and fromNode generators based on feedback
hpmellema Jan 25, 2024
d2519d4
Add support for bigInteger traits and fields without truncation
hpmellema Jan 25, 2024
40de4b2
Remove annotation trait generator in favor of the collection generator
hpmellema Jan 26, 2024
a040bbe
Remove redundant check for extra properties
hpmellema Jan 26, 2024
024a70b
Clean up toNode generator member mapping
hpmellema Jan 26, 2024
734447b
Partial refactor to remove directed codegen
hpmellema Jan 26, 2024
11fb413
Flatten generators to restrict visibility and simplify generation cla…
hpmellema Jan 26, 2024
381b89e
Add a check for existing trait providers to prevent generation of con…
hpmellema Feb 5, 2024
681192b
Documentation pass
hpmellema Feb 6, 2024
1934efa
Update to use integ tests instead of annotation processor for testing…
hpmellema Feb 7, 2024
a94278a
Simplify layout
hpmellema Feb 7, 2024
916a643
Add basic plugin tests
hpmellema Feb 7, 2024
6c26f98
Use path conversion to make location strings platform agnostic
hpmellema Feb 7, 2024
03f2713
Use root symbolprovider toMemberName for member name generation
hpmellema Feb 7, 2024
84cf502
Prefer *withoutFormatting writer methods for static strings
hpmellema Feb 13, 2024
9d31996
Do not wrap html tags within docstrings
hpmellema Feb 13, 2024
d667905
Add testing for html tag handling and address minor issues with docst…
hpmellema Feb 13, 2024
d7152e6
Remove Item suffix
hpmellema Feb 13, 2024
890427e
Remove unused enum symbol property
hpmellema Feb 13, 2024
28248b7
Use consumers for node mapping
hpmellema Feb 13, 2024
eb06cdb
Update integration tests to use parameterized test inputs
hpmellema Feb 16, 2024
cbb8c48
Update to only generate traits within a single namespace
hpmellema Feb 21, 2024
1131342
Do not import duplicate symbols in import container
hpmellema Feb 21, 2024
46cfae4
Remove addImports and only allow symbol imports via formatter
hpmellema Feb 21, 2024
f16a179
Update Writer and Import container to handle name conflicts
hpmellema Feb 22, 2024
7414897
Add reserved word handling for java keywords
hpmellema Feb 22, 2024
02817f2
Use unformatted member names for serde
hpmellema Feb 22, 2024
9320793
Handle poorly formatted members and structure names
hpmellema Feb 22, 2024
b9a327d
Add context after pushing state
hpmellema Feb 27, 2024
e935a3e
UseObject nonnull instead of smithy builder state to check for requir…
hpmellema Feb 27, 2024
7fe0f08
Simplify javadoc integrations
hpmellema Feb 27, 2024
d6b8556
Add javadocs for section properties
hpmellema Feb 27, 2024
a377f96
Move ToNodeMapper property to visitor
hpmellema Feb 27, 2024
f89c2c8
Move member and fromNode mappers to visitors
hpmellema Feb 27, 2024
8ba0afc
Simplify symbol provider
hpmellema Feb 27, 2024
7b10d93
Remove mapper class
hpmellema Feb 27, 2024
ab4133c
Clean up import container
hpmellema Feb 27, 2024
1abff09
Use optional returns for non-required maps and lists
hpmellema Feb 27, 2024
2e9ac0c
Address nits
hpmellema Feb 28, 2024
f872128
Move to a single defaultName method for traits and other shapes
hpmellema Feb 28, 2024
25c1552
Fix some weird spacing in generated structures
hpmellema Feb 28, 2024
b4689dc
Update to use full names for Entryto avoid using full names for maps
hpmellema Feb 28, 2024
b4408bf
Add transformation to handle legacy enums
hpmellema Feb 28, 2024
5d1aa46
Flatten mixins
hpmellema Feb 28, 2024
35be8d4
Add tests for mixins and legacy enums
hpmellema Feb 28, 2024
2b76fc0
Update to use DataShapeVisitor class where possible
hpmellema Feb 28, 2024
6b2d932
Add support for nested document members
hpmellema Feb 28, 2024
6bad106
Add support for nested timestamps
hpmellema Feb 28, 2024
14e0596
Support timestampFormat trait
hpmellema Feb 28, 2024
159a75c
Support timestamp traits
hpmellema Feb 29, 2024
3f21790
Update enums to return a nested enum value type
hpmellema Feb 29, 2024
38dac82
Remove support for blob shapes
hpmellema Feb 29, 2024
6a1b8d6
Inline static strings
hpmellema Feb 29, 2024
225f358
Refactor tests to use a single file per trait under test
hpmellema Feb 29, 2024
59be213
Filter traits to only include sources in closure
hpmellema Mar 1, 2024
c9755df
Add support for Unstable Trait
hpmellema Mar 5, 2024
2dea8f6
Reserve smithy-model namespace
hpmellema Mar 5, 2024
c878572
Restrict to source projection
hpmellema Mar 5, 2024
861e975
Tighten restrictions on namespace and package name
hpmellema Mar 5, 2024
84c9d59
Correct some whitespace errors
hpmellema Mar 5, 2024
59ee888
Add value getter to document traits
hpmellema Mar 5, 2024
f88c10e
Add error on null enum value
hpmellema Mar 5, 2024
1136917
Add orEmpty getters for lists and maps
hpmellema Mar 5, 2024
757e061
Ensure the node cache is set for all value traits
hpmellema Mar 6, 2024
a501b20
Simplify timestamp switch case
hpmellema Mar 6, 2024
bec1754
Consolidate generators into a single class
hpmellema Mar 6, 2024
a76544d
Simplify control flow with restricted visitor for traits
hpmellema Mar 6, 2024
6db9a3d
Add support for handling multiple timestampformats if no format is sp…
hpmellema Mar 6, 2024
f325b67
Correct whitespace issue
hpmellema Mar 6, 2024
aaf6d4e
Fix StringListTrait builders
hpmellema Mar 6, 2024
cbb0daf
Use primitive types for Number traits
hpmellema Mar 26, 2024
aabfd47
Update javadocs
hpmellema Mar 26, 2024
28b3be5
Merge branch 'main' into trait-code-generation
hpmellema Mar 27, 2024
569ed18
Update smithy-trait-codegen/src/main/java/software/amazon/smithy/trai…
hpmellema Mar 27, 2024
07496a7
Apply suggestions from code review
hpmellema Mar 27, 2024
092255e
Update to address PR comments
hpmellema Mar 27, 2024
745a3de
Allow for nullable collection members
hpmellema Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add additional javadocs on integrations
  • Loading branch information
hpmellema committed Feb 28, 2024
commit 91a1c37f75ceb9dff478a5fd215669c06a792942
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import software.amazon.smithy.traitcodegen.TraitCodegenUtils;
import software.amazon.smithy.utils.ListUtils;

/**
* Handles the conversion of String members and String types with the {@code IdRef} trait to
* the {@link ShapeId} type.
*/
public class IdRefDecoratorIntegration implements TraitCodegenIntegration {
private static final String INTEGRATION_NAME = "id-ref-integration";
private static final Symbol SHAPE_ID_SYMBOL = TraitCodegenUtils.fromClass(ShapeId.class).toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import software.amazon.smithy.utils.CodeSection;
import software.amazon.smithy.utils.ListUtils;

/**
* Adds Javadocs to generated Trait classes.
*/
public final class JavaDocIntegration implements TraitCodegenIntegration {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
* Generates traits for the special case where the list's member is represented by a
* java string symbol.
*
* <p>List Traits with only a member shape that can be represented as a java string
* can use the base trait class {@link StringListTrait}.
*/
final class StringListTraitGenerator extends TraitGenerator {
private static final String CLASS_TEMPLATE = "public final class $1T extends StringListTrait implements "
+ "ToSmithyBuilder<$1T> {";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
import software.amazon.smithy.traitcodegen.generators.traits.TraitGenerator;
import software.amazon.smithy.traitcodegen.writer.TraitCodegenWriter;

/**
* Generates traits for the special case where the trait is a String trait that can
* be represented by a Java String symbol.
*
* <p>When a String trait is represented by a Java string, the trait can use the
* base class {@link StringTrait}.
*/
public class StringTraitGenerator extends TraitGenerator {
private static final String CLASS_TEMPLATE = "public final class $T extends StringTrait {";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
/**
* Handles the special cases related to the use of strings.
*
* <p>
* NOTE: Must be run after all other integrations to ensure any symbol changes
* <p>NOTE: Must be run after all other integrations to ensure any symbol changes
* applied by other integrations are picked up
*/
public class StringsIntegration implements TraitCodegenIntegration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
import software.amazon.smithy.traitcodegen.TraitCodegenUtils;
import software.amazon.smithy.utils.ListUtils;

/**
* Handles type conversions associated with the use of the {@code UniqueItems} trait.
*
* <p>Lists shapes and list members with the UniqueItems trait should be represented by
* a {@link Set} rather than a list.
*/
public class UniqueItemDecoratorIntegration implements TraitCodegenIntegration {
private static final String SET_INITIALIZER = "forOrderedSet()";
private static final String INTEGRATION_NAME = "unique-items-integration";
Expand Down