From a3dbb5e35644bd9e5f85eb4a5e514faeb7538a28 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Wed, 18 Nov 2020 13:20:15 -0500 Subject: [PATCH] Use `.of()` to construct Knowledge Indices (#39) `.of()` will use a cached index on the model when it exists --- .../software/amazon/smithy/rust/codegen/smithy/SymbolVisitor.kt | 2 +- .../rust/codegen/smithy/generators/HttpTraitBindingGenerator.kt | 2 +- .../smithy/rust/codegen/smithy/generators/ServiceGenerator.kt | 2 +- .../amazon/smithy/rust/codegen/smithy/protocols/AwsRestJson.kt | 2 +- .../smithy/rust/codegen/smithy/protocols/ProtocolLoader.kt | 2 +- .../rust/codegen/smithy/transformers/RecursiveShapeBoxer.kt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/SymbolVisitor.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/SymbolVisitor.kt index 14231a0ac..961cdf205 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/SymbolVisitor.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/SymbolVisitor.kt @@ -110,7 +110,7 @@ class SymbolVisitor( private val config: SymbolVisitorConfig = DefaultConfig ) : SymbolProvider, ShapeVisitor { - private val nullableIndex = NullableIndex(model) + private val nullableIndex = NullableIndex.of(model) override fun toSymbol(shape: Shape): Symbol { return shape.accept(this) } diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpTraitBindingGenerator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpTraitBindingGenerator.kt index f2df1281d..e87a6b8f0 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpTraitBindingGenerator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpTraitBindingGenerator.kt @@ -66,7 +66,7 @@ class HttpTraitBindingGenerator( ) { // TODO: make defaultTimestampFormat configurable private val defaultTimestampFormat = TimestampFormatTrait.Format.EPOCH_SECONDS - private val index = HttpBindingIndex(model) + private val index = HttpBindingIndex.of(model) /** * Generates `update_http_builder` and all necessary dependency functions into the impl block provided by diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/ServiceGenerator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/ServiceGenerator.kt index c835e4333..f40dbfc9c 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/ServiceGenerator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/ServiceGenerator.kt @@ -16,7 +16,7 @@ class ServiceGenerator( private val protocolGenerator: HttpProtocolGenerator, private val config: ProtocolConfig ) { - private val index = TopDownIndex(config.model) + private val index = TopDownIndex.of(config.model) fun render() { val operations = index.getContainedOperations(config.serviceShape) diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/AwsRestJson.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/AwsRestJson.kt index 7bad44ab4..4b2ce7416 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/AwsRestJson.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/AwsRestJson.kt @@ -38,7 +38,7 @@ class AwsRestJsonGenerator( private val model = protocolConfig.model private val symbolProvider = protocolConfig.symbolProvider private val runtimeConfig = protocolConfig.runtimeConfig - private val httpIndex = HttpBindingIndex(model) + private val httpIndex = HttpBindingIndex.of(model) private val requestBuilder = RuntimeType.Http("request::Builder") override fun toHttpRequestImpl( diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/ProtocolLoader.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/ProtocolLoader.kt index 73db7e5c3..0294a4f29 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/ProtocolLoader.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/ProtocolLoader.kt @@ -18,7 +18,7 @@ class ProtocolLoader(private val supportedProtocols: Map> { - val protocols: MutableMap = ServiceIndex(model).getProtocols(serviceShape) + val protocols: MutableMap = ServiceIndex.of(model).getProtocols(serviceShape) val matchingProtocols = protocols.keys.mapNotNull { protocolId -> supportedProtocols[protocolId]?.let { protocolId to it } } if (matchingProtocols.isEmpty()) { diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/transformers/RecursiveShapeBoxer.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/transformers/RecursiveShapeBoxer.kt index 50bc6eb4f..361f301ff 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/transformers/RecursiveShapeBoxer.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/transformers/RecursiveShapeBoxer.kt @@ -43,7 +43,7 @@ object RecursiveShapeBoxer { // 4. Select the member shape in that loop with the earliest shape id // 5. Box it. // (External to this function) Go back to 1. - val index = TopologicalIndex(model) + val index = TopologicalIndex.of(model) val recursiveShapes = index.recursiveShapes val loops = recursiveShapes.map { // Get all the shapes in the closure (represented as Paths -- GitLab