From ac2c53829267d87697b3f76b27c02f9a773230ff Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Tue, 23 Feb 2021 06:19:29 +0000 Subject: [PATCH 1/2] chore(codegen): remove calls to deprecated model.getKnowledge Regular expression used for search 'model.getKnowledge\(([^\.]*).class\)' and replaced with $1.of(model) --- .../smithy/aws/typescript/codegen/AddBuiltinPlugins.java | 2 +- .../codegen/AddEventStreamHandlingDependency.java | 6 +++--- .../codegen/AwsPackageFixturesGeneratorIntegration.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java index b443c581a6659..72fc7a5996cb4 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java @@ -138,7 +138,7 @@ private static boolean testInputContainsMember( OperationShape operationShape, Set expectedMemberNames ) { - OperationIndex operationIndex = model.getKnowledge(OperationIndex.class); + OperationIndex operationIndex = OperationIndex.of(model); return operationIndex.getInput(operationShape) .filter(input -> input.getMemberNames().stream().anyMatch(expectedMemberNames::contains)) .isPresent(); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java index a6f48892036d4..95b93cc78593c 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java @@ -129,9 +129,9 @@ public Map> getRuntimeConfigWriters( } private static boolean hasEventStreamInput(Model model, ServiceShape service) { - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); Set operations = topDownIndex.getContainedOperations(service); - EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class); + EventStreamIndex eventStreamIndex = EventStreamIndex.of(model); for (OperationShape operation : operations) { if (eventStreamIndex.getInputInfo(operation).isPresent()) { return true; @@ -141,7 +141,7 @@ private static boolean hasEventStreamInput(Model model, ServiceShape service) { } private static boolean hasEventStreamInput(Model model, ServiceShape service, OperationShape operation) { - EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class); + EventStreamIndex eventStreamIndex = EventStreamIndex.of(model); return eventStreamIndex.getInputInfo(operation).isPresent(); } } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java index 0332d9acf5270..c9a707f2bf015 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java @@ -74,7 +74,7 @@ public void writeAdditionalFiles( .collect(Collectors.joining("\n")); resource = resource.replaceAll(Pattern.quote("${documentation}"), documentation); - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); OperationShape firstOperation = topDownIndex.getContainedOperations(service).iterator().next(); String operationName = firstOperation.getId().getName(); resource = resource.replaceAll(Pattern.quote("${commandName}"), operationName); From c9c762a504796f84464ad420d7e0194884c9c6c6 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Tue, 23 Feb 2021 06:28:10 +0000 Subject: [PATCH 2/2] chore(codegen): remove more occurences of getKnowledge --- .../smithy/aws/typescript/codegen/AwsProtocolUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java index 0cd517fa1a6c4..9e9a36fca5c10 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java @@ -80,7 +80,7 @@ static void generateDocumentBodyShapeSerde( ShapeVisitor visitor ) { // Walk all the shapes within those in the document and generate for them as well. - Walker shapeWalker = new Walker(context.getModel().getKnowledge(NeighborProviderIndex.class).getProvider()); + Walker shapeWalker = new Walker(NeighborProviderIndex.of(context.getModel()).getProvider()); Set shapesToGenerate = new TreeSet<>(shapes); shapes.forEach(shape -> shapesToGenerate.addAll(shapeWalker.walkShapes(shape))); shapesToGenerate.forEach(shape -> shape.accept(visitor)); @@ -264,7 +264,7 @@ static String getInputTimestampValueProvider( Format defaultFormat, String inputLocation ) { - HttpBindingIndex httpIndex = context.getModel().getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel()); TimestampFormatTrait.Format format = httpIndex.determineTimestampFormat(memberShape, DOCUMENT, defaultFormat); return HttpProtocolGeneratorUtils.getTimestampInputParam(context, inputLocation, memberShape, format); }