1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16-
1716//===----------------------------------------------------------------------===//
1817//
1918// This source file is part of the SwiftOpenAPIGenerator open source project
@@ -66,11 +65,14 @@ struct ImportDescription: Equatable, Codable {
6665/// A description of an access modifier.
6766///
6867/// For example: `public`.
69- enum AccessModifier : String , Equatable , Codable {
68+ internal enum AccessModifier : String , Sendable , Equatable , Codable {
7069
7170 /// A declaration accessible outside of the module.
7271 case `public`
7372
73+ /// A declaration accessible outside of the module but only inside the containing package or project.
74+ case `package`
75+
7476 /// A declaration only accessible inside of the module.
7577 case `internal`
7678
@@ -256,7 +258,7 @@ struct VariableDescription: Equatable, Codable {
256258 /// The name of the variable.
257259 ///
258260 /// For example, in `let foo = 42`, `left` is `foo`.
259- var left : String
261+ var left : Expression
260262
261263 /// The type of the variable.
262264 ///
@@ -1126,6 +1128,49 @@ extension Declaration {
11261128 setter: [ CodeBlock ] ? = nil ,
11271129 modify: [ CodeBlock ] ? = nil
11281130
1131+ ) -> Self {
1132+ . variable(
1133+ accessModifier: accessModifier,
1134+ isStatic: isStatic,
1135+ kind: kind,
1136+ left: . identifierPattern( left) ,
1137+ type: type,
1138+ right: right,
1139+ getter: getter,
1140+ getterEffects: getterEffects,
1141+ setter: setter,
1142+ modify: modify
1143+ )
1144+ }
1145+
1146+ /// A variable declaration.
1147+ ///
1148+ /// For example: `let foo = 42`.
1149+ /// - Parameters:
1150+ /// - accessModifier: An access modifier.
1151+ /// - isStatic: A Boolean value that indicates whether the variable
1152+ /// is static.
1153+ /// - kind: The variable binding kind.
1154+ /// - left: The name of the variable.
1155+ /// - type: The type of the variable.
1156+ /// - right: The expression to be assigned to the variable.
1157+ /// - getter: Body code for the getter of the variable.
1158+ /// - getterEffects: Effects of the getter.
1159+ /// - setter: Body code for the setter of the variable.
1160+ /// - modify: Body code for the `_modify` accessor.
1161+ /// - Returns: Variable declaration.
1162+ static func variable(
1163+ accessModifier: AccessModifier ? = nil ,
1164+ isStatic: Bool = false ,
1165+ kind: BindingKind ,
1166+ left: Expression ,
1167+ type: ExistingTypeDescription ? = nil ,
1168+ right: Expression ? = nil ,
1169+ getter: [ CodeBlock ] ? = nil ,
1170+ getterEffects: [ FunctionKeyword ] = [ ] ,
1171+ setter: [ CodeBlock ] ? = nil ,
1172+ modify: [ CodeBlock ] ? = nil
1173+
11291174 ) -> Self {
11301175 . variable(
11311176 . init(
@@ -1573,15 +1618,6 @@ extension MemberAccessDescription {
15731618 static func dot( _ member: String ) -> Self { . init( right: member) }
15741619}
15751620
1576- extension Expression : ExpressibleByStringLiteral , ExpressibleByNilLiteral , ExpressibleByArrayLiteral
1577- {
1578- init ( arrayLiteral elements: Expression ... ) { self = . literal( . array( elements) ) }
1579-
1580- init ( stringLiteral value: String ) { self = . literal( . string( value) ) }
1581-
1582- init ( nilLiteral: ( ) ) { self = . literal( . nil ) }
1583- }
1584-
15851621extension LiteralDescription : ExpressibleByStringLiteral , ExpressibleByNilLiteral ,
15861622 ExpressibleByArrayLiteral
15871623{
@@ -1599,14 +1635,18 @@ extension VariableDescription {
15991635 /// For example `var foo = 42`.
16001636 /// - Parameter name: The name of the variable.
16011637 /// - Returns: A new mutable variable declaration.
1602- static func `var`( _ name: String ) -> Self { Self . init ( kind: . var, left: name) }
1638+ static func `var`( _ name: String ) -> Self {
1639+ Self . init ( kind: . var, left: . identifierPattern( name) )
1640+ }
16031641
16041642 /// Returns a new immutable variable declaration.
16051643 ///
16061644 /// For example `let foo = 42`.
16071645 /// - Parameter name: The name of the variable.
16081646 /// - Returns: A new immutable variable declaration.
1609- static func `let`( _ name: String ) -> Self { Self . init ( kind: . let, left: name) }
1647+ static func `let`( _ name: String ) -> Self {
1648+ Self . init ( kind: . let, left: . identifierPattern( name) )
1649+ }
16101650}
16111651
16121652extension Expression {
@@ -1618,10 +1658,6 @@ extension Expression {
16181658 func equals( _ rhs: Expression ) -> AssignmentDescription { . init( left: self , right: rhs) }
16191659}
16201660
1621- extension FunctionArgumentDescription : ExpressibleByStringLiteral {
1622- init ( stringLiteral value: String ) { self = . init( expression: . literal( . string( value) ) ) }
1623- }
1624-
16251661extension FunctionSignatureDescription {
16261662 /// Returns a new function signature description that has the access
16271663 /// modifier updated to the specified one.
0 commit comments