Skip to content

Commit 2b4b2c0

Browse files
authored
Remove calls to deprecated model.getKnowledge (#257)
Regular expression used for search 'model.getKnowledge\(([^\.]*).class\)' and replaced with $1.of(model)
1 parent 3582007 commit 2b4b2c0

File tree

10 files changed

+14
-14
lines changed

10 files changed

+14
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static String getOperationSerializerContextType(
5454
// Get default SerdeContext.
5555
List<String> contextInterfaceList = getDefaultOperationSerdeContextTypes(writer);
5656
// If event stream trait exists, add corresponding serde context type to the intersection type.
57-
EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class);
57+
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
5858
if (eventStreamIndex.getInputInfo(operation).isPresent()) {
5959
writer.addImport("EventStreamSerdeContext", "__EventStreamSerdeContext", "@aws-sdk/types");
6060
contextInterfaceList.add("__EventStreamSerdeContext");
@@ -77,7 +77,7 @@ public static String getOperationDeserializerContextType(
7777
// Get default SerdeContext.
7878
List<String> contextInterfaceList = getDefaultOperationSerdeContextTypes(writer);
7979
// If event stream trait exists, add corresponding serde context type to the intersection type.
80-
EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class);
80+
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
8181
if (eventStreamIndex.getOutputInfo(operation).isPresent()) {
8282
writer.addImport("EventStreamSerdeContext", "__EventStreamSerdeContext", "@aws-sdk/types");
8383
contextInterfaceList.add("__EventStreamSerdeContext");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public Void serviceShape(ServiceShape shape) {
294294
settings, model, symbolProvider, nonModularName, writer, applicationProtocol).run());
295295

296296
// Generate each operation for the service.
297-
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
297+
TopDownIndex topDownIndex = TopDownIndex.of(model);
298298
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
299299
boolean hasPaginatedOperation = false;
300300

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ final class CommandGenerator implements Runnable {
7878
this.applicationProtocol = applicationProtocol;
7979

8080
symbol = symbolProvider.toSymbol(operation);
81-
operationIndex = model.getKnowledge(OperationIndex.class);
81+
operationIndex = OperationIndex.of(model);
8282
inputType = symbol.expectProperty("inputType", Symbol.class);
8383
outputType = symbol.expectProperty("outputType", Symbol.class);
8484
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ final class HttpProtocolTestGenerator implements Runnable {
115115

116116
@Override
117117
public void run() {
118-
OperationIndex operationIndex = model.getKnowledge(OperationIndex.class);
119-
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
118+
OperationIndex operationIndex = OperationIndex.of(model);
119+
TopDownIndex topDownIndex = TopDownIndex.of(model);
120120

121121
// Use a TreeSet to have a fixed ordering of tests.
122122
for (OperationShape operation : new TreeSet<>(topDownIndex.getContainedOperations(service))) {
@@ -296,7 +296,7 @@ private void writeRequestBodyAssertions(OperationShape operation, HttpRequestTes
296296
// Fast check if we have an undescribed or plain text body.
297297
if (mediaType == null || mediaType.equals("text/plain")) {
298298
// Handle converting to the right comparison format for blob payloads.
299-
HttpBindingIndex httpBindingIndex = model.getKnowledge(HttpBindingIndex.class);
299+
HttpBindingIndex httpBindingIndex = HttpBindingIndex.of(model);
300300
List<HttpBinding> payloadBindings = httpBindingIndex.getRequestBindings(operation, Location.PAYLOAD);
301301
if (!payloadBindings.isEmpty() && hasBlobBinding(payloadBindings)) {
302302
writer.write("expect(r.body).toMatchObject(Uint8Array.from($S, c => c.charCodeAt(0)));", body);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void writeIndex(
5454
writer.write("export * from \"./" + nonModularName + "\";");
5555

5656
// write export statements for each command in /commands directory
57-
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
57+
TopDownIndex topDownIndex = TopDownIndex.of(model);
5858
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
5959
boolean hasPaginatedOperation = false;
6060
for (OperationShape operation : containedOperations) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class NonModularServiceGenerator implements Runnable {
6464

6565
@Override
6666
public void run() {
67-
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
67+
TopDownIndex topDownIndex = TopDownIndex.of(model);
6868

6969
// Generate the client and extend from the modular client.
7070
writer.writeShapeDocs(service);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void writeInputOutputTypeUnion(
117117
Function<Symbol, Optional<Symbol>> mapper,
118118
Consumer<TypeScriptWriter> defaultTypeGenerator
119119
) {
120-
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
120+
TopDownIndex topDownIndex = TopDownIndex.of(model);
121121
Set<OperationShape> containedOperations = topDownIndex.getContainedOperations(service);
122122

123123
List<Symbol> symbols = containedOperations.stream()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ final class SymbolVisitor implements SymbolProvider, ShapeVisitor<Symbol> {
102102
.buildEscaper();
103103

104104
// Get each structure that's used an error.
105-
OperationIndex operationIndex = model.getKnowledge(OperationIndex.class);
105+
OperationIndex operationIndex = OperationIndex.of(model);
106106
model.shapes(OperationShape.class).forEach(operationShape -> {
107107
errorShapes.addAll(operationIndex.getErrors(operationShape));
108108
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public ShapeId resolveServiceProtocol(Model model, ServiceShape service, Set<Sha
254254
return protocol;
255255
}
256256

257-
ServiceIndex serviceIndex = model.getKnowledge(ServiceIndex.class);
257+
ServiceIndex serviceIndex = ServiceIndex.of(model);
258258
Set<ShapeId> resolvedProtocols = serviceIndex.getProtocols(service).keySet();
259259
if (resolvedProtocols.isEmpty()) {
260260
throw new UnresolvableProtocolException(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ private static boolean hasEventStream(
102102
Model model,
103103
ServiceShape service
104104
) {
105-
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
105+
TopDownIndex topDownIndex = TopDownIndex.of(model);
106106
Set<OperationShape> operations = topDownIndex.getContainedOperations(service);
107-
EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class);
107+
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
108108
for (OperationShape operation : operations) {
109109
if (eventStreamIndex.getInputInfo(operation).isPresent()
110110
|| eventStreamIndex.getOutputInfo(operation).isPresent()

0 commit comments

Comments
 (0)