@willbooster/web-tree-sitter 19.1.1 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -20
- package/debug/web-tree-sitter.cjs +101 -452
- package/debug/web-tree-sitter.cjs.map +4 -4
- package/debug/web-tree-sitter.js +101 -450
- package/debug/web-tree-sitter.js.map +4 -4
- package/debug/web-tree-sitter.wasm +0 -0
- package/debug/web-tree-sitter.wasm.map +19 -23
- package/package.json +6 -7
- package/web-tree-sitter.cjs +3 -3
- package/web-tree-sitter.cjs.map +4 -4
- package/web-tree-sitter.d.cts +2 -154
- package/web-tree-sitter.d.cts.map +3 -9
- package/web-tree-sitter.d.ts +2 -154
- package/web-tree-sitter.d.ts.map +3 -9
- package/web-tree-sitter.js +3 -3
- package/web-tree-sitter.js.map +4 -4
- package/web-tree-sitter.wasm +0 -0
- package/web-tree-sitter.wasm.map +24 -28
- package/web-tree-sitter.web.js +3 -3
- package/web-tree-sitter.web.js.map +4 -4
|
@@ -320,7 +320,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
320
320
|
if (Module["wasmMemory"]) {
|
|
321
321
|
wasmMemory = Module["wasmMemory"];
|
|
322
322
|
} else {
|
|
323
|
-
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] ||
|
|
323
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 524288;
|
|
324
324
|
assert(INITIAL_MEMORY >= 65536, "INITIAL_MEMORY should be larger than STACK_SIZE, was " + INITIAL_MEMORY + "! (STACK_SIZE=65536)");
|
|
325
325
|
wasmMemory = new WebAssembly.Memory({
|
|
326
326
|
"initial": INITIAL_MEMORY / 65536,
|
|
@@ -771,7 +771,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
771
771
|
newDSO("__main__", 0, wasmImports);
|
|
772
772
|
}
|
|
773
773
|
};
|
|
774
|
-
var ___heap_base =
|
|
774
|
+
var ___heap_base = 81968;
|
|
775
775
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
|
|
776
776
|
assert(alignment, "alignment argument is required");
|
|
777
777
|
return Math.ceil(size / alignment) * alignment;
|
|
@@ -866,7 +866,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
866
866
|
}, "convertJsFunctionToWasm");
|
|
867
867
|
var wasmTableMirror = [];
|
|
868
868
|
var wasmTable = new WebAssembly.Table({
|
|
869
|
-
"initial":
|
|
869
|
+
"initial": 58,
|
|
870
870
|
"element": "anyfunc"
|
|
871
871
|
});
|
|
872
872
|
var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
|
|
@@ -1402,12 +1402,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1402
1402
|
"value": "i32",
|
|
1403
1403
|
"mutable": false
|
|
1404
1404
|
}, 1024);
|
|
1405
|
-
var ___stack_high =
|
|
1406
|
-
var ___stack_low =
|
|
1405
|
+
var ___stack_high = 81968;
|
|
1406
|
+
var ___stack_low = 16432;
|
|
1407
1407
|
var ___stack_pointer = new WebAssembly.Global({
|
|
1408
1408
|
"value": "i32",
|
|
1409
1409
|
"mutable": true
|
|
1410
|
-
},
|
|
1410
|
+
}, 81968);
|
|
1411
1411
|
var ___table_base = new WebAssembly.Global({
|
|
1412
1412
|
"value": "i32",
|
|
1413
1413
|
"mutable": false
|
|
@@ -1704,22 +1704,15 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1704
1704
|
var _ts_language_abi_version = Module["_ts_language_abi_version"] = makeInvalidEarlyAccess("_ts_language_abi_version");
|
|
1705
1705
|
var _ts_language_name = Module["_ts_language_name"] = makeInvalidEarlyAccess("_ts_language_name");
|
|
1706
1706
|
var _ts_language_field_count = Module["_ts_language_field_count"] = makeInvalidEarlyAccess("_ts_language_field_count");
|
|
1707
|
-
var _ts_language_next_state = Module["_ts_language_next_state"] = makeInvalidEarlyAccess("_ts_language_next_state");
|
|
1708
1707
|
var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = makeInvalidEarlyAccess("_ts_language_symbol_name");
|
|
1709
1708
|
var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = makeInvalidEarlyAccess("_ts_language_symbol_for_name");
|
|
1710
1709
|
var _strncmp = Module["_strncmp"] = makeInvalidEarlyAccess("_strncmp");
|
|
1711
1710
|
var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = makeInvalidEarlyAccess("_ts_language_symbol_type");
|
|
1712
1711
|
var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = makeInvalidEarlyAccess("_ts_language_field_name_for_id");
|
|
1713
|
-
var
|
|
1714
|
-
var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_delete");
|
|
1715
|
-
var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset_state");
|
|
1716
|
-
var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset");
|
|
1717
|
-
var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_next");
|
|
1718
|
-
var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_current_symbol");
|
|
1712
|
+
var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
|
|
1719
1713
|
var _ts_parser_delete = Module["_ts_parser_delete"] = makeInvalidEarlyAccess("_ts_parser_delete");
|
|
1720
1714
|
var _ts_parser_set_language = Module["_ts_parser_set_language"] = makeInvalidEarlyAccess("_ts_parser_set_language");
|
|
1721
1715
|
var _ts_parser_reset = Module["_ts_parser_reset"] = makeInvalidEarlyAccess("_ts_parser_reset");
|
|
1722
|
-
var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
|
|
1723
1716
|
var _ts_tree_cursor_current_descendant_index = Module["_ts_tree_cursor_current_descendant_index"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index");
|
|
1724
1717
|
var _ts_tree_cursor_current_depth = Module["_ts_tree_cursor_current_depth"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth");
|
|
1725
1718
|
var _ts_tree_copy = Module["_ts_tree_copy"] = makeInvalidEarlyAccess("_ts_tree_copy");
|
|
@@ -1743,9 +1736,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1743
1736
|
var _ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = makeInvalidEarlyAccess("_ts_language_subtypes_wasm");
|
|
1744
1737
|
var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_root_node_wasm");
|
|
1745
1738
|
var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = makeInvalidEarlyAccess("_ts_tree_root_node_with_offset_wasm");
|
|
1746
|
-
var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = makeInvalidEarlyAccess("_ts_tree_edit_wasm");
|
|
1747
1739
|
var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_tree_included_ranges_wasm");
|
|
1748
|
-
var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = makeInvalidEarlyAccess("_ts_tree_get_changed_ranges_wasm");
|
|
1749
1740
|
var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_new_wasm");
|
|
1750
1741
|
var _ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_copy_wasm");
|
|
1751
1742
|
var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_delete_wasm");
|
|
@@ -1759,14 +1750,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1759
1750
|
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_previous_sibling_wasm");
|
|
1760
1751
|
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_descendant_wasm");
|
|
1761
1752
|
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_parent_wasm");
|
|
1762
|
-
var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_state_id_wasm");
|
|
1763
1753
|
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_id_wasm");
|
|
1764
1754
|
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_position_wasm");
|
|
1765
1755
|
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
|
|
1766
|
-
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
|
|
1767
|
-
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
|
|
1768
1756
|
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
|
|
1769
|
-
var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = makeInvalidEarlyAccess("_ts_node_symbol_wasm");
|
|
1770
1757
|
var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_child_wasm");
|
|
1771
1758
|
var _ts_node_field_name_for_named_child_wasm = Module["_ts_node_field_name_for_named_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_named_child_wasm");
|
|
1772
1759
|
var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = makeInvalidEarlyAccess("_ts_node_children_by_field_id_wasm");
|
|
@@ -1789,20 +1776,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1789
1776
|
var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_index_wasm");
|
|
1790
1777
|
var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_for_position_wasm");
|
|
1791
1778
|
var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_position_wasm");
|
|
1792
|
-
var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = makeInvalidEarlyAccess("_ts_node_end_point_wasm");
|
|
1793
|
-
var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = makeInvalidEarlyAccess("_ts_node_end_index_wasm");
|
|
1794
1779
|
var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = makeInvalidEarlyAccess("_ts_node_to_string_wasm");
|
|
1795
1780
|
var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = makeInvalidEarlyAccess("_ts_node_children_wasm");
|
|
1796
1781
|
var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = makeInvalidEarlyAccess("_ts_node_named_children_wasm");
|
|
1797
1782
|
var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = makeInvalidEarlyAccess("_ts_node_descendants_of_type_wasm");
|
|
1798
|
-
var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = makeInvalidEarlyAccess("_ts_node_is_named_wasm");
|
|
1799
|
-
var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = makeInvalidEarlyAccess("_ts_node_has_changes_wasm");
|
|
1800
|
-
var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = makeInvalidEarlyAccess("_ts_node_has_error_wasm");
|
|
1801
|
-
var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = makeInvalidEarlyAccess("_ts_node_is_error_wasm");
|
|
1802
|
-
var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = makeInvalidEarlyAccess("_ts_node_is_missing_wasm");
|
|
1803
|
-
var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = makeInvalidEarlyAccess("_ts_node_is_extra_wasm");
|
|
1804
|
-
var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_parse_state_wasm");
|
|
1805
|
-
var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_next_parse_state_wasm");
|
|
1806
1783
|
var _memcpy = Module["_memcpy"] = makeInvalidEarlyAccess("_memcpy");
|
|
1807
1784
|
var _memmove = Module["_memmove"] = makeInvalidEarlyAccess("_memmove");
|
|
1808
1785
|
var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
|
|
@@ -1844,22 +1821,15 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1844
1821
|
Module["_ts_language_abi_version"] = _ts_language_abi_version = createExportWrapper("ts_language_abi_version", 1);
|
|
1845
1822
|
Module["_ts_language_name"] = _ts_language_name = createExportWrapper("ts_language_name", 1);
|
|
1846
1823
|
Module["_ts_language_field_count"] = _ts_language_field_count = createExportWrapper("ts_language_field_count", 1);
|
|
1847
|
-
Module["_ts_language_next_state"] = _ts_language_next_state = createExportWrapper("ts_language_next_state", 3);
|
|
1848
1824
|
Module["_ts_language_symbol_name"] = _ts_language_symbol_name = createExportWrapper("ts_language_symbol_name", 2);
|
|
1849
1825
|
Module["_ts_language_symbol_for_name"] = _ts_language_symbol_for_name = createExportWrapper("ts_language_symbol_for_name", 4);
|
|
1850
1826
|
Module["_strncmp"] = _strncmp = createExportWrapper("strncmp", 3);
|
|
1851
1827
|
Module["_ts_language_symbol_type"] = _ts_language_symbol_type = createExportWrapper("ts_language_symbol_type", 2);
|
|
1852
1828
|
Module["_ts_language_field_name_for_id"] = _ts_language_field_name_for_id = createExportWrapper("ts_language_field_name_for_id", 2);
|
|
1853
|
-
Module["
|
|
1854
|
-
Module["_ts_lookahead_iterator_delete"] = _ts_lookahead_iterator_delete = createExportWrapper("ts_lookahead_iterator_delete", 1);
|
|
1855
|
-
Module["_ts_lookahead_iterator_reset_state"] = _ts_lookahead_iterator_reset_state = createExportWrapper("ts_lookahead_iterator_reset_state", 2);
|
|
1856
|
-
Module["_ts_lookahead_iterator_reset"] = _ts_lookahead_iterator_reset = createExportWrapper("ts_lookahead_iterator_reset", 3);
|
|
1857
|
-
Module["_ts_lookahead_iterator_next"] = _ts_lookahead_iterator_next = createExportWrapper("ts_lookahead_iterator_next", 1);
|
|
1858
|
-
Module["_ts_lookahead_iterator_current_symbol"] = _ts_lookahead_iterator_current_symbol = createExportWrapper("ts_lookahead_iterator_current_symbol", 1);
|
|
1829
|
+
Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
|
|
1859
1830
|
Module["_ts_parser_delete"] = _ts_parser_delete = createExportWrapper("ts_parser_delete", 1);
|
|
1860
1831
|
Module["_ts_parser_set_language"] = _ts_parser_set_language = createExportWrapper("ts_parser_set_language", 2);
|
|
1861
1832
|
Module["_ts_parser_reset"] = _ts_parser_reset = createExportWrapper("ts_parser_reset", 1);
|
|
1862
|
-
Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
|
|
1863
1833
|
Module["_ts_tree_cursor_current_descendant_index"] = _ts_tree_cursor_current_descendant_index = createExportWrapper("ts_tree_cursor_current_descendant_index", 1);
|
|
1864
1834
|
Module["_ts_tree_cursor_current_depth"] = _ts_tree_cursor_current_depth = createExportWrapper("ts_tree_cursor_current_depth", 1);
|
|
1865
1835
|
Module["_ts_tree_copy"] = _ts_tree_copy = createExportWrapper("ts_tree_copy", 1);
|
|
@@ -1871,7 +1841,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1871
1841
|
Module["_ts_scanner_realloc_wasm"] = _ts_scanner_realloc_wasm = createExportWrapper("ts_scanner_realloc_wasm", 2);
|
|
1872
1842
|
Module["_ts_parser_new_wasm"] = _ts_parser_new_wasm = createExportWrapper("ts_parser_new_wasm", 0);
|
|
1873
1843
|
Module["_ts_parser_enable_logger_wasm"] = _ts_parser_enable_logger_wasm = createExportWrapper("ts_parser_enable_logger_wasm", 2);
|
|
1874
|
-
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm",
|
|
1844
|
+
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 2);
|
|
1875
1845
|
Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm", 2);
|
|
1876
1846
|
Module["_ts_parser_last_parse_operations_wasm"] = _ts_parser_last_parse_operations_wasm = createExportWrapper("ts_parser_last_parse_operations_wasm", 1);
|
|
1877
1847
|
Module["_ts_parser_abort_limited_wasm"] = _ts_parser_abort_limited_wasm = createExportWrapper("ts_parser_abort_limited_wasm", 0);
|
|
@@ -1883,9 +1853,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1883
1853
|
Module["_ts_language_subtypes_wasm"] = _ts_language_subtypes_wasm = createExportWrapper("ts_language_subtypes_wasm", 2);
|
|
1884
1854
|
Module["_ts_tree_root_node_wasm"] = _ts_tree_root_node_wasm = createExportWrapper("ts_tree_root_node_wasm", 1);
|
|
1885
1855
|
Module["_ts_tree_root_node_with_offset_wasm"] = _ts_tree_root_node_with_offset_wasm = createExportWrapper("ts_tree_root_node_with_offset_wasm", 1);
|
|
1886
|
-
Module["_ts_tree_edit_wasm"] = _ts_tree_edit_wasm = createExportWrapper("ts_tree_edit_wasm", 1);
|
|
1887
1856
|
Module["_ts_tree_included_ranges_wasm"] = _ts_tree_included_ranges_wasm = createExportWrapper("ts_tree_included_ranges_wasm", 1);
|
|
1888
|
-
Module["_ts_tree_get_changed_ranges_wasm"] = _ts_tree_get_changed_ranges_wasm = createExportWrapper("ts_tree_get_changed_ranges_wasm", 2);
|
|
1889
1857
|
Module["_ts_tree_cursor_new_wasm"] = _ts_tree_cursor_new_wasm = createExportWrapper("ts_tree_cursor_new_wasm", 1);
|
|
1890
1858
|
Module["_ts_tree_cursor_copy_wasm"] = _ts_tree_cursor_copy_wasm = createExportWrapper("ts_tree_cursor_copy_wasm", 1);
|
|
1891
1859
|
Module["_ts_tree_cursor_delete_wasm"] = _ts_tree_cursor_delete_wasm = createExportWrapper("ts_tree_cursor_delete_wasm", 1);
|
|
@@ -1899,14 +1867,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1899
1867
|
Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
|
|
1900
1868
|
Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
|
|
1901
1869
|
Module["_ts_tree_cursor_goto_parent_wasm"] = _ts_tree_cursor_goto_parent_wasm = createExportWrapper("ts_tree_cursor_goto_parent_wasm", 1);
|
|
1902
|
-
Module["_ts_tree_cursor_current_node_state_id_wasm"] = _ts_tree_cursor_current_node_state_id_wasm = createExportWrapper("ts_tree_cursor_current_node_state_id_wasm", 1);
|
|
1903
1870
|
Module["_ts_tree_cursor_current_node_id_wasm"] = _ts_tree_cursor_current_node_id_wasm = createExportWrapper("ts_tree_cursor_current_node_id_wasm", 1);
|
|
1904
1871
|
Module["_ts_tree_cursor_start_position_wasm"] = _ts_tree_cursor_start_position_wasm = createExportWrapper("ts_tree_cursor_start_position_wasm", 1);
|
|
1905
1872
|
Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
|
|
1906
|
-
Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
|
|
1907
|
-
Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
|
|
1908
1873
|
Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
|
|
1909
|
-
Module["_ts_node_symbol_wasm"] = _ts_node_symbol_wasm = createExportWrapper("ts_node_symbol_wasm", 1);
|
|
1910
1874
|
Module["_ts_node_field_name_for_child_wasm"] = _ts_node_field_name_for_child_wasm = createExportWrapper("ts_node_field_name_for_child_wasm", 2);
|
|
1911
1875
|
Module["_ts_node_field_name_for_named_child_wasm"] = _ts_node_field_name_for_named_child_wasm = createExportWrapper("ts_node_field_name_for_named_child_wasm", 2);
|
|
1912
1876
|
Module["_ts_node_children_by_field_id_wasm"] = _ts_node_children_by_field_id_wasm = createExportWrapper("ts_node_children_by_field_id_wasm", 2);
|
|
@@ -1929,20 +1893,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1929
1893
|
Module["_ts_node_named_descendant_for_index_wasm"] = _ts_node_named_descendant_for_index_wasm = createExportWrapper("ts_node_named_descendant_for_index_wasm", 1);
|
|
1930
1894
|
Module["_ts_node_descendant_for_position_wasm"] = _ts_node_descendant_for_position_wasm = createExportWrapper("ts_node_descendant_for_position_wasm", 1);
|
|
1931
1895
|
Module["_ts_node_named_descendant_for_position_wasm"] = _ts_node_named_descendant_for_position_wasm = createExportWrapper("ts_node_named_descendant_for_position_wasm", 1);
|
|
1932
|
-
Module["_ts_node_end_point_wasm"] = _ts_node_end_point_wasm = createExportWrapper("ts_node_end_point_wasm", 1);
|
|
1933
|
-
Module["_ts_node_end_index_wasm"] = _ts_node_end_index_wasm = createExportWrapper("ts_node_end_index_wasm", 1);
|
|
1934
1896
|
Module["_ts_node_to_string_wasm"] = _ts_node_to_string_wasm = createExportWrapper("ts_node_to_string_wasm", 1);
|
|
1935
1897
|
Module["_ts_node_children_wasm"] = _ts_node_children_wasm = createExportWrapper("ts_node_children_wasm", 1);
|
|
1936
1898
|
Module["_ts_node_named_children_wasm"] = _ts_node_named_children_wasm = createExportWrapper("ts_node_named_children_wasm", 1);
|
|
1937
1899
|
Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 3);
|
|
1938
|
-
Module["_ts_node_is_named_wasm"] = _ts_node_is_named_wasm = createExportWrapper("ts_node_is_named_wasm", 1);
|
|
1939
|
-
Module["_ts_node_has_changes_wasm"] = _ts_node_has_changes_wasm = createExportWrapper("ts_node_has_changes_wasm", 1);
|
|
1940
|
-
Module["_ts_node_has_error_wasm"] = _ts_node_has_error_wasm = createExportWrapper("ts_node_has_error_wasm", 1);
|
|
1941
|
-
Module["_ts_node_is_error_wasm"] = _ts_node_is_error_wasm = createExportWrapper("ts_node_is_error_wasm", 1);
|
|
1942
|
-
Module["_ts_node_is_missing_wasm"] = _ts_node_is_missing_wasm = createExportWrapper("ts_node_is_missing_wasm", 1);
|
|
1943
|
-
Module["_ts_node_is_extra_wasm"] = _ts_node_is_extra_wasm = createExportWrapper("ts_node_is_extra_wasm", 1);
|
|
1944
|
-
Module["_ts_node_parse_state_wasm"] = _ts_node_parse_state_wasm = createExportWrapper("ts_node_parse_state_wasm", 1);
|
|
1945
|
-
Module["_ts_node_next_parse_state_wasm"] = _ts_node_next_parse_state_wasm = createExportWrapper("ts_node_next_parse_state_wasm", 1);
|
|
1946
1900
|
Module["_memcpy"] = _memcpy = createExportWrapper("memcpy", 3);
|
|
1947
1901
|
Module["_memmove"] = _memmove = createExportWrapper("memmove", 3);
|
|
1948
1902
|
Module["_memset"] = _memset = createExportWrapper("memset", 3);
|
|
@@ -2010,8 +1964,6 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2010
1964
|
/** @export */
|
|
2011
1965
|
invoke_iiii,
|
|
2012
1966
|
/** @export */
|
|
2013
|
-
invoke_iiiii,
|
|
2014
|
-
/** @export */
|
|
2015
1967
|
invoke_ji,
|
|
2016
1968
|
/** @export */
|
|
2017
1969
|
invoke_vi,
|
|
@@ -2084,17 +2036,6 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2084
2036
|
}
|
|
2085
2037
|
}
|
|
2086
2038
|
__name(invoke_iiii, "invoke_iiii");
|
|
2087
|
-
function invoke_iiiii(index, a1, a2, a3, a4) {
|
|
2088
|
-
var sp = stackSave();
|
|
2089
|
-
try {
|
|
2090
|
-
return getWasmTableEntry(index)(a1, a2, a3, a4);
|
|
2091
|
-
} catch (e) {
|
|
2092
|
-
stackRestore(sp);
|
|
2093
|
-
if (e !== e + 0) throw e;
|
|
2094
|
-
_setThrew(1, 0);
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
__name(invoke_iiiii, "invoke_iiiii");
|
|
2098
2039
|
function invoke_iii(index, a1, a2) {
|
|
2099
2040
|
var sp = stackSave();
|
|
2100
2041
|
try {
|
|
@@ -2135,7 +2076,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2135
2076
|
}
|
|
2136
2077
|
__name(callMain, "callMain");
|
|
2137
2078
|
function stackCheckInit() {
|
|
2138
|
-
_emscripten_stack_set_limits(
|
|
2079
|
+
_emscripten_stack_set_limits(81968, 16432);
|
|
2139
2080
|
writeStackCookie();
|
|
2140
2081
|
}
|
|
2141
2082
|
__name(stackCheckInit, "stackCheckInit");
|
|
@@ -2231,10 +2172,8 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2231
2172
|
// src/index.ts
|
|
2232
2173
|
var index_exports = {};
|
|
2233
2174
|
__export(index_exports, {
|
|
2234
|
-
Edit: () => Edit,
|
|
2235
2175
|
LANGUAGE_VERSION: () => LANGUAGE_VERSION,
|
|
2236
2176
|
Language: () => Language,
|
|
2237
|
-
LookaheadIterator: () => LookaheadIterator,
|
|
2238
2177
|
MIN_COMPATIBLE_VERSION: () => MIN_COMPATIBLE_VERSION,
|
|
2239
2178
|
Node: () => Node,
|
|
2240
2179
|
Parser: () => Parser,
|
|
@@ -2243,111 +2182,9 @@ __export(index_exports, {
|
|
|
2243
2182
|
});
|
|
2244
2183
|
module.exports = __toCommonJS(index_exports);
|
|
2245
2184
|
|
|
2246
|
-
// src/edit.ts
|
|
2247
|
-
var Edit = class {
|
|
2248
|
-
static {
|
|
2249
|
-
__name(this, "Edit");
|
|
2250
|
-
}
|
|
2251
|
-
/** The start position of the change. */
|
|
2252
|
-
startPosition;
|
|
2253
|
-
/** The end position of the change before the edit. */
|
|
2254
|
-
oldEndPosition;
|
|
2255
|
-
/** The end position of the change after the edit. */
|
|
2256
|
-
newEndPosition;
|
|
2257
|
-
/** The start index of the change. */
|
|
2258
|
-
startIndex;
|
|
2259
|
-
/** The end index of the change before the edit. */
|
|
2260
|
-
oldEndIndex;
|
|
2261
|
-
/** The end index of the change after the edit. */
|
|
2262
|
-
newEndIndex;
|
|
2263
|
-
constructor({
|
|
2264
|
-
startIndex,
|
|
2265
|
-
oldEndIndex,
|
|
2266
|
-
newEndIndex,
|
|
2267
|
-
startPosition,
|
|
2268
|
-
oldEndPosition,
|
|
2269
|
-
newEndPosition
|
|
2270
|
-
}) {
|
|
2271
|
-
this.startIndex = startIndex >>> 0;
|
|
2272
|
-
this.oldEndIndex = oldEndIndex >>> 0;
|
|
2273
|
-
this.newEndIndex = newEndIndex >>> 0;
|
|
2274
|
-
this.startPosition = startPosition;
|
|
2275
|
-
this.oldEndPosition = oldEndPosition;
|
|
2276
|
-
this.newEndPosition = newEndPosition;
|
|
2277
|
-
}
|
|
2278
|
-
/**
|
|
2279
|
-
* Edit a point and index to keep it in-sync with source code that has been edited.
|
|
2280
|
-
*
|
|
2281
|
-
* This function updates a single point's byte offset and row/column position
|
|
2282
|
-
* based on an edit operation. This is useful for editing points without
|
|
2283
|
-
* requiring a tree or node instance.
|
|
2284
|
-
*/
|
|
2285
|
-
editPoint(point, index) {
|
|
2286
|
-
let newIndex = index;
|
|
2287
|
-
const newPoint = { ...point };
|
|
2288
|
-
if (index >= this.oldEndIndex) {
|
|
2289
|
-
newIndex = this.newEndIndex + (index - this.oldEndIndex);
|
|
2290
|
-
const originalRow = point.row;
|
|
2291
|
-
newPoint.row = this.newEndPosition.row + (point.row - this.oldEndPosition.row);
|
|
2292
|
-
newPoint.column = originalRow === this.oldEndPosition.row ? this.newEndPosition.column + (point.column - this.oldEndPosition.column) : point.column;
|
|
2293
|
-
} else if (index > this.startIndex) {
|
|
2294
|
-
newIndex = this.newEndIndex;
|
|
2295
|
-
newPoint.row = this.newEndPosition.row;
|
|
2296
|
-
newPoint.column = this.newEndPosition.column;
|
|
2297
|
-
}
|
|
2298
|
-
return { point: newPoint, index: newIndex };
|
|
2299
|
-
}
|
|
2300
|
-
/**
|
|
2301
|
-
* Edit a range to keep it in-sync with source code that has been edited.
|
|
2302
|
-
*
|
|
2303
|
-
* This function updates a range's start and end positions based on an edit
|
|
2304
|
-
* operation. This is useful for editing ranges without requiring a tree
|
|
2305
|
-
* or node instance.
|
|
2306
|
-
*/
|
|
2307
|
-
editRange(range) {
|
|
2308
|
-
const newRange = {
|
|
2309
|
-
startIndex: range.startIndex,
|
|
2310
|
-
startPosition: { ...range.startPosition },
|
|
2311
|
-
endIndex: range.endIndex,
|
|
2312
|
-
endPosition: { ...range.endPosition }
|
|
2313
|
-
};
|
|
2314
|
-
if (range.endIndex >= this.oldEndIndex) {
|
|
2315
|
-
if (range.endIndex !== Number.MAX_SAFE_INTEGER) {
|
|
2316
|
-
newRange.endIndex = this.newEndIndex + (range.endIndex - this.oldEndIndex);
|
|
2317
|
-
newRange.endPosition = {
|
|
2318
|
-
row: this.newEndPosition.row + (range.endPosition.row - this.oldEndPosition.row),
|
|
2319
|
-
column: range.endPosition.row === this.oldEndPosition.row ? this.newEndPosition.column + (range.endPosition.column - this.oldEndPosition.column) : range.endPosition.column
|
|
2320
|
-
};
|
|
2321
|
-
if (newRange.endIndex < this.newEndIndex) {
|
|
2322
|
-
newRange.endIndex = Number.MAX_SAFE_INTEGER;
|
|
2323
|
-
newRange.endPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
} else if (range.endIndex > this.startIndex) {
|
|
2327
|
-
newRange.endIndex = this.startIndex;
|
|
2328
|
-
newRange.endPosition = { ...this.startPosition };
|
|
2329
|
-
}
|
|
2330
|
-
if (range.startIndex >= this.oldEndIndex) {
|
|
2331
|
-
newRange.startIndex = this.newEndIndex + (range.startIndex - this.oldEndIndex);
|
|
2332
|
-
newRange.startPosition = {
|
|
2333
|
-
row: this.newEndPosition.row + (range.startPosition.row - this.oldEndPosition.row),
|
|
2334
|
-
column: range.startPosition.row === this.oldEndPosition.row ? this.newEndPosition.column + (range.startPosition.column - this.oldEndPosition.column) : range.startPosition.column
|
|
2335
|
-
};
|
|
2336
|
-
if (newRange.startIndex < this.newEndIndex) {
|
|
2337
|
-
newRange.startIndex = Number.MAX_SAFE_INTEGER;
|
|
2338
|
-
newRange.startPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };
|
|
2339
|
-
}
|
|
2340
|
-
} else if (range.startIndex > this.startIndex) {
|
|
2341
|
-
newRange.startIndex = this.startIndex;
|
|
2342
|
-
newRange.startPosition = { ...this.startPosition };
|
|
2343
|
-
}
|
|
2344
|
-
return newRange;
|
|
2345
|
-
}
|
|
2346
|
-
};
|
|
2347
|
-
|
|
2348
2185
|
// src/constants.ts
|
|
2349
2186
|
var SIZE_OF_INT = 4;
|
|
2350
|
-
var SIZE_OF_NODE =
|
|
2187
|
+
var SIZE_OF_NODE = 9 * SIZE_OF_INT;
|
|
2351
2188
|
var SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
2352
2189
|
var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
2353
2190
|
var ZERO_POINT = { row: 0, column: 0 };
|
|
@@ -2377,100 +2214,8 @@ function newFinalizer(handler) {
|
|
|
2377
2214
|
}
|
|
2378
2215
|
__name(newFinalizer, "newFinalizer");
|
|
2379
2216
|
|
|
2380
|
-
// src/lookahead_iterator.ts
|
|
2381
|
-
var finalizer = newFinalizer((address) => {
|
|
2382
|
-
C._ts_lookahead_iterator_delete(address);
|
|
2383
|
-
});
|
|
2384
|
-
var LookaheadIterator = class {
|
|
2385
|
-
static {
|
|
2386
|
-
__name(this, "LookaheadIterator");
|
|
2387
|
-
}
|
|
2388
|
-
/** @internal */
|
|
2389
|
-
[0] = 0;
|
|
2390
|
-
// Internal handle for Wasm
|
|
2391
|
-
/** @internal */
|
|
2392
|
-
language;
|
|
2393
|
-
/** @internal */
|
|
2394
|
-
positioned = false;
|
|
2395
|
-
/** @internal */
|
|
2396
|
-
constructor(internal, address, language) {
|
|
2397
|
-
assertInternal(internal);
|
|
2398
|
-
this[0] = address;
|
|
2399
|
-
this.language = language;
|
|
2400
|
-
finalizer?.register(this, address, this);
|
|
2401
|
-
}
|
|
2402
|
-
/**
|
|
2403
|
-
* Get the current symbol of the lookahead iterator.
|
|
2404
|
-
*
|
|
2405
|
-
* Returns `null` if the iterator is not positioned on a symbol:
|
|
2406
|
-
*
|
|
2407
|
-
* - Before the first iteration step
|
|
2408
|
-
* - After the iterator is exhausted
|
|
2409
|
-
* - After a {@link reset} or {@link resetState} call
|
|
2410
|
-
*/
|
|
2411
|
-
get currentTypeId() {
|
|
2412
|
-
return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
|
|
2413
|
-
}
|
|
2414
|
-
/**
|
|
2415
|
-
* Get the current symbol name of the lookahead iterator.
|
|
2416
|
-
*
|
|
2417
|
-
* Returns `null` if the iterator is not positioned on a symbol.
|
|
2418
|
-
*/
|
|
2419
|
-
get currentType() {
|
|
2420
|
-
const id = this.currentTypeId;
|
|
2421
|
-
if (id === null) return null;
|
|
2422
|
-
return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
|
|
2423
|
-
}
|
|
2424
|
-
/** Delete the lookahead iterator, freeing its resources. */
|
|
2425
|
-
delete() {
|
|
2426
|
-
finalizer?.unregister(this);
|
|
2427
|
-
C._ts_lookahead_iterator_delete(this[0]);
|
|
2428
|
-
this[0] = 0;
|
|
2429
|
-
}
|
|
2430
|
-
/**
|
|
2431
|
-
* Reset the lookahead iterator.
|
|
2432
|
-
*
|
|
2433
|
-
* This returns `true` if the language was set successfully and `false`
|
|
2434
|
-
* otherwise.
|
|
2435
|
-
*/
|
|
2436
|
-
reset(language, stateId) {
|
|
2437
|
-
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
2438
|
-
this.language = language;
|
|
2439
|
-
this.positioned = false;
|
|
2440
|
-
return true;
|
|
2441
|
-
}
|
|
2442
|
-
return false;
|
|
2443
|
-
}
|
|
2444
|
-
/**
|
|
2445
|
-
* Reset the lookahead iterator to another state.
|
|
2446
|
-
*
|
|
2447
|
-
* This returns `true` if the iterator was reset to the given state and
|
|
2448
|
-
* `false` otherwise.
|
|
2449
|
-
*/
|
|
2450
|
-
resetState(stateId) {
|
|
2451
|
-
if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
|
|
2452
|
-
this.positioned = false;
|
|
2453
|
-
return true;
|
|
2454
|
-
}
|
|
2455
|
-
/**
|
|
2456
|
-
* Returns an iterator that iterates over the symbols of the lookahead iterator.
|
|
2457
|
-
*
|
|
2458
|
-
* The iterator will yield the current symbol name as a string for each step
|
|
2459
|
-
* until there are no more symbols to iterate over.
|
|
2460
|
-
*/
|
|
2461
|
-
[Symbol.iterator]() {
|
|
2462
|
-
return {
|
|
2463
|
-
next: /* @__PURE__ */ __name(() => {
|
|
2464
|
-
this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
|
|
2465
|
-
const value = this.currentType;
|
|
2466
|
-
return value === null ? { done: true, value: "" } : { done: false, value };
|
|
2467
|
-
}, "next")
|
|
2468
|
-
};
|
|
2469
|
-
}
|
|
2470
|
-
};
|
|
2471
|
-
|
|
2472
2217
|
// src/tree_cursor.ts
|
|
2473
|
-
var
|
|
2218
|
+
var finalizer = newFinalizer((address) => {
|
|
2474
2219
|
C._ts_tree_cursor_delete_wasm(address);
|
|
2475
2220
|
});
|
|
2476
2221
|
var TreeCursor = class _TreeCursor {
|
|
@@ -2483,8 +2228,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
2483
2228
|
/** @internal */
|
|
2484
2229
|
tree;
|
|
2485
2230
|
/** @internal */
|
|
2486
|
-
editVersion = -1;
|
|
2487
|
-
/** @internal */
|
|
2488
2231
|
_nodeTypeId = 0;
|
|
2489
2232
|
/** @internal */
|
|
2490
2233
|
_fieldId = 0;
|
|
@@ -2500,7 +2243,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2500
2243
|
this[0] = address;
|
|
2501
2244
|
this.tree = tree;
|
|
2502
2245
|
this.readNodeCache();
|
|
2503
|
-
|
|
2246
|
+
finalizer?.register(this, address, this);
|
|
2504
2247
|
}
|
|
2505
2248
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
2506
2249
|
copy() {
|
|
@@ -2509,7 +2252,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2509
2252
|
}
|
|
2510
2253
|
/** Delete the tree cursor, freeing its resources. */
|
|
2511
2254
|
delete() {
|
|
2512
|
-
|
|
2255
|
+
finalizer?.unregister(this);
|
|
2513
2256
|
C._ts_tree_cursor_delete_wasm(this[0]);
|
|
2514
2257
|
this[0] = 0;
|
|
2515
2258
|
}
|
|
@@ -2552,10 +2295,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
2552
2295
|
get nodeTypeId() {
|
|
2553
2296
|
return this._nodeTypeId;
|
|
2554
2297
|
}
|
|
2555
|
-
/** Get the state id of the cursor's current node. */
|
|
2556
|
-
get nodeStateId() {
|
|
2557
|
-
return C._ts_tree_cursor_current_node_state_id_wasm(this[0]);
|
|
2558
|
-
}
|
|
2559
2298
|
/** Get the id of the cursor's current node. */
|
|
2560
2299
|
get nodeId() {
|
|
2561
2300
|
return C._ts_tree_cursor_current_node_id_wasm(this[0]);
|
|
@@ -2580,7 +2319,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
2580
2319
|
}
|
|
2581
2320
|
/** Get the string content of the cursor's current node. */
|
|
2582
2321
|
get nodeText() {
|
|
2583
|
-
this.syncIndices();
|
|
2584
2322
|
const { textSource } = this.tree;
|
|
2585
2323
|
return typeof textSource === "string" ? textSource.slice(this._startIndex, this._endIndex) : getCallbackText(textSource, this._startIndex, this._endIndex, this.startPosition);
|
|
2586
2324
|
}
|
|
@@ -2596,12 +2334,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
2596
2334
|
}
|
|
2597
2335
|
/** Get the start index of the cursor's current node. */
|
|
2598
2336
|
get startIndex() {
|
|
2599
|
-
this.syncIndices();
|
|
2600
2337
|
return this._startIndex;
|
|
2601
2338
|
}
|
|
2602
2339
|
/** Get the end index of the cursor's current node. */
|
|
2603
2340
|
get endIndex() {
|
|
2604
|
-
this.syncIndices();
|
|
2605
2341
|
return this._endIndex;
|
|
2606
2342
|
}
|
|
2607
2343
|
/**
|
|
@@ -2747,15 +2483,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
2747
2483
|
this._startIndex = heap[base + 2];
|
|
2748
2484
|
this._endIndex = heap[base + 3];
|
|
2749
2485
|
this._flags = heap[base + 4];
|
|
2750
|
-
this.editVersion = this.tree.editVersion;
|
|
2751
|
-
}
|
|
2752
|
-
/** @internal */
|
|
2753
|
-
syncIndices() {
|
|
2754
|
-
if (this.editVersion !== this.tree.editVersion) {
|
|
2755
|
-
this._startIndex = C._ts_tree_cursor_start_index_wasm(this[0]) >>> 0;
|
|
2756
|
-
this._endIndex = C._ts_tree_cursor_end_index_wasm(this[0]) >>> 0;
|
|
2757
|
-
this.editVersion = this.tree.editVersion;
|
|
2758
|
-
}
|
|
2759
2486
|
}
|
|
2760
2487
|
};
|
|
2761
2488
|
|
|
@@ -2781,7 +2508,7 @@ function getCallbackText(textSource, startIndex, endIndex, startPosition) {
|
|
|
2781
2508
|
return result ?? "";
|
|
2782
2509
|
}
|
|
2783
2510
|
__name(getCallbackText, "getCallbackText");
|
|
2784
|
-
var
|
|
2511
|
+
var finalizer2 = newFinalizer((address) => {
|
|
2785
2512
|
C._ts_tree_delete(address);
|
|
2786
2513
|
});
|
|
2787
2514
|
var Tree2 = class _Tree {
|
|
@@ -2793,8 +2520,6 @@ var Tree2 = class _Tree {
|
|
|
2793
2520
|
// Internal handle for Wasm
|
|
2794
2521
|
/** @internal */
|
|
2795
2522
|
textSource;
|
|
2796
|
-
/** @internal */
|
|
2797
|
-
editVersion = 0;
|
|
2798
2523
|
/** The language that was used to parse the syntax tree. */
|
|
2799
2524
|
language;
|
|
2800
2525
|
/** @internal */
|
|
@@ -2803,7 +2528,7 @@ var Tree2 = class _Tree {
|
|
|
2803
2528
|
this[0] = address;
|
|
2804
2529
|
this.language = language;
|
|
2805
2530
|
this.textSource = textSource;
|
|
2806
|
-
|
|
2531
|
+
finalizer2?.register(this, address, this);
|
|
2807
2532
|
}
|
|
2808
2533
|
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
2809
2534
|
copy() {
|
|
@@ -2812,7 +2537,7 @@ var Tree2 = class _Tree {
|
|
|
2812
2537
|
}
|
|
2813
2538
|
/** Delete the syntax tree, freeing its resources. */
|
|
2814
2539
|
delete() {
|
|
2815
|
-
|
|
2540
|
+
finalizer2?.unregister(this);
|
|
2816
2541
|
C._ts_tree_delete(this[0]);
|
|
2817
2542
|
this[0] = 0;
|
|
2818
2543
|
}
|
|
@@ -2832,42 +2557,12 @@ var Tree2 = class _Tree {
|
|
|
2832
2557
|
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
2833
2558
|
return unmarshalNode(this);
|
|
2834
2559
|
}
|
|
2835
|
-
/**
|
|
2836
|
-
* Edit the syntax tree to keep it in sync with source code that has been
|
|
2837
|
-
* edited.
|
|
2838
|
-
*
|
|
2839
|
-
* You must describe the edit both in terms of byte offsets and in terms of
|
|
2840
|
-
* row/column coordinates.
|
|
2841
|
-
*/
|
|
2842
|
-
edit(edit) {
|
|
2843
|
-
marshalEdit(edit);
|
|
2844
|
-
C._ts_tree_edit_wasm(this[0]);
|
|
2845
|
-
this.editVersion++;
|
|
2846
|
-
}
|
|
2847
2560
|
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
2848
2561
|
walk() {
|
|
2849
2562
|
C._ts_tree_root_node_wasm(this[0]);
|
|
2850
2563
|
const address = C._ts_tree_cursor_new_wasm(this[0]);
|
|
2851
2564
|
return new TreeCursor(INTERNAL, this, address);
|
|
2852
2565
|
}
|
|
2853
|
-
/**
|
|
2854
|
-
* Compare this old edited syntax tree to a new syntax tree representing
|
|
2855
|
-
* the same document, returning a sequence of ranges whose syntactic
|
|
2856
|
-
* structure has changed.
|
|
2857
|
-
*
|
|
2858
|
-
* For this to work correctly, this syntax tree must have been edited such
|
|
2859
|
-
* that its ranges match up to the new tree. Generally, you'll want to
|
|
2860
|
-
* call this method right after calling one of the [`Parser::parse`]
|
|
2861
|
-
* functions. Call it on the old tree that was passed to parse, and
|
|
2862
|
-
* pass the new tree that was returned from `parse`.
|
|
2863
|
-
*/
|
|
2864
|
-
getChangedRanges(other) {
|
|
2865
|
-
if (!(other instanceof _Tree)) {
|
|
2866
|
-
throw new TypeError("Argument must be a Tree");
|
|
2867
|
-
}
|
|
2868
|
-
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
2869
|
-
return unmarshalRanges();
|
|
2870
|
-
}
|
|
2871
2566
|
/** Get the included ranges that were used to parse the syntax tree. */
|
|
2872
2567
|
getIncludedRanges() {
|
|
2873
2568
|
C._ts_tree_included_ranges_wasm(this[0]);
|
|
@@ -2876,6 +2571,7 @@ var Tree2 = class _Tree {
|
|
|
2876
2571
|
};
|
|
2877
2572
|
|
|
2878
2573
|
// src/node.ts
|
|
2574
|
+
var singleTypeSymbolsCache = /* @__PURE__ */ new WeakMap();
|
|
2879
2575
|
var Node = class {
|
|
2880
2576
|
static {
|
|
2881
2577
|
__name(this, "Node");
|
|
@@ -2885,6 +2581,14 @@ var Node = class {
|
|
|
2885
2581
|
[0] = 0;
|
|
2886
2582
|
// Internal handle for Wasm
|
|
2887
2583
|
/** @internal */
|
|
2584
|
+
_endIndex;
|
|
2585
|
+
/** @internal */
|
|
2586
|
+
_endRow;
|
|
2587
|
+
/** @internal */
|
|
2588
|
+
_endColumn;
|
|
2589
|
+
/** @internal */
|
|
2590
|
+
_flags;
|
|
2591
|
+
/** @internal */
|
|
2888
2592
|
_children;
|
|
2889
2593
|
/** @internal */
|
|
2890
2594
|
_namedChildren;
|
|
@@ -2894,7 +2598,11 @@ var Node = class {
|
|
|
2894
2598
|
tree,
|
|
2895
2599
|
startIndex,
|
|
2896
2600
|
startPosition,
|
|
2897
|
-
other
|
|
2601
|
+
other,
|
|
2602
|
+
endIndex,
|
|
2603
|
+
endRow,
|
|
2604
|
+
endColumn,
|
|
2605
|
+
flags: flags2
|
|
2898
2606
|
}) {
|
|
2899
2607
|
assertInternal(internal);
|
|
2900
2608
|
this[0] = other;
|
|
@@ -2902,18 +2610,15 @@ var Node = class {
|
|
|
2902
2610
|
this.tree = tree;
|
|
2903
2611
|
this.startIndex = startIndex;
|
|
2904
2612
|
this.startPosition = startPosition;
|
|
2613
|
+
this._endIndex = endIndex;
|
|
2614
|
+
this._endRow = endRow;
|
|
2615
|
+
this._endColumn = endColumn;
|
|
2616
|
+
this._flags = flags2;
|
|
2905
2617
|
}
|
|
2906
2618
|
/**
|
|
2907
2619
|
* The numeric id for this node that is unique.
|
|
2908
2620
|
*
|
|
2909
|
-
* Within a given syntax tree, no two nodes have the same id.
|
|
2910
|
-
*
|
|
2911
|
-
* * If a new tree is created based on an older tree, and a node from the old tree is reused in
|
|
2912
|
-
* the process, then that node will have the same id in both trees.
|
|
2913
|
-
*
|
|
2914
|
-
* * A node not marked as having changes does not guarantee it was reused.
|
|
2915
|
-
*
|
|
2916
|
-
* * If a node is marked as having changed in the old tree, it will not be reused.
|
|
2621
|
+
* Within a given syntax tree, no two nodes have the same id.
|
|
2917
2622
|
*/
|
|
2918
2623
|
id;
|
|
2919
2624
|
/** The byte index where this node starts. */
|
|
@@ -2924,8 +2629,7 @@ var Node = class {
|
|
|
2924
2629
|
tree;
|
|
2925
2630
|
/** Get this node's type as a numerical id. */
|
|
2926
2631
|
get typeId() {
|
|
2927
|
-
|
|
2928
|
-
return C._ts_node_symbol_wasm(this.tree[0]);
|
|
2632
|
+
return this._flags & 65535;
|
|
2929
2633
|
}
|
|
2930
2634
|
/**
|
|
2931
2635
|
* Get the node's type as a numerical id as it appears in the grammar,
|
|
@@ -2937,7 +2641,7 @@ var Node = class {
|
|
|
2937
2641
|
}
|
|
2938
2642
|
/** Get this node's type as a string. */
|
|
2939
2643
|
get type() {
|
|
2940
|
-
return this.tree.language.types[this.
|
|
2644
|
+
return this.tree.language.types[this._flags & 65535] || "ERROR";
|
|
2941
2645
|
}
|
|
2942
2646
|
/**
|
|
2943
2647
|
* Get this node's symbol name as it appears in the grammar, ignoring
|
|
@@ -2953,8 +2657,7 @@ var Node = class {
|
|
|
2953
2657
|
* *anonymous* nodes correspond to string literals in the grammar.
|
|
2954
2658
|
*/
|
|
2955
2659
|
get isNamed() {
|
|
2956
|
-
|
|
2957
|
-
return C._ts_node_is_named_wasm(this.tree[0]) === 1;
|
|
2660
|
+
return (this._flags & 65536) !== 0;
|
|
2958
2661
|
}
|
|
2959
2662
|
/**
|
|
2960
2663
|
* Check if this node is *extra*.
|
|
@@ -2963,8 +2666,7 @@ var Node = class {
|
|
|
2963
2666
|
* by the grammar, but can appear anywhere.
|
|
2964
2667
|
*/
|
|
2965
2668
|
get isExtra() {
|
|
2966
|
-
|
|
2967
|
-
return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
|
|
2669
|
+
return (this._flags & 131072) !== 0;
|
|
2968
2670
|
}
|
|
2969
2671
|
/**
|
|
2970
2672
|
* Check if this node represents a syntax error.
|
|
@@ -2973,8 +2675,7 @@ var Node = class {
|
|
|
2973
2675
|
* into a valid syntax tree.
|
|
2974
2676
|
*/
|
|
2975
2677
|
get isError() {
|
|
2976
|
-
|
|
2977
|
-
return C._ts_node_is_error_wasm(this.tree[0]) === 1;
|
|
2678
|
+
return (this._flags & 1048576) !== 0;
|
|
2978
2679
|
}
|
|
2979
2680
|
/**
|
|
2980
2681
|
* Check if this node is *missing*.
|
|
@@ -2983,47 +2684,27 @@ var Node = class {
|
|
|
2983
2684
|
* certain kinds of syntax errors.
|
|
2984
2685
|
*/
|
|
2985
2686
|
get isMissing() {
|
|
2986
|
-
|
|
2987
|
-
return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
|
|
2988
|
-
}
|
|
2989
|
-
/** Check if this node has been edited. */
|
|
2990
|
-
get hasChanges() {
|
|
2991
|
-
marshalNode(this);
|
|
2992
|
-
return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
|
|
2687
|
+
return (this._flags & 262144) !== 0;
|
|
2993
2688
|
}
|
|
2994
2689
|
/**
|
|
2995
2690
|
* Check if this node represents a syntax error or contains any syntax
|
|
2996
2691
|
* errors anywhere within it.
|
|
2997
2692
|
*/
|
|
2998
2693
|
get hasError() {
|
|
2999
|
-
|
|
3000
|
-
return C._ts_node_has_error_wasm(this.tree[0]) === 1;
|
|
2694
|
+
return (this._flags & 524288) !== 0;
|
|
3001
2695
|
}
|
|
3002
2696
|
/** Get the byte index where this node ends. */
|
|
3003
2697
|
get endIndex() {
|
|
3004
|
-
|
|
3005
|
-
return C._ts_node_end_index_wasm(this.tree[0]);
|
|
2698
|
+
return this._endIndex;
|
|
3006
2699
|
}
|
|
3007
2700
|
/** Get the position where this node ends. */
|
|
3008
2701
|
get endPosition() {
|
|
3009
|
-
|
|
3010
|
-
C._ts_node_end_point_wasm(this.tree[0]);
|
|
3011
|
-
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2702
|
+
return { row: this._endRow, column: this._endColumn };
|
|
3012
2703
|
}
|
|
3013
2704
|
/** Get the string content of this node. */
|
|
3014
2705
|
get text() {
|
|
3015
2706
|
const { textSource } = this.tree;
|
|
3016
|
-
return typeof textSource === "string" ? textSource.slice(this.startIndex, this.
|
|
3017
|
-
}
|
|
3018
|
-
/** Get this node's parse state. */
|
|
3019
|
-
get parseState() {
|
|
3020
|
-
marshalNode(this);
|
|
3021
|
-
return C._ts_node_parse_state_wasm(this.tree[0]);
|
|
3022
|
-
}
|
|
3023
|
-
/** Get the parse state after this node. */
|
|
3024
|
-
get nextParseState() {
|
|
3025
|
-
marshalNode(this);
|
|
3026
|
-
return C._ts_node_next_parse_state_wasm(this.tree[0]);
|
|
2707
|
+
return typeof textSource === "string" ? textSource.slice(this.startIndex, this._endIndex) : getCallbackText(textSource, this.startIndex, this._endIndex, this.startPosition);
|
|
3027
2708
|
}
|
|
3028
2709
|
/** Check if this node is equal to another node. */
|
|
3029
2710
|
equals(other) {
|
|
@@ -3199,23 +2880,10 @@ var Node = class {
|
|
|
3199
2880
|
* Additionally, a `startPosition` and `endPosition` can be passed in to restrict the search to a byte range.
|
|
3200
2881
|
*/
|
|
3201
2882
|
descendantsOfType(types, startPosition = ZERO_POINT, endPosition = ZERO_POINT) {
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
const typesBySymbol = this.tree.language.types;
|
|
3205
|
-
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
3206
|
-
if (types.includes(typesBySymbol[i2])) {
|
|
3207
|
-
symbols.push(i2);
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
if (types.includes("ERROR")) {
|
|
3211
|
-
symbols.push(65535);
|
|
3212
|
-
}
|
|
2883
|
+
const symbols = symbolsForTypes(this.tree.language, types);
|
|
2884
|
+
if (symbols.length === 0) return [];
|
|
3213
2885
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
3214
|
-
|
|
3215
|
-
const symbolsBase = symbolsAddress >>> 2;
|
|
3216
|
-
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
3217
|
-
symbolsHeap[symbolsBase + i2] = symbols[i2];
|
|
3218
|
-
}
|
|
2886
|
+
C.HEAPU32.set(symbols, symbolsAddress >>> 2);
|
|
3219
2887
|
marshalNode(this);
|
|
3220
2888
|
const pointAddress = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3221
2889
|
marshalPoint(pointAddress, startPosition);
|
|
@@ -3348,20 +3016,6 @@ var Node = class {
|
|
|
3348
3016
|
const address = C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
3349
3017
|
return new TreeCursor(INTERNAL, this.tree, address);
|
|
3350
3018
|
}
|
|
3351
|
-
/**
|
|
3352
|
-
* Edit this node to keep it in-sync with source code that has been edited.
|
|
3353
|
-
*
|
|
3354
|
-
* This function is only rarely needed. When you edit a syntax tree with
|
|
3355
|
-
* the {@link Tree#edit} method, all of the nodes that you retrieve from
|
|
3356
|
-
* the tree afterward will already reflect the edit. You only need to
|
|
3357
|
-
* use {@link Node#edit} when you have a specific {@link Node} instance that
|
|
3358
|
-
* you want to keep and continue to use after an edit.
|
|
3359
|
-
*/
|
|
3360
|
-
edit(edit) {
|
|
3361
|
-
const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
|
|
3362
|
-
this.startPosition = point;
|
|
3363
|
-
this.startIndex = index;
|
|
3364
|
-
}
|
|
3365
3019
|
/** Get the S-expression representation of this node. */
|
|
3366
3020
|
toString() {
|
|
3367
3021
|
marshalNode(this);
|
|
@@ -3371,6 +3025,44 @@ var Node = class {
|
|
|
3371
3025
|
return result;
|
|
3372
3026
|
}
|
|
3373
3027
|
};
|
|
3028
|
+
function symbolsForTypes(language, types) {
|
|
3029
|
+
if (typeof types === "string") {
|
|
3030
|
+
return symbolsForSingleType(language, types);
|
|
3031
|
+
}
|
|
3032
|
+
if (types.length === 1) {
|
|
3033
|
+
return symbolsForSingleType(language, types[0]);
|
|
3034
|
+
}
|
|
3035
|
+
return collectSymbolsForTypes(language, types);
|
|
3036
|
+
}
|
|
3037
|
+
__name(symbolsForTypes, "symbolsForTypes");
|
|
3038
|
+
function symbolsForSingleType(language, type) {
|
|
3039
|
+
let byType = singleTypeSymbolsCache.get(language);
|
|
3040
|
+
if (!byType) {
|
|
3041
|
+
byType = /* @__PURE__ */ new Map();
|
|
3042
|
+
singleTypeSymbolsCache.set(language, byType);
|
|
3043
|
+
}
|
|
3044
|
+
let cached = byType.get(type);
|
|
3045
|
+
if (!cached) {
|
|
3046
|
+
cached = collectSymbolsForTypes(language, [type]);
|
|
3047
|
+
byType.set(type, cached);
|
|
3048
|
+
}
|
|
3049
|
+
return cached;
|
|
3050
|
+
}
|
|
3051
|
+
__name(symbolsForSingleType, "symbolsForSingleType");
|
|
3052
|
+
function collectSymbolsForTypes(language, types) {
|
|
3053
|
+
const symbols = [];
|
|
3054
|
+
const typesBySymbol = language.types;
|
|
3055
|
+
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
3056
|
+
if (types.includes(typesBySymbol[i2])) {
|
|
3057
|
+
symbols.push(i2);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
if (types.includes("ERROR")) {
|
|
3061
|
+
symbols.push(65535);
|
|
3062
|
+
}
|
|
3063
|
+
return Uint32Array.from(symbols);
|
|
3064
|
+
}
|
|
3065
|
+
__name(collectSymbolsForTypes, "collectSymbolsForTypes");
|
|
3374
3066
|
|
|
3375
3067
|
// src/marshal.ts
|
|
3376
3068
|
function marshalNode(node, index = 0) {
|
|
@@ -3394,7 +3086,11 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
|
3394
3086
|
tree,
|
|
3395
3087
|
startIndex: heapU32[base + 1],
|
|
3396
3088
|
startPosition: { row: heapU32[base + 2], column: heapU32[base + 3] },
|
|
3397
|
-
other: heap[base + 4]
|
|
3089
|
+
other: heap[base + 4],
|
|
3090
|
+
endIndex: heapU32[base + 5],
|
|
3091
|
+
endRow: heapU32[base + 6],
|
|
3092
|
+
endColumn: heapU32[base + 7],
|
|
3093
|
+
flags: heapU32[base + 8]
|
|
3398
3094
|
});
|
|
3399
3095
|
}
|
|
3400
3096
|
__name(unmarshalNode, "unmarshalNode");
|
|
@@ -3436,20 +3132,6 @@ function unmarshalRange(address) {
|
|
|
3436
3132
|
};
|
|
3437
3133
|
}
|
|
3438
3134
|
__name(unmarshalRange, "unmarshalRange");
|
|
3439
|
-
function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
3440
|
-
const base = address >>> 2;
|
|
3441
|
-
const heap = C.HEAP32;
|
|
3442
|
-
heap[base] = edit.startPosition.row;
|
|
3443
|
-
heap[base + 1] = edit.startPosition.column;
|
|
3444
|
-
heap[base + 2] = edit.oldEndPosition.row;
|
|
3445
|
-
heap[base + 3] = edit.oldEndPosition.column;
|
|
3446
|
-
heap[base + 4] = edit.newEndPosition.row;
|
|
3447
|
-
heap[base + 5] = edit.newEndPosition.column;
|
|
3448
|
-
heap[base + 6] = edit.startIndex;
|
|
3449
|
-
heap[base + 7] = edit.oldEndIndex;
|
|
3450
|
-
heap[base + 8] = edit.newEndIndex;
|
|
3451
|
-
}
|
|
3452
|
-
__name(marshalEdit, "marshalEdit");
|
|
3453
3135
|
function unmarshalLanguageMetadata(address) {
|
|
3454
3136
|
const base = address >>> 2;
|
|
3455
3137
|
const heap = C.HEAP32;
|
|
@@ -3642,33 +3324,6 @@ var Language = class {
|
|
|
3642
3324
|
C._ts_language_subtypes_wasm(this[0], supertype);
|
|
3643
3325
|
return unmarshalSymbols();
|
|
3644
3326
|
}
|
|
3645
|
-
/**
|
|
3646
|
-
* Get the next state id for a given state id and node type id.
|
|
3647
|
-
*/
|
|
3648
|
-
nextState(stateId, typeId) {
|
|
3649
|
-
return C._ts_language_next_state(this[0], stateId, typeId);
|
|
3650
|
-
}
|
|
3651
|
-
/**
|
|
3652
|
-
* Create a new lookahead iterator for this language and parse state.
|
|
3653
|
-
*
|
|
3654
|
-
* This returns `null` if state is invalid for this language.
|
|
3655
|
-
*
|
|
3656
|
-
* Iterating {@link LookaheadIterator} will yield valid symbols in the given
|
|
3657
|
-
* parse state. A newly created iterator is not positioned on a symbol, so
|
|
3658
|
-
* {@link LookaheadIterator#currentType} returns `null` until the first
|
|
3659
|
-
* iteration step.
|
|
3660
|
-
*
|
|
3661
|
-
* Lookahead iterators can be useful for generating suggestions and improving
|
|
3662
|
-
* syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
|
|
3663
|
-
* lookahead iterator on its first leaf node state. For `MISSING` nodes, a
|
|
3664
|
-
* lookahead iterator created on the previous non-extra leaf node may be
|
|
3665
|
-
* appropriate.
|
|
3666
|
-
*/
|
|
3667
|
-
lookaheadIterator(stateId) {
|
|
3668
|
-
const address = C._ts_lookahead_iterator_new(this[0], stateId);
|
|
3669
|
-
if (address) return new LookaheadIterator(INTERNAL, address, this);
|
|
3670
|
-
return null;
|
|
3671
|
-
}
|
|
3672
3327
|
/**
|
|
3673
3328
|
* Load a language from a WebAssembly module.
|
|
3674
3329
|
* The module can be provided as a path to a file, a `URL` to a file, a
|
|
@@ -3761,7 +3416,7 @@ function assertSupportedLanguage(language) {
|
|
|
3761
3416
|
}
|
|
3762
3417
|
}
|
|
3763
3418
|
__name(assertSupportedLanguage, "assertSupportedLanguage");
|
|
3764
|
-
var
|
|
3419
|
+
var finalizer3 = newFinalizer((addresses) => {
|
|
3765
3420
|
C._ts_parser_delete(addresses[0]);
|
|
3766
3421
|
C._free(addresses[1]);
|
|
3767
3422
|
});
|
|
@@ -3802,7 +3457,7 @@ var Parser = class {
|
|
|
3802
3457
|
*/
|
|
3803
3458
|
constructor() {
|
|
3804
3459
|
this.initialize();
|
|
3805
|
-
|
|
3460
|
+
finalizer3?.register(this, [this[0], this[1]], this);
|
|
3806
3461
|
}
|
|
3807
3462
|
/** @internal */
|
|
3808
3463
|
initialize() {
|
|
@@ -3817,7 +3472,7 @@ var Parser = class {
|
|
|
3817
3472
|
}
|
|
3818
3473
|
/** Delete the parser, freeing its resources. */
|
|
3819
3474
|
delete() {
|
|
3820
|
-
|
|
3475
|
+
finalizer3?.unregister(this);
|
|
3821
3476
|
C._ts_parser_delete(this[0]);
|
|
3822
3477
|
C._free(this[1]);
|
|
3823
3478
|
this[0] = 0;
|
|
@@ -3852,10 +3507,6 @@ var Parser = class {
|
|
|
3852
3507
|
*
|
|
3853
3508
|
* @param {string | ParseCallback} callback - The UTF8-encoded text to parse or a callback function.
|
|
3854
3509
|
*
|
|
3855
|
-
* @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the
|
|
3856
|
-
* document has changed since `oldTree` was created, then you must edit `oldTree` to match
|
|
3857
|
-
* the new text using {@link Tree#edit}.
|
|
3858
|
-
*
|
|
3859
3510
|
* @param {ParseOptions} [options] - Options for parsing the text.
|
|
3860
3511
|
* This can be used to set the included ranges, or a progress callback.
|
|
3861
3512
|
*
|
|
@@ -3864,7 +3515,7 @@ var Parser = class {
|
|
|
3864
3515
|
* - The progress callback returned true.
|
|
3865
3516
|
* - The memory limit was reached or the operation limit was exceeded.
|
|
3866
3517
|
*/
|
|
3867
|
-
parse(callback,
|
|
3518
|
+
parse(callback, options) {
|
|
3868
3519
|
const maxMemoryBytes = validateMemoryLimit(options?.maxMemoryBytes);
|
|
3869
3520
|
const maxOperations = validateOperationLimit(options?.maxOperations);
|
|
3870
3521
|
if (typeof callback !== "string" && typeof callback !== "function") {
|
|
@@ -3876,7 +3527,7 @@ var Parser = class {
|
|
|
3876
3527
|
this.syncLogger();
|
|
3877
3528
|
this.lastParseOperations = 0;
|
|
3878
3529
|
try {
|
|
3879
|
-
const treeAddress = this.runParse(
|
|
3530
|
+
const treeAddress = this.runParse(options, maxMemoryBytes, maxOperations);
|
|
3880
3531
|
if (!treeAddress) return null;
|
|
3881
3532
|
if (!this.language) throw new Error("Parser must have a language to parse");
|
|
3882
3533
|
return new Tree2(INTERNAL, treeAddress, this.language, callback);
|
|
@@ -3901,7 +3552,7 @@ var Parser = class {
|
|
|
3901
3552
|
}
|
|
3902
3553
|
}
|
|
3903
3554
|
/** @internal */
|
|
3904
|
-
runParse(
|
|
3555
|
+
runParse(options, maxMemoryBytes, maxOperations) {
|
|
3905
3556
|
if (maxMemoryBytes !== void 0 && !C.treeSitterSetMemoryLimit(maxMemoryBytes)) {
|
|
3906
3557
|
return 0;
|
|
3907
3558
|
}
|
|
@@ -3910,7 +3561,7 @@ var Parser = class {
|
|
|
3910
3561
|
if (rangeCount && !rangeAddress) return 0;
|
|
3911
3562
|
marshalParseInputs(maxOperations, rangeAddress, rangeCount, options?.progressCallback ? 1 : 0);
|
|
3912
3563
|
try {
|
|
3913
|
-
return maxMemoryBytes === void 0 ? this.executeOrdinaryParse(
|
|
3564
|
+
return maxMemoryBytes === void 0 ? this.executeOrdinaryParse() : this.executeLimitedParse();
|
|
3914
3565
|
} finally {
|
|
3915
3566
|
this.lastParseOperations = unmarshalOperationCount();
|
|
3916
3567
|
}
|
|
@@ -3919,9 +3570,9 @@ var Parser = class {
|
|
|
3919
3570
|
}
|
|
3920
3571
|
}
|
|
3921
3572
|
/** @internal */
|
|
3922
|
-
executeOrdinaryParse(
|
|
3573
|
+
executeOrdinaryParse() {
|
|
3923
3574
|
try {
|
|
3924
|
-
return C._ts_parser_parse_wasm(this[0], this[1]
|
|
3575
|
+
return C._ts_parser_parse_wasm(this[0], this[1]);
|
|
3925
3576
|
} catch (error) {
|
|
3926
3577
|
C._ts_parser_last_parse_operations_wasm(this[0]);
|
|
3927
3578
|
throw error;
|
|
@@ -4024,10 +3675,8 @@ function clearCallbacks() {
|
|
|
4024
3675
|
__name(clearCallbacks, "clearCallbacks");
|
|
4025
3676
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4026
3677
|
0 && (module.exports = {
|
|
4027
|
-
Edit,
|
|
4028
3678
|
LANGUAGE_VERSION,
|
|
4029
3679
|
Language,
|
|
4030
|
-
LookaheadIterator,
|
|
4031
3680
|
MIN_COMPATIBLE_VERSION,
|
|
4032
3681
|
Node,
|
|
4033
3682
|
Parser,
|