Skip to content

Commit b3932db

Browse files
committed
Update PoundFileIDExprSyntax
1 parent fd2183f commit b3932db

12 files changed

+216
-3
lines changed

Sources/SwiftSyntax/gyb_generated/Misc.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ extension SyntaxNode {
183183
return PoundFileExprSyntax(asSyntaxData)
184184
}
185185

186+
public var isPoundFileIDExpr: Bool { return raw.kind == .poundFileIDExpr }
187+
public var asPoundFileIDExpr: PoundFileIDExprSyntax? {
188+
guard isPoundFileIDExpr else { return nil }
189+
return PoundFileIDExprSyntax(asSyntaxData)
190+
}
191+
186192
public var isPoundFilePathExpr: Bool { return raw.kind == .poundFilePathExpr }
187193
public var asPoundFilePathExpr: PoundFilePathExprSyntax? {
188194
guard isPoundFilePathExpr else { return nil }
@@ -1507,6 +1513,8 @@ extension Syntax {
15071513
return node
15081514
case .poundFileExpr(let node):
15091515
return node
1516+
case .poundFileIDExpr(let node):
1517+
return node
15101518
case .poundFilePathExpr(let node):
15111519
return node
15121520
case .poundFunctionExpr(let node):
@@ -1928,6 +1936,6 @@ extension Syntax {
19281936
extension SyntaxParser {
19291937
static func verifyNodeDeclarationHash() -> Bool {
19301938
return String(cString: swiftparse_syntax_structure_versioning_identifier()!) ==
1931-
"4bfa1e0be5331f20c60a9cd4e1a32ce39b42dcd1"
1939+
"77e9551aa9f94761b9808f610830fa826cc8323a"
19321940
}
19331941
}

Sources/SwiftSyntax/gyb_generated/SyntaxAnyVisitor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
253253
override open func visitPost(_ node: PoundFileExprSyntax) {
254254
visitAnyPost(node._syntaxNode)
255255
}
256+
override open func visit(_ node: PoundFileIDExprSyntax) -> SyntaxVisitorContinueKind {
257+
return visitAny(node._syntaxNode)
258+
}
259+
260+
override open func visitPost(_ node: PoundFileIDExprSyntax) {
261+
visitAnyPost(node._syntaxNode)
262+
}
256263
override open func visit(_ node: PoundFilePathExprSyntax) -> SyntaxVisitorContinueKind {
257264
return visitAny(node._syntaxNode)
258265
}

Sources/SwiftSyntax/gyb_generated/SyntaxBaseNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
164164
/// `nil` if the conversion is not possible.
165165
public init?(_ syntax: Syntax) {
166166
switch syntax.raw.kind {
167-
case .unknownExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .editorPlaceholderExpr, .objectLiteralExpr:
167+
case .unknownExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFileIDExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .editorPlaceholderExpr, .objectLiteralExpr:
168168
self._syntaxNode = syntax
169169
default:
170170
return nil
@@ -178,7 +178,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
178178
// Assert that the kind of the given data matches in debug builds.
179179
#if DEBUG
180180
switch data.raw.kind {
181-
case .unknownExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .editorPlaceholderExpr, .objectLiteralExpr:
181+
case .unknownExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFileIDExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .editorPlaceholderExpr, .objectLiteralExpr:
182182
break
183183
default:
184184
fatalError("Unable to create ExprSyntax from \(data.raw.kind)")

Sources/SwiftSyntax/gyb_generated/SyntaxBuilders.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,44 @@ extension PoundFileExprSyntax {
677677
}
678678
}
679679

680+
public struct PoundFileIDExprSyntaxBuilder {
681+
private var layout =
682+
Array<RawSyntax?>(repeating: nil, count: 1)
683+
684+
internal init() {}
685+
686+
public mutating func usePoundFileID(_ node: TokenSyntax) {
687+
let idx = PoundFileIDExprSyntax.Cursor.poundFileID.rawValue
688+
layout[idx] = node.raw
689+
}
690+
691+
internal mutating func buildData() -> SyntaxData {
692+
if (layout[0] == nil) {
693+
layout[0] = RawSyntax.missingToken(TokenKind.poundFileIDKeyword)
694+
}
695+
696+
return .forRoot(RawSyntax.createAndCalcLength(kind: .poundFileIDExpr,
697+
layout: layout, presence: .present))
698+
}
699+
}
700+
701+
extension PoundFileIDExprSyntax {
702+
/// Creates a `PoundFileIDExprSyntax` using the provided build function.
703+
/// - Parameter:
704+
/// - build: A closure that wil be invoked in order to initialize
705+
/// the fields of the syntax node.
706+
/// This closure is passed a `PoundFileIDExprSyntaxBuilder` which you can use to
707+
/// incrementally build the structure of the node.
708+
/// - Returns: A `PoundFileIDExprSyntax` with all the fields populated in the builder
709+
/// closure.
710+
public init(_ build: (inout PoundFileIDExprSyntaxBuilder) -> Void) {
711+
var builder = PoundFileIDExprSyntaxBuilder()
712+
build(&builder)
713+
let data = builder.buildData()
714+
self.init(data)
715+
}
716+
}
717+
680718
public struct PoundFilePathExprSyntaxBuilder {
681719
private var layout =
682720
Array<RawSyntax?>(repeating: nil, count: 1)

Sources/SwiftSyntax/gyb_generated/SyntaxClassification.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ extension RawTokenKind {
286286
return .keyword
287287
case .poundFileKeyword:
288288
return .keyword
289+
case .poundFileIDKeyword:
290+
return .keyword
289291
case .poundFilePathKeyword:
290292
return .keyword
291293
case .poundColumnKeyword:

Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public enum SyntaxEnum {
4848
case exprList(ExprListSyntax)
4949
case poundLineExpr(PoundLineExprSyntax)
5050
case poundFileExpr(PoundFileExprSyntax)
51+
case poundFileIDExpr(PoundFileIDExprSyntax)
5152
case poundFilePathExpr(PoundFilePathExprSyntax)
5253
case poundFunctionExpr(PoundFunctionExprSyntax)
5354
case poundDsohandleExpr(PoundDsohandleExprSyntax)
@@ -329,6 +330,8 @@ public extension Syntax {
329330
return .poundLineExpr(PoundLineExprSyntax(self)!)
330331
case .poundFileExpr:
331332
return .poundFileExpr(PoundFileExprSyntax(self)!)
333+
case .poundFileIDExpr:
334+
return .poundFileIDExpr(PoundFileIDExprSyntax(self)!)
332335
case .poundFilePathExpr:
333336
return .poundFilePathExpr(PoundFilePathExprSyntax(self)!)
334337
case .poundFunctionExpr:

Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,23 @@ public enum SyntaxFactory {
456456
], length: .zero, presence: .present))
457457
return PoundFileExprSyntax(data)
458458
}
459+
public static func makePoundFileIDExpr(poundFileID: TokenSyntax) -> PoundFileIDExprSyntax {
460+
let layout: [RawSyntax?] = [
461+
poundFileID.raw,
462+
]
463+
let raw = RawSyntax.createAndCalcLength(kind: SyntaxKind.poundFileIDExpr,
464+
layout: layout, presence: SourcePresence.present)
465+
let data = SyntaxData.forRoot(raw)
466+
return PoundFileIDExprSyntax(data)
467+
}
468+
469+
public static func makeBlankPoundFileIDExpr() -> PoundFileIDExprSyntax {
470+
let data = SyntaxData.forRoot(RawSyntax.create(kind: .poundFileIDExpr,
471+
layout: [
472+
RawSyntax.missingToken(TokenKind.poundFileIDKeyword),
473+
], length: .zero, presence: .present))
474+
return PoundFileIDExprSyntax(data)
475+
}
459476
public static func makePoundFilePathExpr(poundFilePath: TokenSyntax) -> PoundFilePathExprSyntax {
460477
let layout: [RawSyntax?] = [
461478
poundFilePath.raw,
@@ -5244,6 +5261,12 @@ public enum SyntaxFactory {
52445261
leadingTrivia: leadingTrivia,
52455262
trailingTrivia: trailingTrivia)
52465263
}
5264+
public static func makePoundFileIDKeyword(leadingTrivia: Trivia = [],
5265+
trailingTrivia: Trivia = []) -> TokenSyntax {
5266+
return makeToken(.poundFileIDKeyword, presence: .present,
5267+
leadingTrivia: leadingTrivia,
5268+
trailingTrivia: trailingTrivia)
5269+
}
52475270
public static func makePoundFilePathKeyword(leadingTrivia: Trivia = [],
52485271
trailingTrivia: Trivia = []) -> TokenSyntax {
52495272
return makeToken(.poundFilePathKeyword, presence: .present,

Sources/SwiftSyntax/gyb_generated/SyntaxKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ internal enum SyntaxKind: CSyntaxKind {
4848
case exprList = 170
4949
case poundLineExpr = 34
5050
case poundFileExpr = 35
51+
case poundFileIDExpr = 247
5152
case poundFilePathExpr = 240
5253
case poundFunctionExpr = 36
5354
case poundDsohandleExpr = 37

Sources/SwiftSyntax/gyb_generated/SyntaxRewriter.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ open class SyntaxRewriter {
212212
return ExprSyntax(visitChildren(node))
213213
}
214214

215+
/// Visit a `PoundFileIDExprSyntax`.
216+
/// - Parameter node: the node that is being visited
217+
/// - Returns: the rewritten node
218+
open func visit(_ node: PoundFileIDExprSyntax) -> ExprSyntax {
219+
return ExprSyntax(visitChildren(node))
220+
}
221+
215222
/// Visit a `PoundFilePathExprSyntax`.
216223
/// - Parameter node: the node that is being visited
217224
/// - Returns: the rewritten node
@@ -2022,6 +2029,16 @@ open class SyntaxRewriter {
20222029
return Syntax(visit(node))
20232030
}
20242031

2032+
/// Implementation detail of visit(_:). Do not call directly.
2033+
private func visitImplPoundFileIDExprSyntax(_ data: SyntaxData) -> Syntax {
2034+
let node = PoundFileIDExprSyntax(data)
2035+
// Accessing _syntaxNode directly is faster than calling Syntax(node)
2036+
visitPre(node._syntaxNode)
2037+
defer { visitPost(node._syntaxNode) }
2038+
if let newNode = visitAny(node._syntaxNode) { return newNode }
2039+
return Syntax(visit(node))
2040+
}
2041+
20252042
/// Implementation detail of visit(_:). Do not call directly.
20262043
private func visitImplPoundFilePathExprSyntax(_ data: SyntaxData) -> Syntax {
20272044
let node = PoundFilePathExprSyntax(data)
@@ -4208,6 +4225,8 @@ open class SyntaxRewriter {
42084225
return visitImplPoundLineExprSyntax
42094226
case .poundFileExpr:
42104227
return visitImplPoundFileExprSyntax
4228+
case .poundFileIDExpr:
4229+
return visitImplPoundFileIDExprSyntax
42114230
case .poundFilePathExpr:
42124231
return visitImplPoundFilePathExprSyntax
42134232
case .poundFunctionExpr:
@@ -4701,6 +4720,8 @@ open class SyntaxRewriter {
47014720
return visitImplPoundLineExprSyntax(data)
47024721
case .poundFileExpr:
47034722
return visitImplPoundFileExprSyntax(data)
4723+
case .poundFileIDExpr:
4724+
return visitImplPoundFileIDExprSyntax(data)
47044725
case .poundFilePathExpr:
47054726
return visitImplPoundFilePathExprSyntax(data)
47064727
case .poundFunctionExpr:

Sources/SwiftSyntax/gyb_generated/SyntaxVisitor.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ open class SyntaxVisitor {
302302
/// The function called after visiting `PoundFileExprSyntax` and its descendents.
303303
/// - node: the node we just finished visiting.
304304
open func visitPost(_ node: PoundFileExprSyntax) {}
305+
/// Visiting `PoundFileIDExprSyntax` specifically.
306+
/// - Parameter node: the node we are visiting.
307+
/// - Returns: how should we continue visiting.
308+
open func visit(_ node: PoundFileIDExprSyntax) -> SyntaxVisitorContinueKind {
309+
return .visitChildren
310+
}
311+
312+
/// The function called after visiting `PoundFileIDExprSyntax` and its descendents.
313+
/// - node: the node we just finished visiting.
314+
open func visitPost(_ node: PoundFileIDExprSyntax) {}
305315
/// Visiting `PoundFilePathExprSyntax` specifically.
306316
/// - Parameter node: the node we are visiting.
307317
/// - Returns: how should we continue visiting.
@@ -2747,6 +2757,17 @@ open class SyntaxVisitor {
27472757
visitPost(node)
27482758
}
27492759

2760+
/// Implementation detail of doVisit(_:_:). Do not call directly.
2761+
private func visitImplPoundFileIDExprSyntax(_ data: SyntaxData) {
2762+
let node = PoundFileIDExprSyntax(data)
2763+
let needsChildren = (visit(node) == .visitChildren)
2764+
// Avoid calling into visitChildren if possible.
2765+
if needsChildren && node.raw.numberOfChildren > 0 {
2766+
visitChildren(node)
2767+
}
2768+
visitPost(node)
2769+
}
2770+
27502771
/// Implementation detail of doVisit(_:_:). Do not call directly.
27512772
private func visitImplPoundFilePathExprSyntax(_ data: SyntaxData) {
27522773
let node = PoundFilePathExprSyntax(data)
@@ -5108,6 +5129,8 @@ open class SyntaxVisitor {
51085129
visitImplPoundLineExprSyntax(data)
51095130
case .poundFileExpr:
51105131
visitImplPoundFileExprSyntax(data)
5132+
case .poundFileIDExpr:
5133+
visitImplPoundFileIDExprSyntax(data)
51115134
case .poundFilePathExpr:
51125135
visitImplPoundFilePathExprSyntax(data)
51135136
case .poundFunctionExpr:

Sources/SwiftSyntax/gyb_generated/TokenKind.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public enum TokenKind {
105105
case poundLineKeyword
106106
case poundSelectorKeyword
107107
case poundFileKeyword
108+
case poundFileIDKeyword
108109
case poundFilePathKeyword
109110
case poundColumnKeyword
110111
case poundFunctionKeyword
@@ -231,6 +232,7 @@ public enum TokenKind {
231232
case .poundLineKeyword: return "#line"
232233
case .poundSelectorKeyword: return "#selector"
233234
case .poundFileKeyword: return "#file"
235+
case .poundFileIDKeyword: return "#fileID"
234236
case .poundFilePathKeyword: return "#filePath"
235237
case .poundColumnKeyword: return "#column"
236238
case .poundFunctionKeyword: return "#function"
@@ -358,6 +360,7 @@ public enum TokenKind {
358360
case .poundLineKeyword: return true
359361
case .poundSelectorKeyword: return true
360362
case .poundFileKeyword: return true
363+
case .poundFileIDKeyword: return true
361364
case .poundFilePathKeyword: return true
362365
case .poundColumnKeyword: return true
363366
case .poundFunctionKeyword: return true
@@ -485,6 +488,7 @@ public enum TokenKind {
485488
case .poundLineKeyword: return "pound_line"
486489
case .poundSelectorKeyword: return "pound_selector"
487490
case .poundFileKeyword: return "pound_file"
491+
case .poundFileIDKeyword: return "pound_fileID"
488492
case .poundFilePathKeyword: return "pound_filePath"
489493
case .poundColumnKeyword: return "pound_column"
490494
case .poundFunctionKeyword: return "pound_function"
@@ -612,6 +616,7 @@ public enum TokenKind {
612616
case .poundLineKeyword: return SourceLength(utf8Length: 5)
613617
case .poundSelectorKeyword: return SourceLength(utf8Length: 9)
614618
case .poundFileKeyword: return SourceLength(utf8Length: 5)
619+
case .poundFileIDKeyword: return SourceLength(utf8Length: 7)
615620
case .poundFilePathKeyword: return SourceLength(utf8Length: 9)
616621
case .poundColumnKeyword: return SourceLength(utf8Length: 7)
617622
case .poundFunctionKeyword: return SourceLength(utf8Length: 9)
@@ -741,6 +746,7 @@ extension TokenKind: Equatable {
741746
case (.poundLineKeyword, .poundLineKeyword): return true
742747
case (.poundSelectorKeyword, .poundSelectorKeyword): return true
743748
case (.poundFileKeyword, .poundFileKeyword): return true
749+
case (.poundFileIDKeyword, .poundFileIDKeyword): return true
744750
case (.poundFilePathKeyword, .poundFilePathKeyword): return true
745751
case (.poundColumnKeyword, .poundColumnKeyword): return true
746752
case (.poundFunctionKeyword, .poundFunctionKeyword): return true
@@ -975,6 +981,8 @@ extension TokenKind {
975981
return .poundSelectorKeyword
976982
case 68:
977983
return .poundFileKeyword
984+
case 122:
985+
return .poundFileIDKeyword
978986
case 121:
979987
return .poundFilePathKeyword
980988
case 70:
@@ -1233,6 +1241,8 @@ extension TokenKind {
12331241
return false
12341242
case 68:
12351243
return false
1244+
case 122:
1245+
return false
12361246
case 121:
12371247
return false
12381248
case 70:
@@ -1394,6 +1404,7 @@ internal enum RawTokenKind: CTokenKind {
13941404
case poundLineKeyword = 69
13951405
case poundSelectorKeyword = 73
13961406
case poundFileKeyword = 68
1407+
case poundFileIDKeyword = 122
13971408
case poundFilePathKeyword = 121
13981409
case poundColumnKeyword = 70
13991410
case poundFunctionKeyword = 72
@@ -1708,6 +1719,9 @@ extension TokenKind {
17081719
case .poundFileKeyword:
17091720
let length = 5
17101721
return body(.init(kind: .poundFileKeyword, length: length))
1722+
case .poundFileIDKeyword:
1723+
let length = 7
1724+
return body(.init(kind: .poundFileIDKeyword, length: length))
17111725
case .poundFilePathKeyword:
17121726
let length = 9
17131727
return body(.init(kind: .poundFilePathKeyword, length: length))

0 commit comments

Comments
 (0)