@lzehrung/codegraph 2.3.24 → 2.3.26

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.
Files changed (181) hide show
  1. package/README.md +1 -1
  2. package/codegraph-skill/codegraph/SKILL.md +1 -1
  3. package/dist/bin/cli.js +3420 -1620
  4. package/dist/bin/query-index-worker.js +569 -229
  5. package/dist/cli/context.d.ts.map +1 -1
  6. package/dist/cli/context.js +7 -4
  7. package/dist/cli/context.js.map +1 -1
  8. package/dist/cli/doctor.d.ts +1 -0
  9. package/dist/cli/doctor.d.ts.map +1 -1
  10. package/dist/cli/doctor.js +8 -1
  11. package/dist/cli/doctor.js.map +1 -1
  12. package/dist/document-links/asciidoc.d.ts.map +1 -1
  13. package/dist/document-links/asciidoc.js +33 -0
  14. package/dist/document-links/asciidoc.js.map +1 -1
  15. package/dist/document-links/language-ids.d.ts +10 -0
  16. package/dist/document-links/language-ids.d.ts.map +1 -0
  17. package/dist/document-links/language-ids.js +15 -0
  18. package/dist/document-links/language-ids.js.map +1 -0
  19. package/dist/document-links/markdown.d.ts.map +1 -1
  20. package/dist/document-links/markdown.js +103 -21
  21. package/dist/document-links/markdown.js.map +1 -1
  22. package/dist/document-links/shared.d.ts.map +1 -1
  23. package/dist/document-links/shared.js +1 -0
  24. package/dist/document-links/shared.js.map +1 -1
  25. package/dist/document-links.d.ts +1 -3
  26. package/dist/document-links.d.ts.map +1 -1
  27. package/dist/document-links.js +1 -8
  28. package/dist/document-links.js.map +1 -1
  29. package/dist/duplicates/unit-cache.d.ts +1 -1
  30. package/dist/duplicates/unit-cache.d.ts.map +1 -1
  31. package/dist/duplicates/unit-cache.js +4 -1
  32. package/dist/duplicates/unit-cache.js.map +1 -1
  33. package/dist/duplicates/units.d.ts +1 -0
  34. package/dist/duplicates/units.d.ts.map +1 -1
  35. package/dist/duplicates/units.js +55 -10
  36. package/dist/duplicates/units.js.map +1 -1
  37. package/dist/graphs/edge-resolution.d.ts.map +1 -1
  38. package/dist/graphs/edge-resolution.js +3 -0
  39. package/dist/graphs/edge-resolution.js.map +1 -1
  40. package/dist/graphs/external/stdlib.d.ts.map +1 -1
  41. package/dist/graphs/external/stdlib.js +18 -11
  42. package/dist/graphs/external/stdlib.js.map +1 -1
  43. package/dist/graphs/specifiers.d.ts +3 -2
  44. package/dist/graphs/specifiers.d.ts.map +1 -1
  45. package/dist/graphs/specifiers.js +76 -39
  46. package/dist/graphs/specifiers.js.map +1 -1
  47. package/dist/graphs/symbol-graph-detailed/receiver-calls.js +1 -1
  48. package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
  49. package/dist/indexer/build-cache/options.d.ts +8 -2
  50. package/dist/indexer/build-cache/options.d.ts.map +1 -1
  51. package/dist/indexer/build-cache/options.js +10 -2
  52. package/dist/indexer/build-cache/options.js.map +1 -1
  53. package/dist/indexer/build-cache/reports.d.ts.map +1 -1
  54. package/dist/indexer/build-cache/reports.js +29 -21
  55. package/dist/indexer/build-cache/reports.js.map +1 -1
  56. package/dist/indexer/expand-star-imports.d.ts.map +1 -1
  57. package/dist/indexer/expand-star-imports.js +8 -3
  58. package/dist/indexer/expand-star-imports.js.map +1 -1
  59. package/dist/indexer/imports/language-specific.d.ts.map +1 -1
  60. package/dist/indexer/imports/language-specific.js +166 -32
  61. package/dist/indexer/imports/language-specific.js.map +1 -1
  62. package/dist/indexer/imports/native-captures.d.ts.map +1 -1
  63. package/dist/indexer/imports/native-captures.js +4 -3
  64. package/dist/indexer/imports/native-captures.js.map +1 -1
  65. package/dist/indexer/imports/python.d.ts +2 -0
  66. package/dist/indexer/imports/python.d.ts.map +1 -1
  67. package/dist/indexer/imports/python.js +113 -8
  68. package/dist/indexer/imports/python.js.map +1 -1
  69. package/dist/indexer/imports.d.ts.map +1 -1
  70. package/dist/indexer/imports.js +25 -12
  71. package/dist/indexer/imports.js.map +1 -1
  72. package/dist/indexer/locals-and-exports.d.ts.map +1 -1
  73. package/dist/indexer/locals-and-exports.js +153 -38
  74. package/dist/indexer/locals-and-exports.js.map +1 -1
  75. package/dist/indexer/navigation-goto.js +1 -1
  76. package/dist/indexer/navigation-goto.js.map +1 -1
  77. package/dist/indexer/scope-types.d.ts +1 -1
  78. package/dist/indexer/scope-types.d.ts.map +1 -1
  79. package/dist/indexer/scope.d.ts.map +1 -1
  80. package/dist/indexer/scope.js +43 -2
  81. package/dist/indexer/scope.js.map +1 -1
  82. package/dist/languages/definitions/c-family.d.ts +5 -0
  83. package/dist/languages/definitions/c-family.d.ts.map +1 -1
  84. package/dist/languages/definitions/c-family.js +27 -6
  85. package/dist/languages/definitions/c-family.js.map +1 -1
  86. package/dist/languages/definitions/c.d.ts.map +1 -1
  87. package/dist/languages/definitions/c.js +5 -0
  88. package/dist/languages/definitions/c.js.map +1 -1
  89. package/dist/languages/definitions/cpp.d.ts.map +1 -1
  90. package/dist/languages/definitions/cpp.js +41 -3
  91. package/dist/languages/definitions/cpp.js.map +1 -1
  92. package/dist/languages/definitions/csharp.d.ts.map +1 -1
  93. package/dist/languages/definitions/csharp.js +52 -21
  94. package/dist/languages/definitions/csharp.js.map +1 -1
  95. package/dist/languages/definitions/go.d.ts.map +1 -1
  96. package/dist/languages/definitions/go.js +10 -7
  97. package/dist/languages/definitions/go.js.map +1 -1
  98. package/dist/languages/definitions/html-stub.d.ts +6 -7
  99. package/dist/languages/definitions/html-stub.d.ts.map +1 -1
  100. package/dist/languages/definitions/html-stub.js +6 -7
  101. package/dist/languages/definitions/html-stub.js.map +1 -1
  102. package/dist/languages/definitions/html.js +13 -13
  103. package/dist/languages/definitions/html.js.map +1 -1
  104. package/dist/languages/definitions/java.d.ts.map +1 -1
  105. package/dist/languages/definitions/java.js +6 -0
  106. package/dist/languages/definitions/java.js.map +1 -1
  107. package/dist/languages/definitions/javascript.d.ts.map +1 -1
  108. package/dist/languages/definitions/javascript.js +48 -30
  109. package/dist/languages/definitions/javascript.js.map +1 -1
  110. package/dist/languages/definitions/kotlin.d.ts.map +1 -1
  111. package/dist/languages/definitions/kotlin.js +49 -61
  112. package/dist/languages/definitions/kotlin.js.map +1 -1
  113. package/dist/languages/definitions/php.js +1 -1
  114. package/dist/languages/definitions/php.js.map +1 -1
  115. package/dist/languages/definitions/python.d.ts.map +1 -1
  116. package/dist/languages/definitions/python.js +85 -20
  117. package/dist/languages/definitions/python.js.map +1 -1
  118. package/dist/languages/definitions/ruby.d.ts.map +1 -1
  119. package/dist/languages/definitions/ruby.js +13 -11
  120. package/dist/languages/definitions/ruby.js.map +1 -1
  121. package/dist/languages/definitions/rust.d.ts.map +1 -1
  122. package/dist/languages/definitions/rust.js +22 -5
  123. package/dist/languages/definitions/rust.js.map +1 -1
  124. package/dist/languages/definitions/scss.d.ts.map +1 -1
  125. package/dist/languages/definitions/scss.js +21 -17
  126. package/dist/languages/definitions/scss.js.map +1 -1
  127. package/dist/languages/definitions/sql.js +1 -1
  128. package/dist/languages/definitions/sql.js.map +1 -1
  129. package/dist/languages/definitions/swift.d.ts.map +1 -1
  130. package/dist/languages/definitions/swift.js +66 -16
  131. package/dist/languages/definitions/swift.js.map +1 -1
  132. package/dist/languages/definitions/typescript.d.ts.map +1 -1
  133. package/dist/languages/definitions/typescript.js +30 -9
  134. package/dist/languages/definitions/typescript.js.map +1 -1
  135. package/dist/languages/definitions/zig.d.ts.map +1 -1
  136. package/dist/languages/definitions/zig.js +26 -5
  137. package/dist/languages/definitions/zig.js.map +1 -1
  138. package/dist/languages/import-statement-parsers.d.ts +14 -1
  139. package/dist/languages/import-statement-parsers.d.ts.map +1 -1
  140. package/dist/languages/import-statement-parsers.js +473 -45
  141. package/dist/languages/import-statement-parsers.js.map +1 -1
  142. package/dist/languages/types.d.ts +11 -0
  143. package/dist/languages/types.d.ts.map +1 -1
  144. package/dist/languages.d.ts +1 -0
  145. package/dist/languages.d.ts.map +1 -1
  146. package/dist/languages.js +9 -2
  147. package/dist/languages.js.map +1 -1
  148. package/dist/native/backend-report-format.d.ts +4 -0
  149. package/dist/native/backend-report-format.d.ts.map +1 -0
  150. package/dist/native/backend-report-format.js +14 -0
  151. package/dist/native/backend-report-format.js.map +1 -0
  152. package/dist/native/contracts.d.ts +2 -0
  153. package/dist/native/contracts.d.ts.map +1 -1
  154. package/dist/util/comments.js +1 -1
  155. package/dist/util/comments.js.map +1 -1
  156. package/dist/util/member-access.d.ts +1 -1
  157. package/dist/util/member-access.d.ts.map +1 -1
  158. package/dist/util/member-access.js +5 -2
  159. package/dist/util/member-access.js.map +1 -1
  160. package/dist/util/project-files.js +1 -1
  161. package/dist/util/project-files.js.map +1 -1
  162. package/dist/util/resolution/rust.d.ts +8 -1
  163. package/dist/util/resolution/rust.d.ts.map +1 -1
  164. package/dist/util/resolution/rust.js +521 -7
  165. package/dist/util/resolution/rust.js.map +1 -1
  166. package/dist/util/resolution-candidates.d.ts +1 -1
  167. package/dist/util/resolution-candidates.d.ts.map +1 -1
  168. package/dist/util/resolution-candidates.js +11 -8
  169. package/dist/util/resolution-candidates.js.map +1 -1
  170. package/dist/util/resolution.d.ts +5 -0
  171. package/dist/util/resolution.d.ts.map +1 -1
  172. package/dist/util/resolution.js +18 -7
  173. package/dist/util/resolution.js.map +1 -1
  174. package/dist/util/rust-test-modules.d.ts.map +1 -1
  175. package/dist/util/rust-test-modules.js +2 -5
  176. package/dist/util/rust-test-modules.js.map +1 -1
  177. package/dist/util/specifiers.d.ts +8 -0
  178. package/dist/util/specifiers.d.ts.map +1 -1
  179. package/dist/util/specifiers.js +33 -7
  180. package/dist/util/specifiers.js.map +1 -1
  181. package/package.json +3 -3
@@ -192,7 +192,7 @@ var BASE_STRUCTURE = {
192
192
  },
193
193
  {
194
194
  type: "module",
195
- nameQuery: "name: (identifier) @chunk.name body: (statement_block) @chunk.block.namespace",
195
+ nameQuery: "name: [ (identifier) (string) ] @chunk.name body: (statement_block) @chunk.block.namespace",
196
196
  captureId: "namespace"
197
197
  },
198
198
  // Data
