Skip to content

Commit b97ca6e

Browse files
committed
Add experimental flag and keyPathMethodComponent node.
1 parent 5c57421 commit b97ca6e

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

Diff for: CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public enum ExperimentalFeature: String, CaseIterable {
2121
case coroutineAccessors
2222
case valueGenerics
2323
case abiAttribute
24+
case keypathWithMethodMembers
2425

2526
/// The name of the feature as it is written in the compiler's `Features.def` file.
2627
public var featureName: String {
@@ -41,6 +42,8 @@ public enum ExperimentalFeature: String, CaseIterable {
4142
return "ValueGenerics"
4243
case .abiAttribute:
4344
return "ABIAttribute"
45+
case .keypathWithMethodMembers:
46+
return "KeypathWithMethodMembers"
4447
}
4548
}
4649

@@ -63,6 +66,8 @@ public enum ExperimentalFeature: String, CaseIterable {
6366
return "value generics"
6467
case .abiAttribute:
6568
return "@abi attribute"
69+
case .keypathWithMethodMembers:
70+
return "keypaths with method members"
6671
}
6772
}
6873

Diff for: CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

+32
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,11 @@ public let EXPR_NODES: [Node] = [
12081208
name: "property",
12091209
kind: .node(kind: .keyPathPropertyComponent)
12101210
),
1211+
Child(
1212+
name: "method",
1213+
kind: .node(kind: .keyPathMethodComponent),
1214+
experimentalFeature: .keypathWithMethodMembers
1215+
),
12111216
Child(
12121217
name: "subscript",
12131218
kind: .node(kind: .keyPathSubscriptComponent)
@@ -1312,6 +1317,33 @@ public let EXPR_NODES: [Node] = [
13121317
]
13131318
),
13141319

1320+
Node(
1321+
kind: .keyPathMethodComponent,
1322+
base: .syntax,
1323+
experimentalFeature: .keypathWithMethodMembers,
1324+
nameForDiagnostics: "key path method component",
1325+
documentation: "A key path component like `.method()`, `.method(10)`, or `.method(val: 10)`.",
1326+
children: [
1327+
Child(
1328+
name: "declName",
1329+
kind: .node(kind: .declReferenceExpr)
1330+
),
1331+
Child(
1332+
name: "leftParen",
1333+
kind: .token(choices: [.token(.leftParen)])
1334+
),
1335+
Child(
1336+
name: "arguments",
1337+
kind: .collection(kind: .labeledExprList, collectionElementName: "Argument"),
1338+
nameForDiagnostics: "arguments"
1339+
),
1340+
Child(
1341+
name: "rightParen",
1342+
kind: .token(choices: [.token(.rightParen)])
1343+
),
1344+
]
1345+
),
1346+
13151347
Node(
13161348
kind: .macroExpansionExpr,
13171349
base: .expr,

Diff for: CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
182182
case keyPathOptionalComponent
183183
case keyPathPropertyComponent
184184
case keyPathSubscriptComponent
185+
case keyPathMethodComponent
185186
case labeledExpr
186187
case labeledExprList
187188
case labeledSpecializeArgument

Diff for: CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

+4
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ class ValidateSyntaxNodes: XCTestCase {
570570
),
571571
ValidationFailure(node: .lifetimeTypeSpecifier, message: "could conform to trait 'Parenthesized' but does not"),
572572
ValidationFailure(node: .codeBlockFile, message: "could conform to trait 'WithCodeBlock' but does not"),
573+
ValidationFailure(
574+
node: .keyPathMethodComponent,
575+
message: "could conform to trait 'Parenthesized' but does not"
576+
),
573577
]
574578
)
575579
}

0 commit comments

Comments
 (0)