Skip to content

Commit 7fbd3d5

Browse files
committed
Add supporting code.
1 parent 0ed644b commit 7fbd3d5

File tree

14 files changed

+495
-3
lines changed

14 files changed

+495
-3
lines changed

Sources/SwiftParser/generated/ExperimentalFeatures.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ extension Parser.ExperimentalFeatures {
5151
/// Whether to enable the parsing of 'unsafe' expression.
5252
public static let unsafeExpression = Self (rawValue: 1 << 8)
5353

54+
/// Whether to enable the parsing of keypaths with method members.
55+
public static let keypathWithMethodMembers = Self (rawValue: 1 << 9)
56+
5457
/// Creates a new value representing the experimental feature with the
5558
/// given name, or returns nil if the name is not recognized.
5659
public init?(name: String) {
@@ -73,6 +76,8 @@ extension Parser.ExperimentalFeatures {
7376
self = .abiAttribute
7477
case "WarnUnsafe":
7578
self = .unsafeExpression
79+
case "KeypathWithMethodMembers":
80+
self = .keypathWithMethodMembers
7681
default:
7782
return nil
7883
}

Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String? {
206206
return "generic where clause"
207207
case \KeyPathExprSyntax.root:
208208
return "root"
209+
case \KeyPathMethodComponentSyntax.arguments:
210+
return "arguments"
209211
case \KeyPathSubscriptComponentSyntax.arguments:
210212
return "arguments"
211213
case \LabeledExprSyntax.label:

Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ extension SyntaxKind {
243243
return "key path component"
244244
case .keyPathExpr:
245245
return "key path"
246+
case .keyPathMethodComponent:
247+
return "key path method component"
246248
case .keyPathOptionalComponent:
247249
return "key path optional component"
248250
case .keyPathPropertyComponent:

Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,24 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
19011901
return "components"
19021902
case \KeyPathExprSyntax.unexpectedAfterComponents:
19031903
return "unexpectedAfterComponents"
1904+
case \KeyPathMethodComponentSyntax.unexpectedBeforeDeclName:
1905+
return "unexpectedBeforeDeclName"
1906+
case \KeyPathMethodComponentSyntax.declName:
1907+
return "declName"
1908+
case \KeyPathMethodComponentSyntax.unexpectedBetweenDeclNameAndLeftParen:
1909+
return "unexpectedBetweenDeclNameAndLeftParen"
1910+
case \KeyPathMethodComponentSyntax.leftParen:
1911+
return "leftParen"
1912+
case \KeyPathMethodComponentSyntax.unexpectedBetweenLeftParenAndArguments:
1913+
return "unexpectedBetweenLeftParenAndArguments"
1914+
case \KeyPathMethodComponentSyntax.arguments:
1915+
return "arguments"
1916+
case \KeyPathMethodComponentSyntax.unexpectedBetweenArgumentsAndRightParen:
1917+
return "unexpectedBetweenArgumentsAndRightParen"
1918+
case \KeyPathMethodComponentSyntax.rightParen:
1919+
return "rightParen"
1920+
case \KeyPathMethodComponentSyntax.unexpectedAfterRightParen:
1921+
return "unexpectedAfterRightParen"
19041922
case \KeyPathOptionalComponentSyntax.unexpectedBeforeQuestionOrExclamationMark:
19051923
return "unexpectedBeforeQuestionOrExclamationMark"
19061924
case \KeyPathOptionalComponentSyntax.questionOrExclamationMark:

Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,16 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
12941294
visitAnyPost(node._syntaxNode)
12951295
}
12961296

1297+
@_spi(ExperimentalLanguageFeatures)
1298+
override open func visit(_ node: KeyPathMethodComponentSyntax) -> SyntaxVisitorContinueKind {
1299+
return visitAny(node._syntaxNode)
1300+
}
1301+
1302+
@_spi(ExperimentalLanguageFeatures)
1303+
override open func visitPost(_ node: KeyPathMethodComponentSyntax) {
1304+
visitAnyPost(node._syntaxNode)
1305+
}
1306+
12971307
override open func visit(_ node: KeyPathOptionalComponentSyntax) -> SyntaxVisitorContinueKind {
12981308
return visitAny(node._syntaxNode)
12991309
}

Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,7 @@ extension Syntax {
16721672
.node(KeyPathComponentListSyntax.self),
16731673
.node(KeyPathComponentSyntax.self),
16741674
.node(KeyPathExprSyntax.self),
1675+
.node(KeyPathMethodComponentSyntax.self),
16751676
.node(KeyPathOptionalComponentSyntax.self),
16761677
.node(KeyPathPropertyComponentSyntax.self),
16771678
.node(KeyPathSubscriptComponentSyntax.self),

Sources/SwiftSyntax/generated/SyntaxEnum.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public enum SyntaxEnum: Sendable {
172172
case keyPathComponentList(KeyPathComponentListSyntax)
173173
case keyPathComponent(KeyPathComponentSyntax)
174174
case keyPathExpr(KeyPathExprSyntax)
175+
@_spi(ExperimentalLanguageFeatures)
176+
case keyPathMethodComponent(KeyPathMethodComponentSyntax)
175177
case keyPathOptionalComponent(KeyPathOptionalComponentSyntax)
176178
case keyPathPropertyComponent(KeyPathPropertyComponentSyntax)
177179
case keyPathSubscriptComponent(KeyPathSubscriptComponentSyntax)
@@ -625,6 +627,8 @@ extension Syntax {
625627
return .keyPathComponent(KeyPathComponentSyntax(self)!)
626628
case .keyPathExpr:
627629
return .keyPathExpr(KeyPathExprSyntax(self)!)
630+
case .keyPathMethodComponent:
631+
return .keyPathMethodComponent(KeyPathMethodComponentSyntax(self)!)
628632
case .keyPathOptionalComponent:
629633
return .keyPathOptionalComponent(KeyPathOptionalComponentSyntax(self)!)
630634
case .keyPathPropertyComponent:

Sources/SwiftSyntax/generated/SyntaxKind.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public enum SyntaxKind: Sendable {
172172
case keyPathComponentList
173173
case keyPathComponent
174174
case keyPathExpr
175+
@_spi(ExperimentalLanguageFeatures)
176+
case keyPathMethodComponent
175177
case keyPathOptionalComponent
176178
case keyPathPropertyComponent
177179
case keyPathSubscriptComponent
@@ -750,6 +752,8 @@ public enum SyntaxKind: Sendable {
750752
return KeyPathComponentSyntax.self
751753
case .keyPathExpr:
752754
return KeyPathExprSyntax.self
755+
case .keyPathMethodComponent:
756+
return KeyPathMethodComponentSyntax.self
753757
case .keyPathOptionalComponent:
754758
return KeyPathOptionalComponentSyntax.self
755759
case .keyPathPropertyComponent:

Sources/SwiftSyntax/generated/SyntaxRewriter.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,14 @@ open class SyntaxRewriter {
11791179
return ExprSyntax(KeyPathExprSyntax(unsafeCasting: visitChildren(node._syntaxNode)))
11801180
}
11811181

1182+
/// Visit a `KeyPathMethodComponentSyntax`.
1183+
/// - Parameter node: the node that is being visited
1184+
/// - Returns: the rewritten node
1185+
@_spi(ExperimentalLanguageFeatures)
1186+
open func visit(_ node: KeyPathMethodComponentSyntax) -> KeyPathMethodComponentSyntax {
1187+
return KeyPathMethodComponentSyntax(unsafeCasting: visitChildren(node._syntaxNode))
1188+
}
1189+
11821190
/// Visit a ``KeyPathOptionalComponentSyntax``.
11831191
/// - Parameter node: the node that is being visited
11841192
/// - Returns: the rewritten node
@@ -2918,6 +2926,11 @@ open class SyntaxRewriter {
29182926
Syntax(visit(KeyPathExprSyntax(unsafeCasting: node)))
29192927
}
29202928

2929+
@inline(never)
2930+
private func visitKeyPathMethodComponentSyntaxImpl(_ node: Syntax) -> Syntax {
2931+
Syntax(visit(KeyPathMethodComponentSyntax(unsafeCasting: node)))
2932+
}
2933+
29212934
@inline(never)
29222935
private func visitKeyPathOptionalComponentSyntaxImpl(_ node: Syntax) -> Syntax {
29232936
Syntax(visit(KeyPathOptionalComponentSyntax(unsafeCasting: node)))
@@ -3914,6 +3927,8 @@ open class SyntaxRewriter {
39143927
return self.visitKeyPathComponentSyntaxImpl(_:)
39153928
case .keyPathExpr:
39163929
return self.visitKeyPathExprSyntaxImpl(_:)
3930+
case .keyPathMethodComponent:
3931+
return self.visitKeyPathMethodComponentSyntaxImpl(_:)
39173932
case .keyPathOptionalComponent:
39183933
return self.visitKeyPathOptionalComponentSyntaxImpl(_:)
39193934
case .keyPathPropertyComponent:
@@ -4496,6 +4511,8 @@ open class SyntaxRewriter {
44964511
return visitKeyPathComponentSyntaxImpl(node)
44974512
case .keyPathExpr:
44984513
return visitKeyPathExprSyntaxImpl(node)
4514+
case .keyPathMethodComponent:
4515+
return visitKeyPathMethodComponentSyntaxImpl(node)
44994516
case .keyPathOptionalComponent:
45004517
return visitKeyPathOptionalComponentSyntaxImpl(node)
45014518
case .keyPathPropertyComponent:

Sources/SwiftSyntax/generated/SyntaxVisitor.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,20 @@ open class SyntaxVisitor {
18881888
open func visitPost(_ node: KeyPathExprSyntax) {
18891889
}
18901890

1891+
/// Visiting `KeyPathMethodComponentSyntax` specifically.
1892+
/// - Parameter node: the node we are visiting.
1893+
/// - Returns: how should we continue visiting.
1894+
@_spi(ExperimentalLanguageFeatures)
1895+
open func visit(_ node: KeyPathMethodComponentSyntax) -> SyntaxVisitorContinueKind {
1896+
return .visitChildren
1897+
}
1898+
1899+
/// The function called after visiting `KeyPathMethodComponentSyntax` and its descendants.
1900+
/// - node: the node we just finished visiting.
1901+
@_spi(ExperimentalLanguageFeatures)
1902+
open func visitPost(_ node: KeyPathMethodComponentSyntax) {
1903+
}
1904+
18911905
/// Visiting ``KeyPathOptionalComponentSyntax`` specifically.
18921906
/// - Parameter node: the node we are visiting.
18931907
/// - Returns: how should we continue visiting.
@@ -4733,6 +4747,14 @@ open class SyntaxVisitor {
47334747
visitPost(KeyPathExprSyntax(unsafeCasting: node))
47344748
}
47354749

4750+
@inline(never)
4751+
private func visitKeyPathMethodComponentSyntaxImpl(_ node: Syntax) {
4752+
if visit(KeyPathMethodComponentSyntax(unsafeCasting: node)) == .visitChildren {
4753+
visitChildren(node)
4754+
}
4755+
visitPost(KeyPathMethodComponentSyntax(unsafeCasting: node))
4756+
}
4757+
47364758
@inline(never)
47374759
private func visitKeyPathOptionalComponentSyntaxImpl(_ node: Syntax) {
47384760
if visit(KeyPathOptionalComponentSyntax(unsafeCasting: node)) == .visitChildren {
@@ -6125,6 +6147,8 @@ open class SyntaxVisitor {
61256147
return self.visitKeyPathComponentSyntaxImpl(_:)
61266148
case .keyPathExpr:
61276149
return self.visitKeyPathExprSyntaxImpl(_:)
6150+
case .keyPathMethodComponent:
6151+
return self.visitKeyPathMethodComponentSyntaxImpl(_:)
61286152
case .keyPathOptionalComponent:
61296153
return self.visitKeyPathOptionalComponentSyntaxImpl(_:)
61306154
case .keyPathPropertyComponent:
@@ -6707,6 +6731,8 @@ open class SyntaxVisitor {
67076731
self.visitKeyPathComponentSyntaxImpl(node)
67086732
case .keyPathExpr:
67096733
self.visitKeyPathExprSyntaxImpl(node)
6734+
case .keyPathMethodComponent:
6735+
self.visitKeyPathMethodComponentSyntaxImpl(node)
67106736
case .keyPathOptionalComponent:
67116737
self.visitKeyPathOptionalComponentSyntaxImpl(node)
67126738
case .keyPathPropertyComponent:

0 commit comments

Comments
 (0)