diff --git a/unified/extractor/tree-sitter-swift/grammar.js b/unified/extractor/tree-sitter-swift/grammar.js index 75d7c450bf0..9137fb94cee 100644 --- a/unified/extractor/tree-sitter-swift/grammar.js +++ b/unified/extractor/tree-sitter-swift/grammar.js @@ -291,7 +291,7 @@ module.exports = grammar({ "package", $._parameter_ownership_modifier ), - identifier: ($) => sep1($.simple_identifier, $._dot), + identifier: ($) => sep1(field("part", $.simple_identifier), $._dot), // Literals _basic_literal: ($) => choice( @@ -355,13 +355,13 @@ module.exports = grammar({ seq( field("text", $.raw_str_part), field("interpolation", $.raw_str_interpolation), - optional($.raw_str_continuing_indicator) + field("continuing", optional($.raw_str_continuing_indicator)) ) ), field("text", $.raw_str_end_part) ), raw_str_interpolation: ($) => - seq($.raw_str_interpolation_start, $._interpolation_contents, ")"), + seq(field("start", $.raw_str_interpolation_start), $._interpolation_contents, ")"), raw_str_interpolation_start: ($) => /\\#*\(/, _multi_line_string_content: ($) => choice($.multi_line_str_text, $.str_escaped_char, '"'), @@ -410,7 +410,7 @@ module.exports = grammar({ _possibly_implicitly_unwrapped_type: ($) => choice($.type, $.implicitly_unwrapped_type), implicitly_unwrapped_type: ($) => - seq($.type, token.immediate("!")), + seq(field("name", $.type), token.immediate("!")), type: ($) => prec.right( PRECS.ty, @@ -436,7 +436,7 @@ module.exports = grammar({ ) ), // The grammar just calls this whole thing a `type-identifier` but that's a bit confusing. - user_type: ($) => sep1($._simple_user_type, $._dot), + user_type: ($) => sep1(field("part", $._simple_user_type), $._dot), _simple_user_type: ($) => prec.right( PRECS.ty, @@ -459,7 +459,7 @@ module.exports = grammar({ PRECS.expr, seq( optional($._tuple_type_item_identifier), - optional($.parameter_modifiers), + field("modifiers", optional($.parameter_modifiers)), field("type", $.type) ) ), @@ -475,8 +475,8 @@ module.exports = grammar({ function_type: ($) => seq( field("params", choice($.tuple_type, $.unannotated_type)), - optional($._async_keyword), - optional(choice($.throws_clause, $.throws)), + field("async", optional($._async_keyword)), + field("throws", optional(choice($.throws_clause, $.throws))), $._arrow_operator, field("return_type", $.type) ), @@ -493,18 +493,18 @@ module.exports = grammar({ repeat1(alias($._immediate_quest, "?")) ) ), - metatype: ($) => seq($.unannotated_type, ".", choice("Type", "Protocol")), + metatype: ($) => seq(field("name", $.unannotated_type), ".", choice("Type", "Protocol")), _quest: ($) => "?", _immediate_quest: ($) => token.immediate("?"), - opaque_type: ($) => prec.right(seq("some", $.unannotated_type)), - existential_type: ($) => prec.right(seq("any", $.unannotated_type)), - type_parameter_pack: ($) => prec.left(seq("each", $.unannotated_type)), - type_pack_expansion: ($) => prec.left(seq("repeat", $.unannotated_type)), + opaque_type: ($) => prec.right(seq("some", field("name", $.unannotated_type))), + existential_type: ($) => prec.right(seq("any", field("name", $.unannotated_type))), + type_parameter_pack: ($) => prec.left(seq("each", field("name", $.unannotated_type))), + type_pack_expansion: ($) => prec.left(seq("repeat", field("name", $.unannotated_type))), protocol_composition_type: ($) => prec.left( seq( - $.unannotated_type, - repeat1(seq("&", prec.right($.unannotated_type))) + field("type", $.unannotated_type), + repeat1(seq("&", prec.right(field("type", $.unannotated_type)))) ) ), suppressed_constraint: ($) => @@ -535,7 +535,7 @@ module.exports = grammar({ ) ), optional_chain_marker: ($) => - seq($.expression, alias($._immediate_quest, "?")), + seq(field("expr", $.expression), alias($._immediate_quest, "?")), // Unary expressions _unary_expression: ($) => choice( @@ -568,7 +568,7 @@ module.exports = grammar({ "constructed_type", choice($.array_type, $.dictionary_type, $.user_type) ), - $.constructor_suffix + field("suffix", $.constructor_suffix) ) ), _parenthesized_type: ($) => @@ -626,7 +626,7 @@ module.exports = grammar({ as_expression: ($) => prec.left( PRECS.as, - seq(field("expr", $.expression), $.as_operator, field("type", $.type)) + seq(field("expr", $.expression), field("operator", $.as_operator), field("type", $.type)) ), selector_expression: ($) => seq( @@ -634,7 +634,7 @@ module.exports = grammar({ "selector", "(", optional(choice("getter:", "setter:")), - $.expression, + field("expr", $.expression), ")" ), // Binary expressions @@ -778,15 +778,15 @@ module.exports = grammar({ ) ), _constructor_value_arguments: ($) => - seq("(", optional(sep1Opt($.value_argument, ",")), ")"), + seq("(", optional(sep1Opt(field("argument", $.value_argument), ",")), ")"), _fn_call_lambda_arguments: ($) => sep1($.lambda_literal, seq(field("name", $.simple_identifier), ":")), - type_arguments: ($) => prec.left(seq("<", sep1Opt($.type, ","), ">")), + type_arguments: ($) => prec.left(seq("<", sep1Opt(field("argument", $.type), ","), ">")), value_arguments: ($) => seq( choice( - seq("(", optional(sep1Opt($.value_argument, ",")), ")"), - seq("[", optional(sep1Opt($.value_argument, ",")), "]") + seq("(", optional(sep1Opt(field("argument", $.value_argument), ",")), ")"), + seq("[", optional(sep1Opt(field("argument", $.value_argument), ",")), "]") ) ), value_argument_label: ($) => @@ -802,7 +802,7 @@ module.exports = grammar({ value_argument: ($) => prec.left( seq( - optional($.type_modifiers), + field("type_modifiers", optional($.type_modifiers)), choice( repeat1( seq(field("reference_specifier", $.value_argument_label), ":") @@ -818,7 +818,7 @@ module.exports = grammar({ prec.right( PRECS["try"], seq( - $.try_operator, + field("operator", $.try_operator), field( "expr", choice( @@ -885,7 +885,7 @@ module.exports = grammar({ call_expression: ($) => prec( PRECS.call, - prec.dynamic(DYNAMIC_PRECS.call, seq($.expression, $.call_suffix)) + prec.dynamic(DYNAMIC_PRECS.call, seq(field("function", $.expression), field("suffix", $.call_suffix))) ), macro_invocation: ($) => prec( @@ -894,9 +894,9 @@ module.exports = grammar({ DYNAMIC_PRECS.call, seq( $._hash_symbol, - $.simple_identifier, - optional($.type_parameters), - $.call_suffix + field("name", $.simple_identifier), + field("type_parameters", optional($.type_parameters)), + field("suffix", $.call_suffix) ) ) ), @@ -965,7 +965,7 @@ module.exports = grammar({ $._hash_symbol, choice("colorLiteral", "fileLiteral", "imageLiteral"), "(", - sep1Opt(seq($.simple_identifier, ":", $.expression), ","), + sep1Opt(seq(field("name", $.simple_identifier), ":", field("value", $.expression)), ","), ")" ), lambda_literal: ($) => @@ -974,25 +974,25 @@ module.exports = grammar({ seq( choice("{", "^{"), optional($._lambda_type_declaration), - optional($.statements), + field("body", optional($.statements)), "}" ) ), _lambda_type_declaration: ($) => seq( - repeat($.attribute), + repeat(field("attribute", $.attribute)), prec(PRECS.expr, optional(field("captures", $.capture_list))), optional(field("type", $.lambda_function_type)), "in" ), - capture_list: ($) => seq("[", sep1Opt($.capture_list_item, ","), "]"), + capture_list: ($) => seq("[", sep1Opt(field("item", $.capture_list_item), ","), "]"), capture_list_item: ($) => choice( field("name", $.self_expression), prec( PRECS.expr, seq( - optional($.ownership_modifier), + field("ownership", optional($.ownership_modifier)), field("name", $.simple_identifier), optional(seq($._equal_sign, field("value", $.expression))) ) @@ -1003,11 +1003,11 @@ module.exports = grammar({ PRECS.expr, seq( choice( - $.lambda_function_type_parameters, - seq("(", optional($.lambda_function_type_parameters), ")") + field("params", $.lambda_function_type_parameters), + seq("(", field("params", optional($.lambda_function_type_parameters)), ")") ), - optional($._async_keyword), - optional(choice($.throws_clause, $.throws)), + field("async", optional($._async_keyword)), + field("throws", optional(choice($.throws_clause, $.throws))), optional( seq( $._arrow_operator, @@ -1016,11 +1016,11 @@ module.exports = grammar({ ) ) ), - lambda_function_type_parameters: ($) => sep1Opt($.lambda_parameter, ","), + lambda_function_type_parameters: ($) => sep1Opt(field("parameter", $.lambda_parameter), ","), lambda_parameter: ($) => seq( choice( - $.self_expression, + field("name", $.self_expression), prec(PRECS.expr, field("name", $.simple_identifier)), prec( PRECS.expr, @@ -1028,7 +1028,7 @@ module.exports = grammar({ optional(field("external_name", $.simple_identifier)), field("name", $.simple_identifier), ":", - optional($.parameter_modifiers), + field("modifiers", optional($.parameter_modifiers)), field("type", $._possibly_implicitly_unwrapped_type) ) ) @@ -1036,7 +1036,7 @@ module.exports = grammar({ ), self_expression: ($) => "self", super_expression: ($) => seq("super"), - _else_options: ($) => choice($._block, $.if_statement), + _else_options: ($) => choice($._block, field("else_branch", $.if_statement)), if_statement: ($) => prec.right( PRECS["if"], @@ -1044,16 +1044,16 @@ module.exports = grammar({ "if", sep1(field("condition", $.if_condition), ","), $._block, - optional(seq($["else"], $._else_options)) + optional(seq(field("else_keyword", $["else"]), $._else_options)) ) ), if_condition: ($) => - choice($.if_let_binding, $.expression, $.availability_condition), + field("kind", choice($.if_let_binding, $.expression, $.availability_condition)), if_let_binding: ($) => seq( $._direct_or_indirect_binding, - optional(seq($._equal_sign, $.expression)), - optional($.where_clause) + optional(seq($._equal_sign, field("value", $.expression))), + field("where", optional($.where_clause)) ), guard_statement: ($) => prec.right( @@ -1061,7 +1061,7 @@ module.exports = grammar({ seq( "guard", sep1(field("condition", $.if_condition), ","), - $["else"], + field("else_keyword", $["else"]), $._block ) ), @@ -1072,7 +1072,7 @@ module.exports = grammar({ "switch", field("expr", $.expression), "{", - repeat($.switch_entry), + repeat(field("entry", $.switch_entry)), "}" ) ), @@ -1096,15 +1096,15 @@ module.exports = grammar({ ), switch_pattern: ($) => alias($._binding_pattern_with_expr, $.pattern), do_statement: ($) => - prec.right(PRECS["do"], seq("do", $._block, repeat($.catch_block))), + prec.right(PRECS["do"], seq("do", $._block, repeat(field("catch", $.catch_block)))), catch_block: ($) => seq( - $.catch_keyword, + field("keyword", $.catch_keyword), field("error", optional(alias($._binding_pattern_no_expr, $.pattern))), - optional($.where_clause), + field("where", optional($.where_clause)), $._block ), - where_clause: ($) => prec.left(seq($.where_keyword, $.expression)), + where_clause: ($) => prec.left(seq(field("keyword", $.where_keyword), field("expr", $.expression))), key_path_expression: ($) => prec.right( PRECS.keypath, @@ -1117,7 +1117,7 @@ module.exports = grammar({ ) ), key_path_string_expression: ($) => - prec.left(seq($._hash_symbol, "keyPath", "(", $.expression, ")")), + prec.left(seq($._hash_symbol, "keyPath", "(", field("expr", $.expression), ")")), _key_path_component: ($) => prec.left( choice( @@ -1173,7 +1173,7 @@ module.exports = grammar({ ), _bitwise_binary_operator: ($) => choice("&", "|", "^", "<<", ">>"), _postfix_unary_operator: ($) => choice("++", "--", $.bang), - directly_assignable_expression: ($) => $.expression, + directly_assignable_expression: ($) => field("expr", $.expression), //////////////////////////////// // Statements - https://docs.swift.org/swift-book/ReferenceManual/Statements.html @@ -1201,7 +1201,7 @@ module.exports = grammar({ $._labeled_statement, $._throw_statement ), - _block: ($) => prec(PRECS.block, seq("{", optional($.statements), "}")), + _block: ($) => prec(PRECS.block, seq("{", field("body", optional($.statements)), "}")), _labeled_statement: ($) => seq( optional($.statement_label), @@ -1221,13 +1221,13 @@ module.exports = grammar({ PRECS.loop, seq( "for", - optional($.try_operator), + field("try", optional($.try_operator)), optional($._await_operator), field("item", alias($._binding_pattern_no_expr, $.pattern)), - optional($.type_annotation), + field("type", optional($.type_annotation)), "in", field("collection", $._for_statement_collection), - optional($.where_clause), + field("where", optional($.where_clause)), $._block ) ), @@ -1246,7 +1246,7 @@ module.exports = grammar({ "while", sep1(field("condition", $.if_condition), ","), "{", - optional($.statements), + field("body", optional($.statements)), "}" ) ), @@ -1256,7 +1256,7 @@ module.exports = grammar({ seq( "repeat", "{", - optional($.statements), + field("body", optional($.statements)), "}", // Make sure we make it to the `while` before assuming this is a parameter pack. repeat($._implicit_semi), @@ -1270,7 +1270,7 @@ module.exports = grammar({ prec.right( PRECS.control_transfer, seq( - $._optionally_valueful_control_keyword, + field("kind", $._optionally_valueful_control_keyword), field("result", optional($.expression)) ) ) @@ -1289,9 +1289,9 @@ module.exports = grammar({ ) ), value_parameter_pack: ($) => - prec.left(PRECS.parameter_pack, seq("each", $.expression)), + prec.left(PRECS.parameter_pack, seq("each", field("expr", $.expression))), value_pack_expansion: ($) => - prec.left(PRECS.parameter_pack, seq("repeat", $.expression)), + prec.left(PRECS.parameter_pack, seq("repeat", field("expr", $.expression))), availability_condition: ($) => seq( $._hash_symbol, @@ -1343,30 +1343,30 @@ module.exports = grammar({ ), _local_property_declaration: ($) => seq( - optional($._locally_permitted_modifiers), + field("modifiers", optional($._locally_permitted_modifiers)), $._modifierless_property_declaration ), _local_typealias_declaration: ($) => seq( - optional($._locally_permitted_modifiers), + field("modifiers", optional($._locally_permitted_modifiers)), $._modifierless_typealias_declaration ), _local_function_declaration: ($) => seq( - optional($._locally_permitted_modifiers), + field("modifiers", optional($._locally_permitted_modifiers)), $._modifierless_function_declaration ), _local_class_declaration: ($) => seq( - optional($._locally_permitted_modifiers), + field("modifiers", optional($._locally_permitted_modifiers)), $._modifierless_class_declaration ), import_declaration: ($) => seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), "import", optional($._import_kind), - $.identifier + field("name", $.identifier) ), _import_kind: ($) => choice( @@ -1382,17 +1382,17 @@ module.exports = grammar({ protocol_property_declaration: ($) => prec.right( seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), field("name", alias($._binding_kind_and_pattern, $.pattern)), - optional($.type_annotation), - optional($.type_constraints), - $.protocol_property_requirements + field("type", optional($.type_annotation)), + field("type_constraints", optional($.type_constraints)), + field("requirements", $.protocol_property_requirements) ) ), protocol_property_requirements: ($) => - seq("{", repeat(choice($.getter_specifier, $.setter_specifier)), "}"), + seq("{", repeat(field("accessor", choice($.getter_specifier, $.setter_specifier))), "}"), property_declaration: ($) => - seq(optional($.modifiers), $._modifierless_property_declaration), + seq(field("modifiers", optional($.modifiers)), $._modifierless_property_declaration), _modifierless_property_declaration: ($) => prec.right( seq( @@ -1429,30 +1429,30 @@ module.exports = grammar({ seq($._equal_sign, field("value", $.expression)), willset_didset_block: ($) => choice( - seq("{", $.willset_clause, optional($.didset_clause), "}"), - seq("{", $.didset_clause, optional($.willset_clause), "}") + seq("{", field("willset", $.willset_clause), field("didset", optional($.didset_clause)), "}"), + seq("{", field("didset", $.didset_clause), field("willset", optional($.willset_clause)), "}") ), willset_clause: ($) => seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), "willSet", - optional(seq("(", $.simple_identifier, ")")), + optional(seq("(", field("parameter", $.simple_identifier), ")")), $._block ), didset_clause: ($) => seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), "didSet", - optional(seq("(", $.simple_identifier, ")")), + optional(seq("(", field("parameter", $.simple_identifier), ")")), $._block ), typealias_declaration: ($) => - seq(optional($.modifiers), $._modifierless_typealias_declaration), + seq(field("modifiers", optional($.modifiers)), $._modifierless_typealias_declaration), _modifierless_typealias_declaration: ($) => seq( "typealias", field("name", alias($.simple_identifier, $.type_identifier)), - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), $._equal_sign, field("value", $.type) ), @@ -1469,7 +1469,7 @@ module.exports = grammar({ ), _bodyless_function_declaration: ($) => seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), optional("class"), // XXX: This should be possible in non-last position, but that creates parsing ambiguity $._modifierless_function_declaration_no_body ), @@ -1477,17 +1477,17 @@ module.exports = grammar({ prec.right( seq( $._non_constructor_function_decl, - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), $._function_value_parameters, - optional($._async_keyword), - optional(choice($.throws_clause, $.throws)), + field("async", optional($._async_keyword)), + field("throws", optional(choice($.throws_clause, $.throws))), optional( seq( $._arrow_operator, field("return_type", $._possibly_implicitly_unwrapped_type) ) ), - optional($.type_constraints) + field("type_constraints", optional($.type_constraints)) ) ), function_body: ($) => $._block, @@ -1513,36 +1513,36 @@ module.exports = grammar({ ), external_macro_definition: ($) => - seq($._hash_symbol, "externalMacro", $.value_arguments), + seq($._hash_symbol, "externalMacro", field("arguments", $.value_arguments)), class_declaration: ($) => - seq(optional($.modifiers), $._modifierless_class_declaration), + seq(field("modifiers", optional($.modifiers)), $._modifierless_class_declaration), _modifierless_class_declaration: ($) => prec.right( choice( seq( field("declaration_kind", choice("class", "struct", "actor")), field("name", alias($.simple_identifier, $.type_identifier)), - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), optional(seq(":", $._inheritance_specifiers)), - optional($.type_constraints), + field("type_constraints", optional($.type_constraints)), field("body", $.class_body) ), seq( field("declaration_kind", "extension"), field("name", $.unannotated_type), - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), optional(seq(":", $._inheritance_specifiers)), - optional($.type_constraints), + field("type_constraints", optional($.type_constraints)), field("body", $.class_body) ), seq( optional("indirect"), field("declaration_kind", "enum"), field("name", alias($.simple_identifier, $.type_identifier)), - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), optional(seq(":", $._inheritance_specifiers)), - optional($.type_constraints), + field("type_constraints", optional($.type_constraints)), field("body", $.enum_class_body) ) ) @@ -1550,6 +1550,8 @@ module.exports = grammar({ class_body: ($) => seq("{", optional($._class_member_declarations), "}"), _inheritance_specifiers: ($) => prec.left(sep1($._annotated_inheritance_specifier, choice(",", "&"))), + _annotated_inheritance_specifier: ($) => + seq(repeat(field("attribute", $.attribute)), $.inheritance_specifier), inheritance_specifier: ($) => prec.left( field( @@ -1557,20 +1559,18 @@ module.exports = grammar({ choice($.user_type, $.function_type, $.suppressed_constraint) ) ), - _annotated_inheritance_specifier: ($) => - seq(repeat($.attribute), $.inheritance_specifier), type_parameters: ($) => seq( "<", - sep1Opt($.type_parameter, ","), - optional($.type_constraints), + sep1Opt(field("parameter", $.type_parameter), ","), + field("constraints", optional($.type_constraints)), ">" ), type_parameter: ($) => seq( - optional($.type_parameter_modifiers), - $._type_parameter_possibly_packed, - optional(seq(":", $.type)) + field("modifiers", optional($.type_parameter_modifiers)), + field("name", $._type_parameter_possibly_packed), + optional(seq(":", field("type", $.type))) ), _type_parameter_possibly_packed: ($) => choice( @@ -1579,19 +1579,19 @@ module.exports = grammar({ ), type_constraints: ($) => - prec.right(seq($.where_keyword, sep1Opt($.type_constraint, ","))), + prec.right(seq(field("keyword", $.where_keyword), sep1Opt(field("constraint", $.type_constraint), ","))), type_constraint: ($) => - choice($.inheritance_constraint, $.equality_constraint), + field("constraint", choice($.inheritance_constraint, $.equality_constraint)), inheritance_constraint: ($) => seq( - repeat($.attribute), + repeat(field("attribute", $.attribute)), field("constrained_type", $._constrained_type), ":", field("inherits_from", $._possibly_implicitly_unwrapped_type) ), equality_constraint: ($) => seq( - repeat($.attribute), + repeat(field("attribute", $.attribute)), field("constrained_type", $._constrained_type), choice($._equal_sign, $._eq_eq), field("must_equal", $.type) @@ -1599,8 +1599,8 @@ module.exports = grammar({ _constrained_type: ($) => choice($.identifier, $.nested_type_identifier), nested_type_identifier: ($) => seq( - $.unannotated_type, - optional(seq(".", sep1($.simple_identifier, "."))) + field("base", $.unannotated_type), + optional(seq(".", sep1(field("member", $.simple_identifier), "."))) ), _class_member_separator: ($) => choice($._semi, $.multiline_comment), _class_member_declarations: ($) => @@ -1614,8 +1614,8 @@ module.exports = grammar({ ), _function_value_parameter: ($) => seq( - optional($.attribute), - $.parameter, + field("attribute", optional($.attribute)), + field("parameter", $.parameter), optional(seq($._equal_sign, field("default_value", $.expression))) ), parameter: ($) => @@ -1623,7 +1623,7 @@ module.exports = grammar({ optional(field("external_name", $.simple_identifier)), field("name", $.simple_identifier), ":", - optional($.parameter_modifiers), + field("modifiers", optional($.parameter_modifiers)), field("type", $._possibly_implicitly_unwrapped_type), optional($._three_dot_operator) ), @@ -1633,7 +1633,7 @@ module.exports = grammar({ field("name", choice($.simple_identifier, $.referenceable_operator)) ), referenceable_operator: ($) => - choice( + field("operator", choice( $.custom_operator, $._comparison_operator, $._additive_operator, @@ -1649,7 +1649,7 @@ module.exports = grammar({ "<<", ">>", "&" - ), + )), // Hide the fact that certain symbols come from the custom scanner by aliasing them to their // string variants. This keeps us from having to see them in the syntax tree (which would be // noisy) but allows callers to refer to them as nodes by their text form like with any @@ -1676,7 +1676,7 @@ module.exports = grammar({ seq("{", repeat(field("member", choice($.enum_entry, $.type_level_declaration))), "}"), enum_entry: ($) => seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), optional("indirect"), "case", sep1( @@ -1713,12 +1713,12 @@ module.exports = grammar({ protocol_declaration: ($) => prec.right( seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), field("declaration_kind", "protocol"), field("name", alias($.simple_identifier, $.type_identifier)), - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), optional(seq(":", $._inheritance_specifiers)), - optional($.type_constraints), + field("type_constraints", optional($.type_constraints)), field("body", $.protocol_body) ) ), @@ -1744,28 +1744,28 @@ module.exports = grammar({ init_declaration: ($) => prec.right( seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), optional("class"), field("name", "init"), - optional(choice($._quest, $.bang)), - optional($.type_parameters), + optional(choice($._quest, field("bang", $.bang))), + field("type_parameters", optional($.type_parameters)), $._function_value_parameters, - optional($._async_keyword), - optional(choice($.throws_clause, $.throws)), - optional($.type_constraints), + field("async", optional($._async_keyword)), + field("throws", optional(choice($.throws_clause, $.throws))), + field("type_constraints", optional($.type_constraints)), optional(field("body", $.function_body)) ) ), deinit_declaration: ($) => prec.right( - seq(optional($.modifiers), "deinit", field("body", $.function_body)) + seq(field("modifiers", optional($.modifiers)), "deinit", field("body", $.function_body)) ), subscript_declaration: ($) => prec.right( seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), "subscript", - optional($.type_parameters), + field("type_parameters", optional($.type_parameters)), $._function_value_parameters, optional( seq( @@ -1773,45 +1773,45 @@ module.exports = grammar({ field("return_type", $._possibly_implicitly_unwrapped_type) ) ), - optional($.type_constraints), - $.computed_property + field("type_constraints", optional($.type_constraints)), + field("body", $.computed_property) ) ), computed_property: ($) => seq( "{", choice( - optional($.statements), + field("body", optional($.statements)), repeat( - choice($.computed_getter, $.computed_setter, $.computed_modify) + field("accessor", choice($.computed_getter, $.computed_setter, $.computed_modify)) ) ), "}" ), computed_getter: ($) => - seq(repeat($.attribute), $.getter_specifier, optional($._block)), + seq(repeat(field("attribute", $.attribute)), field("specifier", $.getter_specifier), optional($._block)), computed_modify: ($) => - seq(repeat($.attribute), $.modify_specifier, optional($._block)), + seq(repeat(field("attribute", $.attribute)), field("specifier", $.modify_specifier), optional($._block)), computed_setter: ($) => seq( - repeat($.attribute), - $.setter_specifier, - optional(seq("(", $.simple_identifier, ")")), + repeat(field("attribute", $.attribute)), + field("specifier", $.setter_specifier), + optional(seq("(", field("parameter", $.simple_identifier), ")")), optional($._block) ), getter_specifier: ($) => - seq(optional($.mutation_modifier), "get", optional($._getter_effects)), - setter_specifier: ($) => seq(optional($.mutation_modifier), "set"), - modify_specifier: ($) => seq(optional($.mutation_modifier), "_modify"), + seq(field("mutation", optional($.mutation_modifier)), "get", optional($._getter_effects)), + setter_specifier: ($) => seq(field("mutation", optional($.mutation_modifier)), "set"), + modify_specifier: ($) => seq(field("mutation", optional($.mutation_modifier)), "_modify"), _getter_effects: ($) => repeat1(field("effect", choice(alias($._async_keyword, $.async_keyword), $.throws_clause, $.throws))), operator_declaration: ($) => seq( - choice("prefix", "infix", "postfix"), + field("kind", choice("prefix", "infix", "postfix")), "operator", - $.referenceable_operator, - optional(seq(":", $.simple_identifier)), - optional($.deprecated_operator_declaration_body) + field("name", $.referenceable_operator), + optional(seq(":", field("precedence_group", $.simple_identifier))), + field("body", optional($.deprecated_operator_declaration_body)) ), // The Swift compiler no longer accepts these, but some very old code still uses it. deprecated_operator_declaration_body: ($) => @@ -1819,25 +1819,25 @@ module.exports = grammar({ precedence_group_declaration: ($) => seq( "precedencegroup", - $.simple_identifier, + field("name", $.simple_identifier), "{", - optional($.precedence_group_attributes), + field("attributes", optional($.precedence_group_attributes)), "}" ), - precedence_group_attributes: ($) => repeat1($.precedence_group_attribute), + precedence_group_attributes: ($) => repeat1(field("attribute", $.precedence_group_attribute)), precedence_group_attribute: ($) => seq( - $.simple_identifier, + field("name", $.simple_identifier), ":", - choice($.simple_identifier, $.boolean_literal) + field("value", choice($.simple_identifier, $.boolean_literal)) ), associatedtype_declaration: ($) => seq( - optional($.modifiers), + field("modifiers", optional($.modifiers)), "associatedtype", field("name", alias($.simple_identifier, $.type_identifier)), optional(seq(":", field("must_inherit", $.type))), - optional($.type_constraints), + field("type_constraints", optional($.type_constraints)), optional(seq($._equal_sign, field("default_value", $.type))) ), //////////////////////////////// @@ -1846,20 +1846,20 @@ module.exports = grammar({ attribute: ($) => seq( "@", - $.user_type, + field("name", $.user_type), // attribute arguments are a mess of special cases, maybe this is good enough? optional(seq("(", sep1Opt($._attribute_argument, ","), ")")) ), _attribute_argument: ($) => choice( // labeled function parameters, used in custom property wrappers - seq($.simple_identifier, ":", $.expression), + seq(field("argument_name", $.simple_identifier), ":", field("argument", $.expression)), // Unlabeled function parameters, simple identifiers, or `*` - $.expression, + field("argument", $.expression), // References to param names (used in `@objc(foo:bar:)`) - repeat1(seq($.simple_identifier, ":")), + repeat1(seq(field("param_ref", $.simple_identifier), ":")), // Version restrictions (iOS 3.4.5, Swift 5.0.0) - seq(repeat1($.simple_identifier), sep1($.integer_literal, ".")) + seq(repeat1(field("platform", $.simple_identifier)), sep1(field("version", $.integer_literal), ".")) ), //////////////////////////////// // Patterns - https://docs.swift.org/swift-book/ReferenceManual/Patterns.html @@ -1952,12 +1952,12 @@ module.exports = grammar({ modifiers: ($) => repeat1( prec.left( - choice($._non_local_scope_modifier, $._locally_permitted_modifiers) + field("modifier", choice($._non_local_scope_modifier, $._locally_permitted_modifiers)) ) ), _locally_permitted_modifiers: ($) => repeat1(choice($.attribute, $._locally_permitted_modifier)), - parameter_modifiers: ($) => repeat1($.parameter_modifier), + parameter_modifiers: ($) => repeat1(field("modifier", $.parameter_modifier)), _modifier: ($) => choice($._non_local_scope_modifier, $._locally_permitted_modifier), _non_local_scope_modifier: ($) => @@ -1976,7 +1976,7 @@ module.exports = grammar({ $.property_behavior_modifier ), property_behavior_modifier: ($) => "lazy", - type_modifiers: ($) => repeat1($.attribute), + type_modifiers: ($) => repeat1(field("attribute", $.attribute)), member_modifier: ($) => choice("override", "convenience", "required", "nonisolated"), visibility_modifier: ($) => @@ -1991,7 +1991,7 @@ module.exports = grammar({ ), optional(seq("(", "set", ")")) ), - type_parameter_modifiers: ($) => repeat1($.attribute), + type_parameter_modifiers: ($) => repeat1(field("attribute", $.attribute)), function_modifier: ($) => choice("infix", "postfix", "prefix"), mutation_modifier: ($) => choice("mutating", "nonmutating"), property_modifier: ($) => diff --git a/unified/extractor/tree-sitter-swift/node-types.yml b/unified/extractor/tree-sitter-swift/node-types.yml index 219904ae939..4d4faf641d1 100644 --- a/unified/extractor/tree-sitter-swift/node-types.yml +++ b/unified/extractor/tree-sitter-swift/node-types.yml @@ -119,8 +119,8 @@ named: array_type: element: type as_expression: - $children: as_operator expr: expression + operator: as_operator type: type as_operator: assignment: @@ -128,13 +128,19 @@ named: result: expression target: directly_assignable_expression associatedtype_declaration: - $children*: [modifiers, type_constraints] default_value?: type + modifiers?: modifiers must_inherit?: type name: type_identifier + type_constraints?: type_constraints async_keyword: attribute: - $children+: [expression, user_type] + argument*: expression + argument_name*: simple_identifier + name: user_type + param_ref*: simple_identifier + platform*: simple_identifier + version*: integer_literal availability_condition: $children*: [identifier, integer_literal] await_expression: @@ -148,19 +154,23 @@ named: rhs: expression boolean_literal: call_expression: - $children+: [call_suffix, expression] + $children*: [call_suffix, expression] + function?: expression + suffix?: call_suffix call_suffix: $children+: [lambda_literal, value_arguments] name*: simple_identifier capture_list: - $children+: capture_list_item + item+: capture_list_item capture_list_item: - $children?: ownership_modifier name: [self_expression, simple_identifier] + ownership?: ownership_modifier value?: expression catch_block: - $children+: [catch_keyword, statements, where_clause] + body?: statements error?: pattern + keyword: catch_keyword + where?: where_clause catch_keyword: check_expression: op: "is" @@ -170,41 +180,54 @@ named: $children*: multiline_comment member*: type_level_declaration class_declaration: - $children*: [attribute, inheritance_modifier, inheritance_specifier, modifiers, ownership_modifier, property_behavior_modifier, type_constraints, type_parameters] + $children*: inheritance_specifier + attribute*: attribute body: [class_body, enum_class_body] declaration_kind: ["actor", "class", "enum", "extension", "struct"] + modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier] name: [type_identifier, unannotated_type] + type_constraints?: type_constraints + type_parameters?: type_parameters comment: comparison_expression: lhs: expression op: ["<", "<=", ">", ">="] rhs: expression computed_getter: - $children+: [attribute, getter_specifier, statements] + attribute*: attribute + body?: statements + specifier: getter_specifier computed_modify: - $children+: [attribute, modify_specifier, statements] + attribute*: attribute + body?: statements + specifier: modify_specifier computed_property: - $children*: [computed_getter, computed_modify, computed_setter, statements] + accessor*: [computed_getter, computed_modify, computed_setter] + body?: statements computed_setter: - $children+: [attribute, setter_specifier, simple_identifier, statements] + attribute*: attribute + body?: statements + parameter?: simple_identifier + specifier: setter_specifier conjunction_expression: lhs: expression op: "&&" rhs: expression constructor_expression: - $children: constructor_suffix constructed_type: [array_type, dictionary_type, user_type] + suffix: constructor_suffix constructor_suffix: $children+: [lambda_literal, value_arguments] name*: simple_identifier control_transfer_statement: $children*: [expression, throw_keyword] + kind?: ["break", "continue", "return", "yield"] result?: expression custom_operator: default_keyword: deinit_declaration: - $children?: modifiers body: function_body + modifiers?: modifiers deprecated_operator_declaration_body: $children*: [bin_literal, boolean_literal, hex_literal, integer_literal, line_string_literal, multi_line_string_literal, oct_literal, raw_string_literal, real_literal, regex_literal, simple_identifier] diagnostic: @@ -215,29 +238,32 @@ named: key: type value: type didset_clause: - $children*: [modifiers, simple_identifier, statements] + body?: statements + modifiers?: modifiers + parameter?: simple_identifier directive: $children*: [boolean_literal, integer_literal, simple_identifier] directly_assignable_expression: - $children: expression + expr: expression disjunction_expression: lhs: expression op: "||" rhs: expression do_statement: - $children*: [catch_block, statements] + body?: statements + catch*: catch_block else: enum_class_body: member*: [enum_entry, type_level_declaration] enum_entry: - $children?: modifiers data_contents*: enum_type_parameters + modifiers?: modifiers name+: simple_identifier raw_value*: expression enum_type_parameters: $children*: [expression, type, wildcard_pattern] equality_constraint: - $children*: attribute + attribute*: attribute constrained_type: [identifier, nested_type_identifier] must_equal: type equality_expression: @@ -245,107 +271,137 @@ named: op: ["!=", "!==", "==", "==="] rhs: expression existential_type: - $children: unannotated_type + name: unannotated_type external_macro_definition: - $children: value_arguments + arguments: value_arguments for_statement: - $children*: [statements, try_operator, type_annotation, where_clause] + body?: statements collection: expression item: pattern + try?: try_operator + type?: type_annotation + where?: where_clause fully_open_range: function_body: - $children?: statements + body?: statements function_declaration: - $children*: [attribute, inheritance_modifier, modifiers, ownership_modifier, parameter, property_behavior_modifier, throws, throws_clause, type_constraints, type_parameters] + async?: "async" + attribute*: attribute body: function_body default_value*: expression + modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier] name: [referenceable_operator, simple_identifier] + parameter*: parameter return_type?: [implicitly_unwrapped_type, type] + throws?: [throws, throws_clause] + type_constraints?: type_constraints + type_parameters?: type_parameters function_modifier: function_type: - $children?: [throws, throws_clause] + async?: "async" params: unannotated_type return_type: type + throws?: [throws, throws_clause] getter_specifier: - $children?: mutation_modifier effect*: [async_keyword, throws, throws_clause] + mutation?: mutation_modifier guard_statement: - $children+: [else, statements] + body?: statements condition+: if_condition + else_keyword: else hex_literal: identifier: - $children+: simple_identifier + part+: simple_identifier if_condition: - $children: [availability_condition, expression, if_let_binding] + kind: [availability_condition, expression, if_let_binding] if_let_binding: - $children*: [expression, pattern, type, type_annotation, user_type, value_binding_pattern, where_clause, wildcard_pattern] + $children*: [pattern, simple_identifier, type, type_annotation, user_type, value_binding_pattern, wildcard_pattern] bound_identifier?: simple_identifier + value?: expression + where?: where_clause if_statement: - $children*: [else, if_statement, statements] + body*: statements condition+: if_condition + else_branch?: if_statement + else_keyword?: else implicitly_unwrapped_type: - $children: type + name: type import_declaration: - $children+: [identifier, modifiers] + modifiers?: modifiers + name: identifier infix_expression: lhs: expression op: custom_operator rhs: expression inheritance_constraint: - $children*: attribute + attribute*: attribute constrained_type: [identifier, nested_type_identifier] inherits_from: [implicitly_unwrapped_type, type] inheritance_modifier: inheritance_specifier: inherits_from: [function_type, suppressed_constraint, user_type] init_declaration: - $children*: [attribute, bang, modifiers, parameter, throws, throws_clause, type_constraints, type_parameters] + async?: "async" + attribute*: attribute + bang?: bang body?: function_body default_value*: expression + modifiers?: modifiers name: "init" + parameter*: parameter + throws?: [throws, throws_clause] + type_constraints?: type_constraints + type_parameters?: type_parameters integer_literal: interpolated_expression: - $children?: type_modifiers name?: value_argument_label reference_specifier*: value_argument_label + type_modifiers?: type_modifiers value?: expression key_path_expression: $children*: [array_type, bang, dictionary_type, simple_identifier, type_arguments, type_identifier, value_argument] key_path_string_expression: - $children: expression + expr: expression lambda_function_type: - $children*: [lambda_function_type_parameters, throws, throws_clause] + async?: "async" + params?: lambda_function_type_parameters return_type?: [implicitly_unwrapped_type, type] + throws?: [throws, throws_clause] lambda_function_type_parameters: - $children+: lambda_parameter + parameter+: lambda_parameter lambda_literal: - $children*: [attribute, statements] + attribute*: attribute + body?: statements captures?: capture_list type?: lambda_function_type lambda_parameter: - $children?: [parameter_modifiers, self_expression] external_name?: simple_identifier - name?: simple_identifier + modifiers?: parameter_modifiers + name: [self_expression, simple_identifier] type?: [implicitly_unwrapped_type, type] line_str_text: line_string_literal: interpolation*: interpolated_expression text*: [line_str_text, str_escaped_char] macro_declaration: - $children+: [attribute, modifiers, parameter, simple_identifier, type_constraints, type_parameters, unannotated_type] + $children+: [modifiers, simple_identifier, type_constraints, type_parameters, unannotated_type] + attribute*: attribute default_value*: expression definition?: macro_definition + parameter*: parameter macro_definition: body: [expression, external_macro_definition] macro_invocation: - $children+: [call_suffix, simple_identifier, type_parameters] + name: simple_identifier + suffix: call_suffix + type_parameters?: type_parameters member_modifier: metatype: - $children: unannotated_type + name: unannotated_type modifiers: - $children+: [attribute, function_modifier, inheritance_modifier, member_modifier, mutation_modifier, ownership_modifier, parameter_modifier, property_behavior_modifier, property_modifier, visibility_modifier] + modifier+: [attribute, function_modifier, inheritance_modifier, member_modifier, mutation_modifier, ownership_modifier, parameter_modifier, property_behavior_modifier, property_modifier, visibility_modifier] modify_specifier: - $children?: mutation_modifier + mutation?: mutation_modifier multi_line_str_text: multi_line_string_literal: interpolation*: interpolated_expression @@ -362,76 +418,97 @@ named: navigation_suffix: suffix: [integer_literal, simple_identifier] nested_type_identifier: - $children+: [simple_identifier, unannotated_type] + base: unannotated_type + member*: simple_identifier nil_coalescing_expression: if_nil: expression value: expression oct_literal: opaque_type: - $children: unannotated_type + name: unannotated_type open_end_range_expression: start: expression open_start_range_expression: end: expression operator_declaration: - $children+: [deprecated_operator_declaration_body, referenceable_operator, simple_identifier] + body?: deprecated_operator_declaration_body + kind: ["infix", "postfix", "prefix"] + name: referenceable_operator + precedence_group?: simple_identifier optional_chain_marker: - $children: expression + expr: expression optional_type: wrapped: [array_type, dictionary_type, tuple_type, user_type] ownership_modifier: parameter: - $children?: parameter_modifiers external_name?: simple_identifier + modifiers?: parameter_modifiers name: simple_identifier type: [implicitly_unwrapped_type, type] parameter_modifier: parameter_modifiers: - $children+: parameter_modifier + modifier+: parameter_modifier pattern: $children*: [expression, pattern, type, user_type, value_binding_pattern, wildcard_pattern] bound_identifier?: simple_identifier playground_literal: - $children+: expression + name+: simple_identifier + value+: expression postfix_expression: operation: ["++", "--", bang] target: expression precedence_group_attribute: - $children+: [boolean_literal, simple_identifier] + name: simple_identifier + value: [boolean_literal, simple_identifier] precedence_group_attributes: - $children+: precedence_group_attribute + attribute+: precedence_group_attribute precedence_group_declaration: - $children+: [precedence_group_attributes, simple_identifier] + attributes?: precedence_group_attributes + name: simple_identifier prefix_expression: operation: ["&", "+", "++", "-", "--", ".", bang, custom_operator, "~"] target: expression property_behavior_modifier: property_declaration: - $children*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier, type_annotation, type_constraints, value_binding_pattern, willset_didset_block] + $children*: [type_annotation, type_constraints, value_binding_pattern, willset_didset_block] computed_value*: computed_property + modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier] name+: pattern value*: expression property_modifier: protocol_body: member*: protocol_member_declaration protocol_composition_type: - $children+: unannotated_type + type+: unannotated_type protocol_declaration: - $children*: [attribute, inheritance_specifier, modifiers, type_constraints, type_parameters] + $children*: inheritance_specifier + attribute*: attribute body: protocol_body declaration_kind: "protocol" + modifiers?: modifiers name: type_identifier + type_constraints?: type_constraints + type_parameters?: type_parameters protocol_function_declaration: - $children*: [attribute, modifiers, parameter, throws, throws_clause, type_constraints, type_parameters] + async?: "async" + attribute*: attribute body?: function_body default_value*: expression + modifiers?: modifiers name: [referenceable_operator, simple_identifier] + parameter*: parameter return_type?: [implicitly_unwrapped_type, type] + throws?: [throws, throws_clause] + type_constraints?: type_constraints + type_parameters?: type_parameters protocol_property_declaration: - $children+: [modifiers, protocol_property_requirements, type_annotation, type_constraints] + modifiers?: modifiers name: pattern + requirements: protocol_property_requirements + type?: type_annotation + type_constraints?: type_constraints protocol_property_requirements: - $children*: [getter_specifier, setter_specifier] + accessor*: [getter_specifier, setter_specifier] range_expression: end: expression op: ["...", "..<"] @@ -439,26 +516,26 @@ named: raw_str_continuing_indicator: raw_str_end_part: raw_str_interpolation: - $children: raw_str_interpolation_start interpolation+: interpolated_expression + start: raw_str_interpolation_start raw_str_interpolation_start: raw_str_part: raw_string_literal: - $children*: raw_str_continuing_indicator + continuing*: raw_str_continuing_indicator interpolation*: raw_str_interpolation text+: [raw_str_end_part, raw_str_part] real_literal: referenceable_operator: - $children?: [bang, custom_operator] + operator: ["!=", "!==", "%", "%=", "&", "*", "*=", "+", "++", "+=", "-", "--", "-=", "/", "/=", "<", "<<", "<=", "=", "==", "===", ">", ">=", ">>", "^", bang, custom_operator, "|", "~"] regex_literal: repeat_while_statement: - $children?: statements + body?: statements condition+: if_condition selector_expression: - $children: expression + expr: expression self_expression: setter_specifier: - $children?: mutation_modifier + mutation?: mutation_modifier shebang_line: simple_identifier: source_file: @@ -470,9 +547,14 @@ named: statement+: [control_transfer_statement, do_statement, expression, for_statement, guard_statement, local_declaration, repeat_while_statement, statement_label, while_statement] str_escaped_char: subscript_declaration: - $children+: [attribute, computed_property, modifiers, parameter, type_constraints, type_parameters] + attribute*: attribute + body: computed_property default_value*: expression + modifiers?: modifiers + parameter*: parameter return_type?: [implicitly_unwrapped_type, type] + type_constraints?: type_constraints + type_parameters?: type_parameters super_expression: suppressed_constraint: suppressed: type_identifier @@ -481,7 +563,7 @@ named: switch_pattern: $children: pattern switch_statement: - $children*: switch_entry + entry*: switch_entry expr: expression ternary_expression: condition: expression @@ -492,8 +574,8 @@ named: throws_clause: type: unannotated_type try_expression: - $children: try_operator expr: expression + operator: try_operator try_operator: tuple_expression: name*: simple_identifier @@ -502,7 +584,8 @@ named: $children?: tuple_type_item element*: tuple_type_item tuple_type_item: - $children*: [dictionary_type, existential_type, opaque_type, parameter_modifiers, wildcard_pattern] + $children?: [dictionary_type, existential_type, opaque_type, wildcard_pattern] + modifiers?: parameter_modifiers name?: simple_identifier type?: type type: @@ -511,57 +594,66 @@ named: type_annotation: type: [implicitly_unwrapped_type, type] type_arguments: - $children+: type + argument+: type type_constraint: - $children: [equality_constraint, inheritance_constraint] + constraint: [equality_constraint, inheritance_constraint] type_constraints: - $children+: [type_constraint, where_keyword] + constraint+: type_constraint + keyword: where_keyword type_identifier: type_modifiers: - $children+: attribute + attribute+: attribute type_pack_expansion: - $children: unannotated_type + name: unannotated_type type_parameter: - $children+: [type, type_identifier, type_parameter_modifiers, type_parameter_pack] + modifiers?: type_parameter_modifiers + name: [type_identifier, type_parameter_pack] + type?: type type_parameter_modifiers: - $children+: attribute + attribute+: attribute type_parameter_pack: - $children: unannotated_type + name: unannotated_type type_parameters: - $children+: [type_constraints, type_parameter] + constraints?: type_constraints + parameter+: type_parameter typealias_declaration: - $children*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier, type_parameters] + modifiers*: [attribute, inheritance_modifier, modifiers, ownership_modifier, property_behavior_modifier] name: type_identifier + type_parameters?: type_parameters value: type user_type: - $children+: [type_arguments, type_identifier] + part+: [type_arguments, type_identifier] value_argument: - $children?: type_modifiers name?: value_argument_label reference_specifier*: value_argument_label + type_modifiers?: type_modifiers value?: expression value_argument_label: $children: simple_identifier value_arguments: - $children*: value_argument + argument*: value_argument value_binding_pattern: mutability: ["let", "var"] value_pack_expansion: - $children: expression + expr: expression value_parameter_pack: - $children: expression + expr: expression visibility_modifier: where_clause: - $children+: [expression, where_keyword] + expr: expression + keyword: where_keyword where_keyword: while_statement: - $children?: statements + body?: statements condition+: if_condition wildcard_pattern: willset_clause: - $children*: [modifiers, simple_identifier, statements] + body?: statements + modifiers?: modifiers + parameter?: simple_identifier willset_didset_block: - $children+: [didset_clause, willset_clause] + didset?: didset_clause + willset?: willset_clause unnamed: - "?"