@@ -220,19 +220,25 @@ var BASE_GRAPH = {
220
220
  exports: `
221
221
  (export_statement) @stmt
222
222
  (export_statement declaration: (function_declaration name: (identifier) @name)) @stmt
223
+ (export_statement declaration: (function_signature name: (identifier) @name)) @stmt
223
224
  (export_statement declaration: (generator_function_declaration name: (identifier) @name)) @stmt
224
225
  (export_statement declaration: (class_declaration name: (type_identifier) @name)) @stmt
225
226
  (export_statement declaration: (abstract_class_declaration name: (type_identifier) @name)) @stmt
226
227
  (export_statement declaration: (enum_declaration name: [ (identifier) (type_identifier) ] @name)) @stmt
228
+ (export_statement declaration: (internal_module name: (identifier) @name)) @stmt
229
+ (export_statement declaration: (module name: (identifier) @name)) @stmt
230
+ (export_statement declaration: (ambient_declaration (function_signature name: (identifier) @name))) @stmt
231
+ (export_statement declaration: (ambient_declaration (internal_module name: (identifier) @name))) @stmt
232
+ (export_statement declaration: (ambient_declaration (module name: (identifier) @name))) @stmt
227
233
  (export_statement declaration: (function_declaration) @anon_default) @stmt
228
234
  (export_statement declaration: (generator_function_declaration) @anon_default) @stmt
229
235
  (export_statement declaration: (class_declaration) @anon_default) @stmt
230
236
  (export_statement declaration: (abstract_class_declaration) @anon_default) @stmt
231
237
  (export_statement declaration: (lexical_declaration (variable_declarator name: (identifier) @name))) @stmt
232
- (export_statement (export_clause (export_specifier name: (identifier) @src alias: (identifier) @alias)) (string) @from) @stmt
233
- (export_statement (export_clause (export_specifier name: (identifier) @src !alias)) (string) @from) @stmt
234
- (export_statement (export_clause (export_specifier name: (identifier) @src alias: (identifier) @alias))) @stmt
235
- (export_statement (export_clause (export_specifier name: (identifier) @src !alias))) @stmt
238
+ (export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src alias: (identifier) @alias)) (string) @from) @stmt
239
+ (export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src !alias)) (string) @from) @stmt
240
+ (export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src alias: (identifier) @alias))) @stmt
241
+ (export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src !alias))) @stmt
236
242
  (export_statement (string) @from) @stmt
237
243
  (export_assignment (identifier) @ts_export_assign)
238
244
  `,
@@ -242,20 +248,23 @@ var BASE_GRAPH = {
242
248
  (method_definition name: (property_identifier) @name)
243
249
  (method_signature name: (property_identifier) @name)
244
250
  (abstract_method_signature name: (property_identifier) @name)
251
+ (function_signature name: (identifier) @name)
245
252
  (class_declaration name: (type_identifier) @name)
246
253
  (abstract_class_declaration name: (type_identifier) @name)
247
254
  (variable_declarator name: (identifier) @name)
248
255
  (interface_declaration name: (type_identifier) @name)
249
256
  (type_alias_declaration name: (type_identifier) @name)
250
257
  (enum_declaration name: [ (identifier) (type_identifier) ] @name)
258
+ (internal_module name: (identifier) @name)
259
+ (module name: (identifier) @name)
251
260
  `,
252
261
  importBindings: `
253
262
  (import_statement) @stmt
254
263
  (import_statement (string) @from) @stmt
255
264
  (import_statement (import_require_clause (identifier) @def (string) @from)) @stmt
256
265
  (import_statement (import_clause (identifier) @def) (string) @from) @stmt
257
- (import_statement (import_clause (named_imports (import_specifier name: (identifier) @iname alias: (identifier) @alias))) (string) @from) @stmt
258
- (import_statement (import_clause (named_imports (import_specifier name: (identifier) @iname))) (string) @from) @stmt
266
+ (import_statement (import_clause (named_imports (import_specifier "type"? @type_kw name: (identifier) @iname alias: (identifier) @alias))) (string) @from) @stmt
267
+ (import_statement (import_clause (named_imports (import_specifier "type"? @type_kw name: (identifier) @iname !alias))) (string) @from) @stmt
259
268
  (import_statement (import_clause (namespace_import (identifier) @ns)) (string) @from) @stmt
260
269
  `
261
270
  };
@@ -278,6 +287,8 @@ var BASE_HELPERS = {
278
287
  return "function";
279
288
  if (t === "abstract_method_signature")
280
289
  return "function";
290
+ if (t === "function_signature")
291
+ return "function";
281
292
  if (t === "class_declaration")
282
293
  return "class";
283
294
  if (t === "abstract_class_declaration")
@@ -286,7 +297,7 @@ var BASE_HELPERS = {
286
297
  return "interface";
287
298
  if (t === "type_alias_declaration")
288
299
  return "type";
289
- if (t === "enum_declaration")
300
+ if (t === "enum_declaration" || t === "internal_module" || t === "module")
290
301
  return "type";
291
302
  return "variable";
292
303
  },
@@ -301,6 +312,9 @@ var BASE_HELPERS = {
301
312
  "interface_declaration",
302
313
  "type_alias_declaration",
303
314
  "enum_declaration",
315
+ "function_signature",
316
+ "internal_module",
317
+ "module",
304
318
  "import_specifier",
305
319
  "namespace_import",
306
320
  "import_clause",
@@ -312,7 +326,14 @@ var BASE_HELPERS = {
312
326
  "abstract_method_signature"
313
327
  ].includes(p);
314
328
  },
315
- createsBlockScope: (n) => n.type === "program" || n.type === "block" || n.type === "class_body",
329
+ // Scope construction has structural handling for the ordinary declaration forms. Ambient
330
+ // overload signatures and `namespace X {}` are not in it, so opt their name nodes in here;
331
+ // `isDeclarationName` already accepts both parents.
332
+ scopeDeclarationNames: (node) => {
333
+ const parent = node.parent?.type;
334
+ return parent === "function_signature" || parent === "internal_module" || parent === "module";
335
+ },
336
+ createsBlockScope: (n) => n.type === "program" || n.type === "block" || n.type === "class_body" || n.type === "class_static_block",
316
337
  createsFunctionScope: (n) => n.type === "generator_function_declaration" || n.type === "function_declaration" || n.type === "function" || n.type === "function_expression" || n.type === "arrow_function" || n.type === "method_definition",
317
338
  membersAreImplicitlyInScope: false,
318
339
  supportsCrossModuleSymbols: true
@@ -358,17 +379,17 @@ registerLanguage(TSX_DEF);
358
379
  // dist/languages/definitions/javascript.js
359
380
  var JS_OBJECT_METHOD_EXPORT_PATTERN = `
360
381
  ;; CJS: module.exports = { helper () {} }
361
- (expression_statement (assignment_expression
382
+ ((expression_statement (assignment_expression
362
383
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
363
384
  right: (object (pair key: (property_identifier) @cjs_export_name value: (function_declaration) @cjs_fn))))
364
- (#eq? @mod "module") (#eq? @prop "exports")
385
+ (#eq? @mod "module") (#eq? @prop "exports"))
365
386
  `;
366
387
  var JS_OBJECT_METHOD_EXPORT_NATIVE_PATTERN = `
367
388
  ;; CJS: module.exports = { helper () {} }
368
- (expression_statement (assignment_expression
389
+ ((expression_statement (assignment_expression
369
390
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
370
391
  right: (object (method_definition name: (property_identifier) @cjs_export_name) @cjs_fn)))
371
- (#eq? @mod "module") (#eq? @prop "exports")
392
+ (#eq? @mod "module") (#eq? @prop "exports"))
372
393
  `;
373
394
  var JAVASCRIPT_DEF = {
374
395
  id: "js",
@@ -401,58 +422,63 @@ var JAVASCRIPT_DEF = {
401
422
  (export_statement (export_clause (export_specifier name: (identifier) @src alias: (identifier) @alias)))
402
423
  (export_statement (export_clause (export_specifier name: (identifier) @src !alias)))
403
424
  (export_statement (string) @from)
404
- (expression_statement (assignment_expression
425
+ ;; CJS whole-module export: module.exports = function () {} / = () => {}
426
+ ((expression_statement (assignment_expression
427
+ left: (member_expression object: (identifier) @mod property: (property_identifier) @cjs_export_name)
428
+ right: [ (function) (arrow_function) ] @cjs_fn))
429
+ (#eq? @mod "module") (#eq? @cjs_export_name "exports"))
430
+ ((expression_statement (assignment_expression
405
431
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
406
432
  right: (object (shorthand_property_identifier) @cjs_shorthand)))
407
- (#eq? @mod "module") (#eq? @prop "exports")
433
+ (#eq? @mod "module") (#eq? @prop "exports"))
408
434
  ;; CJS spread export: module.exports = { ...base }
409
435
  ((expression_statement (assignment_expression
410
436
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
411
437
  right: (object (spread_element (identifier) @cjs_spread))) @stmt)
412
438
  (#eq? @mod "module") (#eq? @prop "exports"))
413
- (expression_statement (assignment_expression
439
+ ((expression_statement (assignment_expression
414
440
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
415
441
  right: (object (pair key: (property_identifier) @cjs_export_name value: (identifier) @cjs_local))))
416
- (#eq? @mod "module") (#eq? @prop "exports")
417
- (expression_statement (assignment_expression
442
+ (#eq? @mod "module") (#eq? @prop "exports"))
443
+ ((expression_statement (assignment_expression
418
444
  left: (member_expression object: (member_expression object: (identifier) @mod property: (property_identifier) @prop) property: (property_identifier) @cjs_export_name)
419
445
  right: (identifier) @cjs_local))
420
- (#eq? @mod "module") (#eq? @prop "exports")
421
- (expression_statement (assignment_expression
446
+ (#eq? @mod "module") (#eq? @prop "exports"))
447
+ ((expression_statement (assignment_expression
422
448
  left: (member_expression object: (identifier) @exp property: (property_identifier) @cjs_export_name)
423
449
  right: (identifier) @cjs_local))
424
- (#eq? @exp "exports")
450
+ (#eq? @exp "exports"))
425
451
  ;; CJS function/arrow direct exports
426
- (expression_statement (assignment_expression
452
+ ((expression_statement (assignment_expression
427
453
  left: (member_expression object: (member_expression object: (identifier) @mod property: (property_identifier) @prop) property: (property_identifier) @cjs_export_name)
428
454
  right: (function) @cjs_fn))
429
- (#eq? @mod "module") (#eq? @prop "exports")
430
- (expression_statement (assignment_expression
455
+ (#eq? @mod "module") (#eq? @prop "exports"))
456
+ ((expression_statement (assignment_expression
431
457
  left: (member_expression object: (member_expression object: (identifier) @mod property: (property_identifier) @prop) property: (property_identifier) @cjs_export_name)
432
458
  right: (arrow_function) @cjs_fn))
433
- (#eq? @mod "module") (#eq? @prop "exports")
434
- (expression_statement (assignment_expression
459
+ (#eq? @mod "module") (#eq? @prop "exports"))
460
+ ((expression_statement (assignment_expression
435
461
  left: (member_expression object: (identifier) @exp property: (property_identifier) @cjs_export_name)
436
462
  right: (function) @cjs_fn))
437
- (#eq? @exp "exports")
438
- (expression_statement (assignment_expression
463
+ (#eq? @exp "exports"))
464
+ ((expression_statement (assignment_expression
439
465
  left: (member_expression object: (identifier) @exp property: (property_identifier) @cjs_export_name)
440
466
  right: (arrow_function) @cjs_fn))
441
- (#eq? @exp "exports")
467
+ (#eq? @exp "exports"))
442
468
  ;; CJS object export with function value
443
- (expression_statement (assignment_expression
469
+ ((expression_statement (assignment_expression
444
470
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
445
471
  right: (object (pair key: (property_identifier) @cjs_export_name value: (function) @cjs_fn))))
446
- (#eq? @mod "module") (#eq? @prop "exports")
447
- (expression_statement (assignment_expression
472
+ (#eq? @mod "module") (#eq? @prop "exports"))
473
+ ((expression_statement (assignment_expression
448
474
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
449
475
  right: (object (pair key: (property_identifier) @cjs_export_name value: (arrow_function) @cjs_fn))))
450
- (#eq? @mod "module") (#eq? @prop "exports")
476
+ (#eq? @mod "module") (#eq? @prop "exports"))
451
477
  ;; CJS: module.exports = { helper () {} }
452
- (expression_statement (assignment_expression
478
+ ((expression_statement (assignment_expression
453
479
  left: (member_expression object: (identifier) @mod property: (property_identifier) @prop)
454
480
  right: (object (pair key: (property_identifier) @cjs_export_name value: (function_declaration) @cjs_fn))))
455
- (#eq? @mod "module") (#eq? @prop "exports")
481
+ (#eq? @mod "module") (#eq? @prop "exports"))
456
482
  `,
457
483
  locals: `
458
484
  (function_declaration name: (identifier) @name)
@@ -466,10 +492,12 @@ var JAVASCRIPT_DEF = {
466
492
  (import_statement (string) @from) @stmt
467
493
  (import_statement (import_clause (identifier) @def) (string) @from) @stmt
468
494
  (import_statement (import_clause (named_imports (import_specifier name: (identifier) @iname alias: (identifier) @alias))) (string) @from) @stmt
469
- (import_statement (import_clause (named_imports (import_specifier name: (identifier) @iname))) (string) @from) @stmt
495
+ (import_statement (import_clause (named_imports (import_specifier name: (identifier) @iname !alias))) (string) @from) @stmt
470
496
  (import_statement (import_clause (namespace_import (identifier) @ns)) (string) @from) @stmt
471
- (lexical_declaration (variable_declarator name:(identifier) @def value: (call_expression (identifier) @req arguments: (arguments (string) @from)))) (#eq? @req "require")
472
- (lexical_declaration (variable_declarator (object_pattern) @pattern value: (call_expression (identifier) @req arguments: (arguments (string) @from)))) (#eq? @req "require")
497
+ ((lexical_declaration (variable_declarator name:(identifier) @def value: (call_expression (identifier) @req arguments: (arguments (string) @from))))
498
+ (#eq? @req "require"))
499
+ ((lexical_declaration (variable_declarator (object_pattern) @pattern value: (call_expression (identifier) @req arguments: (arguments (string) @from))))
500
+ (#eq? @req "require"))
473
501
  `
474
502
  },
475
503
  nodeTypes: {
@@ -486,6 +514,8 @@ var JAVASCRIPT_DEF = {
486
514
  return "function";
487
515
  if (t === "method_definition")
488
516
  return "function";
517
+ if (t === "function" || t === "function_expression")
518
+ return "function";
489
519
  if (t === "class_declaration")
490
520
  return "class";
491
521
  return "variable";
@@ -502,10 +532,19 @@ var JAVASCRIPT_DEF = {
502
532
  "import_clause",
503
533
  // Method names in classes: needed so that editing a method name is
504
534
  // classified as a definition change, not an unrecognised node.
505
- "method_definition"
535
+ "method_definition",
536
+ // A named function expression binds its own name; `$scope.x = function x() {}` and
537
+ // `const f = function inner() {}` are the common shapes.
538
+ "function",
539
+ "function_expression"
506
540
  ].includes(p);
507
541
  },
508
- createsBlockScope: (n) => n.type === "program" || n.type === "block" || n.type === "class_body",
542
+ // Scope construction has no structural handling for a function expression's own name.
543
+ scopeDeclarationNames: (node) => {
544
+ const parent = node.parent?.type;
545
+ return parent === "function" || parent === "function_expression";
546
+ },
547
+ createsBlockScope: (n) => n.type === "program" || n.type === "block" || n.type === "class_body" || n.type === "class_static_block",
509
548
  createsFunctionScope: (n) => n.type === "function_declaration" || n.type === "generator_function_declaration" || n.type === "function" || n.type === "function_expression" || n.type === "arrow_function" || n.type === "method_definition",
510
549
  membersAreImplicitlyInScope: false,
511
550
  supportsCrossModuleSymbols: true,
@@ -538,9 +577,24 @@ var GO_IDENTIFIER_SOURCE = String.raw`[\p{L}_][\p{L}\p{Nd}_]*`;
538
577
  var KOTLIN_IDENTIFIER_SOURCE = String.raw`[\p{L}_][\p{L}\p{Nd}_]*`;
539
578
 
540
579
  // dist/languages/definitions/python.js
580
+ function isTypeAliasLeftName(node) {
581
+ const parent = node.parent;
582
+ if (!parent)
583
+ return false;
584
+ if (parent.type === "type") {
585
+ const stmt = parent.parent;
586
+ return stmt?.type === "type_alias_statement" && stmt.childForFieldName("left")?.id === parent.id;
587
+ }
588
+ if (parent.type === "generic_type") {
589
+ const typeNode = parent.parent;
590
+ const stmt = typeNode?.parent;
591
+ return typeNode?.type === "type" && stmt?.type === "type_alias_statement" && stmt.childForFieldName("left")?.id === typeNode.id;
592
+ }
593
+ return false;
594
+ }
541
595
  var PYTHON_DEF = {
542
596
  id: "python",
543
- extensions: [".py", ".pyi"],
597
+ extensions: [".py", ".pyi", ".pyw"],
544
598
  usesQueryDrivenLocals: true,
545
599
  structure: {
546
600
  blocks: [
@@ -564,9 +618,14 @@ var PYTHON_DEF = {
564
618
  // Top level assignments
565
619
  {
566
620
  type: "assignment",
567
- nameQuery: "left: (identifier) @chunk.name",
621
+ nameQuery: "left: [(identifier) @chunk.name (pattern_list (identifier) @chunk.name) (tuple_pattern (identifier) @chunk.name)]",
568
622
  captureId: "module_var"
569
623
  },
624
+ {
625
+ type: "type_alias_statement",
626
+ nameQuery: "left: (type [(identifier) @chunk.name (generic_type (identifier) @chunk.name)])",
627
+ captureId: "type"
628
+ },
570
629
  // Imports
571
630
  { type: "import_statement", captureId: "imports" },
572
631
  { type: "import_from_statement", captureId: "imports" }
@@ -593,35 +652,60 @@ var PYTHON_DEF = {
593
652
  // This is a known limitation - such patterns are rare in practice.
594
653
  exports: `
595
654
  ;; __all__ = ["a", "b"] - simple list assignment
596
- (assignment left: (identifier) @left right: (list (string)+ @all_item)) @stmt
655
+ (module (expression_statement (assignment left: (identifier) @left right: (list (string) @all_item)) @stmt))
597
656
  ;; __all__ = ("a", "b") - tuple assignment
598
- (assignment left: (identifier) @left right: (tuple (string)+ @all_item)) @stmt
657
+ (module (expression_statement (assignment left: (identifier) @left right: (tuple (string) @all_item)) @stmt))
599
658
  ;; __all__ = ["a"] + ["b"] - concatenation (captures strings in both sides)
600
- (assignment left: (identifier) @left right: (binary_operator (list (string)+ @all_item))) @stmt
601
- (assignment left: (identifier) @left right: (binary_operator right: (list (string)+ @all_item))) @stmt
659
+ (module (expression_statement (assignment left: (identifier) @left right: (binary_operator (list (string) @all_item))) @stmt))
660
+ (module (expression_statement (assignment left: (identifier) @left right: (binary_operator right: (list (string) @all_item))) @stmt))
602
661
  ;; __all__.extend(["a"]) - extend pattern
603
- (expression_statement (call function: (attribute object: (identifier) @left attribute: (identifier) @method) arguments: (argument_list (list (string)+ @all_item)))) @stmt
662
+ (module (expression_statement (call function: (attribute object: (identifier) @left attribute: (identifier) @method) arguments: (argument_list (list (string) @all_item)))) @stmt)
604
663
  ;; __all__.append("a") - append pattern
605
- (expression_statement (call function: (attribute object: (identifier) @left attribute: (identifier) @method) arguments: (argument_list (string) @all_item))) @stmt
664
+ (module (expression_statement (call function: (attribute object: (identifier) @left attribute: (identifier) @method) arguments: (argument_list (string) @all_item))) @stmt)
606
665
  ;; __all__ += ["a"] - augmented assignment
607
- (augmented_assignment left: (identifier) @left right: (list (string)+ @all_item)) @stmt
608
- (function_definition name: (identifier) @name)
609
- (class_definition name: (identifier) @name)
610
- (assignment left: (identifier) @name)
666
+ (module (expression_statement (augmented_assignment left: (identifier) @left right: (list (string) @all_item)) @stmt))
667
+ ;; An empty static list or tuple still defines an explicit export set.
668
+ (module (expression_statement (assignment left: (identifier) @left right: [(list) (tuple)]) @stmt))
669
+ (module (function_definition name: (identifier) @name))
670
+ (module (class_definition name: (identifier) @name))
671
+ (module (decorated_definition (function_definition name: (identifier) @name)))
672
+ (module (decorated_definition (class_definition name: (identifier) @name)))
673
+ (module (expression_statement (assignment left: (identifier) @name)))
674
+ (module (expression_statement (assignment left: [(pattern_list (identifier) @name) (tuple_pattern (identifier) @name)])))
675
+ (module (expression_statement (named_expression name: (identifier) @name)))
676
+ (module (type_alias_statement left: (type [(identifier) @name (generic_type (identifier) @name)])))
677
+ (class_definition body: (block (function_definition name: (identifier) @name)))
678
+ (class_definition body: (block (class_definition name: (identifier) @name)))
679
+ (class_definition body: (block (decorated_definition (function_definition name: (identifier) @name))))
680
+ (class_definition body: (block (decorated_definition (class_definition name: (identifier) @name))))
681
+ (class_definition body: (block (expression_statement (assignment left: (identifier) @name))))
682
+ (class_definition body: (block (expression_statement (assignment left: [(pattern_list (identifier) @name) (tuple_pattern (identifier) @name)]))))
683
+ (class_definition body: (block (expression_statement (named_expression name: (identifier) @name))))
684
+ (class_definition body: (block (type_alias_statement left: (type [(identifier) @name (generic_type (identifier) @name)]))))
611
685
  `,
612
686
  locals: `
613
687
  (function_definition name: (identifier) @name)
614
688
  (class_definition name: (identifier) @name)
615
689
  (assignment left: (identifier) @name)
616
- ;; \`case Point(x=x, y=y):\` binds the right-hand identifier of a keyword
617
- ;; pattern as a new local, distinct from the left-hand attribute name it
618
- ;; matches against.
690
+ (assignment left: [(pattern_list (identifier) @name) (tuple_pattern (identifier) @name)])
691
+ (named_expression name: (identifier) @name)
692
+ (type_alias_statement left: (type [(identifier) @name (generic_type (identifier) @name)]))
693
+ ;; \`case Point(x=px, y=py):\` is case_pattern -> class_pattern ->
694
+ ;; case_pattern -> keyword_pattern. The binding is the dotted_name child;
695
+ ;; the left-hand attribute is a bare identifier and must not be captured.
696
+ ;; Anchoring to the first and last (named) child restricts the match to a
697
+ ;; single-segment dotted_name, so a qualified value like \`x=module.CONST\`
698
+ ;; does not create locals for \`module\` or \`CONST\`.
699
+ (keyword_pattern (dotted_name . (identifier) @name .))
619
700
  ;; A bare identifier in a case pattern is represented as a single-name
620
701
  ;; dotted_name inside a case_pattern. Nested tuple/list/or patterns
621
- ;; preserve this shape for each capture.
622
- (case_pattern (dotted_name (identifier) @name))
702
+ ;; preserve this shape for each capture. The same anchor keeps a qualified
703
+ ;; value pattern such as \`case module.CONST:\` from creating locals.
704
+ (case_pattern (dotted_name . (identifier) @name .))
623
705
  ;; \`case value as alias:\` binds the direct identifier child as its alias.
624
- (as_pattern (identifier) @name)
706
+ ;; \`except E as err\` / \`with ctx as handle\` put the binding in alias.
707
+ (as_pattern !alias (identifier) @name)
708
+ (as_pattern alias: (as_pattern_target (identifier) @name))
625
709
  ;; \`case [head, *tail]:\` binds the capture after the splat.
626
710
  (splat_pattern (identifier) @name)
627
711
  `,
@@ -642,27 +726,39 @@ var PYTHON_DEF = {
642
726
  return "function";
643
727
  if (t === "class_definition")
644
728
  return "class";
729
+ if (isTypeAliasLeftName(n))
730
+ return "type";
645
731
  return "variable";
646
732
  },
647
733
  scopeDeclarationNames: (node) => {
648
734
  const parentType = node.parent?.type;
649
- return parentType === "case_pattern" || parentType === "as_pattern" || parentType === "splat_pattern" || parentType === "dotted_name";
735
+ return parentType === "case_pattern" || parentType === "as_pattern" || parentType === "as_pattern_target" || parentType === "splat_pattern" || parentType === "dotted_name" || parentType === "named_expression" || parentType === "pattern_list" || parentType === "tuple_pattern" || parentType === "type" || parentType === "generic_type";
650
736
  },
651
737
  isDeclarationName: (node) => {
652
738
  const parent = node.parent;
653
739
  const t = parent?.type;
654
740
  if (t === "dotted_name" && parent && parent.namedChildren.length === 1 && (parent.parent?.type === "keyword_pattern" || parent.parent?.type === "case_pattern"))
655
741
  return true;
656
- if (parent?.type === "as_pattern")
742
+ if (t === "as_pattern_target")
657
743
  return true;
744
+ if (t === "as_pattern")
745
+ return parent?.childForFieldName("alias") == null;
658
746
  if (t === "splat_pattern")
659
747
  return true;
748
+ if (t === "named_expression")
749
+ return parent?.childForFieldName("name")?.id === node.id;
750
+ if (t === "pattern_list" || t === "tuple_pattern")
751
+ return true;
752
+ if (isTypeAliasLeftName(node))
753
+ return true;
660
754
  return !!t && ["function_definition", "class_definition", "assignment", "aliased_import"].includes(t);
661
755
  },
662
756
  createsBlockScope: (n) => n.type === "module" || n.type === "block",
663
757
  createsFunctionScope: (n) => n.type === "function_definition" || n.type === "lambda",
664
758
  membersAreImplicitlyInScope: false,
665
759
  supportsCrossModuleSymbols: true,
760
+ // A function body and a class body are both `block`, so only the function form blocks exports.
761
+ exportScopeBlockers: ["function_definition>block"],
666
762
  normalizeIdentifier: (name) => hasNonAsciiCodePoint(name) ? name.normalize("NFKC") : name
667
763
  };
668
764
  registerLanguage(PYTHON_DEF);
@@ -670,7 +766,7 @@ registerLanguage(PYTHON_DEF);
670
766
  // dist/languages/definitions/php.js
671
767
  var PHP_DEF = {
672
768
  id: "php",
673
- extensions: [".php"],
769
+ extensions: [".php", ".phtml", ".php4", ".php8"],
674
770
  usesQueryDrivenLocals: true,
675
771
  structure: {
676
772
  blocks: [
@@ -824,12 +920,12 @@ registerLanguage(PHP_DEF);
824
920
  // dist/languages/definitions/html.js
825
921
  var HTML_DEF = {
826
922
  id: "html",
827
- extensions: [".html", ".htm"],
923
+ extensions: [".html", ".htm", ".xhtml"],
828
924
  structure: {
829
925
  blocks: [
830
926
  {
831
927
  type: "element",
832
- nameQuery: `(start_tag (attribute (attribute_name) @attr (#eq? @attr "id") (quoted_attribute_value (attribute_value) @chunk.name)))`,
928
+ nameQuery: `(start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)id$") (quoted_attribute_value (attribute_value) @chunk.name)))`,
833
929
  captureId: "element"
834
930
  },
835
931
  { type: "script_element", captureId: "script" },
@@ -840,22 +936,22 @@ var HTML_DEF = {
840
936
  },
841
937
  graph: {
842
938
  imports: `
843
- (script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt
844
- (element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "href") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(link|a)$")
845
- (element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "href") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(link|a)$")
846
- (element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#eq? @tag "img")
847
- (element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#eq? @tag "img")
939
+ (script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt
940
+ ((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)(link|a)$"))
941
+ ((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)(link|a)$"))
942
+ ((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)img$"))
943
+ ((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)img$"))
848
944
  `,
849
945
  exports: "",
850
946
  locals: `
851
- (attribute (attribute_name) @attr (#eq? @attr "id") (quoted_attribute_value (attribute_value) @name))
947
+ (attribute (attribute_name) @attr (#match? @attr "^(?i)id$") (quoted_attribute_value (attribute_value) @name))
852
948
  `,
853
949
  importBindings: `
854
- (script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt
855
- (element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "href") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(link|a)$")
856
- (element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "href") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(link|a)$")
857
- (element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt (#eq? @tag "img")
858
- (element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt (#eq? @tag "img")
950
+ (script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt
951
+ ((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)(link|a)$"))
952
+ ((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)(link|a)$"))
953
+ ((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)img$"))
954
+ ((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)img$"))
859
955
  `
860
956
  },
861
957
  nodeTypes: {
@@ -954,16 +1050,10 @@ var CSS_DEF = {
954
1050
  registerLanguage(CSS_DEF);
955
1051
 
956
1052
  // dist/languages/definitions/scss.js
957
- var SCSS_SYMBOL_QUERY_PATTERNS = [
958
- "(mixin_statement (name) @name)",
959
- "(function_statement (name) @name)",
960
- "(variable_declaration (variable) @name)",
961
- "(class_selector (class_name) @name)",
962
- "(id_selector (id_name) @name)"
963
- ];
964
1053
  var SCSS_DEF = {
965
1054
  id: "scss",
966
1055
  extensions: [".scss"],
1056
+ usesQueryDrivenLocals: true,
967
1057
  structure: {
968
1058
  blocks: [
969
1059
  { type: "rule_set", captureId: "rule" },
@@ -978,33 +1068,43 @@ var SCSS_DEF = {
978
1068
  graph: {
979
1069
  imports: `
980
1070
  (import_statement (string_value) @mod) @stmt
1071
+ (import_statement (_ (string_value) @mod)) @stmt
981
1072
  (use_statement (string_value) @mod) @stmt
1073
+ (use_statement (_ (string_value) @mod)) @stmt
982
1074
  (forward_statement (string_value) @mod) @stmt
1075
+ (forward_statement (_ (string_value) @mod)) @stmt
983
1076
  `,
984
1077
  exports: `
985
- (mixin_statement (name) @name)
986
- (function_statement (name) @name)
987
- (variable_declaration (variable) @name)
1078
+ (stylesheet (mixin_statement name: (identifier) @name))
1079
+ (stylesheet (function_statement name: (identifier) @name))
1080
+ ((stylesheet (declaration (property_name) @name)) (#match? @name "^[$]"))
1081
+ (stylesheet (rule_set (selectors (placeholder (identifier) @name))))
988
1082
  `,
989
1083
  locals: `
990
- (mixin_statement (name) @name)
991
- (function_statement (name) @name)
992
- (variable_declaration (variable) @name)
1084
+ (mixin_statement name: (identifier) @name)
1085
+ (function_statement name: (identifier) @name)
1086
+ ((declaration (property_name) @name) (#match? @name "^[$]"))
1087
+ (placeholder (identifier) @name)
993
1088
  (class_selector (class_name) @name)
994
1089
  (id_selector (id_name) @name)
995
1090
  `,
996
1091
  importBindings: `
997
1092
  (import_statement (string_value) @from) @stmt
1093
+ (import_statement (_ (string_value) @from)) @stmt
998
1094
  (use_statement (string_value) @from) @stmt
1095
+ (use_statement (_ (string_value) @from)) @stmt
999
1096
  (forward_statement (string_value) @from) @stmt
1097
+ (forward_statement (_ (string_value) @from)) @stmt
1000
1098
  `
1001
1099
  },
1002
1100
  nodeTypes: {
1003
- identifier: ["name", "variable", "class_name", "id_name"]
1101
+ identifier: ["identifier", "variable", "class_name", "id_name", "property_name"]
1004
1102
  },
1005
- native: {
1006
- normalizeQuery: (_kind, query) => SCSS_SYMBOL_QUERY_PATTERNS.some((pattern) => query.includes(pattern)) ? "" : query,
1007
- notes: ["skips unsupported SCSS symbol queries in the native runtime"]
1103
+ classifyDefinition: (node) => {
1104
+ const parent = node.parent?.type;
1105
+ if (parent === "mixin_statement" || parent === "function_statement")
1106
+ return "function";
1107
+ return "variable";
1008
1108
  }
1009
1109
  };
1010
1110
  registerLanguage(SCSS_DEF);
@@ -1080,17 +1180,17 @@ registerLanguage(SVELTE_DEF);
1080
1180
  // dist/languages/definitions/ruby.js
1081
1181
  var RUBY_DEF = {
1082
1182
  id: "ruby",
1083
- extensions: [".rb"],
1183
+ extensions: [".rb", ".rbw", ".rake", ".gemspec"],
1084
1184
  structure: {
1085
1185
  blocks: [
1086
1186
  {
1087
1187
  type: "class",
1088
- nameQuery: "name: (constant) @chunk.name",
1188
+ nameQuery: "name: [(constant) (scope_resolution)] @chunk.name",
1089
1189
  captureId: "class"
1090
1190
  },
1091
1191
  {
1092
1192
  type: "module",
1093
- nameQuery: "name: (constant) @chunk.name",
1193
+ nameQuery: "name: [(constant) (scope_resolution)] @chunk.name",
1094
1194
  captureId: "module"
1095
1195
  },
1096
1196
  {
@@ -1109,23 +1209,25 @@ var RUBY_DEF = {
1109
1209
  },
1110
1210
  graph: {
1111
1211
  imports: `
1112
- (call method: (identifier) @method arguments: (argument_list (string (string_content) @mod)) (#match? @method "^(require|require_relative)$")) @stmt
1212
+ (call method: (identifier) @method arguments: (argument_list (string (string_content) @mod)) (#match? @method "^(require|require_relative|load|autoload)$")) @stmt
1113
1213
  `,
1114
1214
  exports: `
1115
- (class name: (constant) @name)
1116
- (module name: (constant) @name)
1117
- (method name: (identifier) @name)
1215
+ (class name: [(constant) (scope_resolution)] @name)
1216
+ (module name: [(constant) (scope_resolution)] @name)
1217
+ (method name: [(identifier) (setter)] @name)
1218
+ (singleton_method name: [(identifier) (setter)] @name)
1118
1219
  (assignment left: (constant) @name)
1119
1220
  `,
1120
1221
  locals: `
1121
- (class name: (constant) @name)
1122
- (module name: (constant) @name)
1123
- (method name: (identifier) @name)
1222
+ (class name: [(constant) (scope_resolution)] @name)
1223
+ (module name: [(constant) (scope_resolution)] @name)
1224
+ (method name: [(identifier) (setter)] @name)
1225
+ (singleton_method name: [(identifier) (setter)] @name)
1124
1226
  (assignment left: (identifier) @name)
1125
1227
  (assignment left: (constant) @name)
1126
1228
  `,
1127
1229
  importBindings: `
1128
- ((call method: (identifier) @method arguments: (argument_list (string (string_content) @from))) @stmt (#match? @method "^(require|require_relative)$"))
1230
+ ((call method: (identifier) @method arguments: (argument_list (string (string_content) @from))) @stmt (#match? @method "^(require|require_relative|load|autoload)$"))
1129
1231
  `
1130
1232
  },
1131
1233
  nodeTypes: {
@@ -1202,9 +1304,9 @@ var GO_DEF = {
1202
1304
  exports: `
1203
1305
  (function_declaration name: (identifier) @name)
1204
1306
  (method_declaration name: (field_identifier) @name)
1205
- (type_spec name: (type_identifier) @name)
1206
- (const_spec name: (identifier) @name)
1207
- (var_spec name: (identifier) @name)
1307
+ (source_file (type_declaration (type_spec name: (type_identifier) @name)))
1308
+ (source_file (const_declaration (const_spec (identifier) @name)))
1309
+ (source_file (var_declaration (var_spec (identifier) @name)))
1208
1310
  `,
1209
1311
  locals: `
1210
1312
  (function_declaration name: (identifier) @name)
@@ -1212,9 +1314,10 @@ var GO_DEF = {
1212
1314
  (type_spec name: (type_identifier) @name)
1213
1315
  (parameter_declaration name: (identifier) @name)
1214
1316
  (variadic_parameter_declaration name: (identifier) @name)
1317
+ (type_parameter_declaration name: (identifier) @name)
1215
1318
  (short_var_declaration left: (expression_list (identifier) @name))
1216
- (var_spec name: (identifier) @name)
1217
- (const_spec name: (identifier) @name)
1319
+ (var_spec (identifier) @name)
1320
+ (const_spec (identifier) @name)
1218
1321
  (type_spec type: (struct_type (field_declaration_list (field_declaration name: (field_identifier) @name))))
1219
1322
  (range_clause left: (expression_list (identifier) @name) (#not-eq? @name "_"))
1220
1323
  `,
@@ -1236,6 +1339,8 @@ var GO_DEF = {
1236
1339
  return "function";
1237
1340
  if (parent.type === "type_spec" && parent.childForFieldName("name")?.id === node.id)
1238
1341
  return "type";
1342
+ if (parent.type === "type_parameter_declaration")
1343
+ return "type";
1239
1344
  return "variable";
1240
1345
  },
1241
1346
  createsFunctionScope: (node) => node.type === "function_declaration" || node.type === "method_declaration" || node.type === "func_literal",
@@ -1251,9 +1356,9 @@ var GO_DEF = {
1251
1356
  return true;
1252
1357
  if (p.type === "type_spec" && p.childForFieldName("name")?.id === node.id)
1253
1358
  return true;
1254
- if (p.type === "var_spec" && p.childForFieldName("name")?.id === node.id)
1359
+ if ((p.type === "var_spec" || p.type === "const_spec") && node.type === "identifier")
1255
1360
  return true;
1256
- if (p.type === "const_spec" && p.childForFieldName("name")?.id === node.id)
1361
+ if (p.type === "type_parameter_declaration" && node.type === "identifier")
1257
1362
  return true;
1258
1363
  if (p.type === "expression_list" && p.parent?.type === "short_var_declaration")
1259
1364
  return node.type === "identifier";
@@ -1340,6 +1445,9 @@ var JAVA_DEF = {
1340
1445
  (enum_constant name: (identifier) @name)
1341
1446
  (method_declaration name: (identifier) @name)
1342
1447
  (variable_declarator name: (identifier) @name)
1448
+ (formal_parameter name: (identifier) @name)
1449
+ (spread_parameter (variable_declarator name: (identifier) @name))
1450
+ (receiver_parameter (identifier) @name)
1343
1451
  `,
1344
1452
  importBindings: `
1345
1453
  (import_declaration . (_) @from) @stmt
@@ -1350,6 +1458,7 @@ var JAVA_DEF = {
1350
1458
  memberExpression: "field_access"
1351
1459
  },
1352
1460
  supportsCrossModuleSymbols: true,
1461
+ exportScopeBlockers: ["block", "constructor_body"],
1353
1462
  classifyDefinition: (node) => {
1354
1463
  const parent = node.parent;
1355
1464
  if (!parent)
@@ -1388,6 +1497,8 @@ var JAVA_DEF = {
1388
1497
  return true;
1389
1498
  if (p.type === "formal_parameter" && p.childForFieldName("name")?.id === node.id)
1390
1499
  return true;
1500
+ if (p.type === "receiver_parameter" && node.type === "identifier")
1501
+ return true;
1391
1502
  return false;
1392
1503
  },
1393
1504
  normalizeIdentifier: (name) => hasNonAsciiCodePoint(name, true) ? name.replace(JAVA_IDENTIFIER_IGNORABLE_PATTERN, "") : name
@@ -1398,7 +1509,7 @@ registerLanguage(JAVA_DEF);
1398
1509
  var CSHARP_IDENTIFIER_FORMAT_PATTERN = new RegExp(`[${CSHARP_IDENTIFIER_FORMAT_SOURCE}]`, "gu");
1399
1510
  var CSHARP_DEF = {
1400
1511
  id: "csharp",
1401
- extensions: [".cs"],
1512
+ extensions: [".cs", ".csx"],
1402
1513
  usesQueryDrivenLocals: true,
1403
1514
  structure: {
1404
1515
  blocks: [
@@ -1407,6 +1518,11 @@ var CSHARP_DEF = {
1407
1518
  nameQuery: "name: (identifier) @chunk.name",
1408
1519
  captureId: "class"
1409
1520
  },
1521
+ {
1522
+ type: "struct_declaration",
1523
+ nameQuery: "name: (identifier) @chunk.name",
1524
+ captureId: "struct"
1525
+ },
1410
1526
  {
1411
1527
  type: "record_declaration",
1412
1528
  nameQuery: "name: (identifier) @chunk.name",
@@ -1431,6 +1547,11 @@ var CSHARP_DEF = {
1431
1547
  type: "namespace_declaration",
1432
1548
  nameQuery: "name: (identifier) @chunk.name",
1433
1549
  captureId: "namespace"
1550
+ },
1551
+ {
1552
+ type: "file_scoped_namespace_declaration",
1553
+ nameQuery: "name: (identifier) @chunk.name",
1554
+ captureId: "namespace"
1434
1555
  }
1435
1556
  ],
1436
1557
  splitPoints: [
@@ -1445,30 +1566,41 @@ var CSHARP_DEF = {
1445
1566
  },
1446
1567
  graph: {
1447
1568
  imports: `
1448
- (using_directive . (_) @mod) @stmt
1569
+ (using_directive !name (_) @mod) @stmt
1570
+ (using_directive name: (identifier) (_) @mod) @stmt
1571
+ (extern_alias_directive name: (identifier) @mod) @stmt
1449
1572
  `,
1450
1573
  exports: `
1451
1574
  (class_declaration name: (identifier) @name)
1452
1575
  (record_declaration name: (identifier) @name)
1576
+ (struct_declaration name: (identifier) @name)
1453
1577
  (interface_declaration name: (identifier) @name)
1454
1578
  (enum_declaration name: (identifier) @name)
1455
1579
  (enum_member_declaration name: (identifier) @name)
1456
1580
  (method_declaration name: (identifier) @name)
1581
+ (delegate_declaration name: (identifier) @name)
1457
1582
  (property_declaration name: (identifier) @name)
1583
+ (field_declaration (variable_declaration (variable_declarator name: (identifier) @name)))
1584
+ (event_field_declaration (variable_declaration (variable_declarator name: (identifier) @name)))
1458
1585
  `,
1459
1586
  locals: `
1460
1587
  (class_declaration name: (identifier) @name)
1461
1588
  (record_declaration name: (identifier) @name)
1589
+ (struct_declaration name: (identifier) @name)
1462
1590
  (interface_declaration name: (identifier) @name)
1463
1591
  (enum_declaration name: (identifier) @name)
1464
1592
  (enum_member_declaration name: (identifier) @name)
1465
1593
  (method_declaration name: (identifier) @name)
1466
- (variable_declarator (identifier) @name)
1594
+ (delegate_declaration name: (identifier) @name)
1595
+ (local_function_statement name: (identifier) @name)
1596
+ (property_declaration name: (identifier) @name)
1597
+ (variable_declarator name: (identifier) @name)
1467
1598
  (declaration_pattern name: (identifier) @name)
1468
1599
  `,
1469
1600
  importBindings: `
1470
- (using_directive name: (identifier) @alias . (_) @from) @stmt
1471
- (using_directive . (_) @from) @stmt
1601
+ (using_directive name: (identifier) @alias (_) @from) @stmt
1602
+ (using_directive !name (_) @from) @stmt
1603
+ (extern_alias_directive name: (identifier) @alias) @stmt
1472
1604
  `
1473
1605
  },
1474
1606
  nodeTypes: {
@@ -1480,35 +1612,25 @@ var CSHARP_DEF = {
1480
1612
  const parent = node.parent;
1481
1613
  if (!parent)
1482
1614
  return "variable";
1483
- if (parent.type === "method_declaration" || parent.type === "constructor_declaration")
1615
+ if (parent.type === "method_declaration" || parent.type === "constructor_declaration" || parent.type === "destructor_declaration" || parent.type === "local_function_statement")
1484
1616
  return "method";
1485
- if (parent.type === "class_declaration" || parent.type === "record_declaration")
1617
+ if (parent.type === "class_declaration" || parent.type === "record_declaration" || parent.type === "struct_declaration")
1486
1618
  return "class";
1487
1619
  if (parent.type === "interface_declaration")
1488
1620
  return "interface";
1489
- if (parent.type === "enum_declaration")
1621
+ if (parent.type === "enum_declaration" || parent.type === "delegate_declaration")
1490
1622
  return "type";
1491
1623
  return "variable";
1492
1624
  },
1493
- createsFunctionScope: (node) => node.type === "method_declaration" || node.type === "constructor_declaration",
1625
+ createsFunctionScope: (node) => node.type === "method_declaration" || node.type === "constructor_declaration" || node.type === "destructor_declaration" || node.type === "local_function_statement",
1494
1626
  createsBlockScope: (node) => node.type === "block" || node.type === "declaration_list",
1495
1627
  isDeclarationName: (node) => {
1496
1628
  const p = node.parent;
1497
1629
  if (!p)
1498
1630
  return false;
1499
- if (p.type === "class_declaration" && p.childForFieldName("name")?.id === node.id)
1500
- return true;
1501
- if (p.type === "record_declaration" && p.childForFieldName("name")?.id === node.id)
1502
- return true;
1503
- if (p.type === "interface_declaration" && p.childForFieldName("name")?.id === node.id)
1631
+ if ((p.type === "class_declaration" || p.type === "record_declaration" || p.type === "struct_declaration" || p.type === "interface_declaration" || p.type === "enum_declaration" || p.type === "delegate_declaration" || p.type === "enum_member_declaration" || p.type === "method_declaration" || p.type === "constructor_declaration" || p.type === "destructor_declaration" || p.type === "local_function_statement" || p.type === "property_declaration") && p.childForFieldName("name")?.id === node.id)
1504
1632
  return true;
1505
- if (p.type === "enum_declaration" && p.childForFieldName("name")?.id === node.id)
1506
- return true;
1507
- if (p.type === "enum_member_declaration" && p.childForFieldName("name")?.id === node.id)
1508
- return true;
1509
- if (p.type === "method_declaration" && p.childForFieldName("name")?.id === node.id)
1510
- return true;
1511
- if (p.type === "variable_declarator" && p.child(0)?.id === node.id)
1633
+ if (p.type === "variable_declarator" && p.childForFieldName("name")?.id === node.id)
1512
1634
  return true;
1513
1635
  if (p.type === "parameter" && p.childForFieldName("name")?.id === node.id)
1514
1636
  return true;
@@ -1572,8 +1694,11 @@ var RUST_DEF = {
1572
1694
  `,
1573
1695
  exports: `
1574
1696
  (function_item name: (identifier) @name) @stmt
1697
+ (function_signature_item name: (identifier) @name) @stmt
1575
1698
  (struct_item name: (type_identifier) @name) @stmt
1576
1699
  (trait_item name: (type_identifier) @name) @stmt
1700
+ (type_item name: (type_identifier) @name) @stmt
1701
+ (associated_type name: (type_identifier) @name) @stmt
1577
1702
  (enum_item name: (type_identifier) @name) @stmt
1578
1703
  (enum_variant name: (identifier) @name) @stmt
1579
1704
  (const_item name: (identifier) @name) @stmt
@@ -1587,14 +1712,19 @@ var RUST_DEF = {
1587
1712
  ;; form above. The shared path may itself be scoped, so it is captured
1588
1713
  ;; generically rather than requiring a single bare identifier segment.
1589
1714
  (use_declaration argument: (scoped_use_list path: (_) @from list: (use_list (identifier) @src))) @stmt
1590
- ;; Aliased members inside a group (\`use foo::{Bar as Baz}\`) export
1591
- ;; under their alias, matching how a single aliased import behaves.
1592
- (use_declaration argument: (scoped_use_list path: (_) @from list: (use_list (use_as_clause alias: (identifier) @src)))) @stmt
1715
+ ;; Aliased members (\`use foo::Bar as Baz;\` and \`use foo::{Bar as Baz}\`) export under the
1716
+ ;; alias while keeping the original member as the source, so a consumer of the alias
1717
+ ;; resolves to the real definition.
1718
+ (use_declaration argument: (use_as_clause path: (scoped_identifier path: (_) @from name: (identifier) @src) alias: (identifier) @alias)) @stmt
1719
+ (use_declaration argument: (scoped_use_list path: (_) @from list: (use_list (use_as_clause path: (identifier) @src alias: (identifier) @alias)))) @stmt
1593
1720
  `,
1594
1721
  locals: `
1595
1722
  (function_item name: (identifier) @name)
1723
+ (function_signature_item name: (identifier) @name)
1596
1724
  (struct_item name: (type_identifier) @name)
1597
1725
  (trait_item name: (type_identifier) @name)
1726
+ (type_item name: (type_identifier) @name)
1727
+ (associated_type name: (type_identifier) @name)
1598
1728
  (enum_item name: (type_identifier) @name)
1599
1729
  (enum_variant name: (identifier) @name)
1600
1730
  (const_item name: (identifier) @name)
@@ -1622,14 +1752,15 @@ var RUST_DEF = {
1622
1752
  memberExpression: "field_expression"
1623
1753
  },
1624
1754
  supportsCrossModuleSymbols: true,
1755
+ exportScopeBlockers: ["block"],
1625
1756
  scopeDeclarationNames: (node) => node.parent?.type === "macro_definition",
1626
1757
  classifyDefinition: (node) => {
1627
1758
  const parent = node.parent;
1628
1759
  if (!parent)
1629
1760
  return "variable";
1630
- if (parent.type === "function_item" || parent.type === "macro_definition")
1761
+ if (parent.type === "function_item" || parent.type === "function_signature_item" || parent.type === "macro_definition")
1631
1762
  return "function";
1632
- if (parent.type === "enum_item")
1763
+ if (parent.type === "enum_item" || parent.type === "type_item" || parent.type === "associated_type")
1633
1764
  return "type";
1634
1765
  if (parent.type === "struct_item" || parent.type === "trait_item")
1635
1766
  return "class";
@@ -1644,10 +1775,16 @@ var RUST_DEF = {
1644
1775
  return false;
1645
1776
  if (p.type === "function_item" && p.childForFieldName("name")?.id === node.id)
1646
1777
  return true;
1778
+ if (p.type === "function_signature_item" && p.childForFieldName("name")?.id === node.id)
1779
+ return true;
1647
1780
  if (p.type === "struct_item" && p.childForFieldName("name")?.id === node.id)
1648
1781
  return true;
1649
1782
  if (p.type === "trait_item" && p.childForFieldName("name")?.id === node.id)
1650
1783
  return true;
1784
+ if (p.type === "type_item" && p.childForFieldName("name")?.id === node.id)
1785
+ return true;
1786
+ if (p.type === "associated_type" && p.childForFieldName("name")?.id === node.id)
1787
+ return true;
1651
1788
  if (p.type === "enum_item" && p.childForFieldName("name")?.id === node.id)
1652
1789
  return true;
1653
1790
  if (p.type === "enum_variant" && p.childForFieldName("name")?.id === node.id)
@@ -1705,6 +1842,9 @@ function cFunctionNameQuery(captureName, includeFieldIdentifier) {
1705
1842
  patterns.push(`(pointer_declarator declarator: (function_declarator declarator: (${identifierType}) @${captureName}))`);
1706
1843
  patterns.push(`(function_declarator declarator: (parenthesized_declarator (pointer_declarator declarator: (${identifierType}) @${captureName})))`);
1707
1844
  }
1845
+ if (includeFieldIdentifier) {
1846
+ patterns.push(`(function_declarator declarator: (qualified_identifier name: (identifier) @${captureName}))`, `(function_declarator declarator: (qualified_identifier name: (destructor_name) @${captureName}))`, `(function_declarator declarator: (qualified_identifier name: (operator_name) @${captureName}))`, `(function_declarator declarator: (qualified_identifier name: (template_function name: (identifier) @${captureName})))`, `(function_declarator declarator: (destructor_name) @${captureName})`, `(function_declarator declarator: (operator_name) @${captureName})`, `(reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @${captureName})))`, `(reference_declarator (function_declarator declarator: (qualified_identifier name: (destructor_name) @${captureName})))`, `(reference_declarator (function_declarator declarator: (qualified_identifier name: (operator_name) @${captureName})))`, `(reference_declarator (function_declarator declarator: (operator_name) @${captureName}))`);
1847
+ }
1708
1848
  return `
1709
1849
  declarator: [
1710
1850
  ${patterns.join("\n ")}
@@ -1713,21 +1853,31 @@ function cFunctionNameQuery(captureName, includeFieldIdentifier) {
1713
1853
  }
1714
1854
  function cFamilyCoreExportQueries(functionNameQuery) {
1715
1855
  return [
1716
- `(function_definition ${functionNameQuery})`,
1717
- `(declaration ${functionNameQuery})`,
1856
+ // Keep scope/storage evidence even when the native syntax-tree projection is unavailable.
1857
+ `(compound_statement) @export_scope`,
1858
+ `((declaration (storage_class_specifier) @storage) @private_declaration (#eq? @storage "static"))`,
1859
+ `((function_definition (storage_class_specifier) @storage) @private_declaration (#eq? @storage "static"))`,
1860
+ `(function_definition ${functionNameQuery}) @declaration`,
1861
+ `(declaration ${functionNameQuery}) @declaration`,
1718
1862
  `(struct_specifier name: (type_identifier) @name)`,
1719
1863
  `(enum_specifier name: (type_identifier) @name)`,
1720
- `(type_definition declarator: (type_identifier) @name)`,
1721
- `(declaration declarator: (identifier) @name)`,
1722
- `(declaration declarator: (init_declarator declarator: (identifier) @name))`
1864
+ `(type_definition declarator: (_) @declarator)`,
1865
+ `((declaration type: (_) @type declarator: (identifier) @name) @declaration
1866
+ (#not-match? @type "^(import|export)$"))`,
1867
+ `((declaration type: (_) @type declarator: (init_declarator declarator: (identifier) @name)) @declaration
1868
+ (#not-match? @type "^(import|export)$"))`
1723
1869
  ];
1724
1870
  }
1725
1871
  function cFamilyCoreLocalQueries(functionNameQuery) {
1726
1872
  return [
1727
1873
  `(function_definition ${functionNameQuery})`,
1874
+ // A prototype is a `declaration`, not a `function_definition`; without this a header that only
1875
+ // declares its API has no function locals at all.
1876
+ `(declaration ${functionNameQuery})`,
1728
1877
  `(struct_specifier name: (type_identifier) @name)`,
1729
1878
  `(enum_specifier name: (type_identifier) @name)`,
1730
- `(type_definition declarator: (type_identifier) @name)`,
1879
+ // Resolve the declarator chain in the consumer, without a fixed pointer/array depth.
1880
+ `(type_definition declarator: (_) @declarator)`,
1731
1881
  `(declaration declarator: (identifier) @name)`,
1732
1882
  `(declaration declarator: (init_declarator declarator: (identifier) @name))`,
1733
1883
  `(parameter_declaration declarator: (identifier) @name)`,
@@ -1782,6 +1932,9 @@ function createCFamilyLanguageDefinition(options) {
1782
1932
  createsFunctionScope: options.createsFunctionScope,
1783
1933
  createsBlockScope: (node) => node.type === "compound_statement",
1784
1934
  supportsCrossModuleSymbols: true,
1935
+ // A name declared inside a function body is not a module export. The exports query cannot
1936
+ // anchor on `translation_unit` because include guards nest every header declaration.
1937
+ exportScopeBlockers: ["compound_statement"],
1785
1938
  usesQueryDrivenLocals: options.usesQueryDrivenLocals || false
1786
1939
  };
1787
1940
  }
@@ -1851,6 +2004,7 @@ var C_DEF = createCFamilyLanguageDefinition({
1851
2004
  id: "c",
1852
2005
  extensions: [".c", ".h", ".i"],
1853
2006
  includeFieldIdentifier: false,
2007
+ usesQueryDrivenLocals: true,
1854
2008
  blocks: (functionNameQuery) => [
1855
2009
  cFamilyFunctionBlock(functionNameQuery),
1856
2010
  cFamilyTypeIdentifierBlock("struct_specifier", "struct"),
@@ -1892,6 +2046,8 @@ var C_DEF = createCFamilyLanguageDefinition({
1892
2046
  return "function";
1893
2047
  if (container?.type === "declaration" && isFunctionDeclarator(node))
1894
2048
  return "function";
2049
+ if (container?.type === "type_definition")
2050
+ return "type";
1895
2051
  return "variable";
1896
2052
  },
1897
2053
  isDeclarationName: (node) => {
@@ -1936,16 +2092,34 @@ var CPP_DEF = createCFamilyLanguageDefinition({
1936
2092
  splitPoints: [...cFamilyControlSplitPoints, "try_statement", "catch_clause"],
1937
2093
  extraExportQueries: [
1938
2094
  `(class_specifier name: (type_identifier) @name)`,
2095
+ `(class_specifier name: (template_type name: (type_identifier) @name))`,
2096
+ `(union_specifier name: (type_identifier) @name)`,
1939
2097
  `(enumerator name: (identifier) @name)`,
1940
2098
  `(namespace_definition name: (namespace_identifier) @name)`,
2099
+ `(namespace_definition name: (nested_namespace_specifier (namespace_identifier) @name))`,
1941
2100
  `(alias_declaration name: (type_identifier) @name)`,
1942
- `(using_declaration (qualified_identifier name: (identifier) @name))`
2101
+ `(concept_definition name: (identifier) @name)`,
2102
+ `(preproc_def name: (identifier) @name)`,
2103
+ `(preproc_function_def name: (identifier) @name)`,
2104
+ `(class_specifier body: (field_declaration_list (field_declaration declarator: (function_declarator declarator: (field_identifier) @name))))`,
2105
+ `(class_specifier body: (field_declaration_list (field_declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name)))))`,
2106
+ `(class_specifier body: (field_declaration_list (declaration declarator: (function_declarator declarator: (destructor_name) @name))))`
1943
2107
  ],
1944
2108
  extraLocalQueries: [
1945
2109
  `(class_specifier name: (type_identifier) @name)`,
2110
+ `(class_specifier name: (template_type name: (type_identifier) @name))`,
2111
+ `(enum_specifier name: (type_identifier) @name)`,
2112
+ `(union_specifier name: (type_identifier) @name)`,
1946
2113
  `(enumerator name: (identifier) @name)`,
1947
2114
  `(namespace_definition name: (namespace_identifier) @name)`,
1948
- `(alias_declaration name: (type_identifier) @name)`
2115
+ `(namespace_definition name: (nested_namespace_specifier (namespace_identifier) @name))`,
2116
+ `(alias_declaration name: (type_identifier) @name)`,
2117
+ `(concept_definition name: (identifier) @name)`,
2118
+ `(preproc_def name: (identifier) @name)`,
2119
+ `(preproc_function_def name: (identifier) @name)`,
2120
+ `(class_specifier body: (field_declaration_list (field_declaration declarator: (function_declarator declarator: (field_identifier) @name))))`,
2121
+ `(class_specifier body: (field_declaration_list (field_declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name)))))`,
2122
+ `(class_specifier body: (field_declaration_list (declaration declarator: (function_declarator declarator: (destructor_name) @name))))`
1949
2123
  ],
1950
2124
  nodeTypes: {
1951
2125
  identifier: ["identifier", "field_identifier", "type_identifier", "namespace_identifier"],
@@ -1958,7 +2132,7 @@ var CPP_DEF = createCFamilyLanguageDefinition({
1958
2132
  return "variable";
1959
2133
  if (parent.type === "enum_specifier")
1960
2134
  return "type";
1961
- if (parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "namespace_definition")
2135
+ if (parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "namespace_definition" || parent.type === "nested_namespace_specifier")
1962
2136
  return "class";
1963
2137
  if (parent.type === "alias_declaration" || parent.type === "type_definition" && isInField(node, parent, "declarator"))
1964
2138
  return "type";
@@ -1967,18 +2141,27 @@ var CPP_DEF = createCFamilyLanguageDefinition({
1967
2141
  return "function";
1968
2142
  if (container?.type === "declaration" && isFunctionDeclarator(node))
1969
2143
  return "function";
2144
+ if (container?.type === "type_definition")
2145
+ return "type";
1970
2146
  return "variable";
1971
2147
  },
1972
2148
  isDeclarationName: (node) => {
1973
2149
  const parent = node.parent;
1974
2150
  if (!parent)
1975
2151
  return false;
1976
- if ((parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "enum_specifier") && isInField(node, parent, "name"))
2152
+ if ((parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "enum_specifier") && isInField(node, parent, "name"))
1977
2153
  return true;
1978
2154
  if (parent.type === "namespace_definition" && isInField(node, parent, "name"))
1979
2155
  return true;
2156
+ if (parent.type === "nested_namespace_specifier") {
2157
+ const namespaceDefinition = findAncestor(node, /* @__PURE__ */ new Set(["namespace_definition"]));
2158
+ if (namespaceDefinition && isInField(node, namespaceDefinition, "name"))
2159
+ return true;
2160
+ }
1980
2161
  if (parent.type === "alias_declaration" && isInField(node, parent, "name"))
1981
2162
  return true;
2163
+ if (parent.type === "concept_definition" && isInField(node, parent, "name"))
2164
+ return true;
1982
2165
  if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["parameter_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["field_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["init_declarator"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["type_definition"])))
1983
2166
  return true;
1984
2167
  if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["function_definition"])) && !isInParameterList(node))
@@ -1989,6 +2172,10 @@ var CPP_DEF = createCFamilyLanguageDefinition({
1989
2172
  return true;
1990
2173
  if (parent.type === "enumerator" && isInField(node, parent, "name"))
1991
2174
  return true;
2175
+ if (parent.type === "preproc_def" && isInField(node, parent, "name"))
2176
+ return true;
2177
+ if (parent.type === "preproc_function_def" && isInField(node, parent, "name"))
2178
+ return true;
1992
2179
  return false;
1993
2180
  },
1994
2181
  createsFunctionScope: (node) => node.type === "function_definition" || node.type === "lambda_expression"
@@ -1996,51 +2183,35 @@ var CPP_DEF = createCFamilyLanguageDefinition({
1996
2183
  registerLanguage(CPP_DEF);
1997
2184
 
1998
2185
  // dist/languages/definitions/kotlin.js
1999
- function normalizeKotlinNativeQuery(kind, query) {
2000
- if (kind === "imports") {
2001
- return `
2002
- (import (qualified_identifier) @mod) @stmt
2003
- `;
2004
- }
2005
- if (kind === "importBindings") {
2006
- return `
2007
- (import (qualified_identifier) @from (identifier) @alias) @stmt
2008
- (import (qualified_identifier) @from "*" @wild) @stmt
2009
- (import (qualified_identifier) @from) @stmt
2010
- `;
2011
- }
2012
- const normalized = query.replace(/\bimport_header\b/g, "import").replace(/\bsimple_identifier\b/g, "identifier").replace(/\btype_identifier\b/g, "identifier");
2013
- return normalized;
2014
- }
2015
2186
  var KOTLIN_DEF = {
2016
2187
  id: "kotlin",
2017
- extensions: [".kt", ".kts"],
2188
+ extensions: [".kt", ".kts", ".ktm"],
2018
2189
  usesQueryDrivenLocals: true,
2019
2190
  structure: {
2020
2191
  blocks: [
2021
2192
  {
2022
2193
  type: "class_declaration",
2023
- nameQuery: "(type_identifier) @chunk.name",
2194
+ nameQuery: "(identifier) @chunk.name",
2024
2195
  captureId: "class"
2025
2196
  },
2026
2197
  {
2027
2198
  type: "object_declaration",
2028
- nameQuery: "(type_identifier) @chunk.name",
2199
+ nameQuery: "(identifier) @chunk.name",
2029
2200
  captureId: "object"
2030
2201
  },
2031
2202
  {
2032
2203
  type: "function_declaration",
2033
- nameQuery: "(simple_identifier) @chunk.name",
2204
+ nameQuery: "(identifier) @chunk.name",
2034
2205
  captureId: "function"
2035
2206
  },
2036
2207
  {
2037
2208
  type: "property_declaration",
2038
- nameQuery: "(variable_declaration (simple_identifier) @chunk.name)",
2209
+ nameQuery: "(variable_declaration (identifier) @chunk.name)",
2039
2210
  captureId: "property"
2040
2211
  },
2041
2212
  {
2042
2213
  type: "type_alias",
2043
- nameQuery: "(type_identifier) @chunk.name",
2214
+ nameQuery: "(identifier) @chunk.name",
2044
2215
  captureId: "type"
2045
2216
  }
2046
2217
  ],
@@ -2058,36 +2229,47 @@ var KOTLIN_DEF = {
2058
2229
  },
2059
2230
  graph: {
2060
2231
  imports: `
2061
- (import_header (identifier) @mod) @stmt
2232
+ (import (qualified_identifier) @mod) @stmt
2062
2233
  `,
2063
2234
  exports: `
2064
- (class_declaration (type_identifier) @name)
2065
- (object_declaration (type_identifier) @name)
2066
- (function_declaration (simple_identifier) @name)
2067
- (property_declaration (variable_declaration (simple_identifier) @name))
2068
- (type_alias (type_identifier) @name)
2069
- (enum_entry (simple_identifier) @name)
2235
+ (source_file
2236
+ [
2237
+ (class_declaration name: (identifier) @name)
2238
+ (object_declaration name: (identifier) @name)
2239
+ (function_declaration name: (identifier) @name)
2240
+ (property_declaration (variable_declaration (identifier) @name))
2241
+ (type_alias type: (identifier) @name)
2242
+ ])
2243
+ (class_body
2244
+ [
2245
+ (class_declaration name: (identifier) @name)
2246
+ (object_declaration name: (identifier) @name)
2247
+ (function_declaration name: (identifier) @name)
2248
+ (property_declaration (variable_declaration (identifier) @name))
2249
+ (type_alias type: (identifier) @name)
2250
+ ])
2251
+ (enum_class_body (enum_entry (identifier) @name))
2070
2252
  `,
2071
2253
  locals: `
2072
- (class_declaration (type_identifier) @name)
2073
- (object_declaration (type_identifier) @name)
2074
- (function_declaration (simple_identifier) @name)
2075
- (property_declaration (variable_declaration (simple_identifier) @name))
2076
- (type_alias (type_identifier) @name)
2077
- (enum_entry (simple_identifier) @name)
2078
- (parameter (simple_identifier) @name)
2079
- (class_parameter (simple_identifier) @name)
2080
- (type_parameter (type_identifier) @name)
2254
+ (class_declaration name: (identifier) @name)
2255
+ (object_declaration name: (identifier) @name)
2256
+ (function_declaration name: (identifier) @name)
2257
+ (property_declaration (variable_declaration (identifier) @name))
2258
+ (type_alias type: (identifier) @name)
2259
+ (enum_entry (identifier) @name)
2260
+ (parameter (identifier) @name)
2261
+ (class_parameter (identifier) @name)
2262
+ (type_parameter (identifier) @name)
2081
2263
  `,
2082
2264
  importBindings: `
2083
- (import_header (identifier) @from (import_alias (type_identifier) @alias)) @stmt
2084
- (import_header (identifier) @from (wildcard_import) @wild) @stmt
2085
- (import_header (identifier) @from) @stmt
2265
+ (import (qualified_identifier) @from (identifier) @alias) @stmt
2266
+ (import (qualified_identifier) @from ("*") @wild) @stmt
2267
+ (import (qualified_identifier) @from) @stmt
2086
2268
  `
2087
2269
  },
2088
2270
  nodeTypes: {
2089
- identifier: ["identifier", "interpolated_identifier", "simple_identifier", "type_identifier"],
2090
- propertyIdentifier: ["simple_identifier", "type_identifier"],
2271
+ identifier: ["identifier"],
2272
+ propertyIdentifier: ["identifier"],
2091
2273
  memberExpression: "navigation_expression"
2092
2274
  },
2093
2275
  classifyDefinition: (node) => {
@@ -2106,35 +2288,31 @@ var KOTLIN_DEF = {
2106
2288
  const parent = node.parent;
2107
2289
  if (!parent)
2108
2290
  return false;
2109
- if (parent.type === "class_declaration" && node.type === "type_identifier")
2291
+ if (parent.type === "class_declaration" && node.type === "identifier")
2110
2292
  return true;
2111
- if (parent.type === "object_declaration" && node.type === "type_identifier")
2293
+ if (parent.type === "object_declaration" && node.type === "identifier")
2112
2294
  return true;
2113
- if (parent.type === "function_declaration" && (node.type === "simple_identifier" || node.type === "identifier"))
2295
+ if (parent.type === "function_declaration" && node.type === "identifier")
2114
2296
  return true;
2115
- if (parent.type === "type_alias" && node.type === "type_identifier")
2297
+ if (parent.type === "type_alias" && node.type === "identifier")
2116
2298
  return true;
2117
- if (parent.type === "variable_declaration" && node.type === "simple_identifier")
2299
+ if (parent.type === "variable_declaration" && node.type === "identifier")
2118
2300
  return true;
2119
- if (parent.type === "parameter" && (node.type === "simple_identifier" || node.type === "identifier"))
2301
+ if (parent.type === "parameter" && node.type === "identifier")
2120
2302
  return true;
2121
- if (parent.type === "class_parameter" && (node.type === "simple_identifier" || node.type === "identifier"))
2303
+ if (parent.type === "class_parameter" && node.type === "identifier")
2122
2304
  return true;
2123
- if (parent.type === "enum_entry" && (node.type === "simple_identifier" || node.type === "identifier"))
2305
+ if (parent.type === "enum_entry" && node.type === "identifier")
2124
2306
  return true;
2125
- if (parent.type === "type_parameter" && node.type === "type_identifier")
2307
+ if (parent.type === "type_parameter" && node.type === "identifier")
2126
2308
  return true;
2127
2309
  return false;
2128
2310
  },
2129
2311
  scopeDeclarationNames: "all",
2130
2312
  createsFunctionScope: (node) => node.type === "function_declaration" || node.type === "anonymous_function" || node.type === "lambda_literal",
2131
- createsBlockScope: (node) => node.type === "function_body" || node.type === "class_body" || node.type === "control_structure_body" || node.type === "catch_block" || node.type === "finally_block",
2313
+ createsBlockScope: (node) => node.type === "function_body" || node.type === "class_body" || node.type === "block" || node.type === "catch_block" || node.type === "finally_block",
2132
2314
  supportsCrossModuleSymbols: true,
2133
- native: {
2134
- normalizeQuery: normalizeKotlinNativeQuery,
2135
- authoritativeKinds: ["imports", "importBindings", "exports", "locals"],
2136
- notes: ["normalizes kotlin import and identifier node names for the native grammar"]
2137
- }
2315
+ exportScopeBlockers: ["function_body", "lambda_literal", "anonymous_function"]
2138
2316
  };
2139
2317
  registerLanguage(KOTLIN_DEF);
2140
2318
 
@@ -2220,18 +2398,45 @@ var SWIFT_DEF = {
2220
2398
  (import_declaration (identifier) @mod) @stmt
2221
2399
  `,
2222
2400
  exports: `
2223
- (class_declaration declaration_kind: "class" name: (_) @name)
2224
- (class_declaration declaration_kind: "struct" name: (_) @name)
2225
- (class_declaration declaration_kind: "enum" name: (_) @name)
2226
- (class_declaration declaration_kind: "extension" name: (user_type (type_identifier) @name))
2227
- (class_declaration declaration_kind: "actor" name: (_) @name)
2228
- (enum_entry name: (simple_identifier) @name)
2229
- (protocol_declaration name: (type_identifier) @name)
2230
- (function_declaration name: (simple_identifier) @name)
2231
- (typealias_declaration name: (type_identifier) @name)
2232
- (property_declaration name: (pattern bound_identifier: (simple_identifier) @name))
2233
- (protocol_function_declaration name: (simple_identifier) @name)
2234
- (protocol_property_declaration name: (pattern bound_identifier: (simple_identifier) @name))
2401
+ (source_file (class_declaration declaration_kind: "class" name: (_) @name))
2402
+ (class_body (class_declaration declaration_kind: "class" name: (_) @name))
2403
+ (enum_class_body (class_declaration declaration_kind: "class" name: (_) @name))
2404
+ (source_file (class_declaration declaration_kind: "struct" name: (_) @name))
2405
+ (class_body (class_declaration declaration_kind: "struct" name: (_) @name))
2406
+ (enum_class_body (class_declaration declaration_kind: "struct" name: (_) @name))
2407
+ (source_file (class_declaration declaration_kind: "enum" name: (_) @name))
2408
+ (class_body (class_declaration declaration_kind: "enum" name: (_) @name))
2409
+ (enum_class_body (class_declaration declaration_kind: "enum" name: (_) @name))
2410
+ (source_file (class_declaration declaration_kind: "extension" name: (user_type (type_identifier) @name)))
2411
+ (class_body (class_declaration declaration_kind: "extension" name: (user_type (type_identifier) @name)))
2412
+ (enum_class_body (class_declaration declaration_kind: "extension" name: (user_type (type_identifier) @name)))
2413
+ (source_file (class_declaration declaration_kind: "actor" name: (_) @name))
2414
+ (class_body (class_declaration declaration_kind: "actor" name: (_) @name))
2415
+ (enum_class_body (class_declaration declaration_kind: "actor" name: (_) @name))
2416
+ (enum_class_body (enum_entry name: (simple_identifier) @name))
2417
+ (source_file (protocol_declaration name: (type_identifier) @name))
2418
+ (class_body (protocol_declaration name: (type_identifier) @name))
2419
+ (enum_class_body (protocol_declaration name: (type_identifier) @name))
2420
+ (source_file (function_declaration name: (simple_identifier) @name))
2421
+ (class_body (function_declaration name: (simple_identifier) @name))
2422
+ (enum_class_body (function_declaration name: (simple_identifier) @name))
2423
+ (source_file (typealias_declaration name: (type_identifier) @name))
2424
+ (class_body (typealias_declaration name: (type_identifier) @name))
2425
+ (enum_class_body (typealias_declaration name: (type_identifier) @name))
2426
+ (protocol_body (typealias_declaration name: (type_identifier) @name))
2427
+ (source_file (property_declaration name: (pattern bound_identifier: (simple_identifier) @name)))
2428
+ (class_body (property_declaration name: (pattern bound_identifier: (simple_identifier) @name)))
2429
+ (enum_class_body (property_declaration name: (pattern bound_identifier: (simple_identifier) @name)))
2430
+ (protocol_body (protocol_function_declaration name: (simple_identifier) @name))
2431
+ (protocol_body (protocol_property_declaration name: (pattern bound_identifier: (simple_identifier) @name)))
2432
+ (source_file (associatedtype_declaration name: (type_identifier) @name))
2433
+ (protocol_body (associatedtype_declaration name: (type_identifier) @name))
2434
+ (class_body (associatedtype_declaration name: (type_identifier) @name))
2435
+ (enum_class_body (associatedtype_declaration name: (type_identifier) @name))
2436
+ (source_file (macro_declaration (simple_identifier) @name))
2437
+ (source_file (operator_declaration [(custom_operator) (simple_identifier) (bang)] @name))
2438
+ (class_body (operator_declaration [(custom_operator) (simple_identifier) (bang)] @name))
2439
+ (enum_class_body (operator_declaration [(custom_operator) (simple_identifier) (bang)] @name))
2235
2440
  `,
2236
2441
  locals: `
2237
2442
  (class_declaration declaration_kind: "class" name: (_) @name)
@@ -2247,6 +2452,9 @@ var SWIFT_DEF = {
2247
2452
  (parameter name: (simple_identifier) @name)
2248
2453
  (protocol_function_declaration name: (simple_identifier) @name)
2249
2454
  (protocol_property_declaration name: (pattern bound_identifier: (simple_identifier) @name))
2455
+ (associatedtype_declaration name: (type_identifier) @name)
2456
+ (macro_declaration (simple_identifier) @name)
2457
+ (operator_declaration [(custom_operator) (simple_identifier) (bang)] @name)
2250
2458
  `,
2251
2459
  importBindings: `
2252
2460
  (import_declaration (identifier) @from) @stmt
@@ -2261,9 +2469,7 @@ var SWIFT_DEF = {
2261
2469
  const parent = node.parent;
2262
2470
  if (!parent)
2263
2471
  return "variable";
2264
- if (parent.type === "function_declaration")
2265
- return "function";
2266
- if (parent.type === "protocol_function_declaration")
2472
+ if (parent.type === "function_declaration" || parent.type === "protocol_function_declaration" || parent.type === "init_declaration" || parent.type === "deinit_declaration" || parent.type === "subscript_declaration" || parent.type === "macro_declaration" || parent.type === "operator_declaration")
2267
2473
  return "function";
2268
2474
  if (parent.type === "class_declaration") {
2269
2475
  const declarationKind = parent.childForFieldName("declaration_kind")?.text;
@@ -2273,7 +2479,7 @@ var SWIFT_DEF = {
2273
2479
  }
2274
2480
  if (parent.type === "user_type" && parent.parent?.type === "class_declaration")
2275
2481
  return "class";
2276
- if (parent.type === "protocol_declaration" || parent.type === "typealias_declaration")
2482
+ if (parent.type === "protocol_declaration" || parent.type === "typealias_declaration" || parent.type === "associatedtype_declaration")
2277
2483
  return "type";
2278
2484
  return "variable";
2279
2485
  },
@@ -2293,6 +2499,18 @@ var SWIFT_DEF = {
2293
2499
  return true;
2294
2500
  if (parent.type === "typealias_declaration" && parent.childForFieldName("name")?.id === node.id)
2295
2501
  return true;
2502
+ if (parent.type === "associatedtype_declaration" && parent.childForFieldName("name")?.id === node.id)
2503
+ return true;
2504
+ if (parent.type === "macro_declaration" && node.type === "simple_identifier")
2505
+ return true;
2506
+ if (parent.type === "operator_declaration" && (node.type === "custom_operator" || node.type === "simple_identifier" || node.type === "bang"))
2507
+ return true;
2508
+ if (parent.type === "init_declaration" && node.type === "init")
2509
+ return true;
2510
+ if (parent.type === "deinit_declaration" && node.type === "deinit")
2511
+ return true;
2512
+ if (parent.type === "subscript_declaration" && node.type === "subscript")
2513
+ return true;
2296
2514
  if (parent.type === "parameter" && parent.childForFieldName("name")?.id === node.id)
2297
2515
  return true;
2298
2516
  if (parent.type === "protocol_function_declaration" && parent.childForFieldName("name")?.id === node.id)
@@ -2306,14 +2524,15 @@ var SWIFT_DEF = {
2306
2524
  scopeDeclarationNames: "all",
2307
2525
  createsFunctionScope: (node) => node.type === "function_declaration" || node.type === "init_declaration" || node.type === "deinit_declaration" || node.type === "subscript_declaration",
2308
2526
  createsBlockScope: (node) => node.type === "function_body" || node.type === "class_body" || node.type === "protocol_body" || node.type === "enum_class_body" || node.type === "catch_block" || node.type === "willset_didset_block",
2309
- supportsCrossModuleSymbols: true
2527
+ supportsCrossModuleSymbols: true,
2528
+ exportScopeBlockers: ["function_body", "lambda_literal"]
2310
2529
  };
2311
2530
  registerLanguage(SWIFT_DEF);
2312
2531
 
2313
2532
  // dist/languages/definitions/sql.js
2314
2533
  var SQL_DEF = {
2315
2534
  id: "sql",
2316
- extensions: [".sql"],
2535
+ extensions: [".sql", ".ddl", ".pgsql", ".mysql"],
2317
2536
  structure: {
2318
2537
  blocks: [
2319
2538
  { type: "statement", nameQuery: "(create_table)", captureId: "create" },
@@ -2351,7 +2570,8 @@ var ZIG_TYPE_INITIALIZER_TYPES = /* @__PURE__ */ new Set([
2351
2570
  "enum_declaration",
2352
2571
  "union_declaration",
2353
2572
  "opaque_declaration",
2354
- "error_set_declaration"
2573
+ "error_set_declaration",
2574
+ "error_union_type"
2355
2575
  ]);
2356
2576
  var ZIG_DEF = {
2357
2577
  id: "zig",
@@ -2363,13 +2583,16 @@ var ZIG_DEF = {
2363
2583
  { type: "test_declaration", nameQuery: "(string) @chunk.name", captureId: "test" }
2364
2584
  ],
2365
2585
  splitPoints: ["if_expression", "for_expression", "while_expression", "switch_expression"],
2366
- comments: ["line_comment", "doc_comment"]
2586
+ comments: ["comment"]
2367
2587
  },
2368
2588
  graph: {
2369
- imports: '(builtin_function (builtin_identifier) @fn (arguments (string) @mod) (#eq? @fn "@import")) @stmt',
2589
+ imports: `
2590
+ (builtin_function (builtin_identifier) @fn (arguments (string) @mod) (#eq? @fn "@import")) @stmt
2591
+ (builtin_function (builtin_identifier) @mod (arguments) (#eq? @mod "@cImport")) @stmt
2592
+ `,
2370
2593
  exports: `
2371
- (function_declaration name: (identifier) @name)
2372
- (variable_declaration (identifier) @name)
2594
+ (source_file (function_declaration name: (identifier) @name))
2595
+ (source_file (variable_declaration (identifier) @name))
2373
2596
  `,
2374
2597
  locals: `
2375
2598
  (function_declaration name: (identifier) @name)
@@ -2381,6 +2604,13 @@ var ZIG_DEF = {
2381
2604
  (identifier) @alias
2382
2605
  (builtin_function (builtin_identifier) @fn (arguments (string) @from) (#eq? @fn "@import"))
2383
2606
  ) @stmt
2607
+ (variable_declaration
2608
+ (identifier) @alias
2609
+ (builtin_function (builtin_identifier) @from (arguments) (#eq? @from "@cImport"))
2610
+ ) @stmt
2611
+ (using_namespace_declaration
2612
+ (builtin_function (builtin_identifier) @fn (arguments (string) @from) (#eq? @fn "@import"))
2613
+ ) @stmt @wild
2384
2614
  `
2385
2615
  },
2386
2616
  nodeTypes: {
@@ -2399,7 +2629,17 @@ var ZIG_DEF = {
2399
2629
  const declaredName = parent.namedChildren.find((child) => child.type === "identifier");
2400
2630
  if (declaredName?.id !== node.id)
2401
2631
  return "variable";
2402
- const initializer = parent.namedChildren.find((child) => child.id !== node.id);
2632
+ let equalsEndIndex = -1;
2633
+ for (let index = 0; ; index++) {
2634
+ const child = parent.child(index);
2635
+ if (!child)
2636
+ break;
2637
+ if (child.type === "=") {
2638
+ equalsEndIndex = child.endIndex;
2639
+ break;
2640
+ }
2641
+ }
2642
+ const initializer = parent.namedChildren.find((child) => child.startIndex >= equalsEndIndex);
2403
2643
  if (initializer && ZIG_TYPE_INITIALIZER_TYPES.has(initializer.type))
2404
2644
  return "type";
2405
2645
  return "variable";
@@ -2515,6 +2755,103 @@ import { Buffer as Buffer2 } from "node:buffer";
2515
2755
  // dist/languages.js
2516
2756
  import fs from "node:fs";
2517
2757
  import path from "node:path";
2758
+
2759
+ // dist/util/comments.js
2760
+ function transformJsLikeTrivia(src, options) {
2761
+ let out = "";
2762
+ let i = 0;
2763
+ let inSingle = false;
2764
+ let inDouble = false;
2765
+ let inTemplate = false;
2766
+ let escapeNext = false;
2767
+ const maskStrings = options?.maskStrings ?? false;
2768
+ const preserveLength = options?.preserveLength ?? false;
2769
+ const maskedChar = (ch) => ch === "\n" || ch === "\r" ? ch : " ";
2770
+ while (i < src.length) {
2771
+ const ch = src[i];
2772
+ const next = src[i + 1] ?? "";
2773
+ if (inSingle || inDouble || inTemplate) {
2774
+ const isClosingQuote = !escapeNext && (inSingle && ch === "'" || inDouble && ch === '"' || inTemplate && ch === "`");
2775
+ if (maskStrings) {
2776
+ out += isClosingQuote ? ch : maskedChar(ch);
2777
+ } else {
2778
+ out += ch;
2779
+ }
2780
+ if (escapeNext) {
2781
+ escapeNext = false;
2782
+ } else if (ch === "\\") {
2783
+ escapeNext = true;
2784
+ } else if (inSingle && ch === "'") {
2785
+ inSingle = false;
2786
+ } else if (inDouble && ch === '"') {
2787
+ inDouble = false;
2788
+ } else if (inTemplate && ch === "`") {
2789
+ inTemplate = false;
2790
+ }
2791
+ i += 1;
2792
+ continue;
2793
+ }
2794
+ if (ch === "'") {
2795
+ inSingle = true;
2796
+ out += ch;
2797
+ i += 1;
2798
+ continue;
2799
+ }
2800
+ if (ch === '"') {
2801
+ inDouble = true;
2802
+ out += ch;
2803
+ i += 1;
2804
+ continue;
2805
+ }
2806
+ if (ch === "`") {
2807
+ inTemplate = true;
2808
+ out += ch;
2809
+ i += 1;
2810
+ continue;
2811
+ }
2812
+ if (ch === "/" && next === "*") {
2813
+ if (preserveLength)
2814
+ out += " ";
2815
+ i += 2;
2816
+ while (i < src.length) {
2817
+ if (src[i] === "*" && src[i + 1] === "/") {
2818
+ if (preserveLength)
2819
+ out += " ";
2820
+ i += 2;
2821
+ break;
2822
+ }
2823
+ if (preserveLength)
2824
+ out += maskedChar(src[i]);
2825
+ else if (src[i] === "\n")
2826
+ out += "\n";
2827
+ i += 1;
2828
+ }
2829
+ continue;
2830
+ }
2831
+ if (ch === "/" && next === "/") {
2832
+ if (preserveLength)
2833
+ out += " ";
2834
+ i += 2;
2835
+ while (i < src.length && src[i] !== "\n") {
2836
+ if (preserveLength)
2837
+ out += " ";
2838
+ i += 1;
2839
+ }
2840
+ continue;
2841
+ }
2842
+ out += ch;
2843
+ i += 1;
2844
+ }
2845
+ return out;
2846
+ }
2847
+ function maskJsLikeCommentsAndStrings(src) {
2848
+ return transformJsLikeTrivia(src, {
2849
+ maskStrings: true,
2850
+ preserveLength: true
2851
+ });
2852
+ }
2853
+
2854
+ // dist/languages.js
2518
2855
  function adaptDefinition(def) {
2519
2856
  return {
2520
2857
  id: def.id,
@@ -2529,6 +2866,7 @@ function adaptDefinition(def) {
2529
2866
  membersAreImplicitlyInScope: def.membersAreImplicitlyInScope ?? true,
2530
2867
  supportsCrossModuleSymbols: def.supportsCrossModuleSymbols || false,
2531
2868
  isTypeOnly: def.isTypeOnly || (() => false),
2869
+ exportScopeBlockers: def.exportScopeBlockers ?? [],
2532
2870
  supportsExportFromReferences: def.supportsExportFromReferences ?? false,
2533
2871
  usesQueryDrivenLocals: def.usesQueryDrivenLocals || false,
2534
2872
  normalizeIdentifier: def.normalizeIdentifier || ((name) => name),
@@ -2618,7 +2956,8 @@ function supportById(id) {
2618
2956
  return LANGUAGE_SUPPORTS.find((s) => s.id === id);
2619
2957
  }
2620
2958
  var HEADER_SAMPLE_SIZE = 8e3;
2621
- var CPP_HEADER_HINT = /\b(class|namespace|template|typename|constexpr|operator|using\s+namespace)\b|::/;
2959
+ var CPP_HEADER_HINT = /\b(?:class|namespace|template|typename|constexpr)\b(?!\s*(?:;|,|\)|=|\[|\())|\boperator\b(?!\s*[;,):])|\bconcept\s+\w+\s*=|\bco_await\s+\w|\busing\s+(?:namespace|\w+\s*=)|::/;
2960
+ var CPP_MODULE_IMPORT_HINT = /^\s*(?:export\s+)?import\s+(?:[\w.:]+|<[^>\n]+>|"[^"\n]*")\s*;/m;
2622
2961
  function readFileSample(filePath) {
2623
2962
  try {
2624
2963
  const contents = fs.readFileSync(filePath, "utf8");
@@ -2628,7 +2967,8 @@ function readFileSample(filePath) {
2628
2967
  }
2629
2968
  }
2630
2969
  function isLikelyCppHeader(sample) {
2631
- return CPP_HEADER_HINT.test(sample);
2970
+ const masked = maskJsLikeCommentsAndStrings(sample);
2971
+ return CPP_HEADER_HINT.test(masked) || CPP_MODULE_IMPORT_HINT.test(masked);
2632
2972
  }
2633
2973
 
2634
2974
  // dist/native/runtime.js