Skip to content

Commit 71066a0

Browse files
committed
Elaborate on documentation
1 parent a30afc1 commit 71066a0

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/Constraints.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ fun Shape.isDirectlyConstrained(symbolProvider: SymbolProvider): Boolean =
103103
}
104104

105105
/**
106-
* See [Shape.isDirectlyConstrained]
106+
* Finds shapes that are directly constrained in validation phase, which means the shape is a:
107+
* - [StructureShape] with a required member that does not have a non-null default
108+
* - [EnumShape]
109+
* - [IntEnumShape]
110+
* - [MemberShape] that is required and does not have a non-null default
107111
*
108-
* We use this to check for constrained shapes in validation phase because the [SymbolProvider] has not yet been created
112+
* We use this rather than [Shape.isDirectlyConstrained] to check for constrained shapes in validation phase because
113+
* the [SymbolProvider] has not yet been created
109114
*/
110115
fun Shape.isDirectlyConstrainedForValidation(): Boolean =
111116
when (this) {
@@ -160,9 +165,10 @@ fun Shape.canReachConstrainedShape(
160165
}
161166

162167
/**
163-
* See [Shape.canReachConstrainedShape]
168+
* Whether this shape (or the shape's target for [MemberShape]s) can reach constrained shapes for validations.
164169
*
165-
* We use this to check for constrained shapes in validation phase because the [SymbolProvider] has not yet been created
170+
* We use this rather than [Shape.canReachConstrainedShape] to check for constrained shapes in validation phase because
171+
* the [SymbolProvider] has not yet been created
166172
*/
167173
fun Shape.canReachConstrainedShapeForValidation(model: Model): Boolean =
168174
if (this is MemberShape) {

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/util/CustomValidationExceptionUtil.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package software.amazon.smithy.rust.codegen.server.smithy.util
33
import software.amazon.smithy.model.shapes.MemberShape
44
import software.amazon.smithy.rust.codegen.server.smithy.traits.ValidationMessageTrait
55

6-
// Helper function to determine if this [MemberShape] is a validation message either explicitly with the
7-
// @validationMessage trait or implicitly because it is named "message"
6+
/**
7+
* Helper function to determine if this [MemberShape] is a validation message either explicitly with the
8+
* @validationMessage trait or implicitly because it is named "message"
9+
*/
810
fun MemberShape.isValidationMessage(): Boolean {
911
return this.hasTrait(ValidationMessageTrait.ID) || this.memberName == "message"
1012
}

0 commit comments

Comments
 (0)