@willbooster/tree-sitter-rust 1.2.1 → 1.3.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/grammar.js CHANGED
@@ -1204,15 +1204,26 @@ module.exports = grammar({
1204
1204
 
1205
1205
  struct_pattern: ($) =>
1206
1206
  seq(
1207
- field('type', choice($._type_identifier, $.scoped_type_identifier)),
1207
+ field(
1208
+ 'type',
1209
+ choice($._type_identifier, $.scoped_type_identifier, alias($._generic_struct_pattern_type, $.generic_type))
1210
+ ),
1208
1211
  '{',
1209
1212
  sepBy(',', choice($.field_pattern, $.remaining_field_pattern)),
1210
1213
  optional(','),
1211
1214
  '}'
1212
1215
  ),
1213
1216
 
1217
+ _generic_struct_pattern_type: ($) =>
1218
+ seq(
1219
+ field('type', choice($._type_identifier, $.scoped_type_identifier)),
1220
+ '::',
1221
+ field('type_arguments', $.type_arguments)
1222
+ ),
1223
+
1214
1224
  field_pattern: ($) =>
1215
1225
  seq(
1226
+ repeat($.attribute_item),
1216
1227
  optional('ref'),
1217
1228
  optional($.mutable_specifier),
1218
1229
  choice(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-rust",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Rust grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -1,20 +1,14 @@
1
- ; Identifiers
2
-
3
1
  (type_identifier) @type
4
2
  (primitive_type) @type.builtin
5
3
  (field_identifier) @property
6
4
 
7
- ; Identifier conventions
8
5
 
9
- ; Assume all-caps names are constants
10
6
  ((identifier) @constant
11
7
  (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
12
8
 
13
- ; Assume uppercase names are enum constructors
14
9
  ((identifier) @constructor
15
10
  (#match? @constructor "^[A-Z]"))
16
11
 
17
- ; Assume that uppercase names in paths are types
18
12
  ((scoped_identifier
19
13
  path: (identifier) @type)
20
14
  (#match? @type "^[A-Z]"))
@@ -36,8 +30,11 @@
36
30
  (struct_pattern
37
31
  type: (scoped_type_identifier
38
32
  name: (type_identifier) @constructor))
33
+ (struct_pattern
34
+ type: (generic_type
35
+ type: (scoped_type_identifier
36
+ name: (type_identifier) @constructor)))
39
37
 
40
- ; Function calls
41
38
 
42
39
  (call_expression
43
40
  function: (identifier) @function)
@@ -64,7 +61,6 @@
64
61
 
65
62
  (decl_macro name: (identifier) @function.macro)
66
63
 
67
- ; Function definitions
68
64
 
69
65
  (function_item (identifier) @function)
70
66
  (function_signature_item (identifier) @function)
@@ -1963,9 +1963,13 @@
1963
1963
  }
1964
1964
  },
1965
1965
  "children": {
1966
- "multiple": false,
1966
+ "multiple": true,
1967
1967
  "required": false,
1968
1968
  "types": [
1969
+ {
1970
+ "type": "attribute_item",
1971
+ "named": true
1972
+ },
1969
1973
  {
1970
1974
  "type": "mutable_specifier",
1971
1975
  "named": true
@@ -3918,6 +3922,10 @@
3918
3922
  "multiple": false,
3919
3923
  "required": true,
3920
3924
  "types": [
3925
+ {
3926
+ "type": "generic_type",
3927
+ "named": true
3928
+ },
3921
3929
  {
3922
3930
  "type": "scoped_type_identifier",
3923
3931
  "named": true
Binary file
package/tree-sitter.json CHANGED
@@ -22,7 +22,7 @@
22
22
  }
23
23
  ],
24
24
  "metadata": {
25
- "version": "1.2.1",
25
+ "version": "1.3.0",
26
26
  "license": "MIT",
27
27
  "description": "Rust grammar for tree-sitter",
28
28
  "authors": [