Commit 00d9cff
committed
tree-sitter: capture destructuring rename keys (95.3% -> 95.9%)
A `{ key: binding }` destructuring property names a property, but a blanket
`(binding_property (ident) …)` capture would also hit a shorthand `{ a }`, where the
identifier IS the binding (that mistake cost 14 tokens in an earlier attempt). Detect
rules with a `[ identifier, ':', ruleRef ]` branch and anchor the @Property capture on
the trailing element rule, so shorthand bindings stay @variable. Skip the
self-referential `Stmt: Ident ':' Stmt` shape — a labeled statement is a jump target,
not a destructuring key.
This closes the last cleanly-structural gap: 95.9% vs official tree-sitter 92.7%. The
~22 remaining misses are parser-level (the `<`/`>` comparison-vs-generic ambiguity and
template tails, which the official grammars also miss) or niche edge positions
(template-literal types, `typeof X` in a type, tuple element labels) where a query
pattern would mis-paint conditional-type idents. Regenerate TS + JS artifacts.1 parent e9ca26c commit 00d9cff
4 files changed
Lines changed: 32 additions & 2 deletions
File tree
- examples/tree-sitter
- javascript/queries
- typescript/queries
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
1004 | 1009 | | |
1005 | 1010 | | |
1006 | 1011 | | |
| |||
1324 | 1329 | | |
1325 | 1330 | | |
1326 | 1331 | | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1327 | 1355 | | |
1328 | 1356 | | |
1329 | 1357 | | |
| |||
0 commit comments