Skip to content

Commit f7fa4b3

Browse files
sugmanueSteven Yuan
authored andcommitted
Revert "Add hierarchical IDs for DefaultTrait collisions (smithy-lang#1754)" (smithy-lang#1777)
This reverts commit e6b3f30.
1 parent 5adec92 commit f7fa4b3

File tree

5 files changed

+14
-38
lines changed

5 files changed

+14
-38
lines changed

smithy-model/src/main/java/software/amazon/smithy/model/validation/NodeValidationVisitor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,14 @@ private ValidationEvent event(
428428

429429
private List<ValidationEvent> applyPlugins(Shape shape) {
430430
List<ValidationEvent> events = new ArrayList<>();
431-
timestampValidationStrategy.apply(shape, value, validationContext,
432-
(location, severity, message, additionalEventIdParts) ->
433-
events.add(event(message, severity, location.getSourceLocation(), additionalEventIdParts)));
431+
timestampValidationStrategy.apply(shape, value, validationContext, (location, severity, message) -> {
432+
events.add(event(message, severity, location.getSourceLocation()));
433+
});
434434

435435
for (NodeValidatorPlugin plugin : BUILTIN) {
436-
plugin.apply(shape, value, validationContext,
437-
(location, severity, message, additionalEventIdParts) ->
438-
events.add(event(message, severity, location.getSourceLocation(), additionalEventIdParts)));
436+
plugin.apply(shape, value, validationContext, (location, severity, message) -> {
437+
events.add(event(message, severity, location.getSourceLocation()));
438+
});
439439
}
440440

441441
return events;

smithy-model/src/main/java/software/amazon/smithy/model/validation/node/NodeValidatorPlugin.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
*/
3838
@SmithyInternalApi
3939
public interface NodeValidatorPlugin {
40-
String[] EMPTY_STRING_ARRAY = new String[0];
4140

4241
/**
4342
* Applies the plugin to the given shape, node value, and model.
@@ -126,17 +125,10 @@ public boolean hasFeature(NodeValidationVisitor.Feature feature) {
126125
@SmithyInternalApi
127126
@FunctionalInterface
128127
interface Emitter {
129-
void accept(FromSourceLocation sourceLocation,
130-
Severity severity,
131-
String message,
132-
String... additionalEventIdParts);
128+
void accept(FromSourceLocation sourceLocation, Severity severity, String message);
133129

134130
default void accept(FromSourceLocation sourceLocation, String message) {
135-
accept(sourceLocation, Severity.ERROR, message, EMPTY_STRING_ARRAY);
136-
}
137-
138-
default void accept(FromSourceLocation sourceLocation, Severity severity, String message) {
139-
accept(sourceLocation, severity, message, EMPTY_STRING_ARRAY);
131+
accept(sourceLocation, Severity.ERROR, message);
140132
}
141133
}
142134
}

smithy-model/src/main/java/software/amazon/smithy/model/validation/node/RangeTraitPlugin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ private void checkNonNumeric(Shape shape, RangeTrait trait, StringNode node, Emi
5555
if (trait.getMin().isPresent() && value.equals(NonNumericFloat.NEGATIVE_INFINITY)) {
5656
emitter.accept(node, Severity.ERROR, String.format(
5757
"Value provided for `%s` must be greater than or equal to %s, but found \"%s\"",
58-
shape.getId(), trait.getMin().get(), node.getValue()), shape.getId().toString());
58+
shape.getId(), trait.getMin().get(), node.getValue()));
5959
}
6060

6161
if (trait.getMax().isPresent() && value.equals(NonNumericFloat.POSITIVE_INFINITY)) {
6262
emitter.accept(node, Severity.ERROR, String.format(
6363
"Value provided for `%s` must be less than or equal to %s, but found \"%s\"",
64-
shape.getId(), trait.getMax().get(), node.getValue()), shape.getId().toString());
64+
shape.getId(), trait.getMax().get(), node.getValue()));
6565
}
6666
});
6767
}
@@ -76,15 +76,15 @@ protected void check(Shape shape, boolean zeroValueWarning, RangeTrait trait, Nu
7676
if (decimal.compareTo(new BigDecimal(min.toString())) < 0) {
7777
emitter.accept(node, getSeverity(node, zeroValueWarning), String.format(
7878
"Value provided for `%s` must be greater than or equal to %s, but found %s",
79-
shape.getId(), min, number), shape.getId().toString());
79+
shape.getId(), min, number));
8080
}
8181
});
8282

8383
trait.getMax().ifPresent(max -> {
8484
if (decimal.compareTo(new BigDecimal(max.toString())) > 0) {
8585
emitter.accept(node, getSeverity(node, zeroValueWarning), String.format(
8686
"Value provided for `%s` must be less than or equal to %s, but found %s",
87-
shape.getId(), max, number), shape.getId().toString());
87+
shape.getId(), max, number));
8888
}
8989
});
9090
}

smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/defaults/detects-default-out-of-range.errors

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@
66
[WARNING] smithy.example#MinOne: Error validating @default trait: Value provided for `smithy.example#MinOne` must be greater than or equal to 1, but found 0 | DefaultTrait
77
[WARNING] smithy.example#MinAndMax: Error validating @default trait: Value provided for `smithy.example#MinAndMax` must be greater than or equal to 1, but found 0 | DefaultTrait
88
[WARNING] smithy.example#MaxNegativeOne: Error validating @default trait: Value provided for `smithy.example#MaxNegativeOne` must be less than or equal to -1, but found 0 | DefaultTrait
9-
[WARNING] smithy.example#Integers$doublyInvalidDefault: Error validating @default trait: Value provided for `smithy.example#Integers$doublyInvalidDefault` must be greater than or equal to 1, but found 0 | DefaultTrait.smithy.example#Integers$doublyInvalidDefault
10-
[WARNING] smithy.example#Integers$doublyInvalidDefault: Error validating @default trait: Value provided for `smithy.example#MinOne` must be greater than or equal to 1, but found 0 | DefaultTrait.smithy.example#MinOne
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,31 @@
1-
$version: "2.0"
1+
$version: "1.0"
22

33
namespace smithy.example
44

55
structure Integers {
6-
@default(0)
76
noRange: PrimitiveInteger,
87

98
@range(min: 0, max: 1)
10-
@default(0)
119
valid: PrimitiveInteger,
1210

1311
@range(min: 1)
14-
@default(0)
1512
invalidMin: PrimitiveInteger,
1613

1714
@range(max: -1, min: -100)
18-
@default(0)
1915
invalidMax: PrimitiveInteger,
2016

21-
@default(0)
2217
invalidTargetMin: MinOne,
2318

24-
@default(0)
2519
invalidTagetMax: MaxNegativeOne,
2620

27-
@default(0)
28-
invalidMinWithMax: MinAndMax,
29-
30-
@range(min: 1)
31-
@default(0)
32-
doublyInvalidDefault: MinOne
21+
invalidMinWithMax: MinAndMax
3322
}
3423

3524
@range(min: 1)
36-
@default(0)
3725
integer MinOne
3826

3927
@range(min: 1, max: 100)
40-
@default(0)
4128
integer MinAndMax
4229

4330
@range(max: -1)
44-
@default(0)
4531
integer MaxNegativeOne

0 commit comments

Comments
 (0)