From 7c7f8f2a806730c3e25b306f9ae673c615b41187 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Wed, 8 Jan 2025 11:31:29 -0800 Subject: [PATCH] sorting --- .../DafnyAwsSdkClientTypeConversionProtocol.java | 2 +- .../localservice/DafnyLocalServiceGenerator.java | 7 ++++--- .../DafnyLocalServiceTypeConversionProtocol.java | 10 ++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/awssdk/DafnyAwsSdkClientTypeConversionProtocol.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/awssdk/DafnyAwsSdkClientTypeConversionProtocol.java index c66b07a97..659a2c36e 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/awssdk/DafnyAwsSdkClientTypeConversionProtocol.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/awssdk/DafnyAwsSdkClientTypeConversionProtocol.java @@ -496,7 +496,7 @@ private void generateErrorSerializer(final GenerationContext context) { final var errorShapes = awsNormalizedModel.getShapesWithTrait( ErrorTrait.class ).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); + .sorted().collect(Collectors.toCollection(LinkedHashSet::new)); for (final var errorShape : errorShapes) { if ( diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java index 82c6f80ab..20504132e 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceGenerator.java @@ -92,6 +92,7 @@ void generateClient(GoWriter writer) { .getNamespace() .equals(service.getId().getNamespace()) ) + .sorted() .forEach(unionShape -> { new UnionGenerator(model, symbolProvider, unionShape) .generateUnion(writer1); @@ -626,7 +627,7 @@ void generateShim() { void shimErrors(GoWriter writer) { for (final var error : model.getShapesWithTrait(ErrorTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new))) { + .sorted().collect(Collectors.toCollection(LinkedHashSet::new))) { writer.write( """ case $L.$L: @@ -645,7 +646,7 @@ void shimErrors(GoWriter writer) { void resourceErrors(GoWriter writer) { for (final var error : model.getShapesWithTrait(ErrorTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new))) { + .sorted().collect(Collectors.toCollection(LinkedHashSet::new))) { writer.write( """ case $L: @@ -715,7 +716,7 @@ void generateUnmodelledErrors(GenerationContext context) { void generateReferencedResources(final GenerationContext context) { final var refResources = model.getShapesWithTrait(ReferenceTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); + .sorted().collect(Collectors.toCollection(LinkedHashSet::new)); for (final var refResource : refResources) { if (!refResource.expectTrait(ReferenceTrait.class).isService()) { final var resource = refResource diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java index d63af7c6b..c6796ddb6 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithygo/localservice/DafnyLocalServiceTypeConversionProtocol.java @@ -208,7 +208,7 @@ public void generateSerializers(final GenerationContext context) { final var refResources = context .model() .getShapesWithTrait(ReferenceTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); + .sorted().collect(Collectors.toCollection(LinkedHashSet::new)); for (final var refResource : refResources) { final var resource = refResource .expectTrait(ReferenceTrait.class) @@ -588,7 +588,7 @@ public void generateDeserializers(final GenerationContext context) { final var refResources = context .model() .getShapesWithTrait(ReferenceTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); + .sorted().collect(Collectors.toCollection(LinkedHashSet::new)); for (final var refResource : refResources) { final var resource = refResource .expectTrait(ReferenceTrait.class) @@ -989,7 +989,7 @@ private void generateErrorSerializer(final GenerationContext context) { final var errorShapes = context .model() .getShapesWithTrait(ErrorTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); + .sorted().collect(Collectors.toCollection(LinkedHashSet::new)); for (final var errorShape : errorShapes) { if ( @@ -1089,6 +1089,7 @@ func OpaqueError_Input_ToDafny(nativeInput $L.OpaqueError)($L.Error) { .filter(shape -> ModelUtils.isInServiceNamespace(shape.getId(), serviceShape) ) + .sorted() .collect(Collectors.toSet()); context @@ -1346,7 +1347,7 @@ private void generateErrorDeserializer(final GenerationContext context) { final var errorShapes = context .model() .getShapesWithTrait(ErrorTrait.class).stream() - .sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new)); + .sorted().collect(Collectors.toCollection(LinkedHashSet::new)); for (final var errorShape : errorShapes) { if ( !errorShape @@ -1471,6 +1472,7 @@ func OpaqueError_Output_FromDafny(dafnyOutput $L.Error)($L.OpaqueError) { .filter(shape -> ModelUtils.isInServiceNamespace(shape.getId(), serviceShape) ) + .sorted() .collect(Collectors.toSet()); context