@willbooster/tree-sitter-javascript 15.0.1 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,7 +70,8 @@ parser.setLanguage(await Language.load(javascript));
70
70
 
71
71
  The package also ships the node types in `src/node-types.json`, the highlight, injection, locals, and tags queries in
72
72
  `queries/` that `tree-sitter.json` lists, and `grammar.js` for grammars that extend this one (e.g.
73
- `require('@willbooster/tree-sitter-javascript/grammar')`). The crate ships `tree-sitter.json` and `queries/` too.
73
+ `require('@willbooster/tree-sitter-javascript/grammar')`). Its JSDoc describes the array/formal and object-rest
74
+ extension hooks. The crate ships `tree-sitter.json` and `queries/` too.
74
75
 
75
76
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-javascript) and the
76
77
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 15.0.0:
@@ -78,7 +79,7 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
78
79
  ```toml
79
80
  [dependencies]
80
81
  tree-sitter = { package = "willbooster-tree-sitter", version = "15.0.0" }
81
- tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "13" }
82
+ tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "16" }
82
83
  ```
83
84
 
84
85
  ```rust
package/grammar.js CHANGED
@@ -175,6 +175,7 @@ module.exports = grammar({
175
175
  $._jsx_attribute_value,
176
176
  $._jsx_identifier,
177
177
  $._lhs_expression,
178
+ $._object_rest_target,
178
179
  ],
179
180
 
180
181
  precedences: ($) => [
@@ -221,6 +222,7 @@ module.exports = grammar({
221
222
  [$._call_callee, $.call_expression],
222
223
  [$.for_in_clause, $._primary_atom],
223
224
  [$._primary_atom, $.rest_pattern],
225
+ [$._primary_atom, $._object_rest_pattern],
224
226
  [$._primary_atom, $._non_rest_pattern],
225
227
  [$.arrow_function, $._primary_atom],
226
228
  [$._primary_atom, $.await_expression],
@@ -228,6 +230,7 @@ module.exports = grammar({
228
230
  [$.primary_expression, $._assignment_call_primary],
229
231
  [$._local_export_specifier, $._module_export_name],
230
232
  [$.primary_expression, $.rest_pattern],
233
+ [$.primary_expression, $._object_rest_pattern],
231
234
  [$.primary_expression, $._non_rest_pattern],
232
235
  [$.primary_expression, $.for_in_clause],
233
236
  [$.array, $.array_pattern],
@@ -713,7 +716,12 @@ module.exports = grammar({
713
716
  );
714
717
  return prec(
715
718
  'object',
716
- seq('{', repeat(seq(optional(property), ',')), optional(choice(property, $.rest_pattern)), '}')
719
+ seq(
720
+ '{',
721
+ repeat(seq(optional(property), ',')),
722
+ optional(choice(property, alias($._object_rest_pattern, $.rest_pattern))),
723
+ '}'
724
+ )
717
725
  );
718
726
  },
719
727
 
@@ -1669,8 +1677,8 @@ module.exports = grammar({
1669
1677
  class_static_block: ($) => seq('static', field('body', alias($._class_member_body, $.statement_block))),
1670
1678
 
1671
1679
  /**
1672
- * Canonical pattern supertype. Extend `_non_rest_pattern` for non-rest forms and
1673
- * `rest_pattern` for rest syntax; overriding only `pattern` does not extend ordinary slots.
1680
+ * Canonical pattern supertype. Extend `_non_rest_pattern` for non-rest forms;
1681
+ * overriding only `pattern` does not extend ordinary slots.
1674
1682
  */
1675
1683
  pattern: ($) => choice(alias($._non_rest_pattern, $.pattern), alias($._rest_pattern, $.pattern)),
1676
1684
 
@@ -1680,11 +1688,28 @@ module.exports = grammar({
1680
1688
 
1681
1689
  _rest_pattern: ($) => prec.dynamic(-1, $.rest_pattern),
1682
1690
 
1691
+ /** Array-pattern and formal-parameter rest syntax; object rest uses `_object_rest_pattern`. */
1683
1692
  rest_pattern: ($) =>
1684
1693
  prec.right(
1685
1694
  seq('...', choice($._lhs_expression, alias($._parenthesized_simple_target, $.parenthesized_expression)))
1686
1695
  ),
1687
1696
 
1697
+ /**
1698
+ * Object-rest syntax, aliased to public `rest_pattern`. Extend `_object_rest_target`
1699
+ * for target forms; `rest_pattern` and `_lhs_expression` overrides do not extend object rest.
1700
+ */
1701
+ _object_rest_pattern: ($) => prec.right(seq('...', $._object_rest_target)),
1702
+
1703
+ /** Object-rest reference targets, excluding nested destructuring patterns. */
1704
+ _object_rest_target: ($) =>
1705
+ choice(
1706
+ $.member_expression,
1707
+ $.subscript_expression,
1708
+ $._identifier,
1709
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1710
+ alias($._parenthesized_simple_target, $.parenthesized_expression)
1711
+ ),
1712
+
1688
1713
  method_definition: ($) =>
1689
1714
  functionContext((async) =>
1690
1715
  choice(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "15.0.1",
3
+ "version": "16.0.0",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -48,7 +48,7 @@
48
48
  }
49
49
  ],
50
50
  "metadata": {
51
- "version": "15.0.1",
51
+ "version": "16.0.0",
52
52
  "license": "MIT",
53
53
  "description": "JavaScript grammar for tree-sitter",
54
54
  "authors": [