@willbooster/tree-sitter-rust 14.0.5 → 14.0.6

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/grammar.js CHANGED
@@ -310,7 +310,11 @@ module.exports = grammar({
310
310
  ),
311
311
 
312
312
  _associated_attributable_declaration: ($) =>
313
- attributableDeclaration($, alias($._associated_const_item, $.const_item)),
313
+ attributableDeclaration(
314
+ $,
315
+ alias($._associated_const_item, $.const_item),
316
+ alias($._associated_type_item, $.type_item)
317
+ ),
314
318
 
315
319
  _associated_attributed_declaration: ($) =>
316
320
  seq($._outer_attributes, field('declaration', $._associated_attributable_declaration)),
@@ -634,7 +638,9 @@ module.exports = grammar({
634
638
  const_item: ($) => constItem($, choice($.identifier, $._reserved_identifier, alias('_', $.identifier))),
635
639
 
636
640
  _associated_const_item: ($) =>
637
- constItem($, choice(reserved('associated_const_name', $.identifier), $._reserved_identifier)),
641
+ constItem($, choice(reserved('associated_const_name', $.identifier), $._reserved_identifier), [
642
+ optional('default'),
643
+ ]),
638
644
 
639
645
  static_item: ($) => seq(optional($.visibility_modifier), $._static_declaration),
640
646
 
@@ -653,18 +659,9 @@ module.exports = grammar({
653
659
  ';'
654
660
  ),
655
661
 
656
- type_item: ($) =>
657
- seq(
658
- optional($.visibility_modifier),
659
- 'type',
660
- field('name', $._type_identifier),
661
- field('type_parameters', optional($.type_parameters)),
662
- optional($.where_clause),
663
- '=',
664
- field('type', $._type),
665
- optional($.where_clause),
666
- ';'
667
- ),
662
+ type_item: ($) => typeItem($),
663
+
664
+ _associated_type_item: ($) => typeItem($, [optional('default')]),
668
665
 
669
666
  function_item: ($) =>
670
667
  seq(
@@ -2000,8 +1997,9 @@ module.exports = grammar({
2000
1997
  /**
2001
1998
  * @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'empty_statement' | 'inner_attribute_item' | 'macro_invocation' | 'macro_definition' | 'decl_macro' | 'mod_item' | 'foreign_mod_item' | 'struct_item' | 'union_item' | 'enum_item' | 'type_item' | 'function_item' | 'function_signature_item' | 'impl_item' | 'trait_item' | 'trait_alias' | 'associated_type' | 'let_declaration' | 'use_declaration' | 'extern_crate_declaration' | 'static_item' | '_safe_function_signature_item' | '_qualified_static_item'>} $
2002
1999
  * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} constant
2000
+ * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} [typeAlias]
2003
2001
  */
2004
- function attributableDeclaration($, constant) {
2002
+ function attributableDeclaration($, constant, typeAlias = $.type_item) {
2005
2003
  return choice(
2006
2004
  constant,
2007
2005
  $.macro_invocation,
@@ -2012,7 +2010,7 @@ function attributableDeclaration($, constant) {
2012
2010
  $.struct_item,
2013
2011
  $.union_item,
2014
2012
  $.enum_item,
2015
- $.type_item,
2013
+ typeAlias,
2016
2014
  $.function_item,
2017
2015
  $.function_signature_item,
2018
2016
  $.impl_item,
@@ -2031,10 +2029,12 @@ function attributableDeclaration($, constant) {
2031
2029
  /**
2032
2030
  * @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'visibility_modifier' | '_type' | '_expression'>} $
2033
2031
  * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} name
2032
+ * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral[]} [modifier]
2034
2033
  */
2035
- function constItem($, name) {
2034
+ function constItem($, name, modifier = []) {
2036
2035
  return seq(
2037
2036
  optional($.visibility_modifier),
2037
+ ...modifier,
2038
2038
  'const',
2039
2039
  field('name', name),
2040
2040
  ':',
@@ -2044,6 +2044,25 @@ function constItem($, name) {
2044
2044
  );
2045
2045
  }
2046
2046
 
2047
+ /**
2048
+ * @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'visibility_modifier' | '_type_identifier' | 'type_parameters' | 'where_clause' | '_type'>} $
2049
+ * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral[]} [modifier]
2050
+ */
2051
+ function typeItem($, modifier = []) {
2052
+ return seq(
2053
+ optional($.visibility_modifier),
2054
+ ...modifier,
2055
+ 'type',
2056
+ field('name', $._type_identifier),
2057
+ field('type_parameters', optional($.type_parameters)),
2058
+ optional($.where_clause),
2059
+ '=',
2060
+ field('type', $._type),
2061
+ optional($.where_clause),
2062
+ ';'
2063
+ );
2064
+ }
2065
+
2047
2066
  /**
2048
2067
  * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} start
2049
2068
  * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} content
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-rust",
3
- "version": "14.0.5",
3
+ "version": "14.0.6",
4
4
  "description": "Rust grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -25,7 +25,7 @@
25
25
  }
26
26
  ],
27
27
  "metadata": {
28
- "version": "14.0.5",
28
+ "version": "14.0.6",
29
29
  "license": "MIT",
30
30
  "description": "Rust grammar for tree-sitter",
31
31
  "authors": [