Skip to content

Commit

Permalink
Fix createTrait to carry forward the sourceLocation
Browse files Browse the repository at this point in the history
Most existing createTrait methods do this, but these ones were missing
that logic.
  • Loading branch information
gosar committed Jul 19, 2021
1 parent 8593209 commit 93e995d
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
Builder builder = builder();
Builder builder = builder().sourceLocation(value);
for (Map.Entry<StringNode, Node> entry : value.expectObjectNode().getMembers().entrySet()) {
ConditionKeyDefinition definition = ConditionKeyDefinition.fromNode(
entry.getValue().expectObjectNode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
//BUG: sourcelocation
ObjectNode objectNode = value.expectObjectNode();
Builder builder = builder();
Builder builder = builder().sourceLocation(value);
objectNode.getStringMember(TYPE)
.map(StringNode::getValue)
.ifPresent(builder::type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
Builder builder = builder();
ObjectNode objectNode = value.expectObjectNode();
Builder builder = builder().sourceLocation(value);
builder.template(objectNode.expectStringMember(TEMPLATE).getValue());
builder.absolute(objectNode.getBooleanMemberOrDefault(ABSOLUTE));
builder.noRegion(objectNode.getBooleanMemberOrDefault(NO_REGION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
// BUG sourceLocation
ObjectNode objectNode = value.expectObjectNode();
Builder builder = builder();
Builder builder = builder().sourceLocation(value);
String sdkId = objectNode.getStringMember("sdkId")
.map(StringNode::getValue)
.orElseThrow(() -> new SourceException(String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
ObjectNode objectNode = value.expectObjectNode();
return builder()
.sourceLocation(value)
.providerArns(objectNode.expectArrayMember(PROVIDER_ARNS).getElementsAs(StringNode::getValue))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public Provider() {

@Override
public ClientDiscoveredEndpointTrait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
ObjectNode objectNode = value.expectObjectNode();
return builder()
.sourceLocation(value)
.required(objectNode.getBooleanMemberOrDefault(REQUIRED, true))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ public Provider() {

@Override
public ClientEndpointDiscoveryTrait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
ObjectNode objectNode = value.expectObjectNode();
Builder builder = builder().operation(objectNode.expectStringMember(OPERATION).expectShapeId());
Builder builder = builder()
.sourceLocation(value)
.operation(objectNode.expectStringMember(OPERATION).expectShapeId());
objectNode.getStringMember(ERROR).ifPresent(error -> builder.error(error.expectShapeId()));
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
List<ShapeId> values = new ArrayList<>();
for (StringNode node : value.expectArrayNode().getElementsAs(StringNode.class)) {
values.add(node.expectShapeId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public Provider() {

@Override
public Trait createTrait(ShapeId target, Node value) {
// BUG: sourcelocation
return new HttpErrorTrait(value.expectNumberNode().getValue().intValue(), value.getSourceLocation());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public ShapeId getShapeId() {

@Override
public LengthTrait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
ObjectNode objectNode = value.expectObjectNode();
Long minValue = objectNode.getMember("min")
.map(v -> v.expectNumberNode().getValue().longValue()).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public ShapeId getShapeId() {

@Override
public RangeTrait createTrait(ShapeId target, Node value) {
// BUG: sourceLocation
ObjectNode objectNode = value.expectObjectNode();
BigDecimal minValue = objectNode.getMember("min")
.map(node -> new BigDecimal(node.expectNumberNode().getValue().toString())).orElse(null);
Expand Down

0 comments on commit 93e995d

Please sign in to comment.