Skip to content

Commit 5ec7130

Browse files
committed
Use priority instead of getOrder to sort Integrations
1 parent 279f9c4 commit 5ec7130

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.nio.file.Paths;
1919
import java.util.ArrayList;
2020
import java.util.Collection;
21-
import java.util.Comparator;
2221
import java.util.HashMap;
2322
import java.util.List;
2423
import java.util.Map;
@@ -31,6 +30,7 @@
3130
import software.amazon.smithy.build.FileManifest;
3231
import software.amazon.smithy.build.PluginContext;
3332
import software.amazon.smithy.codegen.core.CodegenException;
33+
import software.amazon.smithy.codegen.core.SmithyIntegration;
3434
import software.amazon.smithy.codegen.core.Symbol;
3535
import software.amazon.smithy.codegen.core.SymbolDependency;
3636
import software.amazon.smithy.codegen.core.SymbolProvider;
@@ -84,26 +84,27 @@ class CodegenVisitor extends ShapeVisitor.Default<Void> {
8484
private final FileManifest fileManifest;
8585
private final SymbolProvider symbolProvider;
8686
private final TypeScriptDelegator writers;
87-
private final List<TypeScriptIntegration> integrations = new ArrayList<>();
87+
private final List<TypeScriptIntegration> integrations;
8888
private final List<RuntimeClientPlugin> runtimePlugins = new ArrayList<>();
8989
private final ProtocolGenerator protocolGenerator;
9090
private final ApplicationProtocol applicationProtocol;
9191

9292
CodegenVisitor(PluginContext context, ArtifactType artifactType) {
9393
// Load all integrations.
94+
List<TypeScriptIntegration> unsortedIntegrations = new ArrayList<>();
9495
ClassLoader loader = context.getPluginClassLoader().orElse(getClass().getClassLoader());
9596
LOGGER.info("Attempting to discover TypeScriptIntegration from the classpath...");
9697
ServiceLoader.load(TypeScriptIntegration.class, loader)
9798
.forEach(integration -> {
9899
LOGGER.info(() -> "Adding TypeScriptIntegration: " + integration.getClass().getName());
99-
integrations.add(integration);
100+
unsortedIntegrations.add(integration);
100101
integration.getClientPlugins().forEach(runtimePlugin -> {
101102
LOGGER.info(() -> "Adding TypeScript runtime plugin: " + runtimePlugin);
102103
runtimePlugins.add(runtimePlugin);
103104
});
104105
});
105106
// Sort the integrations in specified order.
106-
integrations.sort(Comparator.comparingInt(TypeScriptIntegration::getOrder));
107+
integrations = SmithyIntegration.sort(unsortedIntegrations);
107108

108109
// Preprocess model using integrations.
109110
settings = TypeScriptSettings.from(context.getModel(), context.getSettings(), artifactType);

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/TypeScriptIntegration.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@
4040
@SmithyUnstableApi
4141
public interface TypeScriptIntegration
4242
extends SmithyIntegration<TypeScriptSettings, TypeScriptWriter, TypeScriptCodegenContext> {
43-
/**
44-
* Gets the sort order of the customization from -128 to 127.
45-
*
46-
* <p>Customizations are applied according to this sort order. Lower values
47-
* are executed before higher values (for example, -128 comes before 0,
48-
* comes before 127). Customizations default to 0, which is the middle point
49-
* between the minimum and maximum order values. The customization
50-
* applied later can override the runtime configurations that provided
51-
* by customizations applied earlier.
52-
*
53-
* @return Returns the sort order, defaulting to 0.
54-
*/
55-
56-
// TODO: Remove in favor of priority
57-
default byte getOrder() {
58-
return 0;
59-
}
6043

6144
/**
6245
* Preprocess the model before code generation.

0 commit comments

Comments
 (0)