Skip to content

Commit ea6f3a9

Browse files
committed
unified: Encapsulate function parameters
The field representation would have made it difficult to figure out which parameters correspond to which default values and attributes, so instead we now encapsulate these in a new `function_parameter` node.
1 parent 5d6dc5c commit ea6f3a9

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,9 +1611,9 @@ module.exports = grammar({
16111611
),
16121612
_function_value_parameters: ($) =>
16131613
repeat1(
1614-
seq("(", optional(sep1Opt($._function_value_parameter, ",")), ")")
1614+
seq("(", optional(sep1Opt(field("parameter", $.function_parameter), ",")), ")")
16151615
),
1616-
_function_value_parameter: ($) =>
1616+
function_parameter: ($) =>
16171617
seq(
16181618
field("attribute", optional($.attribute)),
16191619
field("parameter", $.parameter),

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,19 @@ named:
305305
fully_open_range:
306306
function_declaration:
307307
async?: "async"
308-
attribute*: attribute
309308
body: block
310-
default_value*: expression
311309
modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier]
312310
name: [referenceable_operator, simple_identifier]
313-
parameter*: parameter
311+
parameter*: function_parameter
314312
return_type?: [implicitly_unwrapped_type, type]
315313
throws?: [throws, throws_clause]
316314
type_constraints?: type_constraints
317315
type_parameters?: type_parameters
318316
function_modifier:
317+
function_parameter:
318+
attribute?: attribute
319+
default_value?: expression
320+
parameter: parameter
319321
function_type:
320322
async?: "async"
321323
params: unannotated_type
@@ -361,13 +363,11 @@ named:
361363
inherits_from: [function_type, suppressed_constraint, user_type]
362364
init_declaration:
363365
async?: "async"
364-
attribute*: attribute
365366
bang?: bang
366367
body?: block
367-
default_value*: expression
368368
modifiers?: modifiers
369369
name: "init"
370-
parameter*: parameter
370+
parameter*: function_parameter
371371
throws?: [throws, throws_clause]
372372
type_constraints?: type_constraints
373373
type_parameters?: type_parameters
@@ -410,12 +410,10 @@ named:
410410
interpolation*: interpolated_expression
411411
text*: [line_str_text, str_escaped_char]
412412
macro_declaration:
413-
attribute*: attribute
414-
default_value*: expression
415413
definition?: macro_definition
416414
modifiers?: modifiers
417415
name: simple_identifier
418-
parameter*: parameter
416+
parameter*: function_parameter
419417
return_type?: unannotated_type
420418
type_constraints?: type_constraints
421419
type_parameters?: type_parameters
@@ -527,12 +525,10 @@ named:
527525
type_parameters?: type_parameters
528526
protocol_function_declaration:
529527
async?: "async"
530-
attribute*: attribute
531528
body?: block
532-
default_value*: expression
533529
modifiers?: modifiers
534530
name: [referenceable_operator, simple_identifier]
535-
parameter*: parameter
531+
parameter*: function_parameter
536532
return_type?: [implicitly_unwrapped_type, type]
537533
throws?: [throws, throws_clause]
538534
type_constraints?: type_constraints
@@ -584,11 +580,9 @@ named:
584580
statement_label:
585581
str_escaped_char:
586582
subscript_declaration:
587-
attribute*: attribute
588583
body: computed_property
589-
default_value*: expression
590584
modifiers?: modifiers
591-
parameter*: parameter
585+
parameter*: function_parameter
592586
return_type?: [implicitly_unwrapped_type, type]
593587
type_constraints?: type_constraints
594588
type_parameters?: type_parameters

0 commit comments

Comments
 (0)