Skip to content

Commit 2b824e9

Browse files
trivikrsrchase
authored andcommitted
Remove calls to deprecated context.getModel().getKnowledge (smithy-lang#309)
Regular expression uses for search: `context.getModel\(\)\.getKnowledge\(([^\.]*).class\)` replaced with `$1.of(context.getModel())`
1 parent d0746b5 commit 2b824e9

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ private void generateOperationRequestSerializer(
523523
SymbolProvider symbolProvider = context.getSymbolProvider();
524524
Symbol symbol = symbolProvider.toSymbol(operation);
525525
SymbolReference requestType = getApplicationProtocol().getRequestType();
526-
HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
526+
HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel());
527527
TypeScriptWriter writer = context.getWriter();
528528

529529
// Ensure that the request type is imported.
@@ -1028,7 +1028,7 @@ private String getTimestampInputParam(
10281028
String dataSource,
10291029
MemberShape member
10301030
) {
1031-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
1031+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
10321032
Format format;
10331033
switch (bindingType) {
10341034
case HEADER:
@@ -1477,7 +1477,7 @@ private void generateOperationResponseDeserializer(
14771477
SymbolProvider symbolProvider = context.getSymbolProvider();
14781478
Symbol symbol = symbolProvider.toSymbol(operation);
14791479
SymbolReference responseType = getApplicationProtocol().getResponseType();
1480-
HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
1480+
HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel());
14811481
Model model = context.getModel();
14821482
TypeScriptWriter writer = context.getWriter();
14831483

@@ -1535,7 +1535,7 @@ private void generateOperationResponseDeserializer(
15351535
private void generateErrorDeserializer(GenerationContext context, StructureShape error) {
15361536
TypeScriptWriter writer = context.getWriter();
15371537
SymbolProvider symbolProvider = context.getSymbolProvider();
1538-
HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
1538+
HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel());
15391539
Model model = context.getModel();
15401540
Symbol errorSymbol = symbolProvider.toSymbol(error);
15411541
String errorDeserMethodName = ProtocolGenerator.getDeserFunctionName(errorSymbol,
@@ -2031,7 +2031,7 @@ private String getOutputValue(
20312031
} else if (target instanceof DocumentShape) {
20322032
return dataSource;
20332033
} else if (target instanceof TimestampShape) {
2034-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
2034+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
20352035
Format format = httpIndex.determineTimestampFormat(member, bindingType, getDocumentTimestampFormat());
20362036
return HttpProtocolGeneratorUtils.getTimestampOutputParam(dataSource, bindingType, member, format);
20372037
} else if (target instanceof BlobShape) {
@@ -2165,7 +2165,7 @@ private String getCollectionOutputParam(
21652165
// in their formatted entry, so split on every other "," instead.
21662166
if (collectionTarget.isTimestampShape()) {
21672167
// Check if our member resolves to the HTTP_DATE format.
2168-
HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class);
2168+
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
21692169
Format format = httpIndex.determineTimestampFormat(targetMember, bindingType, Format.HTTP_DATE);
21702170

21712171
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
@@ -134,7 +134,7 @@ public void generateSharedComponents(GenerationContext context) {
134134

135135
@Override
136136
public void generateRequestSerializers(GenerationContext context) {
137-
TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class);
137+
TopDownIndex topDownIndex = TopDownIndex.of(context.getModel());
138138

139139
Set<OperationShape> containedOperations = new TreeSet<>(
140140
topDownIndex.getContainedOperations(context.getService()));
@@ -170,7 +170,7 @@ public void generateOperationHandlerFactory(GenerationContext context, Operation
170170

171171
@Override
172172
public void generateResponseDeserializers(GenerationContext context) {
173-
TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class);
173+
TopDownIndex topDownIndex = TopDownIndex.of(context.getModel());
174174

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

0 commit comments

Comments
 (0)