From eb480d1de47424e700692ccc4349b5ba7ecedab3 Mon Sep 17 00:00:00 2001 From: Taus Date: Tue, 12 May 2026 15:38:29 +0000 Subject: [PATCH] unified: Make parenthesized_type named I'm not entirely happy about this solution, but it seemed to be the most straightforward way of avoiding various kinds of token bleeding. --- unified/extractor/tree-sitter-swift/grammar.js | 10 +++++----- unified/extractor/tree-sitter-swift/node-types.yml | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/unified/extractor/tree-sitter-swift/grammar.js b/unified/extractor/tree-sitter-swift/grammar.js index 0616522ab4c..1bcdc4fbdf1 100644 --- a/unified/extractor/tree-sitter-swift/grammar.js +++ b/unified/extractor/tree-sitter-swift/grammar.js @@ -452,7 +452,7 @@ module.exports = grammar({ optional(sep1Opt(field("element", $.tuple_type_item), ",")), ")" ), - field("element", alias($._parenthesized_type, $.tuple_type_item)) + field("element", alias($.parenthesized_type, $.tuple_type_item)) ), tuple_type_item: ($) => prec( @@ -467,7 +467,7 @@ module.exports = grammar({ prec( PRECS.expr, seq( - optional($.wildcard_pattern), + optional(field("external_name", $.wildcard_pattern)), field("name", $.simple_identifier), ":" ) @@ -571,10 +571,10 @@ module.exports = grammar({ field("suffix", $.constructor_suffix) ) ), - _parenthesized_type: ($) => + parenthesized_type: ($) => seq( "(", - choice($.opaque_type, $.existential_type, $.dictionary_type), + field("type", choice($.opaque_type, $.existential_type, $.dictionary_type)), ")" ), navigation_expression: ($) => @@ -586,7 +586,7 @@ module.exports = grammar({ choice( $._navigable_type_expression, $.expression, - $._parenthesized_type + $.parenthesized_type ) ), field("suffix", $.navigation_suffix) diff --git a/unified/extractor/tree-sitter-swift/node-types.yml b/unified/extractor/tree-sitter-swift/node-types.yml index 223c16e43ec..3b3b5807e47 100644 --- a/unified/extractor/tree-sitter-swift/node-types.yml +++ b/unified/extractor/tree-sitter-swift/node-types.yml @@ -445,7 +445,7 @@ named: mutation_modifier: navigation_expression: suffix: navigation_suffix - target+: ["(", ")", array_type, dictionary_type, existential_type, expression, opaque_type, user_type] + target: [array_type, dictionary_type, expression, parenthesized_type, user_type] navigation_suffix: suffix: [integer_literal, simple_identifier] nested_type_identifier: @@ -479,6 +479,8 @@ named: parameter_modifier: parameter_modifiers: modifier+: parameter_modifier + parenthesized_type: + type: [dictionary_type, existential_type, opaque_type] pattern: binding?: value_binding_pattern bound_identifier?: simple_identifier @@ -630,10 +632,10 @@ named: tuple_type: element*: tuple_type_item tuple_type_item: - $children?: [dictionary_type, existential_type, opaque_type, wildcard_pattern] + external_name?: wildcard_pattern modifiers?: parameter_modifiers name?: simple_identifier - type?: type + type: [dictionary_type, existential_type, opaque_type, type] type: modifiers?: type_modifiers name: unannotated_type