Skip to content

Commit 2577f6c

Browse files
authored
Revert "chore: reduce number of extensions to speed up builds (#276)" (#278)
This reverts commit 2870a27.
1 parent 2870a27 commit 2577f6c

File tree

41 files changed

+162
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+162
-160
lines changed

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/CodegenVisitor.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ class CodegenVisitor(context: PluginContext) : ShapeVisitor.Default<Void>() {
128128
}
129129

130130
override fun structureShape(shape: StructureShape): Void? {
131-
writers.useShapeWriter(shape) { writer: SwiftWriter ->
132-
StructureGenerator(model, symbolProvider, writer, shape).render()
133-
writer.write("")
131+
writers.useShapeWriter(shape) { writer: SwiftWriter -> StructureGenerator(model, symbolProvider, writer, shape).render() }
132+
writers.useShapeExtensionWriter(shape, "CustomDebugStringConvertible") { writer: SwiftWriter ->
134133
CustomDebugStringConvertibleGenerator(symbolProvider, writer, shape).render()
135134
}
136135
return null

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/HttpBindingProtocolGenerator.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
139139
val symbolName = symbol.name
140140
val rootNamespace = ctx.settings.moduleName
141141
val encodeSymbol = Symbol.builder()
142-
.definitionFile("./$rootNamespace/models/$symbolName+Extensions.swift")
142+
.definitionFile("./$rootNamespace/models/$symbolName+Encodable.swift")
143143
.name(symbolName)
144144
.build()
145145

@@ -233,7 +233,7 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
233233
val httpBodyMembers = shape.members().filter { it.isInHttpBody() }.toList()
234234

235235
val decodeSymbol = Symbol.builder()
236-
.definitionFile("./$rootNamespace/models/${bodySymbol.name}+Extensions.swift")
236+
.definitionFile("./$rootNamespace/models/${bodySymbol.name}+Decodable.swift")
237237
.name(bodySymbol.name)
238238
.build()
239239

@@ -377,7 +377,7 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
377377

378378
val rootNamespace = ctx.settings.moduleName
379379
val headerMiddlewareSymbol = Symbol.builder()
380-
.definitionFile("./$rootNamespace/models/${inputSymbol.name}+Extensions.swift")
380+
.definitionFile("./$rootNamespace/models/${inputSymbol.name}+HeaderMiddleware.swift")
381381
.name(inputSymbol.name)
382382
.build()
383383
ctx.delegator.useShapeWriter(headerMiddlewareSymbol) { writer ->
@@ -403,7 +403,7 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
403403

404404
val rootNamespace = ctx.settings.moduleName
405405
val headerMiddlewareSymbol = Symbol.builder()
406-
.definitionFile("./$rootNamespace/models/${inputSymbol.name}+Extensions.swift")
406+
.definitionFile("./$rootNamespace/models/${inputSymbol.name}+QueryItemMiddleware.swift")
407407
.name(inputSymbol.name)
408408
.build()
409409
ctx.delegator.useShapeWriter(headerMiddlewareSymbol) { writer ->
@@ -421,7 +421,7 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
421421
val rootNamespace = ctx.settings.moduleName
422422
val inputSymbol = ctx.symbolProvider.toSymbol(inputShape)
423423
val headerMiddlewareSymbol = Symbol.builder()
424-
.definitionFile("./$rootNamespace/models/${inputSymbol.name}+Extensions.swift")
424+
.definitionFile("./$rootNamespace/models/${inputSymbol.name}+BodyMiddleware.swift")
425425
.name(inputSymbol.name)
426426
.build()
427427
ctx.delegator.useShapeWriter(headerMiddlewareSymbol) { writer ->

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HttpResponseBindingErrorNarrowGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HttpResponseBindingErrorNarrowGenerator(
2020
val operationErrorName = ServiceGenerator.getOperationErrorShapeName(op)
2121
val rootNamespace = ctx.settings.moduleName
2222
val httpBindingSymbol = Symbol.builder()
23-
.definitionFile("./$rootNamespace/models/$operationErrorName+Extensions.swift")
23+
.definitionFile("./$rootNamespace/models/$operationErrorName+HttpResponseBinding.swift")
2424
.name(operationErrorName)
2525
.build()
2626

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HttpResponseBindingOutputGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class HttpResponseBindingOutputGenerator(
3232
.sortedBy { it.memberName }
3333
val rootNamespace = ctx.settings.moduleName
3434
val httpBindingSymbol = Symbol.builder()
35-
.definitionFile("./$rootNamespace/models/$outputShapeName+Extensions.swift")
35+
.definitionFile("./$rootNamespace/models/$outputShapeName+HttpResponseBinding.swift")
3636
.name(outputShapeName)
3737
.build()
3838

smithy-swift-codegen/src/test/kotlin/HttpBindingProtocolGeneratorTests.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class HttpBindingProtocolGeneratorTests {
6565

6666
@Test
6767
fun `it creates correct init for explicit struct payloads`() {
68-
val contents = getModelFileContents("example", "ExplicitStructOutputResponse+Extensions.swift", newTestContext.manifest)
68+
val contents = getModelFileContents("example", "ExplicitStructOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
6969
contents.shouldSyntacticSanityCheck()
7070
val expectedContents =
7171
"""
@@ -97,7 +97,7 @@ extension ExplicitStructOutputResponse: HttpResponseBinding {
9797

9898
@Test
9999
fun `httpResponseCodeOutputResponse response init content`() {
100-
val contents = getModelFileContents("example", "HttpResponseCodeOutputResponse+Extensions.swift", newTestContext.manifest)
100+
val contents = getModelFileContents("example", "HttpResponseCodeOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
101101
contents.shouldSyntacticSanityCheck()
102102
val expectedContents =
103103
"""
@@ -112,7 +112,7 @@ extension HttpResponseCodeOutputResponse: HttpResponseBinding {
112112

113113
@Test
114114
fun `decode the document type in HttpResponseBinding`() {
115-
val contents = getModelFileContents("example", "InlineDocumentAsPayloadOutputResponse+Extensions.swift", newTestContext.manifest)
115+
val contents = getModelFileContents("example", "InlineDocumentAsPayloadOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
116116
contents.shouldSyntacticSanityCheck()
117117
val expectedContents =
118118
"""
@@ -136,7 +136,7 @@ extension InlineDocumentAsPayloadOutputResponse: HttpResponseBinding {
136136
}
137137
@Test
138138
fun `default fooMap to an empty map if keysForFooMap is empty`() {
139-
val contents = getModelFileContents("example", "HttpPrefixHeadersOutputResponse+Extensions.swift", newTestContext.manifest)
139+
val contents = getModelFileContents("example", "HttpPrefixHeadersOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
140140
val expectedContents =
141141
"""
142142
extension HttpPrefixHeadersOutputResponse: HttpResponseBinding {

smithy-swift-codegen/src/test/kotlin/HttpBodyMiddlewareTests.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class HttpBodyMiddlewareTests {
2121

2222
@Test
2323
fun `it builds body middleware smoke test`() {
24-
val contents = getModelFileContents("example", "SmokeTestInput+Extensions.swift", newTestContext.manifest)
24+
val contents = getModelFileContents("example", "SmokeTestInput+BodyMiddleware.swift", newTestContext.manifest)
2525
contents.shouldSyntacticSanityCheck()
2626
val expectedContents =
2727
"""
@@ -63,7 +63,7 @@ class HttpBodyMiddlewareTests {
6363

6464
@Test
6565
fun `it builds body middleware for explicit string payloads`() {
66-
val contents = getModelFileContents("example", "ExplicitStringInput+Extensions.swift", newTestContext.manifest)
66+
val contents = getModelFileContents("example", "ExplicitStringInput+BodyMiddleware.swift", newTestContext.manifest)
6767
contents.shouldSyntacticSanityCheck()
6868
val expectedContents =
6969
"""
@@ -100,7 +100,7 @@ class HttpBodyMiddlewareTests {
100100

101101
@Test
102102
fun `it builds body middleware for explicit blob payloads`() {
103-
val contents = getModelFileContents("example", "ExplicitBlobInput+Extensions.swift", newTestContext.manifest)
103+
val contents = getModelFileContents("example", "ExplicitBlobInput+BodyMiddleware.swift", newTestContext.manifest)
104104
contents.shouldSyntacticSanityCheck()
105105
val expectedContents =
106106
"""
@@ -137,7 +137,7 @@ class HttpBodyMiddlewareTests {
137137

138138
@Test
139139
fun `it builds body middleware for explicit streaming blob payloads`() {
140-
val contents = getModelFileContents("example", "ExplicitBlobStreamInput+Extensions.swift", newTestContext.manifest)
140+
val contents = getModelFileContents("example", "ExplicitBlobStreamInput+BodyMiddleware.swift", newTestContext.manifest)
141141
contents.shouldSyntacticSanityCheck()
142142
val expectedContents =
143143
"""
@@ -174,7 +174,7 @@ class HttpBodyMiddlewareTests {
174174

175175
@Test
176176
fun `it builds body middleware for explicit struct payloads`() {
177-
val contents = getModelFileContents("example", "ExplicitStructInput+Extensions.swift", newTestContext.manifest)
177+
val contents = getModelFileContents("example", "ExplicitStructInput+BodyMiddleware.swift", newTestContext.manifest)
178178
contents.shouldSyntacticSanityCheck()
179179
val expectedContents =
180180
"""

smithy-swift-codegen/src/test/kotlin/HttpHeaderMiddlewareGeneratorTests.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class HttpHeaderMiddlewareGeneratorTests {
1616

1717
@Test
1818
fun `it creates smoke test request builder`() {
19-
val contents = getModelFileContents("example", "SmokeTestInput+Extensions.swift", newTestContext.manifest)
19+
val contents = getModelFileContents("example", "SmokeTestInput+HeaderMiddleware.swift", newTestContext.manifest)
2020
contents.shouldSyntacticSanityCheck()
2121
val expectedContents =
2222
"""
@@ -54,7 +54,7 @@ class HttpHeaderMiddlewareGeneratorTests {
5454

5555
@Test
5656
fun `it builds headers with enums as raw values`() {
57-
val contents = getModelFileContents("example", "EnumInputInput+Extensions.swift", newTestContext.manifest)
57+
val contents = getModelFileContents("example", "EnumInputInput+HeaderMiddleware.swift", newTestContext.manifest)
5858
contents.shouldSyntacticSanityCheck()
5959
val expectedContents =
6060
"""
@@ -91,7 +91,7 @@ class HttpHeaderMiddlewareGeneratorTests {
9191
fun `it builds header with idempotency token value`() {
9292
val contents = getModelFileContents(
9393
"example",
94-
"IdempotencyTokenWithoutHttpPayloadTraitOnTokenInput+Extensions.swift",
94+
"IdempotencyTokenWithoutHttpPayloadTraitOnTokenInput+HeaderMiddleware.swift",
9595
newTestContext.manifest
9696
)
9797
contents.shouldSyntacticSanityCheck()
@@ -129,7 +129,7 @@ class HttpHeaderMiddlewareGeneratorTests {
129129
@Test
130130
fun `it creates http headers for timestamps with format`() {
131131
val contents =
132-
getModelFileContents("example", "TimestampInputInput+Extensions.swift", newTestContext.manifest)
132+
getModelFileContents("example", "TimestampInputInput+HeaderMiddleware.swift", newTestContext.manifest)
133133
contents.shouldSyntacticSanityCheck()
134134
val expectedContents =
135135
"""

smithy-swift-codegen/src/test/kotlin/HttpQueryItemMiddlewareGeneratorTests.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11

22
import io.kotest.matchers.string.shouldContainOnlyOnce
3-
import io.kotest.matchers.string.shouldNotContain
3+
import org.junit.jupiter.api.Assertions
44
import org.junit.jupiter.api.Test
5+
import java.util.Optional
56

67
class HttpQueryItemMiddlewareGeneratorTests {
78
@Test
89
fun `001 it creates query item middleware with idempotency token trait for httpQuery`() {
910
val context = setupTests("http-binding-protocol-generator-test.smithy", "com.test#Example")
1011
val contents =
11-
getModelFileContents("example", "QueryIdempotencyTokenAutoFillInput+Extensions.swift", context.manifest)
12+
getModelFileContents("example", "QueryIdempotencyTokenAutoFillInput+QueryItemMiddleware.swift", context.manifest)
1213
contents.shouldSyntacticSanityCheck()
1314
val expectedContents =
1415
"""
@@ -45,7 +46,7 @@ class HttpQueryItemMiddlewareGeneratorTests {
4546
@Test
4647
fun `002 it creates query item middleware for timestamps with format`() {
4748
val context = setupTests("http-binding-protocol-generator-test.smithy", "com.test#Example")
48-
val contents = getModelFileContents("example", "TimestampInputInput+Extensions.swift", context.manifest)
49+
val contents = getModelFileContents("example", "TimestampInputInput+QueryItemMiddleware.swift", context.manifest)
4950
contents.shouldSyntacticSanityCheck()
5051
val expectedContents =
5152
"""
@@ -88,7 +89,7 @@ class HttpQueryItemMiddlewareGeneratorTests {
8889
@Test
8990
fun `003 it creates query item middleware smoke test`() {
9091
val context = setupTests("http-binding-protocol-generator-test.smithy", "com.test#Example")
91-
val contents = getModelFileContents("example", "SmokeTestInput+Extensions.swift", context.manifest)
92+
val contents = getModelFileContents("example", "SmokeTestInput+QueryItemMiddleware.swift", context.manifest)
9293
contents.shouldSyntacticSanityCheck()
9394
val expectedContents =
9495
"""
@@ -125,14 +126,16 @@ class HttpQueryItemMiddlewareGeneratorTests {
125126
@Test
126127
fun `004 httpQueryParams only should not have BodyMiddleware extension`() {
127128
val context = setupTests("http-query-params-stringmap.smithy", "com.test#Example")
128-
val contents = getFileContents(context.manifest, "/example/models/AllQueryStringTypesInput+Extensions.swift")
129-
contents.shouldNotContain("BodyMiddleware")
129+
Assertions.assertEquals(
130+
Optional.empty<String>(),
131+
context.manifest.getFileString("/example/models/AllQueryStringTypesInput+BodyMiddleware.swift")
132+
)
130133
}
131134

132135
@Test
133136
fun `005 httpQueryParams on StringMap`() {
134137
val context = setupTests("http-query-params-stringmap.smithy", "com.test#Example")
135-
val contents = getFileContents(context.manifest, "/example/models/AllQueryStringTypesInput+Extensions.swift")
138+
val contents = getFileContents(context.manifest, "/example/models/AllQueryStringTypesInput+QueryItemMiddleware.swift")
136139
contents.shouldSyntacticSanityCheck()
137140
val expectedContents =
138141
"""
@@ -178,7 +181,7 @@ class HttpQueryItemMiddlewareGeneratorTests {
178181
@Test
179182
fun `006 httpQueryParams on stringListMap`() {
180183
val context = setupTests("http-query-params-stringlistmap.smithy", "com.test#Example")
181-
val contents = getFileContents(context.manifest, "/example/models/QueryParamsAsStringListMapInput+Extensions.swift")
184+
val contents = getFileContents(context.manifest, "/example/models/QueryParamsAsStringListMapInput+QueryItemMiddleware.swift")
182185
contents.shouldSyntacticSanityCheck()
183186
val expectedContents =
184187
"""
@@ -226,7 +229,7 @@ class HttpQueryItemMiddlewareGeneratorTests {
226229
@Test
227230
fun `007 query precedence with httpQuery and httpQueryParams`() {
228231
val context = setupTests("http-query-params-precedence.smithy", "com.test#Example")
229-
val contents = getFileContents(context.manifest, "/example/models/QueryPrecedenceInput+Extensions.swift")
232+
val contents = getFileContents(context.manifest, "/example/models/QueryPrecedenceInput+QueryItemMiddleware.swift")
230233
contents.shouldSyntacticSanityCheck()
231234
val expectedContents =
232235
"""

smithy-swift-codegen/src/test/kotlin/SensitiveTraitGeneratorTests.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SensitiveTraitGeneratorTests {
1212
fun `SensitiveTraitInRequestInput+CustomDebugStringConvertible`() {
1313
val manifest = setupTest()
1414
var extensionWithSensitiveTrait = manifest
15-
.getFileString("example/models/SensitiveTraitInRequestInput.swift").get()
15+
.getFileString("example/models/SensitiveTraitInRequestInput+CustomDebugStringConvertible.swift").get()
1616
extensionWithSensitiveTrait.shouldSyntacticSanityCheck()
1717
val expectedContents =
1818
"""
@@ -28,7 +28,7 @@ class SensitiveTraitGeneratorTests {
2828
fun `SensitiveTraitInRequestOutput+CustomDebugStringConvertible`() {
2929
val manifest = setupTest()
3030
var extensionWithSensitiveTrait = manifest
31-
.getFileString("example/models/SensitiveTraitInRequestOutputResponse.swift").get()
31+
.getFileString("example/models/SensitiveTraitInRequestOutputResponse+CustomDebugStringConvertible.swift").get()
3232
extensionWithSensitiveTrait.shouldSyntacticSanityCheck()
3333
val expectedContents =
3434
"""
@@ -45,7 +45,7 @@ class SensitiveTraitGeneratorTests {
4545
fun `NoSensitiveMemberStruct+CustomDebugStringConvertible`() {
4646
val manifest = setupTest()
4747
var extensionWithSensitiveTrait = manifest
48-
.getFileString("example/models/SensitiveTraitTestRequestInput.swift").get()
48+
.getFileString("example/models/SensitiveTraitTestRequestInput+CustomDebugStringConvertible.swift").get()
4949
extensionWithSensitiveTrait.shouldSyntacticSanityCheck()
5050
val expectedContents =
5151
"""
@@ -61,7 +61,7 @@ class SensitiveTraitGeneratorTests {
6161
fun `AllSensitiveMemberStruct+CustomDebugStringConvertible`() {
6262
val manifest = setupTest()
6363
var extensionWithSensitiveTrait = manifest
64-
.getFileString("example/models/SensitiveTraitTestRequestOutputResponse.swift").get()
64+
.getFileString("example/models/SensitiveTraitTestRequestOutputResponse+CustomDebugStringConvertible.swift").get()
6565
extensionWithSensitiveTrait.shouldSyntacticSanityCheck()
6666
val expectedContents =
6767
"""

smithy-swift-codegen/src/test/kotlin/StructDecodeGenerationTests.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class StructDecodeGenerationTests {
2727

2828
@Test
2929
fun `it creates decodable conformance in correct file`() {
30-
Assertions.assertTrue(newTestContext.manifest.hasFile("/example/models/SmokeTestOutputResponseBody+Extensions.swift"))
30+
Assertions.assertTrue(newTestContext.manifest.hasFile("/example/models/SmokeTestOutputResponseBody+Decodable.swift"))
3131
}
3232

3333
@Test
@@ -40,7 +40,7 @@ class StructDecodeGenerationTests {
4040

4141
@Test
4242
fun `it creates smoke test request decodable conformance`() {
43-
val contents = getModelFileContents("example", "SmokeTestOutputResponseBody+Extensions.swift", newTestContext.manifest)
43+
val contents = getModelFileContents("example", "SmokeTestOutputResponseBody+Decodable.swift", newTestContext.manifest)
4444
contents.shouldSyntacticSanityCheck()
4545
val expectedContents =
4646
"""
@@ -163,7 +163,7 @@ class StructDecodeGenerationTests {
163163
@Test
164164
fun `it provides decodable conformance to operation outputs with timestamps`() {
165165
val contents =
166-
getModelFileContents("example", "TimestampInputOutputResponseBody+Extensions.swift", newTestContext.manifest)
166+
getModelFileContents("example", "TimestampInputOutputResponseBody+Decodable.swift", newTestContext.manifest)
167167
contents.shouldSyntacticSanityCheck()
168168
val expectedContents =
169169
"""
@@ -254,7 +254,7 @@ extension TimestampInputOutputResponseBody: Decodable {
254254

255255
@Test
256256
fun `it decodes maps correctly`() {
257-
val contents = getModelFileContents("example", "MapInputOutputResponseBody+Extensions.swift", newTestContext.manifest)
257+
val contents = getModelFileContents("example", "MapInputOutputResponseBody+Decodable.swift", newTestContext.manifest)
258258
contents.shouldSyntacticSanityCheck()
259259
val expectedContents =
260260
"""
@@ -363,7 +363,7 @@ extension MapInputOutputResponseBody: Decodable {
363363
@Test
364364
fun `it decodes nested diverse shapes correctly`() {
365365
val contents =
366-
getModelFileContents("example", "NestedShapesOutputResponseBody+Extensions.swift", newTestContext.manifest)
366+
getModelFileContents("example", "NestedShapesOutputResponseBody+Decodable.swift", newTestContext.manifest)
367367
contents.shouldSyntacticSanityCheck()
368368
val expectedContents =
369369
"""

0 commit comments

Comments
 (0)