@willbooster/tree-sitter-dart 0.0.0-stage → 1.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/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-dart",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Dart grammar for tree-sitter",
5
+ "keywords": [
6
+ "incremental",
7
+ "parsing",
8
+ "tree-sitter",
9
+ "dart"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/WillBooster/tree-sitter-dart.git"
14
+ },
15
+ "license": "MIT",
16
+ "author": "WillBooster Inc.",
17
+ "files": [
18
+ "grammar.js",
19
+ "queries/*.scm",
20
+ "src/node-types.json",
21
+ "tree-sitter.json",
22
+ "*.wasm"
23
+ ],
24
+ "scripts": {
25
+ "build-wasm": "script/generate --build-wasm",
26
+ "build/ci": "bun run build-wasm",
27
+ "cleanup": "bun wb lint --fix --format",
28
+ "format": "bun wb lint --format",
29
+ "generate": "script/generate",
30
+ "lint": "bun wb lint",
31
+ "lint-fix": "bun wb lint --fix",
32
+ "prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
33
+ "release": "wb release",
34
+ "prestart": "bun run build-wasm",
35
+ "start": "script/tree-sitter playground",
36
+ "test": "bun wb test",
37
+ "test/ci": "bun wb test-on-ci",
38
+ "test/ci-setup": "playwright install --with-deps chromium",
39
+ "typecheck": "bun wb typecheck",
40
+ "verify": "bun wb verify",
41
+ "verify-full": "bun wb verify --full"
42
+ },
43
+ "devDependencies": {
44
+ "@tsconfig/bun": "1.0.11",
45
+ "@types/bun": "1.4.2",
46
+ "@vitest/browser-playwright": "5.0.3",
47
+ "@willbooster/oxfmt-config": "1.2.2",
48
+ "@willbooster/oxlint-config": "1.4.8",
49
+ "@willbooster/wb": "22.24.0",
50
+ "@willbooster/web-tree-sitter": "2.0.1",
51
+ "conventional-changelog-conventionalcommits": "10.4.0",
52
+ "lefthook": "2.1.16",
53
+ "oxfmt": "0.71.0",
54
+ "oxlint": "1.86.0",
55
+ "oxlint-tsgolint": "7.0.2003",
56
+ "playwright": "1.63.0",
57
+ "semantic-release": "25.0.9",
58
+ "sort-package-json": "4.0.0",
59
+ "typescript": "7.0.2",
60
+ "vitest": "5.0.3",
61
+ "wrangler": "4.147.0"
62
+ },
63
+ "peerDependencies": {
64
+ "@willbooster/web-tree-sitter": "^2.0.0"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "@willbooster/web-tree-sitter": {
68
+ "optional": true
69
+ }
70
+ },
71
+ "publishConfig": {
72
+ "access": "public",
73
+ "registry": "https://registry.npmjs.org/"
74
+ }
75
+ }
@@ -0,0 +1,335 @@
1
+ ; highlights.scm - Dart syntax highlighting queries
2
+
3
+ ; ============================================================================
4
+ ; Comments
5
+ ; ============================================================================
6
+
7
+ (comment) @comment
8
+ (block_comment) @comment.block
9
+ (documentation_block_comment) @comment.block.documentation
10
+
11
+ ; ============================================================================
12
+ ; Literals
13
+ ; ============================================================================
14
+
15
+ (decimal_integer_literal) @number
16
+ (hex_integer_literal) @number
17
+ (decimal_floating_point_literal) @number.float
18
+
19
+ (true) @boolean
20
+ (false) @boolean
21
+ (null_literal) @constant.builtin
22
+
23
+ (string_literal) @string
24
+ (template_chars_single) @string
25
+ (template_chars_double) @string
26
+ (template_chars_single_single) @string
27
+ (template_chars_double_single) @string
28
+ (template_chars_raw_slash) @string
29
+ (escape_sequence) @string.escape
30
+ (template_substitution
31
+ "$" @punctuation.special
32
+ "{" @punctuation.special
33
+ "}" @punctuation.special)
34
+
35
+ (symbol_literal) @string.special.symbol
36
+
37
+ ; ============================================================================
38
+ ; Types
39
+ ; ============================================================================
40
+
41
+ (type_identifier) @type
42
+ (void_type) @type.builtin
43
+
44
+ (type_parameter
45
+ (type_identifier) @type.parameter)
46
+
47
+ "Function" @type.builtin
48
+
49
+ ; Built-in types
50
+ ((type_identifier) @type.builtin
51
+ (#match? @type.builtin "^(int|double|num|String|bool|List|Set|Map|Runes|Symbol|Future|Stream|Iterable|Never|dynamic|Object)$"))
52
+
53
+ ; ============================================================================
54
+ ; Functions
55
+ ; ============================================================================
56
+
57
+ ; Function/getter/setter names (matches at any nesting level)
58
+ (function_signature
59
+ name: (identifier) @function)
60
+
61
+ (getter_signature
62
+ name: (identifier) @function)
63
+
64
+ (setter_signature
65
+ name: (identifier) @function)
66
+
67
+ ; Methods (inside class/mixin/extension bodies)
68
+ (method_signature
69
+ (function_signature
70
+ name: (identifier) @function.method))
71
+
72
+ (method_signature
73
+ (getter_signature
74
+ name: (identifier) @function.method))
75
+
76
+ (method_signature
77
+ (setter_signature
78
+ name: (identifier) @function.method))
79
+
80
+ ; Operator methods
81
+ (operator_signature
82
+ "operator" @keyword)
83
+
84
+ ; Property access
85
+ [
86
+ (member_expression)
87
+ (null_aware_member_expression)
88
+ (cascade_member_expression)
89
+ (cascade_null_aware_member_expression)
90
+ ] property: (identifier) @property
91
+
92
+ ; Function calls (non-method)
93
+ (call_expression
94
+ function: (identifier) @function.call)
95
+
96
+ ; Method calls
97
+ (call_expression
98
+ function: [
99
+ (member_expression property: (identifier) @function.method.call)
100
+ (null_aware_member_expression property: (identifier) @function.method.call)
101
+ ])
102
+
103
+ (cascade_call_expression
104
+ property: (identifier) @function.method.call)
105
+
106
+ ; ============================================================================
107
+ ; Declarations
108
+ ; ============================================================================
109
+
110
+ (class_declaration
111
+ name: (identifier) @type)
112
+
113
+ (mixin_declaration
114
+ (identifier) @type)
115
+
116
+ (extension_declaration
117
+ name: (identifier) @type)
118
+
119
+ (extension_type_declaration
120
+ name: (extension_type_name
121
+ (identifier) @type))
122
+
123
+ (enum_declaration
124
+ name: (identifier) @type)
125
+
126
+ (enum_constant
127
+ name: (identifier) @constant)
128
+
129
+ (type_alias
130
+ (type_identifier) @type.definition)
131
+
132
+ ; Constructors
133
+ (constructor_signature
134
+ name: (identifier) @constructor)
135
+
136
+ (constant_constructor_signature
137
+ (identifier) @constructor)
138
+
139
+ (factory_constructor_signature
140
+ (identifier) @constructor)
141
+
142
+ (redirecting_factory_constructor_signature
143
+ (identifier) @constructor)
144
+
145
+ ; ============================================================================
146
+ ; Parameters
147
+ ; ============================================================================
148
+
149
+ (formal_parameter
150
+ (identifier) @variable.parameter)
151
+
152
+ (constructor_param
153
+ (identifier) @variable.parameter)
154
+
155
+ (super_formal_parameter
156
+ (identifier) @variable.parameter)
157
+
158
+ ; Named arguments
159
+ (named_argument
160
+ (label
161
+ (identifier) @variable.parameter))
162
+
163
+ ; ============================================================================
164
+ ; Variables
165
+ ; ============================================================================
166
+
167
+ (initialized_variable_definition
168
+ name: (identifier) @variable)
169
+
170
+ (initialized_identifier
171
+ (identifier) @variable)
172
+
173
+ (static_final_declaration
174
+ (identifier) @variable)
175
+
176
+ ; ============================================================================
177
+ ; Annotations
178
+ ; ============================================================================
179
+
180
+ (annotation
181
+ "@" @attribute
182
+ name: (identifier) @attribute)
183
+
184
+ ; ============================================================================
185
+ ; Operators
186
+ ; ============================================================================
187
+
188
+ (relational_operator) @operator
189
+ (prefix_operator) @operator
190
+ (negate_operator) @operator
191
+ (is_operator) @keyword.operator
192
+ (binary_operator) @operator
193
+
194
+ [
195
+ "="
196
+ "+="
197
+ "-="
198
+ "*="
199
+ "/="
200
+ "%="
201
+ "~/="
202
+ "<<="
203
+ ">>="
204
+ ">>>="
205
+ "&="
206
+ "^="
207
+ "|="
208
+ "??="
209
+ "=="
210
+ "!="
211
+ "+"
212
+ "-"
213
+ "*"
214
+ "/"
215
+ "%"
216
+ "~/"
217
+ "<<"
218
+ ">>"
219
+ ">>>"
220
+ "&"
221
+ "^"
222
+ "|"
223
+ "&&"
224
+ "||"
225
+ "??"
226
+ "!"
227
+ "~"
228
+ "++"
229
+ "--"
230
+ ".."
231
+ "?.."
232
+ "..."
233
+ "...?"
234
+ "=>"
235
+ ] @operator
236
+
237
+ ; ============================================================================
238
+ ; Punctuation
239
+ ; ============================================================================
240
+
241
+ ["(" ")" "[" "]" "{" "}"] @punctuation.bracket
242
+
243
+ (type_arguments
244
+ "<" @punctuation.bracket
245
+ ">" @punctuation.bracket)
246
+
247
+ (type_parameters
248
+ "<" @punctuation.bracket
249
+ ">" @punctuation.bracket)
250
+
251
+ ["," ";" ":" "." "?." "?."] @punctuation.delimiter
252
+
253
+ "@" @punctuation.special
254
+ "#" @punctuation.special
255
+
256
+ ; ============================================================================
257
+ ; Keywords
258
+ ; ============================================================================
259
+
260
+ [
261
+ "abstract"
262
+ "as"
263
+ "assert"
264
+ "async"
265
+ "async*"
266
+ "augment"
267
+ "await"
268
+ "base"
269
+ "break"
270
+ "case"
271
+ "catch"
272
+ "class"
273
+ "const"
274
+ "continue"
275
+ "covariant"
276
+ "default"
277
+ "deferred"
278
+ "do"
279
+ "else"
280
+ "enum"
281
+ "export"
282
+ "extends"
283
+ "extension"
284
+ "external"
285
+ "factory"
286
+ "final"
287
+ "finally"
288
+ "for"
289
+ "get"
290
+ "hide"
291
+ "if"
292
+ "implements"
293
+ "import"
294
+ "in"
295
+ "inline"
296
+ "interface"
297
+ "is"
298
+ "late"
299
+ "library"
300
+ "mixin"
301
+ "native"
302
+ "new"
303
+ "on"
304
+ "operator"
305
+ "part"
306
+ "required"
307
+ "return"
308
+ "sealed"
309
+ "set"
310
+ "show"
311
+ "static"
312
+ "super"
313
+ "switch"
314
+ "sync*"
315
+ "this"
316
+ "throw"
317
+ "try"
318
+ "type"
319
+ "typedef"
320
+ "var"
321
+ "when"
322
+ "while"
323
+ "with"
324
+ "yield"
325
+ ] @keyword
326
+
327
+ ; ============================================================================
328
+ ; Special identifiers
329
+ ; ============================================================================
330
+
331
+ ((identifier) @variable.builtin
332
+ (#eq? @variable.builtin "this"))
333
+
334
+ ((identifier) @variable.builtin
335
+ (#eq? @variable.builtin "super"))
@@ -0,0 +1,96 @@
1
+ ; locals.scm - Dart scope and variable resolution queries
2
+
3
+ ; ============================================================================
4
+ ; Scopes
5
+ ; ============================================================================
6
+
7
+ [
8
+ (class_declaration)
9
+ (mixin_declaration)
10
+ (extension_declaration)
11
+ (extension_type_declaration)
12
+ (enum_declaration)
13
+ (function_body)
14
+ (function_expression)
15
+ (block)
16
+ (for_statement)
17
+ (try_statement)
18
+ (catch_clause)
19
+ (finally_clause)
20
+ (switch_statement_case)
21
+ ] @local.scope
22
+
23
+ ; ============================================================================
24
+ ; Definitions
25
+ ; ============================================================================
26
+
27
+ ; Variables
28
+ (initialized_variable_definition
29
+ name: (identifier) @local.definition)
30
+
31
+ (initialized_identifier
32
+ (identifier) @local.definition)
33
+
34
+ (static_final_declaration
35
+ (identifier) @local.definition)
36
+
37
+ ; Parameters
38
+ (formal_parameter
39
+ (identifier) @local.definition)
40
+
41
+ (constructor_param
42
+ (identifier) @local.definition)
43
+
44
+ (super_formal_parameter
45
+ (identifier) @local.definition)
46
+
47
+ ; Catch variables
48
+ (catch_clause
49
+ exception: (identifier) @local.definition)
50
+
51
+ (catch_clause
52
+ stack_trace: (identifier) @local.definition)
53
+
54
+ ; Functions
55
+ (function_signature
56
+ name: (identifier) @local.definition)
57
+
58
+ (getter_signature
59
+ name: (identifier) @local.definition)
60
+
61
+ (setter_signature
62
+ name: (identifier) @local.definition)
63
+
64
+ ; Types
65
+ (class_declaration
66
+ name: (identifier) @local.definition)
67
+
68
+ (mixin_declaration
69
+ (identifier) @local.definition)
70
+
71
+ (enum_declaration
72
+ name: (identifier) @local.definition)
73
+
74
+ (extension_declaration
75
+ name: (identifier) @local.definition)
76
+
77
+ (type_alias
78
+ (type_identifier) @local.definition)
79
+
80
+ (type_parameter
81
+ (type_identifier) @local.definition)
82
+
83
+ ; Import aliases
84
+ (import_specification
85
+ alias: (identifier) @local.definition)
86
+
87
+ ; Pattern bindings (Dart 3.0)
88
+ (variable_pattern
89
+ name: (identifier) @local.definition)
90
+
91
+ ; ============================================================================
92
+ ; References
93
+ ; ============================================================================
94
+
95
+ (identifier) @local.reference
96
+ (type_identifier) @local.reference
@@ -0,0 +1,118 @@
1
+ ; tags.scm - Dart symbol tagging queries
2
+
3
+ ; Classes
4
+ (class_declaration
5
+ name: (identifier) @name) @definition.class
6
+
7
+ ; Mixins
8
+ (mixin_declaration
9
+ (identifier) @name) @definition.class
10
+
11
+ ; Extensions
12
+ (extension_declaration
13
+ name: (identifier) @name) @definition.class
14
+
15
+ ; Extension types
16
+ (extension_type_declaration
17
+ name: (extension_type_name
18
+ (identifier) @name)) @definition.class
19
+
20
+ ; Enums
21
+ (enum_declaration
22
+ name: (identifier) @name) @definition.class
23
+
24
+ ; Top-level functions
25
+ (function_declaration
26
+ signature: (function_signature
27
+ name: (identifier) @name)) @definition.function
28
+
29
+ ; Top-level getters
30
+ (getter_declaration
31
+ signature: (getter_signature
32
+ name: (identifier) @name)) @definition.function
33
+
34
+ ; Top-level setters
35
+ (setter_declaration
36
+ signature: (setter_signature
37
+ name: (identifier) @name)) @definition.function
38
+
39
+ ; External top-level functions/getters/setters
40
+ (external_function_declaration
41
+ signature: (function_signature
42
+ name: (identifier) @name)) @definition.function
43
+
44
+ (external_getter_declaration
45
+ signature: (getter_signature
46
+ name: (identifier) @name)) @definition.function
47
+
48
+ (external_setter_declaration
49
+ signature: (setter_signature
50
+ name: (identifier) @name)) @definition.function
51
+
52
+ ; Top-level variables
53
+ (top_level_variable_declaration
54
+ (static_final_declaration_list
55
+ (static_final_declaration
56
+ name: (identifier) @name))) @definition.variable
57
+
58
+ (top_level_variable_declaration
59
+ (initialized_identifier_list
60
+ (initialized_identifier
61
+ name: (identifier) @name))) @definition.variable
62
+
63
+ (external_variable_declaration
64
+ (identifier_list
65
+ (identifier) @name)) @definition.variable
66
+
67
+ ; Methods
68
+ (method_signature
69
+ (function_signature
70
+ name: (identifier) @name)) @definition.method
71
+
72
+ ; Getters (as methods)
73
+ (method_signature
74
+ (getter_signature
75
+ name: (identifier) @name)) @definition.method
76
+
77
+ ; Setters (as methods)
78
+ (method_signature
79
+ (setter_signature
80
+ name: (identifier) @name)) @definition.method
81
+
82
+ ; Operator methods
83
+ (method_signature
84
+ (operator_signature)) @definition.method
85
+
86
+ ; Constructors
87
+ (constructor_signature
88
+ name: (identifier) @name) @definition.method
89
+
90
+ ; Const constructors
91
+ (constant_constructor_signature
92
+ (identifier) @name) @definition.method
93
+
94
+ ; Factory constructors
95
+ (factory_constructor_signature
96
+ (identifier) @name) @definition.method
97
+
98
+ ; Redirecting factory constructors
99
+ (redirecting_factory_constructor_signature
100
+ (identifier) @name) @definition.method
101
+
102
+ ; Typedefs
103
+ (type_alias
104
+ (type_identifier) @name) @definition.type
105
+
106
+ ; Enum constants
107
+ (enum_constant
108
+ name: (identifier) @name) @definition.constant
109
+
110
+ ; Function call references
111
+ (call_expression
112
+ function: (identifier) @name) @reference.call
113
+
114
+ (call_expression
115
+ function: [
116
+ (member_expression property: (identifier) @name)
117
+ (null_aware_member_expression property: (identifier) @name)
118
+ ]) @reference.call