|
13 | 13 | @_spi(RawSyntax) import SwiftParser
|
14 | 14 | @_spi(RawSyntax) import SwiftSyntax
|
15 | 15 |
|
| 16 | +// MARK: - CustomAttribute |
| 17 | + |
| 18 | +extension AttributeSyntax { |
| 19 | + /// A convenience initializer that allows passing in arguments using a result builder |
| 20 | + /// and automatically adds parentheses as needed, similar to the convenience |
| 21 | + /// initializer for ``FunctionCallExpr``. |
| 22 | + public init( |
| 23 | + _ attributeName: TypeSyntax, |
| 24 | + @TupleExprElementListBuilder argumentList: () -> TupleExprElementListSyntax? = { nil } |
| 25 | + ) { |
| 26 | + let argumentList = argumentList() |
| 27 | + self.init( |
| 28 | + attributeName: attributeName, |
| 29 | + leftParen: argumentList != nil ? .leftParenToken() : nil, |
| 30 | + argument: argumentList.map(AttributeSyntax.Argument.argumentList), |
| 31 | + rightParen: argumentList != nil ? .rightParenToken() : nil |
| 32 | + ) |
| 33 | + } |
| 34 | +} |
| 35 | + |
16 | 36 | // MARK: - BinaryOperatorExpr
|
17 | 37 |
|
18 | 38 | extension BinaryOperatorExprSyntax {
|
@@ -51,26 +71,6 @@ extension CatchClauseSyntax {
|
51 | 71 | }
|
52 | 72 | }
|
53 | 73 |
|
54 |
| -// MARK: - CustomAttribute |
55 |
| - |
56 |
| -extension AttributeSyntax { |
57 |
| - /// A convenience initializer that allows passing in arguments using a result builder |
58 |
| - /// and automatically adds parentheses as needed, similar to the convenience |
59 |
| - /// initializer for ``FunctionCallExpr``. |
60 |
| - public init( |
61 |
| - _ attributeName: TypeSyntax, |
62 |
| - @TupleExprElementListBuilder argumentList: () -> TupleExprElementListSyntax? = { nil } |
63 |
| - ) { |
64 |
| - let argumentList = argumentList() |
65 |
| - self.init( |
66 |
| - attributeName: attributeName, |
67 |
| - leftParen: argumentList != nil ? .leftParenToken() : nil, |
68 |
| - argument: argumentList.map(AttributeSyntax.Argument.argumentList), |
69 |
| - rightParen: argumentList != nil ? .rightParenToken() : nil |
70 |
| - ) |
71 |
| - } |
72 |
| -} |
73 |
| - |
74 | 74 | // MARK: - DictionaryExpr
|
75 | 75 |
|
76 | 76 | extension DictionaryExprSyntax {
|
|
0 commit comments