Skip to content

Commit c8c9cd7

Browse files
committed
Move AttributeSyntax to top
1 parent b05d14a commit c8c9cd7

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@
1313
@_spi(RawSyntax) import SwiftParser
1414
@_spi(RawSyntax) import SwiftSyntax
1515

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+
1636
// MARK: - BinaryOperatorExpr
1737

1838
extension BinaryOperatorExprSyntax {
@@ -51,26 +71,6 @@ extension CatchClauseSyntax {
5171
}
5272
}
5373

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-
7474
// MARK: - DictionaryExpr
7575

7676
extension DictionaryExprSyntax {

0 commit comments

Comments
 (0)