@kerebron/tree-sitter 0.4.25 → 0.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/package.json +2 -1
  2. package/esm/deno-tree-sitter/main/extended/base_node.d.ts +0 -48
  3. package/esm/deno-tree-sitter/main/extended/base_node.d.ts.map +0 -1
  4. package/esm/deno-tree-sitter/main/extended/base_node.js +0 -154
  5. package/esm/deno-tree-sitter/main/extended/node_extended.d.ts +0 -237
  6. package/esm/deno-tree-sitter/main/extended/node_extended.d.ts.map +0 -1
  7. package/esm/deno-tree-sitter/main/extended/node_extended.js +0 -572
  8. package/esm/deno-tree-sitter/main/extended/parser.d.ts +0 -37
  9. package/esm/deno-tree-sitter/main/extended/parser.d.ts.map +0 -1
  10. package/esm/deno-tree-sitter/main/extended/parser.js +0 -86
  11. package/esm/deno-tree-sitter/main/extended/soft_node.d.ts +0 -15
  12. package/esm/deno-tree-sitter/main/extended/soft_node.d.ts.map +0 -1
  13. package/esm/deno-tree-sitter/main/extended/soft_node.js +0 -27
  14. package/esm/deno-tree-sitter/main/extended/soft_text_node.d.ts +0 -10
  15. package/esm/deno-tree-sitter/main/extended/soft_text_node.d.ts.map +0 -1
  16. package/esm/deno-tree-sitter/main/extended/soft_text_node.js +0 -10
  17. package/esm/deno-tree-sitter/main/extended/whitespace_node.d.ts +0 -10
  18. package/esm/deno-tree-sitter/main/extended/whitespace_node.d.ts.map +0 -1
  19. package/esm/deno-tree-sitter/main/extended/whitespace_node.js +0 -10
  20. package/esm/deno-tree-sitter/main/extras/misc.d.ts +0 -2
  21. package/esm/deno-tree-sitter/main/extras/misc.d.ts.map +0 -1
  22. package/esm/deno-tree-sitter/main/extras/misc.js +0 -13
  23. package/esm/deno-tree-sitter/main/tree_sitter/bindings.d.ts +0 -14
  24. package/esm/deno-tree-sitter/main/tree_sitter/bindings.d.ts.map +0 -1
  25. package/esm/deno-tree-sitter/main/tree_sitter/bindings.js +0 -21
  26. package/esm/deno-tree-sitter/main/tree_sitter/constants.d.ts +0 -60
  27. package/esm/deno-tree-sitter/main/tree_sitter/constants.d.ts.map +0 -1
  28. package/esm/deno-tree-sitter/main/tree_sitter/constants.js +0 -66
  29. package/esm/deno-tree-sitter/main/tree_sitter/language.d.ts +0 -137
  30. package/esm/deno-tree-sitter/main/tree_sitter/language.d.ts.map +0 -1
  31. package/esm/deno-tree-sitter/main/tree_sitter/language.js +0 -264
  32. package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.d.ts +0 -41
  33. package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.d.ts.map +0 -1
  34. package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.js +0 -65
  35. package/esm/deno-tree-sitter/main/tree_sitter/marshal.d.ts +0 -85
  36. package/esm/deno-tree-sitter/main/tree_sitter/marshal.d.ts.map +0 -1
  37. package/esm/deno-tree-sitter/main/tree_sitter/marshal.js +0 -173
  38. package/esm/deno-tree-sitter/main/tree_sitter/node.d.ts +0 -260
  39. package/esm/deno-tree-sitter/main/tree_sitter/node.d.ts.map +0 -1
  40. package/esm/deno-tree-sitter/main/tree_sitter/node.js +0 -557
  41. package/esm/deno-tree-sitter/main/tree_sitter/parser.d.ts +0 -124
  42. package/esm/deno-tree-sitter/main/tree_sitter/parser.d.ts.map +0 -1
  43. package/esm/deno-tree-sitter/main/tree_sitter/parser.js +0 -252
  44. package/esm/deno-tree-sitter/main/tree_sitter/query.d.ts +0 -134
  45. package/esm/deno-tree-sitter/main/tree_sitter/query.d.ts.map +0 -1
  46. package/esm/deno-tree-sitter/main/tree_sitter/query.js +0 -620
  47. package/esm/deno-tree-sitter/main/tree_sitter/tree.d.ts +0 -49
  48. package/esm/deno-tree-sitter/main/tree_sitter/tree.d.ts.map +0 -1
  49. package/esm/deno-tree-sitter/main/tree_sitter/tree.js +0 -130
  50. package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.d.ts +0 -165
  51. package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.d.ts.map +0 -1
  52. package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.js +0 -280
  53. package/esm/deno-tree-sitter/main/tree_sitter_wasm.d.ts +0 -3
  54. package/esm/deno-tree-sitter/main/tree_sitter_wasm.d.ts.map +0 -1
  55. package/esm/deno-tree-sitter/main/tree_sitter_wasm.js +0 -0
  56. package/esm/deno-tree-sitter/main/wasm_loader.d.ts +0 -29
  57. package/esm/deno-tree-sitter/main/wasm_loader.d.ts.map +0 -1
  58. package/esm/deno-tree-sitter/main/wasm_loader.js +0 -1702
  59. package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.d.ts +0 -3
  60. package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.d.ts.map +0 -1
  61. package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.js +0 -8
  62. package/esm/mod.d.ts +0 -7
  63. package/esm/mod.d.ts.map +0 -1
  64. package/esm/mod.js +0 -7
  65. package/esm/package.json +0 -3
