@@ -16,13 +16,19 @@ extension VariableDecl {
16
16
/// Creates an optionally initialized property.
17
17
public init (
18
18
leadingTrivia: Trivia = [ ] ,
19
- modifiers: ModifierList ? = nil ,
19
+ attributes: ExpressibleAsAttributeList ? = nil ,
20
+ modifiers: ExpressibleAsModifierList ? = nil ,
20
21
_ letOrVarKeyword: TokenSyntax ,
21
22
name: ExpressibleAsIdentifierPattern ,
22
23
type: ExpressibleAsTypeAnnotation ? = nil ,
23
24
initializer: ExpressibleAsInitializerClause ? = nil
24
25
) {
25
- self . init ( leadingTrivia: leadingTrivia, modifiers: modifiers, letOrVarKeyword: letOrVarKeyword) {
26
+ self . init (
27
+ leadingTrivia: leadingTrivia,
28
+ attributes: attributes,
29
+ modifiers: modifiers,
30
+ letOrVarKeyword: attributes != nil ? letOrVarKeyword. withLeadingTrivia ( . space) : letOrVarKeyword
31
+ ) {
26
32
PatternBinding (
27
33
pattern: name,
28
34
typeAnnotation: type,
@@ -34,12 +40,18 @@ extension VariableDecl {
34
40
/// Creates a computed property with the given accessor.
35
41
public init (
36
42
leadingTrivia: Trivia = [ ] ,
37
- modifiers: ModifierList ? = nil ,
43
+ attributes: ExpressibleAsAttributeList ? = nil ,
44
+ modifiers: ExpressibleAsModifierList ? = nil ,
38
45
name: ExpressibleAsIdentifierPattern ,
39
46
type: ExpressibleAsTypeAnnotation ,
40
47
@CodeBlockItemListBuilder accessor: ( ) -> ExpressibleAsCodeBlockItemList
41
48
) {
42
- self . init ( leadingTrivia: leadingTrivia, modifiers: modifiers, letOrVarKeyword: . var) {
49
+ self . init (
50
+ leadingTrivia: leadingTrivia,
51
+ attributes: attributes,
52
+ modifiers: modifiers,
53
+ letOrVarKeyword: . varKeyword( leadingTrivia: attributes != nil ? . space : . zero)
54
+ ) {
43
55
PatternBinding (
44
56
pattern: name,
45
57
typeAnnotation: type,
0 commit comments