@@ -17,6 +17,7 @@ import SwiftSyntax
17
17
// MARK: - ParamDecl
18
18
19
19
fileprivate protocol ValueParameterSyntax : SyntaxProtocol {
20
+ var optionalAttributes : AttributeListSyntax ? { get }
20
21
/// The `firstName` with optional type.
21
22
///
22
23
/// This is the lowest denominator between `FunctionParameterSyntax` and `EnumCaseParameterSyntax`.
@@ -37,6 +38,9 @@ fileprivate protocol ValueParameterSyntax: SyntaxProtocol {
37
38
}
38
39
39
40
extension FunctionParameterSyntax : ValueParameterSyntax {
41
+ fileprivate var optionalAttributes : AttributeListSyntax ? {
42
+ attributes
43
+ }
40
44
fileprivate var optionalFirstName : TokenSyntax ? {
41
45
firstName
42
46
}
@@ -47,6 +51,10 @@ extension FunctionParameterSyntax: ValueParameterSyntax {
47
51
}
48
52
49
53
extension EnumCaseParameterSyntax : ValueParameterSyntax {
54
+ fileprivate var optionalAttributes : AttributeListSyntax ? {
55
+ nil
56
+ }
57
+
50
58
fileprivate var optionalFirstName : TokenSyntax ? {
51
59
firstName
52
60
}
@@ -61,6 +69,10 @@ extension EnumCaseParameterSyntax: ValueParameterSyntax {
61
69
}
62
70
63
71
extension ClosureParameterSyntax : ValueParameterSyntax {
72
+ fileprivate var optionalAttributes : AttributeListSyntax ? {
73
+ attributes
74
+ }
75
+
64
76
fileprivate var optionalFirstName : TokenSyntax ? {
65
77
self . firstName
66
78
}
@@ -98,6 +110,15 @@ extension ASTGenVisitor {
98
110
/// Generate a ParamDecl. If `argNameByDefault` is true, then the parameter's
99
111
/// argument label is inferred from the first name if no second name is present.
100
112
private func makeParamDecl( _ node: some ValueParameterSyntax , argNameByDefault: Bool , at index: Int ) -> BridgedParamDecl {
113
+ var attrs = BridgedDeclAttributes ( )
114
+
115
+ // Attributes.
116
+ if let attributes = node. optionalAttributes {
117
+ self . generateDeclAttributes ( attributeList: attributes) { attr in
118
+ attrs. add ( attr)
119
+ }
120
+ }
121
+
101
122
// FIXME: This location should be derived from the type repr.
102
123
let specifierLoc : BridgedSourceLoc = nil
103
124
@@ -146,7 +167,7 @@ extension ASTGenVisitor {
146
167
initExpr = nil
147
168
}
148
169
149
- return . createParsed(
170
+ let param = BridgedParamDecl . createParsed (
150
171
self . ctx,
151
172
declContext: self . declContext,
152
173
specifierLoc: specifierLoc,
@@ -158,6 +179,8 @@ extension ASTGenVisitor {
158
179
defaultValue: initExpr. asNullable,
159
180
defaultValueInitContext: initContext. asNullable
160
181
)
182
+ param. asDecl. attachParsedAttrs ( attrs)
183
+ return param
161
184
}
162
185
163
186
func generate( closureShorthandParameter node : ClosureShorthandParameterSyntax ) -> BridgedParamDecl {
0 commit comments