@@ -1,130 +0,0 @@
1
- import { INTERNAL, assertInternal, SIZE_OF_NODE, SIZE_OF_INT, SIZE_OF_RANGE, C } from "./constants.js";
2
- import { Language } from "./language.js";
3
- import { Node } from "./node.js";
4
- import { TreeCursor } from "./tree_cursor.js";
5
- import { marshalEdit, marshalPoint, unmarshalNode, unmarshalRange } from "./marshal.js";
6
- import { TRANSFER_BUFFER } from "./parser.js";
7
- /** @internal */
8
- export function getText(tree, startIndex, endIndex, startPosition) {
9
- const length = endIndex - startIndex;
10
- let result = tree.textCallback(startIndex, startPosition);
11
- if (result) {
12
- startIndex += result.length;
13
- while (startIndex < endIndex) {
14
- const string = tree.textCallback(startIndex, startPosition);
15
- if (string && string.length > 0) {
16
- startIndex += string.length;
17
- result += string;
18
- }
19
- else {
20
- break;
21
- }
22
- }
23
- if (startIndex > endIndex) {
24
- result = result.slice(0, length);
25
- }
26
- }
27
- return result ?? "";
28
- }
29
- /** A tree that represents the syntactic structure of a source code file. */
30
- export class Tree {
31
- /** @internal */
32
- [0] = 0; // Internal handle for Wasm
33
- /** @internal */
34
- textCallback;
35
- /** The language that was used to parse the syntax tree. */
36
- language;
37
- /** @internal */
38
- constructor(internal, address, language, textCallback) {
39
- assertInternal(internal);
40
- this[0] = address;
41
- this.language = language;
42
- this.textCallback = textCallback;
43
- }
44
- /** Create a shallow copy of the syntax tree. This is very fast. */
45
- copy() {
46
- const address = C._ts_tree_copy(this[0]);
47
- return new Tree(INTERNAL, address, this.language, this.textCallback);
48
- }
49
- /** Delete the syntax tree, freeing its resources. */
50
- delete() {
51
- C._ts_tree_delete(this[0]);
52
- this[0] = 0;
53
- }
54
- /** Get the root node of the syntax tree. */
55
- get rootNode() {
56
- C._ts_tree_root_node_wasm(this[0]);
57
- return unmarshalNode(this);
58
- }
59
- /**
60
- * Get the root node of the syntax tree, but with its position shifted
61
- * forward by the given offset.
62
- */
63
- rootNodeWithOffset(offsetBytes, offsetExtent) {
64
- const address = TRANSFER_BUFFER + SIZE_OF_NODE;
65
- C.setValue(address, offsetBytes, "i32");
66
- marshalPoint(address + SIZE_OF_INT, offsetExtent);
67
- C._ts_tree_root_node_with_offset_wasm(this[0]);
68
- return unmarshalNode(this);
69
- }
70
- /**
71
- * Edit the syntax tree to keep it in sync with source code that has been
72
- * edited.
73
- *
74
- * You must describe the edit both in terms of byte offsets and in terms of
75
- * row/column coordinates.
76
- */
77
- edit(edit) {
78
- marshalEdit(edit);
79
- C._ts_tree_edit_wasm(this[0]);
80
- }
81
- /** Create a new {@link TreeCursor} starting from the root of the tree. */
82
- walk() {
83
- return this.rootNode.walk();
84
- }
85
- /**
86
- * Compare this old edited syntax tree to a new syntax tree representing
87
- * the same document, returning a sequence of ranges whose syntactic
88
- * structure has changed.
89
- *
90
- * For this to work correctly, this syntax tree must have been edited such
91
- * that its ranges match up to the new tree. Generally, you'll want to
92
- * call this method right after calling one of the [`Parser::parse`]
93
- * functions. Call it on the old tree that was passed to parse, and
94
- * pass the new tree that was returned from `parse`.
95
- */
96
- getChangedRanges(other) {
97
- if (!(other instanceof Tree)) {
98
- throw new TypeError("Argument must be a Tree");
99
- }
100
- C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
101
- const count = C.getValue(TRANSFER_BUFFER, "i32");
102
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
103
- const result = new Array(count);
104
- if (count > 0) {
105
- let address = buffer;
106
- for (let i = 0; i < count; i++) {
107
- result[i] = unmarshalRange(address);
108
- address += SIZE_OF_RANGE;
109
- }
110
- C._free(buffer);
111
- }
112
- return result;
113
- }
114
- /** Get the included ranges that were used to parse the syntax tree. */
115
- getIncludedRanges() {
116
- C._ts_tree_included_ranges_wasm(this[0]);
117
- const count = C.getValue(TRANSFER_BUFFER, "i32");
118
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
119
- const result = new Array(count);
120
- if (count > 0) {
121
- let address = buffer;
122
- for (let i = 0; i < count; i++) {
123
- result[i] = unmarshalRange(address);
124
- address += SIZE_OF_RANGE;
125
- }
126
- C._free(buffer);
127
- }
128
- return result;
129
- }
130
- }
@@ -1,165 +0,0 @@
1
- /** A stateful object for walking a syntax {@link Tree} efficiently. */
2
- export class TreeCursor {
3
- /** @internal */
4
- constructor(internal: any, tree: any);
5
- /** @internal */
6
- 0: number;
7
- /** @internal */
8
- 1: number;
9
- /** @internal */
10
- 2: number;
11
- /** @internal */
12
- 3: number;
13
- /** @internal */
14
- tree: any;
15
- /** Creates a deep copy of the tree cursor. This allocates new memory. */
16
- copy(): TreeCursor;
17
- /** Delete the tree cursor, freeing its resources. */
18
- delete(): void;
19
- /** Get the tree cursor's current {@link Node}. */
20
- get currentNode(): any;
21
- /**
22
- * Get the numerical field id of this tree cursor's current node.
23
- *
24
- * See also {@link TreeCursor#currentFieldName}.
25
- */
26
- get currentFieldId(): any;
27
- /** Get the field name of this tree cursor's current node. */
28
- get currentFieldName(): any;
29
- /**
30
- * Get the depth of the cursor's current node relative to the original
31
- * node that the cursor was constructed with.
32
- */
33
- get currentDepth(): any;
34
- /**
35
- * Get the index of the cursor's current node out of all of the
36
- * descendants of the original node that the cursor was constructed with.
37
- */
38
- get currentDescendantIndex(): any;
39
- /** Get the type of the cursor's current node. */
40
- get nodeType(): any;
41
- /** Get the type id of the cursor's current node. */
42
- get nodeTypeId(): any;
43
- /** Get the state id of the cursor's current node. */
44
- get nodeStateId(): any;
45
- /** Get the id of the cursor's current node. */
46
- get nodeId(): any;
47
- /**
48
- * Check if the cursor's current node is *named*.
49
- *
50
- * Named nodes correspond to named rules in the grammar, whereas
51
- * *anonymous* nodes correspond to string literals in the grammar.
52
- */
53
- get nodeIsNamed(): boolean;
54
- /**
55
- * Check if the cursor's current node is *missing*.
56
- *
57
- * Missing nodes are inserted by the parser in order to recover from
58
- * certain kinds of syntax errors.
59
- */
60
- get nodeIsMissing(): boolean;
61
- /** Get the string content of the cursor's current node. */
62
- get nodeText(): any;
63
- /** Get the start position of the cursor's current node. */
64
- get startPosition(): {
65
- row: number;
66
- column: number;
67
- };
68
- /** Get the end position of the cursor's current node. */
69
- get endPosition(): {
70
- row: number;
71
- column: number;
72
- };
73
- /** Get the start index of the cursor's current node. */
74
- get startIndex(): any;
75
- /** Get the end index of the cursor's current node. */
76
- get endIndex(): any;
77
- /**
78
- * Move this cursor to the first child of its current node.
79
- *
80
- * This returns `true` if the cursor successfully moved, and returns
81
- * `false` if there were no children.
82
- */
83
- gotoFirstChild(): boolean;
84
- /**
85
- * Move this cursor to the last child of its current node.
86
- *
87
- * This returns `true` if the cursor successfully moved, and returns
88
- * `false` if there were no children.
89
- *
90
- * Note that this function may be slower than
91
- * {@link TreeCursor#gotoFirstChild} because it needs to
92
- * iterate through all the children to compute the child's position.
93
- */
94
- gotoLastChild(): boolean;
95
- /**
96
- * Move this cursor to the parent of its current node.
97
- *
98
- * This returns `true` if the cursor successfully moved, and returns
99
- * `false` if there was no parent node (the cursor was already on the
100
- * root node).
101
- *
102
- * Note that the node the cursor was constructed with is considered the root
103
- * of the cursor, and the cursor cannot walk outside this node.
104
- */
105
- gotoParent(): boolean;
106
- /**
107
- * Move this cursor to the next sibling of its current node.
108
- *
109
- * This returns `true` if the cursor successfully moved, and returns
110
- * `false` if there was no next sibling node.
111
- *
112
- * Note that the node the cursor was constructed with is considered the root
113
- * of the cursor, and the cursor cannot walk outside this node.
114
- */
115
- gotoNextSibling(): boolean;
116
- /**
117
- * Move this cursor to the previous sibling of its current node.
118
- *
119
- * This returns `true` if the cursor successfully moved, and returns
120
- * `false` if there was no previous sibling node.
121
- *
122
- * Note that this function may be slower than
123
- * {@link TreeCursor#gotoNextSibling} due to how node
124
- * positions are stored. In the worst case, this will need to iterate
125
- * through all the children up to the previous sibling node to recalculate
126
- * its position. Also note that the node the cursor was constructed with is
127
- * considered the root of the cursor, and the cursor cannot walk outside this node.
128
- */
129
- gotoPreviousSibling(): boolean;
130
- /**
131
- * Move the cursor to the node that is the nth descendant of
132
- * the original node that the cursor was constructed with, where
133
- * zero represents the original node itself.
134
- */
135
- gotoDescendant(goalDescendantIndex: any): void;
136
- /**
137
- * Move this cursor to the first child of its current node that contains or
138
- * starts after the given byte offset.
139
- *
140
- * This returns `true` if the cursor successfully moved to a child node, and returns
141
- * `false` if no such child was found.
142
- */
143
- gotoFirstChildForIndex(goalIndex: any): boolean;
144
- /**
145
- * Move this cursor to the first child of its current node that contains or
146
- * starts after the given byte offset.
147
- *
148
- * This returns the index of the child node if one was found, and returns
149
- * `null` if no such child was found.
150
- */
151
- gotoFirstChildForPosition(goalPosition: any): boolean;
152
- /**
153
- * Re-initialize this tree cursor to start at the original node that the
154
- * cursor was constructed with.
155
- */
156
- reset(node: any): void;
157
- /**
158
- * Re-initialize a tree cursor to the same position as another cursor.
159
- *
160
- * Unlike {@link TreeCursor#reset}, this will not lose parent
161
- * information and allows reusing already created cursors.
162
- */
163
- resetTo(cursor: any): void;
164
- }
165
- //# sourceMappingURL=tree_cursor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tree_cursor.d.ts","sourceRoot":"","sources":["../../../../src/deno-tree-sitter/main/tree_sitter/tree_cursor.js"],"names":[],"mappings":"AAMA,uEAAuE;AACvE;IAgBI,gBAAgB;IAChB,sCAIC;IApBD,gBAAgB;IAChB,UAAQ;IAER,gBAAgB;IAChB,UAAQ;IAER,gBAAgB;IAChB,UAAQ;IAER,gBAAgB;IAChB,UAAO;IAEP,gBAAgB;IAChB,UAAI;IASJ,yEAAyE;IACzE,mBAKC;IAED,qDAAqD;IACrD,eAIC;IAED,kDAAkD;IAClD,uBAIC;IAED;;;;OAIG;IACH,0BAGC;IAED,6DAA6D;IAC7D,4BAEC;IAED;;;OAGG;IACH,wBAGC;IAED;;;OAGG;IACH,kCAGC;IAED,iDAAiD;IACjD,oBAEC;IAED,oDAAoD;IACpD,sBAGC;IAED,qDAAqD;IACrD,uBAGC;IAED,+CAA+C;IAC/C,kBAGC;IAED;;;;;OAKG;IACH,2BAGC;IAED;;;;;OAKG;IACH,6BAGC;IAED,2DAA2D;IAC3D,oBAOC;IAED,2DAA2D;IAC3D;;;MAIC;IAED,yDAAyD;IACzD;;;MAIC;IAED,wDAAwD;IACxD,sBAGC;IAED,sDAAsD;IACtD,oBAGC;IAED;;;;;OAKG;IACH,0BAKC;IAED;;;;;;;;;OASG;IACH,yBAKC;IAED;;;;;;;;;OASG;IACH,sBAKC;IAED;;;;;;;;OAQG;IACH,2BAKC;IAED;;;;;;;;;;;;OAYG;IACH,+BAKC;IAED;;;;OAIG;IACH,+CAIC;IAED;;;;;;OAMG;IACH,gDAMC;IAED;;;;;;OAMG;IACH,sDAMC;IAED;;;OAGG;IACH,uBAKC;IAED;;;;;OAKG;IACH,2BAKC;CACJ"}
@@ -1,280 +0,0 @@
1
- import { INTERNAL, assertInternal, SIZE_OF_NODE, SIZE_OF_CURSOR, C } from "./constants.js";
2
- import { marshalNode, marshalPoint, marshalTreeCursor, unmarshalNode, unmarshalPoint, unmarshalTreeCursor } from "./marshal.js";
3
- import { Node } from "./node.js";
4
- import { TRANSFER_BUFFER } from "./parser.js";
5
- import { getText, Tree } from "./tree.js";
6
- /** A stateful object for walking a syntax {@link Tree} efficiently. */
7
- export class TreeCursor {
8
- /** @internal */
9
- [0] = 0; // Internal handle for Wasm
10
- /** @internal */
11
- [1] = 0; // Internal handle for Wasm
12
- /** @internal */
13
- [2] = 0; // Internal handle for Wasm
14
- /** @internal */
15
- [3] = 0; // Internal handle for Wasm
16
- /** @internal */
17
- tree;
18
- /** @internal */
19
- constructor(internal, tree) {
20
- assertInternal(internal);
21
- this.tree = tree;
22
- unmarshalTreeCursor(this);
23
- }
24
- /** Creates a deep copy of the tree cursor. This allocates new memory. */
25
- copy() {
26
- const copy = new TreeCursor(INTERNAL, this.tree);
27
- C._ts_tree_cursor_copy_wasm(this.tree[0]);
28
- unmarshalTreeCursor(copy);
29
- return copy;
30
- }
31
- /** Delete the tree cursor, freeing its resources. */
32
- delete() {
33
- marshalTreeCursor(this);
34
- C._ts_tree_cursor_delete_wasm(this.tree[0]);
35
- this[0] = this[1] = this[2] = 0;
36
- }
37
- /** Get the tree cursor's current {@link Node}. */
38
- get currentNode() {
39
- marshalTreeCursor(this);
40
- C._ts_tree_cursor_current_node_wasm(this.tree[0]);
41
- return unmarshalNode(this.tree);
42
- }
43
- /**
44
- * Get the numerical field id of this tree cursor's current node.
45
- *
46
- * See also {@link TreeCursor#currentFieldName}.
47
- */
48
- get currentFieldId() {
49
- marshalTreeCursor(this);
50
- return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
51
- }
52
- /** Get the field name of this tree cursor's current node. */
53
- get currentFieldName() {
54
- return this.tree.language.fields[this.currentFieldId];
55
- }
56
- /**
57
- * Get the depth of the cursor's current node relative to the original
58
- * node that the cursor was constructed with.
59
- */
60
- get currentDepth() {
61
- marshalTreeCursor(this);
62
- return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
63
- }
64
- /**
65
- * Get the index of the cursor's current node out of all of the
66
- * descendants of the original node that the cursor was constructed with.
67
- */
68
- get currentDescendantIndex() {
69
- marshalTreeCursor(this);
70
- return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
71
- }
72
- /** Get the type of the cursor's current node. */
73
- get nodeType() {
74
- return this.tree.language.types[this.nodeTypeId] || "ERROR";
75
- }
76
- /** Get the type id of the cursor's current node. */
77
- get nodeTypeId() {
78
- marshalTreeCursor(this);
79
- return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
80
- }
81
- /** Get the state id of the cursor's current node. */
82
- get nodeStateId() {
83
- marshalTreeCursor(this);
84
- return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
85
- }
86
- /** Get the id of the cursor's current node. */
87
- get nodeId() {
88
- marshalTreeCursor(this);
89
- return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
90
- }
91
- /**
92
- * Check if the cursor's current node is *named*.
93
- *
94
- * Named nodes correspond to named rules in the grammar, whereas
95
- * *anonymous* nodes correspond to string literals in the grammar.
96
- */
97
- get nodeIsNamed() {
98
- marshalTreeCursor(this);
99
- return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
100
- }
101
- /**
102
- * Check if the cursor's current node is *missing*.
103
- *
104
- * Missing nodes are inserted by the parser in order to recover from
105
- * certain kinds of syntax errors.
106
- */
107
- get nodeIsMissing() {
108
- marshalTreeCursor(this);
109
- return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
110
- }
111
- /** Get the string content of the cursor's current node. */
112
- get nodeText() {
113
- marshalTreeCursor(this);
114
- const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
115
- const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
116
- C._ts_tree_cursor_start_position_wasm(this.tree[0]);
117
- const startPosition = unmarshalPoint(TRANSFER_BUFFER);
118
- return getText(this.tree, startIndex, endIndex, startPosition);
119
- }
120
- /** Get the start position of the cursor's current node. */
121
- get startPosition() {
122
- marshalTreeCursor(this);
123
- C._ts_tree_cursor_start_position_wasm(this.tree[0]);
124
- return unmarshalPoint(TRANSFER_BUFFER);
125
- }
126
- /** Get the end position of the cursor's current node. */
127
- get endPosition() {
128
- marshalTreeCursor(this);
129
- C._ts_tree_cursor_end_position_wasm(this.tree[0]);
130
- return unmarshalPoint(TRANSFER_BUFFER);
131
- }
132
- /** Get the start index of the cursor's current node. */
133
- get startIndex() {
134
- marshalTreeCursor(this);
135
- return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
136
- }
137
- /** Get the end index of the cursor's current node. */
138
- get endIndex() {
139
- marshalTreeCursor(this);
140
- return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
141
- }
142
- /**
143
- * Move this cursor to the first child of its current node.
144
- *
145
- * This returns `true` if the cursor successfully moved, and returns
146
- * `false` if there were no children.
147
- */
148
- gotoFirstChild() {
149
- marshalTreeCursor(this);
150
- const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
151
- unmarshalTreeCursor(this);
152
- return result === 1;
153
- }
154
- /**
155
- * Move this cursor to the last child of its current node.
156
- *
157
- * This returns `true` if the cursor successfully moved, and returns
158
- * `false` if there were no children.
159
- *
160
- * Note that this function may be slower than
161
- * {@link TreeCursor#gotoFirstChild} because it needs to
162
- * iterate through all the children to compute the child's position.
163
- */
164
- gotoLastChild() {
165
- marshalTreeCursor(this);
166
- const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
167
- unmarshalTreeCursor(this);
168
- return result === 1;
169
- }
170
- /**
171
- * Move this cursor to the parent of its current node.
172
- *
173
- * This returns `true` if the cursor successfully moved, and returns
174
- * `false` if there was no parent node (the cursor was already on the
175
- * root node).
176
- *
177
- * Note that the node the cursor was constructed with is considered the root
178
- * of the cursor, and the cursor cannot walk outside this node.
179
- */
180
- gotoParent() {
181
- marshalTreeCursor(this);
182
- const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
183
- unmarshalTreeCursor(this);
184
- return result === 1;
185
- }
186
- /**
187
- * Move this cursor to the next sibling of its current node.
188
- *
189
- * This returns `true` if the cursor successfully moved, and returns
190
- * `false` if there was no next sibling node.
191
- *
192
- * Note that the node the cursor was constructed with is considered the root
193
- * of the cursor, and the cursor cannot walk outside this node.
194
- */
195
- gotoNextSibling() {
196
- marshalTreeCursor(this);
197
- const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
198
- unmarshalTreeCursor(this);
199
- return result === 1;
200
- }
201
- /**
202
- * Move this cursor to the previous sibling of its current node.
203
- *
204
- * This returns `true` if the cursor successfully moved, and returns
205
- * `false` if there was no previous sibling node.
206
- *
207
- * Note that this function may be slower than
208
- * {@link TreeCursor#gotoNextSibling} due to how node
209
- * positions are stored. In the worst case, this will need to iterate
210
- * through all the children up to the previous sibling node to recalculate
211
- * its position. Also note that the node the cursor was constructed with is
212
- * considered the root of the cursor, and the cursor cannot walk outside this node.
213
- */
214
- gotoPreviousSibling() {
215
- marshalTreeCursor(this);
216
- const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
217
- unmarshalTreeCursor(this);
218
- return result === 1;
219
- }
220
- /**
221
- * Move the cursor to the node that is the nth descendant of
222
- * the original node that the cursor was constructed with, where
223
- * zero represents the original node itself.
224
- */
225
- gotoDescendant(goalDescendantIndex) {
226
- marshalTreeCursor(this);
227
- C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);
228
- unmarshalTreeCursor(this);
229
- }
230
- /**
231
- * Move this cursor to the first child of its current node that contains or
232
- * starts after the given byte offset.
233
- *
234
- * This returns `true` if the cursor successfully moved to a child node, and returns
235
- * `false` if no such child was found.
236
- */
237
- gotoFirstChildForIndex(goalIndex) {
238
- marshalTreeCursor(this);
239
- C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
240
- const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
241
- unmarshalTreeCursor(this);
242
- return result === 1;
243
- }
244
- /**
245
- * Move this cursor to the first child of its current node that contains or
246
- * starts after the given byte offset.
247
- *
248
- * This returns the index of the child node if one was found, and returns
249
- * `null` if no such child was found.
250
- */
251
- gotoFirstChildForPosition(goalPosition) {
252
- marshalTreeCursor(this);
253
- marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
254
- const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
255
- unmarshalTreeCursor(this);
256
- return result === 1;
257
- }
258
- /**
259
- * Re-initialize this tree cursor to start at the original node that the
260
- * cursor was constructed with.
261
- */
262
- reset(node) {
263
- marshalNode(node);
264
- marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
265
- C._ts_tree_cursor_reset_wasm(this.tree[0]);
266
- unmarshalTreeCursor(this);
267
- }
268
- /**
269
- * Re-initialize a tree cursor to the same position as another cursor.
270
- *
271
- * Unlike {@link TreeCursor#reset}, this will not lose parent
272
- * information and allows reusing already created cursors.
273
- */
274
- resetTo(cursor) {
275
- marshalTreeCursor(this, TRANSFER_BUFFER);
276
- marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
277
- C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
278
- unmarshalTreeCursor(this);
279
- }
280
- }
@@ -1,3 +0,0 @@
1
- export default output;
2
- declare let output: Uint8Array<ArrayBuffer>;
3
- //# sourceMappingURL=tree_sitter_wasm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tree_sitter_wasm.d.ts","sourceRoot":"","sources":["../../../src/deno-tree-sitter/main/tree_sitter_wasm.js"],"names":[],"mappings":";AAiEA,4CAm6CoI"}
@@ -1,29 +0,0 @@
1
- export default function _default(Module: any, ...args: any[]): Promise<any>;
2
- export namespace defaults {
3
- let arguments: never[];
4
- let dynamicLibraries: never[];
5
- let thisProgram: string;
6
- let INITIAL_MEMORY: number;
7
- let wasmBinary: null;
8
- let wasmBinaryFilePath: null;
9
- let noExitRuntime: boolean;
10
- let noInitialRun: boolean;
11
- let monitorRunDependencies: null;
12
- let onRuntimeInitialized: null;
13
- let preRun: null;
14
- let preInit: null;
15
- let onAbort: null;
16
- let onExit: null;
17
- let postRun: null;
18
- let setStatus: null;
19
- let defaultWasmPath: string;
20
- function quit(status: any, toThrow: any): never;
21
- function locateFile(relativePath: any): any;
22
- function readAsync(path: any): Promise<void>;
23
- function readBinary(path: any): void;
24
- let print: null;
25
- let printErr: null;
26
- let instantiateWasm: null;
27
- let fetch: typeof globalThis.fetch;
28
- }
29
- //# sourceMappingURL=wasm_loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wasm_loader.d.ts","sourceRoot":"","sources":["../../../src/deno-tree-sitter/main/wasm_loader.js"],"names":[],"mappings":"AA6CA,4EAwnDC;;;;;;;;;;;;;;;;;;;IA7oDa,gDAEL;IACW,4CAEX;IACU,6CAAgB;IACf,qCAAU"}