Skip to content

Commit 31386f5

Browse files
committed
unified: drop element field on _parenthesized_type
Same pattern we've seen many times before: a field on an anonymous node gets attached to the parent node instead. I'm not 100% sure this is the right solution, but it seemed wrong to just make `_parenthesized_type` named instead (we don't usually name parentheticals). At the very least, this cleans up the spurious navigation_expression.element and tuple_type_item.element fields.
1 parent e9822f6 commit 31386f5

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@ module.exports = grammar({
567567
_parenthesized_type: ($) =>
568568
seq(
569569
"(",
570-
field(
571-
"element",
572-
choice($.opaque_type, $.existential_type, $.dictionary_type)
573-
),
570+
choice($.opaque_type, $.existential_type, $.dictionary_type),
574571
")"
575572
),
576573
navigation_expression: ($) =>

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ named:
314314
rhs: expression
315315
mutation_modifier:
316316
navigation_expression:
317-
element?: [dictionary_type, existential_type, opaque_type]
318317
suffix: navigation_suffix
319318
target+: ["(", ")", array_type, dictionary_type, existential_type, expression, opaque_type, user_type]
320319
navigation_suffix:
@@ -459,8 +458,7 @@ named:
459458
$children?: tuple_type_item
460459
element*: tuple_type_item
461460
tuple_type_item:
462-
$children*: [parameter_modifiers, wildcard_pattern]
463-
element?: [dictionary_type, existential_type, opaque_type]
461+
$children*: [dictionary_type, existential_type, opaque_type, parameter_modifiers, wildcard_pattern]
464462
name?: simple_identifier
465463
type?: type
466464
type:

0 commit comments

Comments
 (0)