Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add DSL markers to codegenned structure builders #1065

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/19208b1c-8c36-452b-a6e3-e0bef345776a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "19208b1c-8c36-452b-a6e3-e0bef345776a",
"type": "feature",
"description": "⚠️ **IMPORTANT**: Add new @SdkDsl DSL marker to all generated structure builders, clarifying DSL scopes when building complex types. See the [**Scope control applied to DSL builders** breaking change announcement](https://github.com/awslabs/aws-sdk-kotlin/discussions/1280) for more details.",
"issues": [
"awslabs/smithy-kotlin#428"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ object RuntimeTypes {
val fromEpochMilliseconds = symbol("fromEpochMilliseconds", "time")
val TimestampFormat = symbol("TimestampFormat", "time")
val ClientException = symbol("ClientException")
val SdkDsl = symbol("SdkDsl")

object Collections : RuntimeTypePackage(KotlinDependency.CORE, "collections") {
val Attributes = symbol("Attributes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class StructureGenerator(

private fun renderBuilder() {
writer.write("")
.write("@#T", RuntimeTypes.Core.SdkDsl)
.withBlock("public class Builder {", "}") {
for (member in sortedMembers) {
val (memberName, memberSymbol) = memberNameSymbolIndex[member]!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class StructureGeneratorTest {
@Test
fun `it renders a builder impl`() {
val expected = """
@SdkDsl
public class Builder {
/**
* This *is* documentation about the member.
Expand Down
3 changes: 3 additions & 0 deletions runtime/runtime-core/api/runtime-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class aws/smithy/kotlin/runtime/SdkBaseException : java/lang/RuntimeExcep
public fun getSdkErrorMetadata ()Laws/smithy/kotlin/runtime/ErrorMetadata;
}

public abstract interface annotation class aws/smithy/kotlin/runtime/SdkDsl : java/lang/annotation/Annotation {
}

public class aws/smithy/kotlin/runtime/ServiceErrorMetadata : aws/smithy/kotlin/runtime/ErrorMetadata {
public static final field Companion Laws/smithy/kotlin/runtime/ServiceErrorMetadata$Companion;
public fun <init> ()V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ public annotation class InternalApi
AnnotationTarget.CONSTRUCTOR,
)
public annotation class ExperimentalApi

/**
* Signifies that a type is considered part of an SDK DSL for the purposes of scope control
*/
@DslMarker
public annotation class SdkDsl
Loading