Skip to content

Commit 406a02f

Browse files
committed
unified: Add fields to switch_entry
Of note: this involved un-inlining where_clause.
1 parent 6e5e650 commit 406a02f

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

unified/extractor/tree-sitter-swift/grammar.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,20 +1078,18 @@ module.exports = grammar({
10781078
),
10791079
switch_entry: ($) =>
10801080
seq(
1081-
optional($.modifiers),
1081+
field("modifiers", optional($.modifiers)),
10821082
choice(
10831083
seq(
10841084
"case",
1085-
seq(
1086-
$.switch_pattern,
1087-
optional(seq($.where_keyword, $.expression))
1088-
),
1089-
repeat(seq(",", $.switch_pattern))
1085+
field("pattern", $.switch_pattern),
1086+
field("where", optional($.where_clause)),
1087+
repeat(seq(",", field("pattern", $.switch_pattern)))
10901088
),
1091-
$.default_keyword
1089+
field("default", $.default_keyword)
10921090
),
10931091
":",
1094-
$.statements,
1092+
field("body", $.statements),
10951093
optional("fallthrough")
10961094
),
10971095
switch_pattern: ($) => field("pattern", alias($._binding_pattern_with_expr, $.pattern)),

unified/extractor/tree-sitter-swift/node-types.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ named:
586586
suppressed_constraint:
587587
suppressed: type_identifier
588588
switch_entry:
589-
$children+: [default_keyword, expression, modifiers, statements, switch_pattern, where_keyword]
589+
body: statements
590+
default?: default_keyword
591+
modifiers?: modifiers
592+
pattern*: switch_pattern
593+
where?: where_clause
590594
switch_pattern:
591595
pattern: pattern
592596
switch_statement:

0 commit comments

Comments
 (0)