From 2010844b1eb531e44fcc9c474a4c498f03bf1a17 Mon Sep 17 00:00:00 2001 From: Taus Date: Tue, 12 May 2026 15:14:35 +0000 Subject: [PATCH] unified: Add fields to property_declaration Not entirely sure about the `binding?` field on `pattern`, but it looks like that might actually be useful. --- unified/extractor/tree-sitter-swift/grammar.js | 10 +++++----- unified/extractor/tree-sitter-swift/node-types.yml | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/unified/extractor/tree-sitter-swift/grammar.js b/unified/extractor/tree-sitter-swift/grammar.js index 1f79aedeacf..3af1017a109 100644 --- a/unified/extractor/tree-sitter-swift/grammar.js +++ b/unified/extractor/tree-sitter-swift/grammar.js @@ -1405,13 +1405,13 @@ module.exports = grammar({ prec.left( seq( field("name", alias($._no_expr_pattern_already_bound, $.pattern)), - optional($.type_annotation), - optional($.type_constraints), + field("type", optional($.type_annotation)), + field("type_constraints", optional($.type_constraints)), optional( choice( $._expression_with_willset_didset, $._expression_without_willset_didset, - $.willset_didset_block, + field("observers", $.willset_didset_block), field("computed_value", $.computed_property) ) ) @@ -1423,7 +1423,7 @@ module.exports = grammar({ seq( $._equal_sign, field("value", $.expression), - $.willset_didset_block + field("observers", $.willset_didset_block) ) ), _expression_without_willset_didset: ($) => @@ -1909,7 +1909,7 @@ module.exports = grammar({ ), value_binding_pattern: ($) => field("mutability", choice("var", "let")), _possibly_async_binding_pattern_kind: ($) => - seq(optional($._async_modifier), $.value_binding_pattern), + seq(optional($._async_modifier), field("binding", $.value_binding_pattern)), _binding_kind_and_pattern: ($) => seq( $._possibly_async_binding_pattern_kind, diff --git a/unified/extractor/tree-sitter-swift/node-types.yml b/unified/extractor/tree-sitter-swift/node-types.yml index defb9522670..981a9fede3b 100644 --- a/unified/extractor/tree-sitter-swift/node-types.yml +++ b/unified/extractor/tree-sitter-swift/node-types.yml @@ -474,6 +474,7 @@ named: modifier+: parameter_modifier pattern: $children*: [expression, pattern, type, user_type, value_binding_pattern, wildcard_pattern] + binding?: value_binding_pattern bound_identifier?: simple_identifier playground_literal: name+: simple_identifier @@ -494,10 +495,13 @@ named: target: expression property_behavior_modifier: property_declaration: - $children*: [type_annotation, type_constraints, value_binding_pattern, willset_didset_block] + binding: value_binding_pattern computed_value*: computed_property modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier] name+: pattern + observers*: willset_didset_block + type*: type_annotation + type_constraints*: type_constraints value*: expression property_modifier: protocol_body: