|
34 | 34 | (export_statement |
35 | 35 | (lexical_declaration |
36 | 36 | ["let" "const"] @context |
37 | | - ; Multiple names may be exported - @item is on the declarator to keep |
38 | | - ; ranges distinct. |
39 | 37 | (variable_declarator |
40 | | - name: (_) @name) @item)) |
| 38 | + name: (identifier) @name) @item)) |
41 | 39 |
|
| 40 | +; Exported array destructuring |
| 41 | +(export_statement |
| 42 | + (lexical_declaration |
| 43 | + ["let" "const"] @context |
| 44 | + (variable_declarator |
| 45 | + name: (array_pattern |
| 46 | + [ |
| 47 | + (identifier) @name @item |
| 48 | + (assignment_pattern left: (identifier) @name @item) |
| 49 | + (rest_pattern (identifier) @name @item) |
| 50 | + ])))) |
| 51 | + |
| 52 | +; Exported object destructuring |
| 53 | +(export_statement |
| 54 | + (lexical_declaration |
| 55 | + ["let" "const"] @context |
| 56 | + (variable_declarator |
| 57 | + name: (object_pattern |
| 58 | + [(shorthand_property_identifier_pattern) @name @item |
| 59 | + (pair_pattern |
| 60 | + value: (identifier) @name @item) |
| 61 | + (pair_pattern |
| 62 | + value: (assignment_pattern left: (identifier) @name @item)) |
| 63 | + (rest_pattern (identifier) @name @item)])))) |
| 64 | + |
| 65 | +(program |
| 66 | + (lexical_declaration |
| 67 | + ["let" "const"] @context |
| 68 | + (variable_declarator |
| 69 | + name: (identifier) @name) @item)) |
| 70 | + |
| 71 | +; Top-level array destructuring |
42 | 72 | (program |
43 | 73 | (lexical_declaration |
44 | 74 | ["let" "const"] @context |
45 | | - ; Multiple names may be defined - @item is on the declarator to keep |
46 | | - ; ranges distinct. |
47 | 75 | (variable_declarator |
48 | | - name: (_) @name) @item)) |
| 76 | + name: (array_pattern |
| 77 | + [ |
| 78 | + (identifier) @name @item |
| 79 | + (assignment_pattern left: (identifier) @name @item) |
| 80 | + (rest_pattern (identifier) @name @item) |
| 81 | + ])))) |
| 82 | + |
| 83 | +; Top-level object destructuring |
| 84 | +(program |
| 85 | + (lexical_declaration |
| 86 | + ["let" "const"] @context |
| 87 | + (variable_declarator |
| 88 | + name: (object_pattern |
| 89 | + [(shorthand_property_identifier_pattern) @name @item |
| 90 | + (pair_pattern |
| 91 | + value: (identifier) @name @item) |
| 92 | + (pair_pattern |
| 93 | + value: (assignment_pattern left: (identifier) @name @item)) |
| 94 | + (rest_pattern (identifier) @name @item)])))) |
49 | 95 |
|
50 | 96 | (class_declaration |
51 | 97 | "class" @context |
|
56 | 102 | "class" @context |
57 | 103 | name: (_) @name) @item |
58 | 104 |
|
59 | | -(method_definition |
60 | | - [ |
61 | | - "get" |
62 | | - "set" |
63 | | - "async" |
64 | | - "*" |
65 | | - "readonly" |
66 | | - "static" |
67 | | - (override_modifier) |
68 | | - (accessibility_modifier) |
69 | | - ]* @context |
70 | | - name: (_) @name |
71 | | - parameters: (formal_parameters |
72 | | - "(" @context |
73 | | - ")" @context)) @item |
| 105 | +; Method definitions in classes (not in object literals) |
| 106 | +(class_body |
| 107 | + (method_definition |
| 108 | + [ |
| 109 | + "get" |
| 110 | + "set" |
| 111 | + "async" |
| 112 | + "*" |
| 113 | + "readonly" |
| 114 | + "static" |
| 115 | + (override_modifier) |
| 116 | + (accessibility_modifier) |
| 117 | + ]* @context |
| 118 | + name: (_) @name |
| 119 | + parameters: (formal_parameters |
| 120 | + "(" @context |
| 121 | + ")" @context)) @item) |
| 122 | + |
| 123 | +; Object literal methods |
| 124 | +(variable_declarator |
| 125 | + value: (object |
| 126 | + (method_definition |
| 127 | + [ |
| 128 | + "get" |
| 129 | + "set" |
| 130 | + "async" |
| 131 | + "*" |
| 132 | + ]* @context |
| 133 | + name: (_) @name |
| 134 | + parameters: (formal_parameters |
| 135 | + "(" @context |
| 136 | + ")" @context)) @item)) |
74 | 137 |
|
75 | 138 | (public_field_definition |
76 | 139 | [ |
|
124 | 187 | ) |
125 | 188 | ) @item |
126 | 189 |
|
| 190 | +; Object properties |
| 191 | +(pair |
| 192 | + key: [ |
| 193 | + (property_identifier) @name |
| 194 | + (string (string_fragment) @name) |
| 195 | + (number) @name |
| 196 | + (computed_property_name) @name |
| 197 | + ]) @item |
| 198 | + |
| 199 | + |
| 200 | +; Nested variables in function bodies |
| 201 | +(statement_block |
| 202 | + (lexical_declaration |
| 203 | + ["let" "const"] @context |
| 204 | + (variable_declarator |
| 205 | + name: (identifier) @name) @item)) |
| 206 | + |
| 207 | +; Nested array destructuring in functions |
| 208 | +(statement_block |
| 209 | + (lexical_declaration |
| 210 | + ["let" "const"] @context |
| 211 | + (variable_declarator |
| 212 | + name: (array_pattern |
| 213 | + [ |
| 214 | + (identifier) @name @item |
| 215 | + (assignment_pattern left: (identifier) @name @item) |
| 216 | + (rest_pattern (identifier) @name @item) |
| 217 | + ])))) |
| 218 | + |
| 219 | +; Nested object destructuring in functions |
| 220 | +(statement_block |
| 221 | + (lexical_declaration |
| 222 | + ["let" "const"] @context |
| 223 | + (variable_declarator |
| 224 | + name: (object_pattern |
| 225 | + [(shorthand_property_identifier_pattern) @name @item |
| 226 | + (pair_pattern value: (identifier) @name @item) |
| 227 | + (pair_pattern value: (assignment_pattern left: (identifier) @name @item)) |
| 228 | + (rest_pattern (identifier) @name @item)])))) |
| 229 | + |
127 | 230 | (comment) @annotation |
0 commit comments