@willbooster/web-tree-sitter 18.0.2 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,6 @@ var require_web_tree_sitter = __commonJS({
48
48
  var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
49
49
  var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
50
50
  var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
51
- Module.currentQueryProgressCallback = null;
52
51
  Module.currentProgressCallback = null;
53
52
  Module.currentLogCallback = null;
54
53
  Module.currentParseCallback = null;
@@ -840,7 +839,7 @@ var require_web_tree_sitter = __commonJS({
840
839
  newDSO("__main__", 0, wasmImports);
841
840
  }
842
841
  };
843
- var ___heap_base = 82496;
842
+ var ___heap_base = 82464;
844
843
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
845
844
  assert(alignment, "alignment argument is required");
846
845
  return Math.ceil(size / alignment) * alignment;
@@ -935,7 +934,7 @@ var require_web_tree_sitter = __commonJS({
935
934
  }, "convertJsFunctionToWasm");
936
935
  var wasmTableMirror = [];
937
936
  var wasmTable = new WebAssembly.Table({
938
- "initial": 56,
937
+ "initial": 55,
939
938
  "element": "anyfunc"
940
939
  });
941
940
  var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
@@ -1471,12 +1470,12 @@ var require_web_tree_sitter = __commonJS({
1471
1470
  "value": "i32",
1472
1471
  "mutable": false
1473
1472
  }, 1024);
1474
- var ___stack_high = 82496;
1475
- var ___stack_low = 16960;
1473
+ var ___stack_high = 82464;
1474
+ var ___stack_low = 16928;
1476
1475
  var ___stack_pointer = new WebAssembly.Global({
1477
1476
  "value": "i32",
1478
1477
  "mutable": true
1479
- }, 82496);
1478
+ }, 82464);
1480
1479
  var ___table_base = new WebAssembly.Global({
1481
1480
  "value": "i32",
1482
1481
  "mutable": false
@@ -1609,15 +1608,6 @@ var require_web_tree_sitter = __commonJS({
1609
1608
  return false;
1610
1609
  }
1611
1610
  __name(_tree_sitter_progress_callback, "_tree_sitter_progress_callback");
1612
- function _tree_sitter_query_progress_callback(currentOffset) {
1613
- if (Module.currentQueryProgressCallback) {
1614
- return Module.currentQueryProgressCallback({
1615
- currentOffset
1616
- }) === true;
1617
- }
1618
- return false;
1619
- }
1620
- __name(_tree_sitter_query_progress_callback, "_tree_sitter_query_progress_callback");
1621
1611
  var runtimeKeepaliveCounter = 0;
1622
1612
  var keepRuntimeAlive = /* @__PURE__ */ __name(() => noExitRuntime || runtimeKeepaliveCounter > 0, "keepRuntimeAlive");
1623
1613
  var _proc_exit = /* @__PURE__ */ __name((code) => {
@@ -1829,28 +1819,9 @@ var require_web_tree_sitter = __commonJS({
1829
1819
  var _ts_parser_set_language = Module["_ts_parser_set_language"] = makeInvalidEarlyAccess("_ts_parser_set_language");
1830
1820
  var _ts_parser_reset = Module["_ts_parser_reset"] = makeInvalidEarlyAccess("_ts_parser_reset");
1831
1821
  var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = makeInvalidEarlyAccess("_ts_parser_set_included_ranges");
1832
- var _ts_query_new = Module["_ts_query_new"] = makeInvalidEarlyAccess("_ts_query_new");
1833
- var _ts_query_delete = Module["_ts_query_delete"] = makeInvalidEarlyAccess("_ts_query_delete");
1834
- var _iswspace = Module["_iswspace"] = makeInvalidEarlyAccess("_iswspace");
1835
- var _ts_query_copy = Module["_ts_query_copy"] = makeInvalidEarlyAccess("_ts_query_copy");
1836
- var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = makeInvalidEarlyAccess("_ts_query_pattern_count");
1837
- var _ts_query_capture_count = Module["_ts_query_capture_count"] = makeInvalidEarlyAccess("_ts_query_capture_count");
1838
- var _ts_query_string_count = Module["_ts_query_string_count"] = makeInvalidEarlyAccess("_ts_query_string_count");
1839
- var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = makeInvalidEarlyAccess("_ts_query_capture_name_for_id");
1840
- var _ts_query_capture_quantifier_for_id = Module["_ts_query_capture_quantifier_for_id"] = makeInvalidEarlyAccess("_ts_query_capture_quantifier_for_id");
1841
- var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = makeInvalidEarlyAccess("_ts_query_string_value_for_id");
1842
- var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = makeInvalidEarlyAccess("_ts_query_predicates_for_pattern");
1843
- var _ts_query_start_byte_for_pattern = Module["_ts_query_start_byte_for_pattern"] = makeInvalidEarlyAccess("_ts_query_start_byte_for_pattern");
1844
- var _ts_query_end_byte_for_pattern = Module["_ts_query_end_byte_for_pattern"] = makeInvalidEarlyAccess("_ts_query_end_byte_for_pattern");
1845
- var _ts_query_is_pattern_rooted = Module["_ts_query_is_pattern_rooted"] = makeInvalidEarlyAccess("_ts_query_is_pattern_rooted");
1846
- var _ts_query_is_pattern_non_local = Module["_ts_query_is_pattern_non_local"] = makeInvalidEarlyAccess("_ts_query_is_pattern_non_local");
1847
- var _ts_query_is_pattern_guaranteed_at_step = Module["_ts_query_is_pattern_guaranteed_at_step"] = makeInvalidEarlyAccess("_ts_query_is_pattern_guaranteed_at_step");
1848
- var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = makeInvalidEarlyAccess("_ts_query_disable_capture");
1849
- var _ts_query_disable_pattern = Module["_ts_query_disable_pattern"] = makeInvalidEarlyAccess("_ts_query_disable_pattern");
1850
1822
  var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
1851
1823
  var _ts_tree_copy = Module["_ts_tree_copy"] = makeInvalidEarlyAccess("_ts_tree_copy");
1852
1824
  var _ts_tree_delete = Module["_ts_tree_delete"] = makeInvalidEarlyAccess("_ts_tree_delete");
1853
- var _iswalnum = Module["_iswalnum"] = makeInvalidEarlyAccess("_iswalnum");
1854
1825
  var _ts_init = Module["_ts_init"] = makeInvalidEarlyAccess("_ts_init");
1855
1826
  var _ts_free_wasm = Module["_ts_free_wasm"] = makeInvalidEarlyAccess("_ts_free_wasm");
1856
1827
  var _ts_scanner_malloc_wasm = Module["_ts_scanner_malloc_wasm"] = makeInvalidEarlyAccess("_ts_scanner_malloc_wasm");
@@ -1937,18 +1908,18 @@ var require_web_tree_sitter = __commonJS({
1937
1908
  var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = makeInvalidEarlyAccess("_ts_node_is_extra_wasm");
1938
1909
  var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_parse_state_wasm");
1939
1910
  var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_next_parse_state_wasm");
1940
- var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = makeInvalidEarlyAccess("_ts_query_matches_wasm");
1941
- var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = makeInvalidEarlyAccess("_ts_query_captures_wasm");
1942
1911
  var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
1943
1912
  var _memcpy = Module["_memcpy"] = makeInvalidEarlyAccess("_memcpy");
1944
1913
  var _memmove = Module["_memmove"] = makeInvalidEarlyAccess("_memmove");
1945
1914
  var _fflush = makeInvalidEarlyAccess("_fflush");
1946
1915
  var _strlen = Module["_strlen"] = makeInvalidEarlyAccess("_strlen");
1916
+ var _iswalnum = Module["_iswalnum"] = makeInvalidEarlyAccess("_iswalnum");
1947
1917
  var _iswalpha = Module["_iswalpha"] = makeInvalidEarlyAccess("_iswalpha");
1948
1918
  var _iswblank = Module["_iswblank"] = makeInvalidEarlyAccess("_iswblank");
1949
1919
  var _iswdigit = Module["_iswdigit"] = makeInvalidEarlyAccess("_iswdigit");
1950
1920
  var _iswlower = Module["_iswlower"] = makeInvalidEarlyAccess("_iswlower");
1951
1921
  var _iswpunct = Module["_iswpunct"] = makeInvalidEarlyAccess("_iswpunct");
1922
+ var _iswspace = Module["_iswspace"] = makeInvalidEarlyAccess("_iswspace");
1952
1923
  var _iswupper = Module["_iswupper"] = makeInvalidEarlyAccess("_iswupper");
1953
1924
  var _iswxdigit = Module["_iswxdigit"] = makeInvalidEarlyAccess("_iswxdigit");
1954
1925
  var _memchr = Module["_memchr"] = makeInvalidEarlyAccess("_memchr");
@@ -1996,28 +1967,9 @@ var require_web_tree_sitter = __commonJS({
1996
1967
  Module["_ts_parser_set_language"] = _ts_parser_set_language = createExportWrapper("ts_parser_set_language", 2);
1997
1968
  Module["_ts_parser_reset"] = _ts_parser_reset = createExportWrapper("ts_parser_reset", 1);
1998
1969
  Module["_ts_parser_set_included_ranges"] = _ts_parser_set_included_ranges = createExportWrapper("ts_parser_set_included_ranges", 3);
1999
- Module["_ts_query_new"] = _ts_query_new = createExportWrapper("ts_query_new", 5);
2000
- Module["_ts_query_delete"] = _ts_query_delete = createExportWrapper("ts_query_delete", 1);
2001
- Module["_iswspace"] = _iswspace = createExportWrapper("iswspace", 1);
2002
- Module["_ts_query_copy"] = _ts_query_copy = createExportWrapper("ts_query_copy", 1);
2003
- Module["_ts_query_pattern_count"] = _ts_query_pattern_count = createExportWrapper("ts_query_pattern_count", 1);
2004
- Module["_ts_query_capture_count"] = _ts_query_capture_count = createExportWrapper("ts_query_capture_count", 1);
2005
- Module["_ts_query_string_count"] = _ts_query_string_count = createExportWrapper("ts_query_string_count", 1);
2006
- Module["_ts_query_capture_name_for_id"] = _ts_query_capture_name_for_id = createExportWrapper("ts_query_capture_name_for_id", 3);
2007
- Module["_ts_query_capture_quantifier_for_id"] = _ts_query_capture_quantifier_for_id = createExportWrapper("ts_query_capture_quantifier_for_id", 3);
2008
- Module["_ts_query_string_value_for_id"] = _ts_query_string_value_for_id = createExportWrapper("ts_query_string_value_for_id", 3);
2009
- Module["_ts_query_predicates_for_pattern"] = _ts_query_predicates_for_pattern = createExportWrapper("ts_query_predicates_for_pattern", 3);
2010
- Module["_ts_query_start_byte_for_pattern"] = _ts_query_start_byte_for_pattern = createExportWrapper("ts_query_start_byte_for_pattern", 2);
2011
- Module["_ts_query_end_byte_for_pattern"] = _ts_query_end_byte_for_pattern = createExportWrapper("ts_query_end_byte_for_pattern", 2);
2012
- Module["_ts_query_is_pattern_rooted"] = _ts_query_is_pattern_rooted = createExportWrapper("ts_query_is_pattern_rooted", 2);
2013
- Module["_ts_query_is_pattern_non_local"] = _ts_query_is_pattern_non_local = createExportWrapper("ts_query_is_pattern_non_local", 2);
2014
- Module["_ts_query_is_pattern_guaranteed_at_step"] = _ts_query_is_pattern_guaranteed_at_step = createExportWrapper("ts_query_is_pattern_guaranteed_at_step", 2);
2015
- Module["_ts_query_disable_capture"] = _ts_query_disable_capture = createExportWrapper("ts_query_disable_capture", 3);
2016
- Module["_ts_query_disable_pattern"] = _ts_query_disable_pattern = createExportWrapper("ts_query_disable_pattern", 2);
2017
1970
  Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
2018
1971
  Module["_ts_tree_copy"] = _ts_tree_copy = createExportWrapper("ts_tree_copy", 1);
2019
1972
  Module["_ts_tree_delete"] = _ts_tree_delete = createExportWrapper("ts_tree_delete", 1);
2020
- Module["_iswalnum"] = _iswalnum = createExportWrapper("iswalnum", 1);
2021
1973
  Module["_ts_init"] = _ts_init = createExportWrapper("ts_init", 0);
2022
1974
  Module["_ts_free_wasm"] = _ts_free_wasm = createExportWrapper("ts_free_wasm", 1);
2023
1975
  Module["_ts_scanner_malloc_wasm"] = _ts_scanner_malloc_wasm = createExportWrapper("ts_scanner_malloc_wasm", 1);
@@ -2104,18 +2056,18 @@ var require_web_tree_sitter = __commonJS({
2104
2056
  Module["_ts_node_is_extra_wasm"] = _ts_node_is_extra_wasm = createExportWrapper("ts_node_is_extra_wasm", 1);
2105
2057
  Module["_ts_node_parse_state_wasm"] = _ts_node_parse_state_wasm = createExportWrapper("ts_node_parse_state_wasm", 1);
2106
2058
  Module["_ts_node_next_parse_state_wasm"] = _ts_node_next_parse_state_wasm = createExportWrapper("ts_node_next_parse_state_wasm", 1);
2107
- Module["_ts_query_matches_wasm"] = _ts_query_matches_wasm = createExportWrapper("ts_query_matches_wasm", 16);
2108
- Module["_ts_query_captures_wasm"] = _ts_query_captures_wasm = createExportWrapper("ts_query_captures_wasm", 16);
2109
2059
  Module["_memset"] = _memset = createExportWrapper("memset", 3);
2110
2060
  Module["_memcpy"] = _memcpy = createExportWrapper("memcpy", 3);
2111
2061
  Module["_memmove"] = _memmove = createExportWrapper("memmove", 3);
2112
2062
  _fflush = createExportWrapper("fflush", 1);
2113
2063
  Module["_strlen"] = _strlen = createExportWrapper("strlen", 1);
2064
+ Module["_iswalnum"] = _iswalnum = createExportWrapper("iswalnum", 1);
2114
2065
  Module["_iswalpha"] = _iswalpha = createExportWrapper("iswalpha", 1);
2115
2066
  Module["_iswblank"] = _iswblank = createExportWrapper("iswblank", 1);
2116
2067
  Module["_iswdigit"] = _iswdigit = createExportWrapper("iswdigit", 1);
2117
2068
  Module["_iswlower"] = _iswlower = createExportWrapper("iswlower", 1);
2118
2069
  Module["_iswpunct"] = _iswpunct = createExportWrapper("iswpunct", 1);
2070
+ Module["_iswspace"] = _iswspace = createExportWrapper("iswspace", 1);
2119
2071
  Module["_iswupper"] = _iswupper = createExportWrapper("iswupper", 1);
2120
2072
  Module["_iswxdigit"] = _iswxdigit = createExportWrapper("iswxdigit", 1);
2121
2073
  Module["_memchr"] = _memchr = createExportWrapper("memchr", 3);
@@ -2189,9 +2141,7 @@ var require_web_tree_sitter = __commonJS({
2189
2141
  /** @export */
2190
2142
  tree_sitter_parse_callback: _tree_sitter_parse_callback,
2191
2143
  /** @export */
2192
- tree_sitter_progress_callback: _tree_sitter_progress_callback,
2193
- /** @export */
2194
- tree_sitter_query_progress_callback: _tree_sitter_query_progress_callback
2144
+ tree_sitter_progress_callback: _tree_sitter_progress_callback
2195
2145
  };
2196
2146
  function invoke_vi(index, a1) {
2197
2147
  var sp = stackSave();
@@ -2299,7 +2249,7 @@ var require_web_tree_sitter = __commonJS({
2299
2249
  }
2300
2250
  __name(callMain, "callMain");
2301
2251
  function stackCheckInit() {
2302
- _emscripten_stack_set_limits(82496, 16960);
2252
+ _emscripten_stack_set_limits(82464, 16928);
2303
2253
  writeStackCookie();
2304
2254
  }
2305
2255
  __name(stackCheckInit, "stackCheckInit");
@@ -2395,7 +2345,6 @@ var require_web_tree_sitter = __commonJS({
2395
2345
  // src/index.ts
2396
2346
  var index_exports = {};
2397
2347
  __export(index_exports, {
2398
- CaptureQuantifier: () => CaptureQuantifier,
2399
2348
  Edit: () => Edit,
2400
2349
  LANGUAGE_VERSION: () => LANGUAGE_VERSION,
2401
2350
  Language: () => Language,
@@ -2403,7 +2352,6 @@ __export(index_exports, {
2403
2352
  MIN_COMPATIBLE_VERSION: () => MIN_COMPATIBLE_VERSION,
2404
2353
  Node: () => Node,
2405
2354
  Parser: () => Parser,
2406
- Query: () => Query,
2407
2355
  Tree: () => Tree,
2408
2356
  TreeCursor: () => TreeCursor
2409
2357
  });
@@ -3586,17 +3534,6 @@ var Node = class {
3586
3534
  };
3587
3535
 
3588
3536
  // src/marshal.ts
3589
- function unmarshalCaptures(query, tree, address, patternIndex, result) {
3590
- for (let i2 = 0, n = result.length; i2 < n; i2++) {
3591
- const captureIndex = C.getValue(address, "i32");
3592
- address += SIZE_OF_INT;
3593
- const node = unmarshalNode(tree, address);
3594
- address += SIZE_OF_NODE;
3595
- result[i2] = { patternIndex, name: query.captureNames[captureIndex], node };
3596
- }
3597
- return address;
3598
- }
3599
- __name(unmarshalCaptures, "unmarshalCaptures");
3600
3537
  function marshalNode(node, index = 0) {
3601
3538
  let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;
3602
3539
  C.setValue(address, node.id, "i32");
@@ -4203,671 +4140,8 @@ function clearCallbacks() {
4203
4140
  C.currentProgressCallback = null;
4204
4141
  }
4205
4142
  __name(clearCallbacks, "clearCallbacks");
4206
-
4207
- // src/query.ts
4208
- var PREDICATE_STEP_TYPE_CAPTURE = 1;
4209
- var PREDICATE_STEP_TYPE_STRING = 2;
4210
- var QUERY_WORD_REGEX = /[\w-]+/g;
4211
- var CaptureQuantifier = {
4212
- Zero: 0,
4213
- ZeroOrOne: 1,
4214
- ZeroOrMore: 2,
4215
- One: 3,
4216
- OneOrMore: 4
4217
- };
4218
- var isCaptureStep = /* @__PURE__ */ __name((step) => step.type === "capture", "isCaptureStep");
4219
- var isStringStep = /* @__PURE__ */ __name((step) => step.type === "string", "isStringStep");
4220
- var QueryErrorKind = {
4221
- Syntax: 1,
4222
- NodeName: 2,
4223
- FieldName: 3,
4224
- CaptureName: 4,
4225
- PatternStructure: 5
4226
- };
4227
- var QueryError = class _QueryError extends Error {
4228
- constructor(kind, info2, index, length) {
4229
- super(_QueryError.formatMessage(kind, info2));
4230
- this.kind = kind;
4231
- this.info = info2;
4232
- this.index = index;
4233
- this.length = length;
4234
- this.name = "QueryError";
4235
- }
4236
- kind;
4237
- info;
4238
- index;
4239
- length;
4240
- static {
4241
- __name(this, "QueryError");
4242
- }
4243
- /** Formats an error message based on the error kind and info */
4244
- static formatMessage(kind, info2) {
4245
- switch (kind) {
4246
- case QueryErrorKind.NodeName:
4247
- return `Bad node name '${info2.word}'`;
4248
- case QueryErrorKind.FieldName:
4249
- return `Bad field name '${info2.word}'`;
4250
- case QueryErrorKind.CaptureName:
4251
- return `Bad capture name @${info2.word}`;
4252
- case QueryErrorKind.PatternStructure:
4253
- return `Bad pattern structure at offset ${info2.suffix}`;
4254
- case QueryErrorKind.Syntax:
4255
- return `Bad syntax at offset ${info2.suffix}`;
4256
- }
4257
- }
4258
- };
4259
- function parseAnyPredicate(steps, index, operator, textPredicates) {
4260
- if (steps.length !== 3) {
4261
- throw new Error(
4262
- `Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`
4263
- );
4264
- }
4265
- if (!isCaptureStep(steps[1])) {
4266
- throw new Error(
4267
- `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`
4268
- );
4269
- }
4270
- const isPositive = operator === "eq?" || operator === "any-eq?";
4271
- const matchAll = !operator.startsWith("any-");
4272
- if (isCaptureStep(steps[2])) {
4273
- const captureName1 = steps[1].name;
4274
- const captureName2 = steps[2].name;
4275
- textPredicates[index].push((captures) => {
4276
- const nodes1 = [];
4277
- const nodes2 = [];
4278
- for (const c of captures) {
4279
- if (c.name === captureName1) nodes1.push(c.node);
4280
- if (c.name === captureName2) nodes2.push(c.node);
4281
- }
4282
- const compare = /* @__PURE__ */ __name((n1, n2, positive) => {
4283
- return positive ? n1.text === n2.text : n1.text !== n2.text;
4284
- }, "compare");
4285
- return matchAll ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive))) : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));
4286
- });
4287
- } else {
4288
- const captureName = steps[1].name;
4289
- const stringValue = steps[2].value;
4290
- const matches = /* @__PURE__ */ __name((n) => n.text === stringValue, "matches");
4291
- const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !== stringValue, "doesNotMatch");
4292
- textPredicates[index].push((captures) => {
4293
- const nodes = [];
4294
- for (const c of captures) {
4295
- if (c.name === captureName) nodes.push(c.node);
4296
- }
4297
- const test = isPositive ? matches : doesNotMatch;
4298
- return matchAll ? nodes.every(test) : nodes.some(test);
4299
- });
4300
- }
4301
- }
4302
- __name(parseAnyPredicate, "parseAnyPredicate");
4303
- function parseMatchPredicate(steps, index, operator, textPredicates) {
4304
- if (steps.length !== 3) {
4305
- throw new Error(
4306
- `Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`
4307
- );
4308
- }
4309
- if (steps[1].type !== "capture") {
4310
- throw new Error(
4311
- `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
4312
- );
4313
- }
4314
- if (steps[2].type !== "string") {
4315
- throw new Error(
4316
- `Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].name}.`
4317
- );
4318
- }
4319
- const isPositive = operator === "match?" || operator === "any-match?";
4320
- const matchAll = !operator.startsWith("any-");
4321
- const captureName = steps[1].name;
4322
- const regex = new RegExp(steps[2].value);
4323
- textPredicates[index].push((captures) => {
4324
- const nodes = [];
4325
- for (const c of captures) {
4326
- if (c.name === captureName) nodes.push(c.node.text);
4327
- }
4328
- const test = /* @__PURE__ */ __name((text, positive) => {
4329
- return positive ? regex.test(text) : !regex.test(text);
4330
- }, "test");
4331
- if (nodes.length === 0) return !isPositive;
4332
- return matchAll ? nodes.every((text) => test(text, isPositive)) : nodes.some((text) => test(text, isPositive));
4333
- });
4334
- }
4335
- __name(parseMatchPredicate, "parseMatchPredicate");
4336
- function parseAnyOfPredicate(steps, index, operator, textPredicates) {
4337
- if (steps.length < 2) {
4338
- throw new Error(
4339
- `Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`
4340
- );
4341
- }
4342
- if (steps[1].type !== "capture") {
4343
- throw new Error(
4344
- `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
4345
- );
4346
- }
4347
- const isPositive = operator === "any-of?";
4348
- const captureName = steps[1].name;
4349
- const stringSteps = steps.slice(2);
4350
- if (!stringSteps.every(isStringStep)) {
4351
- throw new Error(
4352
- `Arguments to \`#${operator}\` predicate must be strings.".`
4353
- );
4354
- }
4355
- const values = stringSteps.map((s) => s.value);
4356
- textPredicates[index].push((captures) => {
4357
- const nodes = [];
4358
- for (const c of captures) {
4359
- if (c.name === captureName) nodes.push(c.node.text);
4360
- }
4361
- if (nodes.length === 0) return !isPositive;
4362
- return nodes.every((text) => values.includes(text)) === isPositive;
4363
- });
4364
- }
4365
- __name(parseAnyOfPredicate, "parseAnyOfPredicate");
4366
- function parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties) {
4367
- if (steps.length < 2 || steps.length > 3) {
4368
- throw new Error(
4369
- `Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`
4370
- );
4371
- }
4372
- if (!steps.every(isStringStep)) {
4373
- throw new Error(
4374
- `Arguments to \`#${operator}\` predicate must be strings.".`
4375
- );
4376
- }
4377
- const properties = operator === "is?" ? assertedProperties : refutedProperties;
4378
- if (!properties[index]) properties[index] = {};
4379
- properties[index][steps[1].value] = steps[2]?.value ?? null;
4380
- }
4381
- __name(parseIsPredicate, "parseIsPredicate");
4382
- function parseSetDirective(steps, index, setProperties) {
4383
- if (steps.length < 2 || steps.length > 3) {
4384
- throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
4385
- }
4386
- if (!steps.every(isStringStep)) {
4387
- throw new Error(`Arguments to \`#set!\` predicate must be strings.".`);
4388
- }
4389
- if (!setProperties[index]) setProperties[index] = {};
4390
- setProperties[index][steps[1].value] = steps[2]?.value ?? null;
4391
- }
4392
- __name(parseSetDirective, "parseSetDirective");
4393
- function parsePattern(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
4394
- if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
4395
- const name2 = captureNames[stepValueId];
4396
- steps.push({ type: "capture", name: name2 });
4397
- } else if (stepType === PREDICATE_STEP_TYPE_STRING) {
4398
- steps.push({ type: "string", value: stringValues[stepValueId] });
4399
- } else if (steps.length > 0) {
4400
- if (steps[0].type !== "string") {
4401
- throw new Error("Predicates must begin with a literal value");
4402
- }
4403
- const operator = steps[0].value;
4404
- switch (operator) {
4405
- case "any-not-eq?":
4406
- case "not-eq?":
4407
- case "any-eq?":
4408
- case "eq?":
4409
- parseAnyPredicate(steps, index, operator, textPredicates);
4410
- break;
4411
- case "any-not-match?":
4412
- case "not-match?":
4413
- case "any-match?":
4414
- case "match?":
4415
- parseMatchPredicate(steps, index, operator, textPredicates);
4416
- break;
4417
- case "not-any-of?":
4418
- case "any-of?":
4419
- parseAnyOfPredicate(steps, index, operator, textPredicates);
4420
- break;
4421
- case "is?":
4422
- case "is-not?":
4423
- parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);
4424
- break;
4425
- case "set!":
4426
- parseSetDirective(steps, index, setProperties);
4427
- break;
4428
- default:
4429
- predicates[index].push({ operator, operands: steps.slice(1) });
4430
- }
4431
- steps.length = 0;
4432
- }
4433
- }
4434
- __name(parsePattern, "parsePattern");
4435
- var finalizer5 = newFinalizer((address) => {
4436
- C._ts_query_delete(address);
4437
- });
4438
- var Query = class {
4439
- static {
4440
- __name(this, "Query");
4441
- }
4442
- /** @internal */
4443
- [0] = 0;
4444
- // Internal handle for Wasm
4445
- /** @internal */
4446
- exceededMatchLimit;
4447
- /** @internal */
4448
- textPredicates;
4449
- /** The names of the captures used in the query. */
4450
- captureNames;
4451
- /** The quantifiers of the captures used in the query. */
4452
- captureQuantifiers;
4453
- /**
4454
- * The other user-defined predicates associated with the given index.
4455
- *
4456
- * This includes predicates with operators other than:
4457
- * - `match?`
4458
- * - `eq?` and `not-eq?`
4459
- * - `any-of?` and `not-any-of?`
4460
- * - `is?` and `is-not?`
4461
- * - `set!`
4462
- */
4463
- predicates;
4464
- /** The properties for predicates with the operator `set!`. */
4465
- setProperties;
4466
- /** The properties for predicates with the operator `is?`. */
4467
- assertedProperties;
4468
- /** The properties for predicates with the operator `is-not?`. */
4469
- refutedProperties;
4470
- /** The maximum number of in-progress matches for this cursor. */
4471
- matchLimit;
4472
- /**
4473
- * Create a new query from a string containing one or more S-expression
4474
- * patterns.
4475
- *
4476
- * The query is associated with a particular language, and can only be run
4477
- * on syntax nodes parsed with that language. References to Queries can be
4478
- * shared between multiple threads.
4479
- *
4480
- * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
4481
- */
4482
- constructor(language, source) {
4483
- assertSupportedLanguage(language);
4484
- const sourceLength = C.lengthBytesUTF8(source);
4485
- const sourceAddress = C._malloc(sourceLength + 1);
4486
- C.stringToUTF8(source, sourceAddress, sourceLength + 1);
4487
- const address = C._ts_query_new(
4488
- language[0],
4489
- sourceAddress,
4490
- sourceLength,
4491
- TRANSFER_BUFFER,
4492
- TRANSFER_BUFFER + SIZE_OF_INT
4493
- );
4494
- if (!address) {
4495
- const errorId = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4496
- const errorByte = C.getValue(TRANSFER_BUFFER, "i32");
4497
- const errorIndex = C.UTF8ToString(sourceAddress, errorByte).length;
4498
- const suffix = source.slice(errorIndex, errorIndex + 100).split("\n")[0];
4499
- const word = suffix.match(QUERY_WORD_REGEX)?.[0] ?? "";
4500
- C._free(sourceAddress);
4501
- switch (errorId) {
4502
- case QueryErrorKind.Syntax:
4503
- throw new QueryError(QueryErrorKind.Syntax, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
4504
- case QueryErrorKind.NodeName:
4505
- throw new QueryError(errorId, { word }, errorIndex, word.length);
4506
- case QueryErrorKind.FieldName:
4507
- throw new QueryError(errorId, { word }, errorIndex, word.length);
4508
- case QueryErrorKind.CaptureName:
4509
- throw new QueryError(errorId, { word }, errorIndex, word.length);
4510
- case QueryErrorKind.PatternStructure:
4511
- throw new QueryError(errorId, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
4512
- }
4513
- }
4514
- const stringCount = C._ts_query_string_count(address);
4515
- const captureCount = C._ts_query_capture_count(address);
4516
- const patternCount = C._ts_query_pattern_count(address);
4517
- const captureNames = new Array(captureCount);
4518
- const captureQuantifiers = new Array(patternCount);
4519
- const stringValues = new Array(stringCount);
4520
- for (let i2 = 0; i2 < captureCount; i2++) {
4521
- const nameAddress = C._ts_query_capture_name_for_id(
4522
- address,
4523
- i2,
4524
- TRANSFER_BUFFER
4525
- );
4526
- const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
4527
- captureNames[i2] = C.UTF8ToString(nameAddress, nameLength);
4528
- }
4529
- for (let i2 = 0; i2 < patternCount; i2++) {
4530
- const captureQuantifiersArray = new Array(captureCount);
4531
- for (let j = 0; j < captureCount; j++) {
4532
- const quantifier = C._ts_query_capture_quantifier_for_id(address, i2, j);
4533
- captureQuantifiersArray[j] = quantifier;
4534
- }
4535
- captureQuantifiers[i2] = captureQuantifiersArray;
4536
- }
4537
- for (let i2 = 0; i2 < stringCount; i2++) {
4538
- const valueAddress = C._ts_query_string_value_for_id(
4539
- address,
4540
- i2,
4541
- TRANSFER_BUFFER
4542
- );
4543
- const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
4544
- stringValues[i2] = C.UTF8ToString(valueAddress, nameLength);
4545
- }
4546
- const setProperties = new Array(patternCount);
4547
- const assertedProperties = new Array(patternCount);
4548
- const refutedProperties = new Array(patternCount);
4549
- const predicates = new Array(patternCount);
4550
- const textPredicates = new Array(patternCount);
4551
- for (let i2 = 0; i2 < patternCount; i2++) {
4552
- const predicatesAddress = C._ts_query_predicates_for_pattern(address, i2, TRANSFER_BUFFER);
4553
- const stepCount = C.getValue(TRANSFER_BUFFER, "i32");
4554
- predicates[i2] = [];
4555
- textPredicates[i2] = [];
4556
- const steps = new Array();
4557
- let stepAddress = predicatesAddress;
4558
- for (let j = 0; j < stepCount; j++) {
4559
- const stepType = C.getValue(stepAddress, "i32");
4560
- stepAddress += SIZE_OF_INT;
4561
- const stepValueId = C.getValue(stepAddress, "i32");
4562
- stepAddress += SIZE_OF_INT;
4563
- parsePattern(
4564
- i2,
4565
- stepType,
4566
- stepValueId,
4567
- captureNames,
4568
- stringValues,
4569
- steps,
4570
- textPredicates,
4571
- predicates,
4572
- setProperties,
4573
- assertedProperties,
4574
- refutedProperties
4575
- );
4576
- }
4577
- Object.freeze(textPredicates[i2]);
4578
- Object.freeze(predicates[i2]);
4579
- Object.freeze(setProperties[i2]);
4580
- Object.freeze(assertedProperties[i2]);
4581
- Object.freeze(refutedProperties[i2]);
4582
- }
4583
- C._free(sourceAddress);
4584
- this[0] = address;
4585
- this.captureNames = captureNames;
4586
- this.captureQuantifiers = captureQuantifiers;
4587
- this.textPredicates = textPredicates;
4588
- this.predicates = predicates;
4589
- this.setProperties = setProperties;
4590
- this.assertedProperties = assertedProperties;
4591
- this.refutedProperties = refutedProperties;
4592
- this.exceededMatchLimit = false;
4593
- finalizer5?.register(this, address, this);
4594
- }
4595
- /** Delete the query, freeing its resources. */
4596
- delete() {
4597
- finalizer5?.unregister(this);
4598
- C._ts_query_delete(this[0]);
4599
- this[0] = 0;
4600
- }
4601
- /**
4602
- * Iterate over all of the matches in the order that they were found.
4603
- *
4604
- * Each match contains the index of the pattern that matched, and a list of
4605
- * captures. Because multiple patterns can match the same set of nodes,
4606
- * one match may contain captures that appear *before* some of the
4607
- * captures from a previous match.
4608
- *
4609
- * @param {Node} node - The node to execute the query on.
4610
- *
4611
- * @param {QueryOptions} options - Options for query execution.
4612
- */
4613
- matches(node, options = {}) {
4614
- const startPosition = options.startPosition ?? ZERO_POINT;
4615
- const endPosition = options.endPosition ?? ZERO_POINT;
4616
- const startIndex = options.startIndex ?? 0;
4617
- const endIndex = options.endIndex ?? 0;
4618
- const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
4619
- const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
4620
- const startContainingIndex = options.startContainingIndex ?? 0;
4621
- const endContainingIndex = options.endContainingIndex ?? 0;
4622
- const matchLimit = options.matchLimit ?? 4294967295;
4623
- const maxStartDepth = options.maxStartDepth ?? 4294967295;
4624
- const progressCallback = options.progressCallback;
4625
- if (typeof matchLimit !== "number") {
4626
- throw new Error("Arguments must be numbers");
4627
- }
4628
- this.matchLimit = matchLimit;
4629
- if (endIndex !== 0 && startIndex > endIndex) {
4630
- throw new Error("`startIndex` cannot be greater than `endIndex`");
4631
- }
4632
- if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
4633
- throw new Error("`startPosition` cannot be greater than `endPosition`");
4634
- }
4635
- if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
4636
- throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
4637
- }
4638
- if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
4639
- throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
4640
- }
4641
- if (progressCallback) {
4642
- C.currentQueryProgressCallback = progressCallback;
4643
- }
4644
- marshalNode(node);
4645
- C._ts_query_matches_wasm(
4646
- this[0],
4647
- node.tree[0],
4648
- startPosition.row,
4649
- startPosition.column,
4650
- endPosition.row,
4651
- endPosition.column,
4652
- startIndex,
4653
- endIndex,
4654
- startContainingPosition.row,
4655
- startContainingPosition.column,
4656
- endContainingPosition.row,
4657
- endContainingPosition.column,
4658
- startContainingIndex,
4659
- endContainingIndex,
4660
- matchLimit,
4661
- maxStartDepth
4662
- );
4663
- const rawCount = C.getValue(TRANSFER_BUFFER, "i32");
4664
- const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4665
- const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
4666
- const result = new Array(rawCount);
4667
- this.exceededMatchLimit = Boolean(didExceedMatchLimit);
4668
- let filteredCount = 0;
4669
- let address = startAddress;
4670
- for (let i2 = 0; i2 < rawCount; i2++) {
4671
- const patternIndex = C.getValue(address, "i32");
4672
- address += SIZE_OF_INT;
4673
- const captureCount = C.getValue(address, "i32");
4674
- address += SIZE_OF_INT;
4675
- const captures = new Array(captureCount);
4676
- address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
4677
- if (this.textPredicates[patternIndex].every((p) => p(captures))) {
4678
- result[filteredCount] = { patternIndex, captures };
4679
- const setProperties = this.setProperties[patternIndex];
4680
- result[filteredCount].setProperties = setProperties;
4681
- const assertedProperties = this.assertedProperties[patternIndex];
4682
- result[filteredCount].assertedProperties = assertedProperties;
4683
- const refutedProperties = this.refutedProperties[patternIndex];
4684
- result[filteredCount].refutedProperties = refutedProperties;
4685
- filteredCount++;
4686
- }
4687
- }
4688
- result.length = filteredCount;
4689
- C._ts_free_wasm(startAddress);
4690
- C.currentQueryProgressCallback = null;
4691
- return result;
4692
- }
4693
- /**
4694
- * Iterate over all of the individual captures in the order that they
4695
- * appear.
4696
- *
4697
- * This is useful if you don't care about which pattern matched, and just
4698
- * want a single, ordered sequence of captures.
4699
- *
4700
- * @param {Node} node - The node to execute the query on.
4701
- *
4702
- * @param {QueryOptions} options - Options for query execution.
4703
- */
4704
- captures(node, options = {}) {
4705
- const startPosition = options.startPosition ?? ZERO_POINT;
4706
- const endPosition = options.endPosition ?? ZERO_POINT;
4707
- const startIndex = options.startIndex ?? 0;
4708
- const endIndex = options.endIndex ?? 0;
4709
- const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
4710
- const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
4711
- const startContainingIndex = options.startContainingIndex ?? 0;
4712
- const endContainingIndex = options.endContainingIndex ?? 0;
4713
- const matchLimit = options.matchLimit ?? 4294967295;
4714
- const maxStartDepth = options.maxStartDepth ?? 4294967295;
4715
- const progressCallback = options.progressCallback;
4716
- if (typeof matchLimit !== "number") {
4717
- throw new Error("Arguments must be numbers");
4718
- }
4719
- this.matchLimit = matchLimit;
4720
- if (endIndex !== 0 && startIndex > endIndex) {
4721
- throw new Error("`startIndex` cannot be greater than `endIndex`");
4722
- }
4723
- if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
4724
- throw new Error("`startPosition` cannot be greater than `endPosition`");
4725
- }
4726
- if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
4727
- throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
4728
- }
4729
- if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
4730
- throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
4731
- }
4732
- if (progressCallback) {
4733
- C.currentQueryProgressCallback = progressCallback;
4734
- }
4735
- marshalNode(node);
4736
- C._ts_query_captures_wasm(
4737
- this[0],
4738
- node.tree[0],
4739
- startPosition.row,
4740
- startPosition.column,
4741
- endPosition.row,
4742
- endPosition.column,
4743
- startIndex,
4744
- endIndex,
4745
- startContainingPosition.row,
4746
- startContainingPosition.column,
4747
- endContainingPosition.row,
4748
- endContainingPosition.column,
4749
- startContainingIndex,
4750
- endContainingIndex,
4751
- matchLimit,
4752
- maxStartDepth
4753
- );
4754
- const count = C.getValue(TRANSFER_BUFFER, "i32");
4755
- const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4756
- const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
4757
- const result = new Array();
4758
- this.exceededMatchLimit = Boolean(didExceedMatchLimit);
4759
- const captures = new Array();
4760
- let address = startAddress;
4761
- for (let i2 = 0; i2 < count; i2++) {
4762
- const patternIndex = C.getValue(address, "i32");
4763
- address += SIZE_OF_INT;
4764
- const captureCount = C.getValue(address, "i32");
4765
- address += SIZE_OF_INT;
4766
- const captureIndex = C.getValue(address, "i32");
4767
- address += SIZE_OF_INT;
4768
- captures.length = captureCount;
4769
- address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
4770
- if (this.textPredicates[patternIndex].every((p) => p(captures))) {
4771
- const capture = captures[captureIndex];
4772
- const setProperties = this.setProperties[patternIndex];
4773
- capture.setProperties = setProperties;
4774
- const assertedProperties = this.assertedProperties[patternIndex];
4775
- capture.assertedProperties = assertedProperties;
4776
- const refutedProperties = this.refutedProperties[patternIndex];
4777
- capture.refutedProperties = refutedProperties;
4778
- result.push(capture);
4779
- }
4780
- }
4781
- C._ts_free_wasm(startAddress);
4782
- C.currentQueryProgressCallback = null;
4783
- return result;
4784
- }
4785
- /** Get the predicates for a given pattern. */
4786
- predicatesForPattern(patternIndex) {
4787
- return this.predicates[patternIndex];
4788
- }
4789
- /**
4790
- * Disable a certain capture within a query.
4791
- *
4792
- * This prevents the capture from being returned in matches, and also
4793
- * avoids any resource usage associated with recording the capture.
4794
- */
4795
- disableCapture(captureName) {
4796
- const captureNameLength = C.lengthBytesUTF8(captureName);
4797
- const captureNameAddress = C._malloc(captureNameLength + 1);
4798
- C.stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
4799
- C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
4800
- C._free(captureNameAddress);
4801
- }
4802
- /**
4803
- * Disable a certain pattern within a query.
4804
- *
4805
- * This prevents the pattern from matching, and also avoids any resource
4806
- * usage associated with the pattern. This throws an error if the pattern
4807
- * index is out of bounds.
4808
- */
4809
- disablePattern(patternIndex) {
4810
- if (patternIndex >= this.predicates.length) {
4811
- throw new Error(
4812
- `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4813
- );
4814
- }
4815
- C._ts_query_disable_pattern(this[0], patternIndex);
4816
- }
4817
- /**
4818
- * Check if, on its last execution, this cursor exceeded its maximum number
4819
- * of in-progress matches.
4820
- */
4821
- didExceedMatchLimit() {
4822
- return this.exceededMatchLimit;
4823
- }
4824
- /** Get the byte offset where the given pattern starts in the query's source. */
4825
- startIndexForPattern(patternIndex) {
4826
- if (patternIndex >= this.predicates.length) {
4827
- throw new Error(
4828
- `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4829
- );
4830
- }
4831
- return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
4832
- }
4833
- /** Get the byte offset where the given pattern ends in the query's source. */
4834
- endIndexForPattern(patternIndex) {
4835
- if (patternIndex >= this.predicates.length) {
4836
- throw new Error(
4837
- `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4838
- );
4839
- }
4840
- return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
4841
- }
4842
- /** Get the number of patterns in the query. */
4843
- patternCount() {
4844
- return C._ts_query_pattern_count(this[0]);
4845
- }
4846
- /** Get the index for a given capture name. */
4847
- captureIndexForName(captureName) {
4848
- return this.captureNames.indexOf(captureName);
4849
- }
4850
- /** Check if a given pattern within a query has a single root node. */
4851
- isPatternRooted(patternIndex) {
4852
- return C._ts_query_is_pattern_rooted(this[0], patternIndex) === 1;
4853
- }
4854
- /** Check if a given pattern within a query has a single root node. */
4855
- isPatternNonLocal(patternIndex) {
4856
- return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
4857
- }
4858
- /**
4859
- * Check if a given step in a query is 'definite'.
4860
- *
4861
- * A query step is 'definite' if its parent pattern will be guaranteed to
4862
- * match successfully once it reaches the step.
4863
- */
4864
- isPatternGuaranteedAtStep(byteIndex) {
4865
- return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
4866
- }
4867
- };
4868
4143
  // Annotate the CommonJS export names for ESM import in node:
4869
4144
  0 && (module.exports = {
4870
- CaptureQuantifier,
4871
4145
  Edit,
4872
4146
  LANGUAGE_VERSION,
4873
4147
  Language,
@@ -4875,7 +4149,6 @@ var Query = class {
4875
4149
  MIN_COMPATIBLE_VERSION,
4876
4150
  Node,
4877
4151
  Parser,
4878
- Query,
4879
4152
  Tree,
4880
4153
  TreeCursor
4881
4154
  });