Skip to content

Commit 2484093

Browse files
authored
Remove calls to deprecated context.getModel().getKnowledge (#309)
Regular expression uses for search: `context.getModel\(\)\.getKnowledge\(([^\.]*).class\)` replaced with `$1.of(context.getModel())`
1 parent 673cfaa commit 2484093

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public final String memberShape(MemberShape shape) {
202202

203203
@Override
204204
public String timestampShape(TimestampShape shape) {
205-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
205+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
206206
Format format = httpIndex.determineTimestampFormat(shape, Location.DOCUMENT, defaultTimestampFormat);
207207
return HttpProtocolGeneratorUtils.getTimestampOutputParam(dataSource, Location.DOCUMENT, shape, format);
208208
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public final String memberShape(MemberShape shape) {
199199

200200
@Override
201201
public String timestampShape(TimestampShape shape) {
202-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
202+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
203203
Format format = httpIndex.determineTimestampFormat(shape, Location.DOCUMENT, defaultTimestampFormat);
204204
return HttpProtocolGeneratorUtils.getTimestampInputParam(context, dataSource, shape, format);
205205
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private boolean isNativeSimpleType(Shape target) {
159159

160160
@Override
161161
public void generateRequestSerializers(GenerationContext context) {
162-
TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class);
162+
TopDownIndex topDownIndex = TopDownIndex.of(context.getModel());
163163

164164
Set<OperationShape> containedOperations = new TreeSet<>(
165165
topDownIndex.getContainedOperations(context.getService()));
@@ -175,7 +175,7 @@ public void generateRequestSerializers(GenerationContext context) {
175175

176176
@Override
177177
public void generateResponseDeserializers(GenerationContext context) {
178-
TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class);
178+
TopDownIndex topDownIndex = TopDownIndex.of(context.getModel());
179179

180180
Set<OperationShape> containedOperations = new TreeSet<>(
181181
topDownIndex.getContainedOperations(context.getService()));
@@ -197,7 +197,7 @@ private void generateOperationSerializer(
197197
SymbolProvider symbolProvider = context.getSymbolProvider();
198198
Symbol symbol = symbolProvider.toSymbol(operation);
199199
SymbolReference requestType = getApplicationProtocol().getRequestType();
200-
HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
200+
HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel());
201201
TypeScriptWriter writer = context.getWriter();
202202

203203
// Ensure that the request type is imported.
@@ -615,7 +615,7 @@ private String getTimestampInputParam(
615615
String dataSource,
616616
MemberShape member
617617
) {
618-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
618+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
619619
Format format;
620620
switch (bindingType) {
621621
case HEADER:
@@ -864,7 +864,7 @@ private void generateOperationDeserializer(
864864
SymbolProvider symbolProvider = context.getSymbolProvider();
865865
Symbol symbol = symbolProvider.toSymbol(operation);
866866
SymbolReference responseType = getApplicationProtocol().getResponseType();
867-
HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
867+
HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel());
868868
Model model = context.getModel();
869869
TypeScriptWriter writer = context.getWriter();
870870

@@ -922,7 +922,7 @@ private void generateOperationDeserializer(
922922
private void generateErrorDeserializer(GenerationContext context, StructureShape error) {
923923
TypeScriptWriter writer = context.getWriter();
924924
SymbolProvider symbolProvider = context.getSymbolProvider();
925-
HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
925+
HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel());
926926
Model model = context.getModel();
927927
Symbol errorSymbol = symbolProvider.toSymbol(error);
928928
String errorDeserMethodName = ProtocolGenerator.getDeserFunctionName(errorSymbol,
@@ -1351,7 +1351,7 @@ private String getOutputValue(
13511351
} else if (target instanceof DocumentShape) {
13521352
return dataSource;
13531353
} else if (target instanceof TimestampShape) {
1354-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
1354+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
13551355
Format format = httpIndex.determineTimestampFormat(member, bindingType, getDocumentTimestampFormat());
13561356
return HttpProtocolGeneratorUtils.getTimestampOutputParam(dataSource, bindingType, member, format);
13571357
} else if (target instanceof BlobShape) {
@@ -1465,7 +1465,7 @@ private String getCollectionOutputParam(
14651465
// in their formatted entry, so split on every other "," instead.
14661466
if (collectionTarget.isTimestampShape()) {
14671467
// Check if our member resolves to the HTTP_DATE format.
1468-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
1468+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
14691469
Format format = httpIndex.determineTimestampFormat(targetMember, bindingType, Format.HTTP_DATE);
14701470

14711471
if (format == Format.HTTP_DATE) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void generateSharedComponents(GenerationContext context) {
131131

132132
@Override
133133
public void generateRequestSerializers(GenerationContext context) {
134-
TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class);
134+
TopDownIndex topDownIndex = TopDownIndex.of(context.getModel());
135135

136136
Set<OperationShape> containedOperations = new TreeSet<>(
137137
topDownIndex.getContainedOperations(context.getService()));
@@ -142,7 +142,7 @@ public void generateRequestSerializers(GenerationContext context) {
142142

143143
@Override
144144
public void generateResponseDeserializers(GenerationContext context) {
145-
TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class);
145+
TopDownIndex topDownIndex = TopDownIndex.of(context.getModel());
146146

147147
Set<OperationShape> containedOperations = new TreeSet<>(
148148
topDownIndex.getContainedOperations(context.getService()));

0 commit comments

Comments
 (0)