Skip to content

Commit 2010844

Browse files
committed
unified: Add fields to property_declaration
Not entirely sure about the `binding?` field on `pattern`, but it looks like that might actually be useful.
1 parent 406a02f commit 2010844

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,13 +1405,13 @@ module.exports = grammar({
14051405
prec.left(
14061406
seq(
14071407
field("name", alias($._no_expr_pattern_already_bound, $.pattern)),
1408-
optional($.type_annotation),
1409-
optional($.type_constraints),
1408+
field("type", optional($.type_annotation)),
1409+
field("type_constraints", optional($.type_constraints)),
14101410
optional(
14111411
choice(
14121412
$._expression_with_willset_didset,
14131413
$._expression_without_willset_didset,
1414-
$.willset_didset_block,
1414+
field("observers", $.willset_didset_block),
14151415
field("computed_value", $.computed_property)
14161416
)
14171417
)
@@ -1423,7 +1423,7 @@ module.exports = grammar({
14231423
seq(
14241424
$._equal_sign,
14251425
field("value", $.expression),
1426-
$.willset_didset_block
1426+
field("observers", $.willset_didset_block)
14271427
)
14281428
),
14291429
_expression_without_willset_didset: ($) =>
@@ -1909,7 +1909,7 @@ module.exports = grammar({
19091909
),
19101910
value_binding_pattern: ($) => field("mutability", choice("var", "let")),
19111911
_possibly_async_binding_pattern_kind: ($) =>
1912-
seq(optional($._async_modifier), $.value_binding_pattern),
1912+
seq(optional($._async_modifier), field("binding", $.value_binding_pattern)),
19131913
_binding_kind_and_pattern: ($) =>
19141914
seq(
19151915
$._possibly_async_binding_pattern_kind,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ named:
474474
modifier+: parameter_modifier
475475
pattern:
476476
$children*: [expression, pattern, type, user_type, value_binding_pattern, wildcard_pattern]
477+
binding?: value_binding_pattern
477478
bound_identifier?: simple_identifier
478479
playground_literal:
479480
name+: simple_identifier
@@ -494,10 +495,13 @@ named:
494495
target: expression
495496
property_behavior_modifier:
496497
property_declaration:
497-
$children*: [type_annotation, type_constraints, value_binding_pattern, willset_didset_block]
498+
binding: value_binding_pattern
498499
computed_value*: computed_property
499500
modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier]
500501
name+: pattern
502+
observers*: willset_didset_block
503+
type*: type_annotation
504+
type_constraints*: type_constraints
501505
value*: expression
502506
property_modifier:
503507
protocol_body:

0 commit comments

Comments
 (0)