From 74dd5eaa90e6fce6d2e40ea4341466e59700c45f Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Tue, 13 Apr 2021 14:52:20 +0000 Subject: [PATCH] Remove calls to deprecated context.getModel().getKnowledge Regular expression uses for search: `context.getModel\(\)\.getKnowledge\(([^\.]*).class\)` replaced with `$1.of(context.getModel())` --- .../integration/DocumentMemberDeserVisitor.java | 2 +- .../integration/DocumentMemberSerVisitor.java | 2 +- .../HttpBindingProtocolGenerator.java | 16 ++++++++-------- .../integration/HttpRpcProtocolGenerator.java | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitor.java index c0ae2fe4078..cdc0ed61531 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitor.java @@ -202,7 +202,7 @@ public final String memberShape(MemberShape shape) { @Override public String timestampShape(TimestampShape shape) { - HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel()); Format format = httpIndex.determineTimestampFormat(shape, Location.DOCUMENT, defaultTimestampFormat); return HttpProtocolGeneratorUtils.getTimestampOutputParam(dataSource, Location.DOCUMENT, shape, format); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitor.java index b07a208caea..25ee5e314b6 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitor.java @@ -199,7 +199,7 @@ public final String memberShape(MemberShape shape) { @Override public String timestampShape(TimestampShape shape) { - HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel()); Format format = httpIndex.determineTimestampFormat(shape, Location.DOCUMENT, defaultTimestampFormat); return HttpProtocolGeneratorUtils.getTimestampInputParam(context, dataSource, shape, format); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java index 3039d44e324..3c584e089fc 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java @@ -159,7 +159,7 @@ private boolean isNativeSimpleType(Shape target) { @Override public void generateRequestSerializers(GenerationContext context) { - TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(context.getModel()); Set containedOperations = new TreeSet<>( topDownIndex.getContainedOperations(context.getService())); @@ -175,7 +175,7 @@ public void generateRequestSerializers(GenerationContext context) { @Override public void generateResponseDeserializers(GenerationContext context) { - TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(context.getModel()); Set containedOperations = new TreeSet<>( topDownIndex.getContainedOperations(context.getService())); @@ -197,7 +197,7 @@ private void generateOperationSerializer( SymbolProvider symbolProvider = context.getSymbolProvider(); Symbol symbol = symbolProvider.toSymbol(operation); SymbolReference requestType = getApplicationProtocol().getRequestType(); - HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel()); TypeScriptWriter writer = context.getWriter(); // Ensure that the request type is imported. @@ -615,7 +615,7 @@ private String getTimestampInputParam( String dataSource, MemberShape member ) { - HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel()); Format format; switch (bindingType) { case HEADER: @@ -864,7 +864,7 @@ private void generateOperationDeserializer( SymbolProvider symbolProvider = context.getSymbolProvider(); Symbol symbol = symbolProvider.toSymbol(operation); SymbolReference responseType = getApplicationProtocol().getResponseType(); - HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel()); Model model = context.getModel(); TypeScriptWriter writer = context.getWriter(); @@ -922,7 +922,7 @@ private void generateOperationDeserializer( private void generateErrorDeserializer(GenerationContext context, StructureShape error) { TypeScriptWriter writer = context.getWriter(); SymbolProvider symbolProvider = context.getSymbolProvider(); - HttpBindingIndex bindingIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex bindingIndex = HttpBindingIndex.of(context.getModel()); Model model = context.getModel(); Symbol errorSymbol = symbolProvider.toSymbol(error); String errorDeserMethodName = ProtocolGenerator.getDeserFunctionName(errorSymbol, @@ -1351,7 +1351,7 @@ private String getOutputValue( } else if (target instanceof DocumentShape) { return dataSource; } else if (target instanceof TimestampShape) { - HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel()); Format format = httpIndex.determineTimestampFormat(member, bindingType, getDocumentTimestampFormat()); return HttpProtocolGeneratorUtils.getTimestampOutputParam(dataSource, bindingType, member, format); } else if (target instanceof BlobShape) { @@ -1465,7 +1465,7 @@ private String getCollectionOutputParam( // in their formatted entry, so split on every other "," instead. if (collectionTarget.isTimestampShape()) { // Check if our member resolves to the HTTP_DATE format. - HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel()); Format format = httpIndex.determineTimestampFormat(targetMember, bindingType, Format.HTTP_DATE); if (format == Format.HTTP_DATE) { diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java index d2c09043165..cd627d8a0c7 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java @@ -131,7 +131,7 @@ public void generateSharedComponents(GenerationContext context) { @Override public void generateRequestSerializers(GenerationContext context) { - TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(context.getModel()); Set containedOperations = new TreeSet<>( topDownIndex.getContainedOperations(context.getService())); @@ -142,7 +142,7 @@ public void generateRequestSerializers(GenerationContext context) { @Override public void generateResponseDeserializers(GenerationContext context) { - TopDownIndex topDownIndex = context.getModel().getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(context.getModel()); Set containedOperations = new TreeSet<>( topDownIndex.getContainedOperations(context.getService()));