Skip to content

Commit 6bfb149

Browse files
authored
Merge pull request #293 from kimdv/kimdv/move-tokens-to-token-syntax-extension
Move Token helpers to TokenSyntax extension
2 parents 574288c + 9f21f67 commit 6bfb149

13 files changed

+438
-438
lines changed

Sources/SwiftSyntaxBuilder/BooleanLiteralExprConvenienceInitializers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SwiftSyntax
1414

1515
extension BooleanLiteralExpr {
1616
public init(_ value: Bool) {
17-
self.init(booleanLiteral: value ? Tokens.true : Tokens.false)
17+
self.init(booleanLiteral: value ? .true : .false)
1818
}
1919
}
2020

Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ extension ${node.syntax_kind} {
7272
% end
7373
% elif token and not token.text:
7474
% if child.is_optional:
75-
% init_parameters.append("%s: %s.map(Tokens.%s)" % (child.swift_name, child.swift_name, lowercase_first_word(token.name)))
75+
% init_parameters.append("%s: %s.map(TokenSyntax.%s)" % (child.swift_name, child.swift_name, lowercase_first_word(token.name)))
7676
% else:
77-
% init_parameters.append("%s: Tokens.%s(%s)" % (child.swift_name, lowercase_first_word(token.name), child.swift_name))
77+
% init_parameters.append("%s: TokenSyntax.%s(%s)" % (child.swift_name, lowercase_first_word(token.name), child.swift_name))
7878
% end
7979
% else:
8080
% init_parameters.append("%s: %s" % (child.swift_name, child.swift_name))

Sources/SwiftSyntaxBuilder/StringLiteralExprConvenienceInitializers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ extension StringLiteralExpr {
1818
let segment = StringSegment(content: content)
1919
let segments = StringLiteralSegments([segment])
2020

21-
self.init(openQuote: Tokens.stringQuote,
21+
self.init(openQuote: .stringQuote,
2222
segments: segments,
23-
closeQuote: Tokens.stringQuote)
23+
closeQuote: .stringQuote)
2424
}
2525
}
2626

Sources/SwiftSyntaxBuilder/Tokens.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import SwiftSyntax
2222

2323
/// Namespace for commonly used tokens with default trivia.
24-
public enum Tokens {
24+
public extension TokenSyntax {
2525
% for token in SYNTAX_TOKENS:
2626
% if token.is_keyword:
2727
/// The `${token.text.encode('utf-8').decode('unicode_escape')}` keyword
28-
public static let `${lowercase_first_word(token.name)}` = SyntaxFactory.make${token.name}Keyword()
28+
static let `${lowercase_first_word(token.name)}` = SyntaxFactory.make${token.name}Keyword()
2929
% if token.requires_leading_space:
3030
.withLeadingTrivia(.spaces(1))
3131
% end
@@ -34,15 +34,15 @@ public enum Tokens {
3434
% end
3535
% elif token.text:
3636
/// The `${token.text.encode('utf-8').decode('unicode_escape')}` token
37-
public static let `${lowercase_first_word(token.name)}` = SyntaxFactory.make${token.name}Token()
37+
static let `${lowercase_first_word(token.name)}` = SyntaxFactory.make${token.name}Token()
3838
% if token.requires_leading_space:
3939
.withLeadingTrivia(.spaces(1))
4040
% end
4141
% if token.requires_trailing_space:
4242
.withTrailingTrivia(.spaces(1))
4343
% end
4444
% else:
45-
public static func `${lowercase_first_word(token.name)}`(_ text: String) -> TokenSyntax {
45+
static func `${lowercase_first_word(token.name)}`(_ text: String) -> TokenSyntax {
4646
SyntaxFactory.make${token.name}(text)
4747
% if token.requires_leading_space:
4848
.withLeadingTrivia(.spaces(1))

0 commit comments

Comments
 (0)