Skip to content

Commit

Permalink
Make builderSymbol return a Symbol (#1312)
Browse files Browse the repository at this point in the history
It currently returns a `RuntimeType`. It makes no actual difference
whatsoever, but `RuntimeType` is kept for types we don't code-generate,
but that we use from other crates.
  • Loading branch information
david-perez committed Apr 11, 2022
1 parent 71e2a6d commit aaed505
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ import software.amazon.smithy.rust.codegen.smithy.rustType
import software.amazon.smithy.rust.codegen.util.dq
import software.amazon.smithy.rust.codegen.util.toSnakeCase

fun StructureShape.builderSymbol(symbolProvider: RustSymbolProvider): RuntimeType {
val symbol = symbolProvider.toSymbol(this)
val builderNamespace = RustReservedWords.escapeIfNeeded(symbol.name.toSnakeCase())
return RuntimeType("Builder", null, "${symbol.namespace}::$builderNamespace")
fun StructureShape.builderSymbol(symbolProvider: RustSymbolProvider): Symbol {
val structureSymbol = symbolProvider.toSymbol(this)
val builderNamespace = RustReservedWords.escapeIfNeeded(structureSymbol.name.toSnakeCase())
val rustType = RustType.Opaque("Builder", "${structureSymbol.namespace}::$builderNamespace")
return Symbol.builder()
.rustType(rustType)
.name(rustType.name)
.namespace(rustType.namespace, "::")
.definitionFile(structureSymbol.definitionFile)
.build()
}

fun RuntimeConfig.operationBuildError() = RuntimeType.operationModule(this).member("BuildError")
Expand Down

0 comments on commit aaed505

Please sign in to comment.