Skip to content

Commit

Permalink
Fix Upgrade1to2Command for Set shape
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFossAWS committed Jan 6, 2023
1 parent d2f9c0f commit d374e8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
import software.amazon.smithy.model.SourceLocation;
import software.amazon.smithy.model.loader.ModelAssembler;
import software.amazon.smithy.model.loader.Prelude;
import software.amazon.smithy.model.shapes.ListShape;
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.shapes.ShapeType;
import software.amazon.smithy.model.shapes.ShapeVisitor;
Expand Down Expand Up @@ -321,6 +323,19 @@ public Void stringShape(StringShape shape) {
return null;
}

@Override
public Void listShape(ListShape shape) {
getDefault(shape);
if (shape instanceof SetShape) {
int lineNumber = shape.getSourceLocation().getLine();
writer.eraseLine(lineNumber);
writer.insertLine(lineNumber, "list " + shape.toShapeId().getName() + " {");
writer.insertLine(lineNumber, "@uniqueItems");
}

return null;
}

private String serializeEnum(StringShape shape) {
// Strip all the traits from the shape except the enum trait.
// We're leaving the other traits where they are in the model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ list BadSparseList {
member: NonBoxedInteger,
}

set BadSparseSet {
@uniqueItems
list BadSparseSet {
member: NonBoxedInteger,
}

Expand Down

0 comments on commit d374e8a

Please sign in to comment.