Skip to content

Commit e8b9927

Browse files
Chase Coalwellkstich
authored andcommitted
Fix order of operations related codegen (#78)
1 parent 27b49d9 commit e8b9927

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ public Void serviceShape(ServiceShape shape) {
254254

255255
// Generate each operation for the service.
256256
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
257-
for (OperationShape operation : topDownIndex.getContainedOperations(service)) {
257+
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
258+
for (OperationShape operation : containedOperations) {
258259
writers.useShapeWriter(operation, commandWriter -> new CommandGenerator(
259260
settings, model, operation, symbolProvider, commandWriter,
260261
runtimePlugins, protocolGenerator, applicationProtocol).run());

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/IndexGenerator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.smithy.typescript.codegen;
1717

18+
import java.util.Set;
19+
import java.util.TreeSet;
1820
import software.amazon.smithy.build.FileManifest;
1921
import software.amazon.smithy.codegen.core.Symbol;
2022
import software.amazon.smithy.codegen.core.SymbolProvider;
@@ -49,7 +51,8 @@ static void writeIndex(
4951

5052
// write export statements for each command in /commands directory
5153
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
52-
for (OperationShape operation : topDownIndex.getContainedOperations(service)) {
54+
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
55+
for (OperationShape operation : containedOperations) {
5356
writer.write("export * from \"./commands/" + symbolProvider.toSymbol(operation).getName() + "\";");
5457
}
5558
fileManifest.writeFile("index.ts", writer.toString());

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.smithy.typescript.codegen;
1717

18+
import java.util.Set;
19+
import java.util.TreeSet;
1820
import software.amazon.smithy.codegen.core.Symbol;
1921
import software.amazon.smithy.codegen.core.SymbolProvider;
2022
import software.amazon.smithy.model.Model;
@@ -67,7 +69,8 @@ public void run() {
6769
// Generate the client and extend from the modular client.
6870
writer.writeShapeDocs(service);
6971
writer.openBlock("export class $L extends $T {", "}", nonModularName, serviceSymbol, () -> {
70-
for (OperationShape operation : topDownIndex.getContainedOperations(service)) {
72+
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
73+
for (OperationShape operation : containedOperations) {
7174
Symbol operationSymbol = symbolProvider.toSymbol(operation);
7275
Symbol input = operationSymbol.expectProperty("inputType", Symbol.class);
7376
Symbol output = operationSymbol.expectProperty("outputType", Symbol.class);

0 commit comments

Comments
 (0)