@willbooster/tree-sitter-javascript 17.0.0 → 19.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 +19 -20
- package/grammar.js +34 -24
- package/package.json +9 -10
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter-javascript_script.wasm +0 -0
- package/tree-sitter.json +1 -17
- package/queries/highlights-jsx.scm +0 -8
- package/queries/highlights-params.scm +0 -12
- package/queries/highlights.scm +0 -216
- package/queries/injections.scm +0 -31
- package/queries/locals.scm +0 -23
- package/queries/tags.scm +0 -115
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-javascript)
|
|
10
10
|
|
|
11
11
|
JavaScript and JSX grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
@@ -15,17 +15,24 @@ to its authors and contributors. This is not an official release of that project
|
|
|
15
15
|
This fork fixes parsing bugs and raises conformance with [ECMAScript (ECMA-262)](https://tc39.es/ecma262/) and
|
|
16
16
|
[JSX](https://facebook.github.io/jsx/).
|
|
17
17
|
|
|
18
|
+
## Support Scope
|
|
19
|
+
|
|
20
|
+
This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
|
|
21
|
+
nodes without crashing, hanging, or taking more than linear time. Incremental parsing works as in upstream tree-sitter
|
|
22
|
+
but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
|
|
23
|
+
the trees that error recovery produces may change; such changes are released as new major versions.
|
|
24
|
+
|
|
18
25
|
## Usage
|
|
19
26
|
|
|
20
27
|
The npm package ships two languages for
|
|
21
28
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
22
29
|
browsers, and Cloudflare Workers. The parser carries the ABI number of WillBooster/tree-sitter (`0x5742000b`), so it
|
|
23
|
-
requires that runtime ABI; the upstream runtime rejects it. This package is tested with runtime 15.
|
|
30
|
+
requires that runtime ABI; the upstream runtime rejects it. This package is tested with runtime 15.5.4, and its optional peer dependency covers major 15. In Node.js and Bun, load it from
|
|
24
31
|
the package. Choose `tree-sitter-javascript.wasm` for the Module goal, or
|
|
25
32
|
`tree-sitter-javascript_script.wasm` for the Script goal. The source goal comes from the host or file type;
|
|
26
33
|
`.mjs` uses Module and `.cjs` uses Script, while `.js` depends on the host. For example, `await\nvalue` is one
|
|
27
34
|
await expression in a Module and two identifier statements in a Script. Both languages preserve the same node
|
|
28
|
-
schema
|
|
35
|
+
schema. As with other tree-sitter grammars, parsing does not enforce every ECMAScript early error.
|
|
29
36
|
For the native CLI, select Script with `tree-sitter parse --grammar-path grammars/script`.
|
|
30
37
|
|
|
31
38
|
```js
|
|
@@ -68,18 +75,16 @@ const parser = new Parser();
|
|
|
68
75
|
parser.setLanguage(await Language.load(javascript));
|
|
69
76
|
```
|
|
70
77
|
|
|
71
|
-
The package also ships the node types in `src/node-types.json`,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
extension hooks. The crate ships `tree-sitter.json` and `queries/` too.
|
|
78
|
+
The package also ships the node types in `src/node-types.json`, `tree-sitter.json`, and `grammar.js` for grammars
|
|
79
|
+
that extend this one (e.g. `require('@willbooster/tree-sitter-javascript/grammar')`). Its JSDoc describes the
|
|
80
|
+
array/formal and object-rest extension hooks. The crate ships `tree-sitter.json` too.
|
|
75
81
|
|
|
76
82
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-javascript) and the
|
|
77
|
-
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 15.
|
|
83
|
+
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 15.5.4:
|
|
78
84
|
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "16" }
|
|
85
|
+
```sh
|
|
86
|
+
cargo add willbooster-tree-sitter@15.5.4 --rename tree-sitter
|
|
87
|
+
cargo add willbooster-tree-sitter-javascript --rename tree-sitter-javascript
|
|
83
88
|
```
|
|
84
89
|
|
|
85
90
|
```rust
|
|
@@ -114,9 +119,6 @@ and the release build regenerate the parsers before compiling them.
|
|
|
114
119
|
`bun run test` runs:
|
|
115
120
|
|
|
116
121
|
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
|
|
117
|
-
- an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
|
|
118
|
-
edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
|
|
119
|
-
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
|
|
120
122
|
- a check that the real-world JavaScript files in `examples/`, the checked-in ones and those of the cloned repository,
|
|
121
123
|
fail to parse exactly as listed in `script/known-failures.txt`. The first run clones the repository. The example
|
|
122
124
|
repository is pinned to a commit in `script/parse-examples`. After a grammar change or a moved pin alters that list,
|
|
@@ -129,13 +131,10 @@ and the release build regenerate the parsers before compiling them.
|
|
|
129
131
|
Node.js compatibility (`test/unit/workers.test.ts`). Run `bun run test/ci-setup` once before the first
|
|
130
132
|
run to install Chromium and, on Linux, the system libraries it needs;
|
|
131
133
|
- a check that `package.json` and `Cargo.lock` lock the same WillBooster/tree-sitter runtime version
|
|
132
|
-
(`test/unit/runtimeVersion.test.ts`)
|
|
133
|
-
- a check that the queries `tree-sitter.json` lists compile against the Wasm build and are in both the npm package and
|
|
134
|
-
the crate (`test/unit/queries.test.ts`).
|
|
134
|
+
(`test/unit/runtimeVersion.test.ts`).
|
|
135
135
|
|
|
136
136
|
The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` instead of the CLI's cache shared
|
|
137
|
-
by every checkout, and `mise.toml` sets `TREE_SITTER_LIBDIR` to it for any other command run in the checkout
|
|
138
|
-
`script/fuzz-corpus` builds a parser of its own in `.tmp/fuzz` for each run and deletes it afterwards.
|
|
137
|
+
by every checkout, and `mise.toml` sets `TREE_SITTER_LIBDIR` to it for any other command run in the checkout.
|
|
139
138
|
|
|
140
139
|
CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the
|
|
141
140
|
parser with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
|
package/grammar.js
CHANGED
|
@@ -78,7 +78,8 @@ module.exports = grammar({
|
|
|
78
78
|
// _arrow_function_block_continuation, since the arrow function may be, e.g., an argument.
|
|
79
79
|
sym('_arrow_function_block_end'),
|
|
80
80
|
sym('_arrow_function_block_continuation'),
|
|
81
|
-
// Bindings emit a boundary
|
|
81
|
+
// Bindings emit a boundary where the scanner decides from what follows whether a line break ends the declaration;
|
|
82
|
+
// the other flags only select a scanner line-break rule.
|
|
82
83
|
// Keep those flags alternatives to what follows: leading optional flags duplicate parse states.
|
|
83
84
|
sym('_line_break_ends_statement'),
|
|
84
85
|
sym('_line_break_after_binding'),
|
|
@@ -101,7 +102,8 @@ module.exports = grammar({
|
|
|
101
102
|
// Emitted zero-width decision preserves direct operands and identifier statements before yield.
|
|
102
103
|
sym('_await_yield_identifier_start'),
|
|
103
104
|
sym('_await_yield_identifier_context'),
|
|
104
|
-
// Emitted zero-width after a postfix update;
|
|
105
|
+
// Emitted zero-width after a postfix update; records whether a line break before `(`, `[`, or a template ends the
|
|
106
|
+
// statement, for the automatic semicolon that follows.
|
|
105
107
|
sym('_postfix_update_end'),
|
|
106
108
|
sym('_await_keyword'),
|
|
107
109
|
sym('_let'),
|
|
@@ -482,8 +484,7 @@ module.exports = grammar({
|
|
|
482
484
|
_for_condition: ($) => field('condition', choice(seq($._expressions, ';'), $.empty_statement)),
|
|
483
485
|
|
|
484
486
|
// ECMAScript inserts no semicolon inside a for header, so these declarations end only with `;`. Accepting an
|
|
485
|
-
// automatic semicolon there
|
|
486
|
-
// reuse a declaration built when that ambiguity was resolved differently.
|
|
487
|
+
// automatic semicolon there would make `for (let x\n of y)` ambiguous until `of`.
|
|
487
488
|
for_lexical_declaration: ($) =>
|
|
488
489
|
seq(
|
|
489
490
|
field('kind', choice('let', 'const')),
|
|
@@ -1038,7 +1039,7 @@ module.exports = grammar({
|
|
|
1038
1039
|
'template_call',
|
|
1039
1040
|
seq(
|
|
1040
1041
|
field('function', alias($._assignment_call_primary, $.primary_expression)),
|
|
1041
|
-
field('arguments', $.template_string)
|
|
1042
|
+
field('arguments', alias($._tagged_template_string, $.template_string))
|
|
1042
1043
|
)
|
|
1043
1044
|
),
|
|
1044
1045
|
|
|
@@ -1148,7 +1149,7 @@ module.exports = grammar({
|
|
|
1148
1149
|
'template_call',
|
|
1149
1150
|
seq(
|
|
1150
1151
|
field('function', alias($._constructor_chain_base, $.primary_expression)),
|
|
1151
|
-
field('arguments', $.template_string)
|
|
1152
|
+
field('arguments', alias($._tagged_template_string, $.template_string))
|
|
1152
1153
|
)
|
|
1153
1154
|
),
|
|
1154
1155
|
|
|
@@ -1372,23 +1373,10 @@ module.exports = grammar({
|
|
|
1372
1373
|
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
|
1373
1374
|
comment: () => token(choice(seq('//', /[^\r\n\u2028\u2029]*/), seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
|
|
1374
1375
|
|
|
1375
|
-
template_string: ($) =>
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
repeat(
|
|
1379
|
-
choice(
|
|
1380
|
-
alias(sym('_template_chars'), sym('string_fragment')),
|
|
1381
|
-
$.escape_sequence,
|
|
1382
|
-
alias($._invalid_template_escape, $.escape_sequence),
|
|
1383
|
-
$.template_substitution
|
|
1384
|
-
)
|
|
1385
|
-
),
|
|
1386
|
-
'`'
|
|
1387
|
-
),
|
|
1376
|
+
template_string: ($) => templateString($, false),
|
|
1377
|
+
|
|
1378
|
+
_tagged_template_string: ($) => templateString($, true),
|
|
1388
1379
|
|
|
1389
|
-
// Tagged templates allow `\x` and `\u` without the hex digits an escape_sequence needs (the cooked string is
|
|
1390
|
-
// undefined). The lexer prefers the longer escape_sequence when the digits follow. Untagged templates reject these
|
|
1391
|
-
// escapes, but the lexer cannot tell the two apart.
|
|
1392
1380
|
_invalid_template_escape: () => token.immediate(seq('\\', /[xu]/)),
|
|
1393
1381
|
|
|
1394
1382
|
template_substitution: ($) => seq('${', $._expressions, '}'),
|
|
@@ -1753,14 +1741,17 @@ function contextualIdentifier($, heritage) {
|
|
|
1753
1741
|
}
|
|
1754
1742
|
|
|
1755
1743
|
/**
|
|
1756
|
-
* @param {GrammarSymbols<'import' | 'arguments' | 'template_string' | 'optional_chain'>} $
|
|
1744
|
+
* @param {GrammarSymbols<'import' | 'arguments' | '_tagged_template_string' | 'template_string' | 'optional_chain'>} $
|
|
1757
1745
|
* @param {RuleOrLiteral} callee
|
|
1758
1746
|
* @param {RuleOrLiteral} primary
|
|
1759
1747
|
*/
|
|
1760
1748
|
function callExpression($, callee, primary) {
|
|
1761
1749
|
return choice(
|
|
1762
1750
|
prec('call', seq(field('function', choice(callee, $.import)), field('arguments', $.arguments))),
|
|
1763
|
-
prec(
|
|
1751
|
+
prec(
|
|
1752
|
+
'template_call',
|
|
1753
|
+
seq(field('function', primary), field('arguments', alias($._tagged_template_string, $.template_string)))
|
|
1754
|
+
),
|
|
1764
1755
|
prec(
|
|
1765
1756
|
'member',
|
|
1766
1757
|
seq(field('function', primary), field('optional_chain', $.optional_chain), field('arguments', $.arguments))
|
|
@@ -1871,3 +1862,22 @@ function functionScope(async, content, kind = 'function_signature') {
|
|
|
1871
1862
|
const name = kind === 'function' && !async ? 'sync_function' : `${async ? 'async_' : ''}${kind}`;
|
|
1872
1863
|
return seq(sym(`_${name}_start`), content, sym('_function_context_end'));
|
|
1873
1864
|
}
|
|
1865
|
+
|
|
1866
|
+
/**
|
|
1867
|
+
* @param {GrammarSymbols<'escape_sequence' | '_invalid_template_escape' | 'template_substitution'>} $
|
|
1868
|
+
* @param {boolean} tagged
|
|
1869
|
+
*/
|
|
1870
|
+
function templateString($, tagged) {
|
|
1871
|
+
return seq(
|
|
1872
|
+
'`',
|
|
1873
|
+
repeat(
|
|
1874
|
+
choice(
|
|
1875
|
+
alias(sym('_template_chars'), sym('string_fragment')),
|
|
1876
|
+
$.escape_sequence,
|
|
1877
|
+
...(tagged ? [alias($._invalid_template_escape, $.escape_sequence)] : []),
|
|
1878
|
+
$.template_substitution
|
|
1879
|
+
)
|
|
1880
|
+
),
|
|
1881
|
+
'`'
|
|
1882
|
+
);
|
|
1883
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-javascript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.0",
|
|
4
4
|
"description": "JavaScript grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"grammars/script/grammar.js",
|
|
20
20
|
"grammars/script/src/node-types.json",
|
|
21
21
|
"tree-sitter.json",
|
|
22
|
-
"queries/*",
|
|
23
22
|
"src/node-types.json",
|
|
24
23
|
"*.wasm"
|
|
25
24
|
],
|
|
@@ -47,24 +46,24 @@
|
|
|
47
46
|
"verify-full": "bun wb verify --full"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@babel/parser": "8.0.
|
|
49
|
+
"@babel/parser": "8.0.8",
|
|
51
50
|
"@tsconfig/bun": "1.0.11",
|
|
52
|
-
"@types/bun": "1.4.
|
|
51
|
+
"@types/bun": "1.4.4",
|
|
53
52
|
"@vitest/browser-playwright": "5.0.5",
|
|
54
53
|
"@willbooster/oxlint-config": "1.4.9",
|
|
55
|
-
"@willbooster/wb": "
|
|
56
|
-
"@willbooster/web-tree-sitter": "15.
|
|
54
|
+
"@willbooster/wb": "23.0.2",
|
|
55
|
+
"@willbooster/web-tree-sitter": "15.5.4",
|
|
57
56
|
"acorn": "8.19.0",
|
|
58
57
|
"acorn-jsx": "5.3.2",
|
|
59
58
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
60
59
|
"lefthook": "2.2.2",
|
|
61
|
-
"oxlint": "1.
|
|
62
|
-
"oxlint-tsgolint": "7.0.
|
|
60
|
+
"oxlint": "1.89.0",
|
|
61
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
63
62
|
"playwright": "1.64.1",
|
|
64
63
|
"semantic-release": "25.0.9",
|
|
65
|
-
"vite": "8.3.
|
|
64
|
+
"vite": "8.3.5",
|
|
66
65
|
"vitest": "5.0.5",
|
|
67
|
-
"wrangler": "4.
|
|
66
|
+
"wrangler": "4.152.0"
|
|
68
67
|
},
|
|
69
68
|
"peerDependencies": {
|
|
70
69
|
"@willbooster/web-tree-sitter": "^15.0.0"
|
|
Binary file
|
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -11,14 +11,6 @@
|
|
|
11
11
|
"mjs",
|
|
12
12
|
"jsx"
|
|
13
13
|
],
|
|
14
|
-
"highlights": [
|
|
15
|
-
"queries/highlights.scm",
|
|
16
|
-
"queries/highlights-jsx.scm",
|
|
17
|
-
"queries/highlights-params.scm"
|
|
18
|
-
],
|
|
19
|
-
"injections": "queries/injections.scm",
|
|
20
|
-
"locals": "queries/locals.scm",
|
|
21
|
-
"tags": "queries/tags.scm",
|
|
22
14
|
"injection-regex": "^(js|javascript)$",
|
|
23
15
|
"external-files": [
|
|
24
16
|
"src/function_context.h"
|
|
@@ -32,14 +24,6 @@
|
|
|
32
24
|
"file-types": [
|
|
33
25
|
"cjs"
|
|
34
26
|
],
|
|
35
|
-
"highlights": [
|
|
36
|
-
"queries/highlights.scm",
|
|
37
|
-
"queries/highlights-jsx.scm",
|
|
38
|
-
"queries/highlights-params.scm"
|
|
39
|
-
],
|
|
40
|
-
"injections": "queries/injections.scm",
|
|
41
|
-
"locals": "queries/locals.scm",
|
|
42
|
-
"tags": "queries/tags.scm",
|
|
43
27
|
"injection-regex": "^javascript-script$",
|
|
44
28
|
"external-files": [
|
|
45
29
|
"src/scanner.c",
|
|
@@ -48,7 +32,7 @@
|
|
|
48
32
|
}
|
|
49
33
|
],
|
|
50
34
|
"metadata": {
|
|
51
|
-
"version": "
|
|
35
|
+
"version": "19.0.0",
|
|
52
36
|
"license": "MIT",
|
|
53
37
|
"description": "JavaScript grammar for tree-sitter",
|
|
54
38
|
"authors": [
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
|
2
|
-
(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
|
3
|
-
(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
|
4
|
-
|
|
5
|
-
(jsx_attribute (property_identifier) @attribute)
|
|
6
|
-
(jsx_opening_element (["<" ">"]) @punctuation.bracket)
|
|
7
|
-
(jsx_closing_element (["</" ">"]) @punctuation.bracket)
|
|
8
|
-
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(formal_parameters
|
|
2
|
-
[
|
|
3
|
-
(identifier) @variable.parameter
|
|
4
|
-
(array_pattern
|
|
5
|
-
(identifier) @variable.parameter)
|
|
6
|
-
(object_pattern
|
|
7
|
-
[
|
|
8
|
-
(pair_pattern value: (identifier) @variable.parameter)
|
|
9
|
-
(shorthand_property_identifier_pattern) @variable.parameter
|
|
10
|
-
])
|
|
11
|
-
]
|
|
12
|
-
)
|
package/queries/highlights.scm
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
; Variables
|
|
2
|
-
;----------
|
|
3
|
-
|
|
4
|
-
(identifier) @variable
|
|
5
|
-
|
|
6
|
-
; Properties
|
|
7
|
-
;-----------
|
|
8
|
-
|
|
9
|
-
(property_identifier) @property
|
|
10
|
-
|
|
11
|
-
; Function and method definitions
|
|
12
|
-
;--------------------------------
|
|
13
|
-
|
|
14
|
-
(function_expression
|
|
15
|
-
name: (identifier) @function)
|
|
16
|
-
(function_declaration
|
|
17
|
-
name: (identifier) @function)
|
|
18
|
-
(method_definition
|
|
19
|
-
name: (property_identifier) @function.method)
|
|
20
|
-
|
|
21
|
-
(pair
|
|
22
|
-
key: (property_identifier) @function.method
|
|
23
|
-
value: [(function_expression) (arrow_function)])
|
|
24
|
-
|
|
25
|
-
(assignment_expression
|
|
26
|
-
left: (member_expression
|
|
27
|
-
property: (property_identifier) @function.method)
|
|
28
|
-
right: [(function_expression) (arrow_function)])
|
|
29
|
-
|
|
30
|
-
(variable_declarator
|
|
31
|
-
name: (identifier) @function
|
|
32
|
-
value: [(function_expression) (arrow_function)])
|
|
33
|
-
|
|
34
|
-
(assignment_expression
|
|
35
|
-
left: (identifier) @function
|
|
36
|
-
right: [(function_expression) (arrow_function)])
|
|
37
|
-
|
|
38
|
-
; Function and method calls
|
|
39
|
-
;--------------------------
|
|
40
|
-
|
|
41
|
-
(call_expression
|
|
42
|
-
function: (identifier) @function)
|
|
43
|
-
|
|
44
|
-
(call_expression
|
|
45
|
-
function: (member_expression
|
|
46
|
-
property: (property_identifier) @function.method))
|
|
47
|
-
|
|
48
|
-
; Special identifiers
|
|
49
|
-
;--------------------
|
|
50
|
-
|
|
51
|
-
((identifier) @constructor
|
|
52
|
-
(#match? @constructor "^[A-Z]"))
|
|
53
|
-
|
|
54
|
-
([
|
|
55
|
-
(identifier)
|
|
56
|
-
(shorthand_property_identifier)
|
|
57
|
-
(shorthand_property_identifier_pattern)
|
|
58
|
-
] @constant
|
|
59
|
-
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
|
|
60
|
-
|
|
61
|
-
((identifier) @variable.builtin
|
|
62
|
-
(#match? @variable.builtin "^(arguments|module|console|window|document)$"))
|
|
63
|
-
|
|
64
|
-
((identifier) @function.builtin
|
|
65
|
-
(#eq? @function.builtin "require"))
|
|
66
|
-
|
|
67
|
-
; Literals
|
|
68
|
-
;---------
|
|
69
|
-
|
|
70
|
-
(this) @variable.builtin
|
|
71
|
-
(super) @variable.builtin
|
|
72
|
-
|
|
73
|
-
[
|
|
74
|
-
(true)
|
|
75
|
-
(false)
|
|
76
|
-
(null)
|
|
77
|
-
(undefined)
|
|
78
|
-
] @constant.builtin
|
|
79
|
-
|
|
80
|
-
(comment) @comment
|
|
81
|
-
|
|
82
|
-
[
|
|
83
|
-
(string)
|
|
84
|
-
(template_string)
|
|
85
|
-
] @string
|
|
86
|
-
|
|
87
|
-
(regex) @string.special
|
|
88
|
-
(number) @number
|
|
89
|
-
|
|
90
|
-
; Tokens
|
|
91
|
-
;-------
|
|
92
|
-
|
|
93
|
-
[
|
|
94
|
-
";"
|
|
95
|
-
(optional_chain)
|
|
96
|
-
"."
|
|
97
|
-
","
|
|
98
|
-
] @punctuation.delimiter
|
|
99
|
-
|
|
100
|
-
[
|
|
101
|
-
"-"
|
|
102
|
-
"--"
|
|
103
|
-
"-="
|
|
104
|
-
"+"
|
|
105
|
-
"++"
|
|
106
|
-
"+="
|
|
107
|
-
"*"
|
|
108
|
-
"*="
|
|
109
|
-
"**"
|
|
110
|
-
"**="
|
|
111
|
-
"/"
|
|
112
|
-
"/="
|
|
113
|
-
"%"
|
|
114
|
-
"%="
|
|
115
|
-
"<"
|
|
116
|
-
"<="
|
|
117
|
-
"<<"
|
|
118
|
-
"<<="
|
|
119
|
-
"="
|
|
120
|
-
"=="
|
|
121
|
-
"==="
|
|
122
|
-
"!"
|
|
123
|
-
"!="
|
|
124
|
-
"!=="
|
|
125
|
-
"=>"
|
|
126
|
-
">"
|
|
127
|
-
">="
|
|
128
|
-
">>"
|
|
129
|
-
">>="
|
|
130
|
-
">>>"
|
|
131
|
-
">>>="
|
|
132
|
-
"~"
|
|
133
|
-
"^"
|
|
134
|
-
"&"
|
|
135
|
-
"|"
|
|
136
|
-
"^="
|
|
137
|
-
"&="
|
|
138
|
-
"|="
|
|
139
|
-
"&&"
|
|
140
|
-
"||"
|
|
141
|
-
"??"
|
|
142
|
-
"&&="
|
|
143
|
-
"||="
|
|
144
|
-
"??="
|
|
145
|
-
] @operator
|
|
146
|
-
|
|
147
|
-
[
|
|
148
|
-
"("
|
|
149
|
-
")"
|
|
150
|
-
"["
|
|
151
|
-
"]"
|
|
152
|
-
"{"
|
|
153
|
-
"}"
|
|
154
|
-
] @punctuation.bracket
|
|
155
|
-
|
|
156
|
-
(template_substitution
|
|
157
|
-
"${" @punctuation.special
|
|
158
|
-
"}" @punctuation.special) @embedded
|
|
159
|
-
|
|
160
|
-
[
|
|
161
|
-
"as"
|
|
162
|
-
"async"
|
|
163
|
-
"await"
|
|
164
|
-
"break"
|
|
165
|
-
"case"
|
|
166
|
-
"catch"
|
|
167
|
-
"class"
|
|
168
|
-
"const"
|
|
169
|
-
"continue"
|
|
170
|
-
"debugger"
|
|
171
|
-
"default"
|
|
172
|
-
"delete"
|
|
173
|
-
"do"
|
|
174
|
-
"else"
|
|
175
|
-
"export"
|
|
176
|
-
"extends"
|
|
177
|
-
"finally"
|
|
178
|
-
"for"
|
|
179
|
-
"from"
|
|
180
|
-
"function"
|
|
181
|
-
"get"
|
|
182
|
-
"if"
|
|
183
|
-
"import"
|
|
184
|
-
"in"
|
|
185
|
-
"instanceof"
|
|
186
|
-
"let"
|
|
187
|
-
"new"
|
|
188
|
-
"of"
|
|
189
|
-
"return"
|
|
190
|
-
"set"
|
|
191
|
-
"static"
|
|
192
|
-
"switch"
|
|
193
|
-
"target"
|
|
194
|
-
"throw"
|
|
195
|
-
"try"
|
|
196
|
-
"typeof"
|
|
197
|
-
"var"
|
|
198
|
-
"void"
|
|
199
|
-
"while"
|
|
200
|
-
"with"
|
|
201
|
-
"yield"
|
|
202
|
-
] @keyword
|
|
203
|
-
|
|
204
|
-
; `default` as a module export name is an identifier node.
|
|
205
|
-
(export_specifier
|
|
206
|
-
name: (identifier) @keyword
|
|
207
|
-
(#eq? @keyword "default"))
|
|
208
|
-
(export_specifier
|
|
209
|
-
alias: (identifier) @keyword
|
|
210
|
-
(#eq? @keyword "default"))
|
|
211
|
-
(import_specifier
|
|
212
|
-
name: (identifier) @keyword
|
|
213
|
-
(#eq? @keyword "default"))
|
|
214
|
-
(namespace_export
|
|
215
|
-
(identifier) @keyword
|
|
216
|
-
(#eq? @keyword "default"))
|
package/queries/injections.scm
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
; Parse the contents of tagged template literals using
|
|
2
|
-
; a language inferred from the tag.
|
|
3
|
-
|
|
4
|
-
(call_expression
|
|
5
|
-
function: [
|
|
6
|
-
(identifier) @injection.language
|
|
7
|
-
(member_expression
|
|
8
|
-
property: (property_identifier) @injection.language)
|
|
9
|
-
]
|
|
10
|
-
arguments: (template_string (string_fragment) @injection.content)
|
|
11
|
-
(#set! injection.combined)
|
|
12
|
-
(#set! injection.include-children))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
; Parse regex syntax within regex literals
|
|
16
|
-
|
|
17
|
-
((regex_pattern) @injection.content
|
|
18
|
-
(#set! injection.language "regex"))
|
|
19
|
-
|
|
20
|
-
; Parse JSDoc annotations in comments
|
|
21
|
-
|
|
22
|
-
((comment) @injection.content
|
|
23
|
-
(#set! injection.language "jsdoc"))
|
|
24
|
-
|
|
25
|
-
; Parse Ember/Glimmer/Handlebars/HTMLBars/etc. template literals
|
|
26
|
-
; e.g.: await render(hbs`<SomeComponent />`)
|
|
27
|
-
(call_expression
|
|
28
|
-
function: ((identifier) @_name
|
|
29
|
-
(#eq? @_name "hbs"))
|
|
30
|
-
arguments: ((template_string) @glimmer
|
|
31
|
-
(#offset! @glimmer 0 1 0 -1)))
|
package/queries/locals.scm
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
; Scopes
|
|
2
|
-
;-------
|
|
3
|
-
|
|
4
|
-
[
|
|
5
|
-
(statement_block)
|
|
6
|
-
(function_expression)
|
|
7
|
-
(arrow_function)
|
|
8
|
-
(function_declaration)
|
|
9
|
-
(method_definition)
|
|
10
|
-
] @local.scope
|
|
11
|
-
|
|
12
|
-
; Definitions
|
|
13
|
-
;------------
|
|
14
|
-
|
|
15
|
-
(pattern/identifier) @local.definition
|
|
16
|
-
|
|
17
|
-
(variable_declarator
|
|
18
|
-
name: (identifier) @local.definition)
|
|
19
|
-
|
|
20
|
-
; References
|
|
21
|
-
;------------
|
|
22
|
-
|
|
23
|
-
(identifier) @local.reference
|
package/queries/tags.scm
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
(
|
|
2
|
-
(comment)* @doc
|
|
3
|
-
.
|
|
4
|
-
(method_definition
|
|
5
|
-
name: (property_identifier) @name) @definition.method
|
|
6
|
-
(#not-eq? @name "constructor")
|
|
7
|
-
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
8
|
-
(#select-adjacent! @doc @definition.method)
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
(
|
|
12
|
-
(comment)* @doc
|
|
13
|
-
.
|
|
14
|
-
[
|
|
15
|
-
(class
|
|
16
|
-
name: (_) @name)
|
|
17
|
-
(class_declaration
|
|
18
|
-
name: (_) @name)
|
|
19
|
-
] @definition.class
|
|
20
|
-
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
21
|
-
(#select-adjacent! @doc @definition.class)
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
(comment)* @doc
|
|
26
|
-
.
|
|
27
|
-
[
|
|
28
|
-
(function_expression
|
|
29
|
-
name: (identifier) @name)
|
|
30
|
-
(function_declaration
|
|
31
|
-
name: (identifier) @name)
|
|
32
|
-
(generator_function
|
|
33
|
-
name: (identifier) @name)
|
|
34
|
-
(generator_function_declaration
|
|
35
|
-
name: (identifier) @name)
|
|
36
|
-
] @definition.function
|
|
37
|
-
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
38
|
-
(#select-adjacent! @doc @definition.function)
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
(
|
|
42
|
-
(comment)* @doc
|
|
43
|
-
.
|
|
44
|
-
(lexical_declaration
|
|
45
|
-
(variable_declarator
|
|
46
|
-
name: (identifier) @name
|
|
47
|
-
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
48
|
-
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
49
|
-
(#select-adjacent! @doc @definition.function)
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
(
|
|
53
|
-
(comment)* @doc
|
|
54
|
-
.
|
|
55
|
-
(variable_declaration
|
|
56
|
-
(variable_declarator
|
|
57
|
-
name: (identifier) @name
|
|
58
|
-
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
59
|
-
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
60
|
-
(#select-adjacent! @doc @definition.function)
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
(assignment_expression
|
|
64
|
-
left: [
|
|
65
|
-
(identifier) @name
|
|
66
|
-
(member_expression
|
|
67
|
-
property: (property_identifier) @name)
|
|
68
|
-
]
|
|
69
|
-
right: [(arrow_function) (function_expression)]
|
|
70
|
-
) @definition.function
|
|
71
|
-
|
|
72
|
-
(pair
|
|
73
|
-
key: (property_identifier) @name
|
|
74
|
-
value: [(arrow_function) (function_expression)]) @definition.function
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
(call_expression
|
|
78
|
-
function: (identifier) @name) @reference.call
|
|
79
|
-
(#not-match? @name "^(require)$")
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
(call_expression
|
|
83
|
-
function: (member_expression
|
|
84
|
-
property: (property_identifier) @name)
|
|
85
|
-
arguments: (_)) @reference.call
|
|
86
|
-
|
|
87
|
-
(new_expression
|
|
88
|
-
constructor: (_) @name) @reference.class
|
|
89
|
-
|
|
90
|
-
(
|
|
91
|
-
[
|
|
92
|
-
(jsx_opening_element name: (identifier) @name)
|
|
93
|
-
(jsx_self_closing_element name: (identifier) @name)
|
|
94
|
-
] @reference.call
|
|
95
|
-
(#not-match? @name "^[a-z]|-|\\\\")
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
(
|
|
99
|
-
[
|
|
100
|
-
(jsx_opening_element name: (member_expression property: (property_identifier) @name))
|
|
101
|
-
(jsx_self_closing_element name: (member_expression property: (property_identifier) @name))
|
|
102
|
-
] @reference.call
|
|
103
|
-
(#not-match? @name "\\\\")
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
|
107
|
-
(number)
|
|
108
|
-
(string)
|
|
109
|
-
(identifier)
|
|
110
|
-
(undefined)
|
|
111
|
-
(null)
|
|
112
|
-
(new_expression)
|
|
113
|
-
(binary_expression)
|
|
114
|
-
(call_expression)
|
|
115
|
-
]))) @definition.constant
|