@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
package/debug/web-tree-sitter.js
CHANGED
|
@@ -1,111 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
-
// src/edit.ts
|
|
5
|
-
var Edit = class {
|
|
6
|
-
static {
|
|
7
|
-
__name(this, "Edit");
|
|
8
|
-
}
|
|
9
|
-
/** The start position of the change. */
|
|
10
|
-
startPosition;
|
|
11
|
-
/** The end position of the change before the edit. */
|
|
12
|
-
oldEndPosition;
|
|
13
|
-
/** The end position of the change after the edit. */
|
|
14
|
-
newEndPosition;
|
|
15
|
-
/** The start index of the change. */
|
|
16
|
-
startIndex;
|
|
17
|
-
/** The end index of the change before the edit. */
|
|
18
|
-
oldEndIndex;
|
|
19
|
-
/** The end index of the change after the edit. */
|
|
20
|
-
newEndIndex;
|
|
21
|
-
constructor({
|
|
22
|
-
startIndex,
|
|
23
|
-
oldEndIndex,
|
|
24
|
-
newEndIndex,
|
|
25
|
-
startPosition,
|
|
26
|
-
oldEndPosition,
|
|
27
|
-
newEndPosition
|
|
28
|
-
}) {
|
|
29
|
-
this.startIndex = startIndex >>> 0;
|
|
30
|
-
this.oldEndIndex = oldEndIndex >>> 0;
|
|
31
|
-
this.newEndIndex = newEndIndex >>> 0;
|
|
32
|
-
this.startPosition = startPosition;
|
|
33
|
-
this.oldEndPosition = oldEndPosition;
|
|
34
|
-
this.newEndPosition = newEndPosition;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Edit a point and index to keep it in-sync with source code that has been edited.
|
|
38
|
-
*
|
|
39
|
-
* This function updates a single point's byte offset and row/column position
|
|
40
|
-
* based on an edit operation. This is useful for editing points without
|
|
41
|
-
* requiring a tree or node instance.
|
|
42
|
-
*/
|
|
43
|
-
editPoint(point, index) {
|
|
44
|
-
let newIndex = index;
|
|
45
|
-
const newPoint = { ...point };
|
|
46
|
-
if (index >= this.oldEndIndex) {
|
|
47
|
-
newIndex = this.newEndIndex + (index - this.oldEndIndex);
|
|
48
|
-
const originalRow = point.row;
|
|
49
|
-
newPoint.row = this.newEndPosition.row + (point.row - this.oldEndPosition.row);
|
|
50
|
-
newPoint.column = originalRow === this.oldEndPosition.row ? this.newEndPosition.column + (point.column - this.oldEndPosition.column) : point.column;
|
|
51
|
-
} else if (index > this.startIndex) {
|
|
52
|
-
newIndex = this.newEndIndex;
|
|
53
|
-
newPoint.row = this.newEndPosition.row;
|
|
54
|
-
newPoint.column = this.newEndPosition.column;
|
|
55
|
-
}
|
|
56
|
-
return { point: newPoint, index: newIndex };
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Edit a range to keep it in-sync with source code that has been edited.
|
|
60
|
-
*
|
|
61
|
-
* This function updates a range's start and end positions based on an edit
|
|
62
|
-
* operation. This is useful for editing ranges without requiring a tree
|
|
63
|
-
* or node instance.
|
|
64
|
-
*/
|
|
65
|
-
editRange(range) {
|
|
66
|
-
const newRange = {
|
|
67
|
-
startIndex: range.startIndex,
|
|
68
|
-
startPosition: { ...range.startPosition },
|
|
69
|
-
endIndex: range.endIndex,
|
|
70
|
-
endPosition: { ...range.endPosition }
|
|
71
|
-
};
|
|
72
|
-
if (range.endIndex >= this.oldEndIndex) {
|
|
73
|
-
if (range.endIndex !== Number.MAX_SAFE_INTEGER) {
|
|
74
|
-
newRange.endIndex = this.newEndIndex + (range.endIndex - this.oldEndIndex);
|
|
75
|
-
newRange.endPosition = {
|
|
76
|
-
row: this.newEndPosition.row + (range.endPosition.row - this.oldEndPosition.row),
|
|
77
|
-
column: range.endPosition.row === this.oldEndPosition.row ? this.newEndPosition.column + (range.endPosition.column - this.oldEndPosition.column) : range.endPosition.column
|
|
78
|
-
};
|
|
79
|
-
if (newRange.endIndex < this.newEndIndex) {
|
|
80
|
-
newRange.endIndex = Number.MAX_SAFE_INTEGER;
|
|
81
|
-
newRange.endPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} else if (range.endIndex > this.startIndex) {
|
|
85
|
-
newRange.endIndex = this.startIndex;
|
|
86
|
-
newRange.endPosition = { ...this.startPosition };
|
|
87
|
-
}
|
|
88
|
-
if (range.startIndex >= this.oldEndIndex) {
|
|
89
|
-
newRange.startIndex = this.newEndIndex + (range.startIndex - this.oldEndIndex);
|
|
90
|
-
newRange.startPosition = {
|
|
91
|
-
row: this.newEndPosition.row + (range.startPosition.row - this.oldEndPosition.row),
|
|
92
|
-
column: range.startPosition.row === this.oldEndPosition.row ? this.newEndPosition.column + (range.startPosition.column - this.oldEndPosition.column) : range.startPosition.column
|
|
93
|
-
};
|
|
94
|
-
if (newRange.startIndex < this.newEndIndex) {
|
|
95
|
-
newRange.startIndex = Number.MAX_SAFE_INTEGER;
|
|
96
|
-
newRange.startPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };
|
|
97
|
-
}
|
|
98
|
-
} else if (range.startIndex > this.startIndex) {
|
|
99
|
-
newRange.startIndex = this.startIndex;
|
|
100
|
-
newRange.startPosition = { ...this.startPosition };
|
|
101
|
-
}
|
|
102
|
-
return newRange;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
4
|
// src/constants.ts
|
|
107
5
|
var SIZE_OF_INT = 4;
|
|
108
|
-
var SIZE_OF_NODE =
|
|
6
|
+
var SIZE_OF_NODE = 9 * SIZE_OF_INT;
|
|
109
7
|
var SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
110
8
|
var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
111
9
|
var ZERO_POINT = { row: 0, column: 0 };
|
|
@@ -135,100 +33,8 @@ function newFinalizer(handler) {
|
|
|
135
33
|
}
|
|
136
34
|
__name(newFinalizer, "newFinalizer");
|
|
137
35
|
|
|
138
|
-
// src/lookahead_iterator.ts
|
|
139
|
-
var finalizer = newFinalizer((address) => {
|
|
140
|
-
C._ts_lookahead_iterator_delete(address);
|
|
141
|
-
});
|
|
142
|
-
var LookaheadIterator = class {
|
|
143
|
-
static {
|
|
144
|
-
__name(this, "LookaheadIterator");
|
|
145
|
-
}
|
|
146
|
-
/** @internal */
|
|
147
|
-
[0] = 0;
|
|
148
|
-
// Internal handle for Wasm
|
|
149
|
-
/** @internal */
|
|
150
|
-
language;
|
|
151
|
-
/** @internal */
|
|
152
|
-
positioned = false;
|
|
153
|
-
/** @internal */
|
|
154
|
-
constructor(internal, address, language) {
|
|
155
|
-
assertInternal(internal);
|
|
156
|
-
this[0] = address;
|
|
157
|
-
this.language = language;
|
|
158
|
-
finalizer?.register(this, address, this);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get the current symbol of the lookahead iterator.
|
|
162
|
-
*
|
|
163
|
-
* Returns `null` if the iterator is not positioned on a symbol:
|
|
164
|
-
*
|
|
165
|
-
* - Before the first iteration step
|
|
166
|
-
* - After the iterator is exhausted
|
|
167
|
-
* - After a {@link reset} or {@link resetState} call
|
|
168
|
-
*/
|
|
169
|
-
get currentTypeId() {
|
|
170
|
-
return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Get the current symbol name of the lookahead iterator.
|
|
174
|
-
*
|
|
175
|
-
* Returns `null` if the iterator is not positioned on a symbol.
|
|
176
|
-
*/
|
|
177
|
-
get currentType() {
|
|
178
|
-
const id = this.currentTypeId;
|
|
179
|
-
if (id === null) return null;
|
|
180
|
-
return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
|
|
181
|
-
}
|
|
182
|
-
/** Delete the lookahead iterator, freeing its resources. */
|
|
183
|
-
delete() {
|
|
184
|
-
finalizer?.unregister(this);
|
|
185
|
-
C._ts_lookahead_iterator_delete(this[0]);
|
|
186
|
-
this[0] = 0;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Reset the lookahead iterator.
|
|
190
|
-
*
|
|
191
|
-
* This returns `true` if the language was set successfully and `false`
|
|
192
|
-
* otherwise.
|
|
193
|
-
*/
|
|
194
|
-
reset(language, stateId) {
|
|
195
|
-
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
196
|
-
this.language = language;
|
|
197
|
-
this.positioned = false;
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Reset the lookahead iterator to another state.
|
|
204
|
-
*
|
|
205
|
-
* This returns `true` if the iterator was reset to the given state and
|
|
206
|
-
* `false` otherwise.
|
|
207
|
-
*/
|
|
208
|
-
resetState(stateId) {
|
|
209
|
-
if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
|
|
210
|
-
this.positioned = false;
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Returns an iterator that iterates over the symbols of the lookahead iterator.
|
|
215
|
-
*
|
|
216
|
-
* The iterator will yield the current symbol name as a string for each step
|
|
217
|
-
* until there are no more symbols to iterate over.
|
|
218
|
-
*/
|
|
219
|
-
[Symbol.iterator]() {
|
|
220
|
-
return {
|
|
221
|
-
next: /* @__PURE__ */ __name(() => {
|
|
222
|
-
this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
|
|
223
|
-
const value = this.currentType;
|
|
224
|
-
return value === null ? { done: true, value: "" } : { done: false, value };
|
|
225
|
-
}, "next")
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
36
|
// src/tree_cursor.ts
|
|
231
|
-
var
|
|
37
|
+
var finalizer = newFinalizer((address) => {
|
|
232
38
|
C._ts_tree_cursor_delete_wasm(address);
|
|
233
39
|
});
|
|
234
40
|
var TreeCursor = class _TreeCursor {
|
|
@@ -241,8 +47,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
241
47
|
/** @internal */
|
|
242
48
|
tree;
|
|
243
49
|
/** @internal */
|
|
244
|
-
editVersion = -1;
|
|
245
|
-
/** @internal */
|
|
246
50
|
_nodeTypeId = 0;
|
|
247
51
|
/** @internal */
|
|
248
52
|
_fieldId = 0;
|
|
@@ -258,7 +62,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
258
62
|
this[0] = address;
|
|
259
63
|
this.tree = tree;
|
|
260
64
|
this.readNodeCache();
|
|
261
|
-
|
|
65
|
+
finalizer?.register(this, address, this);
|
|
262
66
|
}
|
|
263
67
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
264
68
|
copy() {
|
|
@@ -267,7 +71,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
267
71
|
}
|
|
268
72
|
/** Delete the tree cursor, freeing its resources. */
|
|
269
73
|
delete() {
|
|
270
|
-
|
|
74
|
+
finalizer?.unregister(this);
|
|
271
75
|
C._ts_tree_cursor_delete_wasm(this[0]);
|
|
272
76
|
this[0] = 0;
|
|
273
77
|
}
|
|
@@ -310,10 +114,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
310
114
|
get nodeTypeId() {
|
|
311
115
|
return this._nodeTypeId;
|
|
312
116
|
}
|
|
313
|
-
/** Get the state id of the cursor's current node. */
|
|
314
|
-
get nodeStateId() {
|
|
315
|
-
return C._ts_tree_cursor_current_node_state_id_wasm(this[0]);
|
|
316
|
-
}
|
|
317
117
|
/** Get the id of the cursor's current node. */
|
|
318
118
|
get nodeId() {
|
|
319
119
|
return C._ts_tree_cursor_current_node_id_wasm(this[0]);
|
|
@@ -338,7 +138,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
338
138
|
}
|
|
339
139
|
/** Get the string content of the cursor's current node. */
|
|
340
140
|
get nodeText() {
|
|
341
|
-
this.syncIndices();
|
|
342
141
|
const { textSource } = this.tree;
|
|
343
142
|
return typeof textSource === "string" ? textSource.slice(this._startIndex, this._endIndex) : getCallbackText(textSource, this._startIndex, this._endIndex, this.startPosition);
|
|
344
143
|
}
|
|
@@ -354,12 +153,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
354
153
|
}
|
|
355
154
|
/** Get the start index of the cursor's current node. */
|
|
356
155
|
get startIndex() {
|
|
357
|
-
this.syncIndices();
|
|
358
156
|
return this._startIndex;
|
|
359
157
|
}
|
|
360
158
|
/** Get the end index of the cursor's current node. */
|
|
361
159
|
get endIndex() {
|
|
362
|
-
this.syncIndices();
|
|
363
160
|
return this._endIndex;
|
|
364
161
|
}
|
|
365
162
|
/**
|
|
@@ -505,15 +302,6 @@ var TreeCursor = class _TreeCursor {
|
|
|
505
302
|
this._startIndex = heap[base + 2];
|
|
506
303
|
this._endIndex = heap[base + 3];
|
|
507
304
|
this._flags = heap[base + 4];
|
|
508
|
-
this.editVersion = this.tree.editVersion;
|
|
509
|
-
}
|
|
510
|
-
/** @internal */
|
|
511
|
-
syncIndices() {
|
|
512
|
-
if (this.editVersion !== this.tree.editVersion) {
|
|
513
|
-
this._startIndex = C._ts_tree_cursor_start_index_wasm(this[0]) >>> 0;
|
|
514
|
-
this._endIndex = C._ts_tree_cursor_end_index_wasm(this[0]) >>> 0;
|
|
515
|
-
this.editVersion = this.tree.editVersion;
|
|
516
|
-
}
|
|
517
305
|
}
|
|
518
306
|
};
|
|
519
307
|
|
|
@@ -539,7 +327,7 @@ function getCallbackText(textSource, startIndex, endIndex, startPosition) {
|
|
|
539
327
|
return result ?? "";
|
|
540
328
|
}
|
|
541
329
|
__name(getCallbackText, "getCallbackText");
|
|
542
|
-
var
|
|
330
|
+
var finalizer2 = newFinalizer((address) => {
|
|
543
331
|
C._ts_tree_delete(address);
|
|
544
332
|
});
|
|
545
333
|
var Tree2 = class _Tree {
|
|
@@ -551,8 +339,6 @@ var Tree2 = class _Tree {
|
|
|
551
339
|
// Internal handle for Wasm
|
|
552
340
|
/** @internal */
|
|
553
341
|
textSource;
|
|
554
|
-
/** @internal */
|
|
555
|
-
editVersion = 0;
|
|
556
342
|
/** The language that was used to parse the syntax tree. */
|
|
557
343
|
language;
|
|
558
344
|
/** @internal */
|
|
@@ -561,7 +347,7 @@ var Tree2 = class _Tree {
|
|
|
561
347
|
this[0] = address;
|
|
562
348
|
this.language = language;
|
|
563
349
|
this.textSource = textSource;
|
|
564
|
-
|
|
350
|
+
finalizer2?.register(this, address, this);
|
|
565
351
|
}
|
|
566
352
|
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
567
353
|
copy() {
|
|
@@ -570,7 +356,7 @@ var Tree2 = class _Tree {
|
|
|
570
356
|
}
|
|
571
357
|
/** Delete the syntax tree, freeing its resources. */
|
|
572
358
|
delete() {
|
|
573
|
-
|
|
359
|
+
finalizer2?.unregister(this);
|
|
574
360
|
C._ts_tree_delete(this[0]);
|
|
575
361
|
this[0] = 0;
|
|
576
362
|
}
|
|
@@ -590,42 +376,12 @@ var Tree2 = class _Tree {
|
|
|
590
376
|
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
591
377
|
return unmarshalNode(this);
|
|
592
378
|
}
|
|
593
|
-
/**
|
|
594
|
-
* Edit the syntax tree to keep it in sync with source code that has been
|
|
595
|
-
* edited.
|
|
596
|
-
*
|
|
597
|
-
* You must describe the edit both in terms of byte offsets and in terms of
|
|
598
|
-
* row/column coordinates.
|
|
599
|
-
*/
|
|
600
|
-
edit(edit) {
|
|
601
|
-
marshalEdit(edit);
|
|
602
|
-
C._ts_tree_edit_wasm(this[0]);
|
|
603
|
-
this.editVersion++;
|
|
604
|
-
}
|
|
605
379
|
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
606
380
|
walk() {
|
|
607
381
|
C._ts_tree_root_node_wasm(this[0]);
|
|
608
382
|
const address = C._ts_tree_cursor_new_wasm(this[0]);
|
|
609
383
|
return new TreeCursor(INTERNAL, this, address);
|
|
610
384
|
}
|
|
611
|
-
/**
|
|
612
|
-
* Compare this old edited syntax tree to a new syntax tree representing
|
|
613
|
-
* the same document, returning a sequence of ranges whose syntactic
|
|
614
|
-
* structure has changed.
|
|
615
|
-
*
|
|
616
|
-
* For this to work correctly, this syntax tree must have been edited such
|
|
617
|
-
* that its ranges match up to the new tree. Generally, you'll want to
|
|
618
|
-
* call this method right after calling one of the [`Parser::parse`]
|
|
619
|
-
* functions. Call it on the old tree that was passed to parse, and
|
|
620
|
-
* pass the new tree that was returned from `parse`.
|
|
621
|
-
*/
|
|
622
|
-
getChangedRanges(other) {
|
|
623
|
-
if (!(other instanceof _Tree)) {
|
|
624
|
-
throw new TypeError("Argument must be a Tree");
|
|
625
|
-
}
|
|
626
|
-
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
627
|
-
return unmarshalRanges();
|
|
628
|
-
}
|
|
629
385
|
/** Get the included ranges that were used to parse the syntax tree. */
|
|
630
386
|
getIncludedRanges() {
|
|
631
387
|
C._ts_tree_included_ranges_wasm(this[0]);
|
|
@@ -634,6 +390,7 @@ var Tree2 = class _Tree {
|
|
|
634
390
|
};
|
|
635
391
|
|
|
636
392
|
// src/node.ts
|
|
393
|
+
var singleTypeSymbolsCache = /* @__PURE__ */ new WeakMap();
|
|
637
394
|
var Node = class {
|
|
638
395
|
static {
|
|
639
396
|
__name(this, "Node");
|
|
@@ -643,6 +400,14 @@ var Node = class {
|
|
|
643
400
|
[0] = 0;
|
|
644
401
|
// Internal handle for Wasm
|
|
645
402
|
/** @internal */
|
|
403
|
+
_endIndex;
|
|
404
|
+
/** @internal */
|
|
405
|
+
_endRow;
|
|
406
|
+
/** @internal */
|
|
407
|
+
_endColumn;
|
|
408
|
+
/** @internal */
|
|
409
|
+
_flags;
|
|
410
|
+
/** @internal */
|
|
646
411
|
_children;
|
|
647
412
|
/** @internal */
|
|
648
413
|
_namedChildren;
|
|
@@ -652,7 +417,11 @@ var Node = class {
|
|
|
652
417
|
tree,
|
|
653
418
|
startIndex,
|
|
654
419
|
startPosition,
|
|
655
|
-
other
|
|
420
|
+
other,
|
|
421
|
+
endIndex,
|
|
422
|
+
endRow,
|
|
423
|
+
endColumn,
|
|
424
|
+
flags: flags2
|
|
656
425
|
}) {
|
|
657
426
|
assertInternal(internal);
|
|
658
427
|
this[0] = other;
|
|
@@ -660,18 +429,15 @@ var Node = class {
|
|
|
660
429
|
this.tree = tree;
|
|
661
430
|
this.startIndex = startIndex;
|
|
662
431
|
this.startPosition = startPosition;
|
|
432
|
+
this._endIndex = endIndex;
|
|
433
|
+
this._endRow = endRow;
|
|
434
|
+
this._endColumn = endColumn;
|
|
435
|
+
this._flags = flags2;
|
|
663
436
|
}
|
|
664
437
|
/**
|
|
665
438
|
* The numeric id for this node that is unique.
|
|
666
439
|
*
|
|
667
|
-
* Within a given syntax tree, no two nodes have the same id.
|
|
668
|
-
*
|
|
669
|
-
* * If a new tree is created based on an older tree, and a node from the old tree is reused in
|
|
670
|
-
* the process, then that node will have the same id in both trees.
|
|
671
|
-
*
|
|
672
|
-
* * A node not marked as having changes does not guarantee it was reused.
|
|
673
|
-
*
|
|
674
|
-
* * If a node is marked as having changed in the old tree, it will not be reused.
|
|
440
|
+
* Within a given syntax tree, no two nodes have the same id.
|
|
675
441
|
*/
|
|
676
442
|
id;
|
|
677
443
|
/** The byte index where this node starts. */
|
|
@@ -682,8 +448,7 @@ var Node = class {
|
|
|
682
448
|
tree;
|
|
683
449
|
/** Get this node's type as a numerical id. */
|
|
684
450
|
get typeId() {
|
|
685
|
-
|
|
686
|
-
return C._ts_node_symbol_wasm(this.tree[0]);
|
|
451
|
+
return this._flags & 65535;
|
|
687
452
|
}
|
|
688
453
|
/**
|
|
689
454
|
* Get the node's type as a numerical id as it appears in the grammar,
|
|
@@ -695,7 +460,7 @@ var Node = class {
|
|
|
695
460
|
}
|
|
696
461
|
/** Get this node's type as a string. */
|
|
697
462
|
get type() {
|
|
698
|
-
return this.tree.language.types[this.
|
|
463
|
+
return this.tree.language.types[this._flags & 65535] || "ERROR";
|
|
699
464
|
}
|
|
700
465
|
/**
|
|
701
466
|
* Get this node's symbol name as it appears in the grammar, ignoring
|
|
@@ -711,8 +476,7 @@ var Node = class {
|
|
|
711
476
|
* *anonymous* nodes correspond to string literals in the grammar.
|
|
712
477
|
*/
|
|
713
478
|
get isNamed() {
|
|
714
|
-
|
|
715
|
-
return C._ts_node_is_named_wasm(this.tree[0]) === 1;
|
|
479
|
+
return (this._flags & 65536) !== 0;
|
|
716
480
|
}
|
|
717
481
|
/**
|
|
718
482
|
* Check if this node is *extra*.
|
|
@@ -721,8 +485,7 @@ var Node = class {
|
|
|
721
485
|
* by the grammar, but can appear anywhere.
|
|
722
486
|
*/
|
|
723
487
|
get isExtra() {
|
|
724
|
-
|
|
725
|
-
return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
|
|
488
|
+
return (this._flags & 131072) !== 0;
|
|
726
489
|
}
|
|
727
490
|
/**
|
|
728
491
|
* Check if this node represents a syntax error.
|
|
@@ -731,8 +494,7 @@ var Node = class {
|
|
|
731
494
|
* into a valid syntax tree.
|
|
732
495
|
*/
|
|
733
496
|
get isError() {
|
|
734
|
-
|
|
735
|
-
return C._ts_node_is_error_wasm(this.tree[0]) === 1;
|
|
497
|
+
return (this._flags & 1048576) !== 0;
|
|
736
498
|
}
|
|
737
499
|
/**
|
|
738
500
|
* Check if this node is *missing*.
|
|
@@ -741,47 +503,27 @@ var Node = class {
|
|
|
741
503
|
* certain kinds of syntax errors.
|
|
742
504
|
*/
|
|
743
505
|
get isMissing() {
|
|
744
|
-
|
|
745
|
-
return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
|
|
746
|
-
}
|
|
747
|
-
/** Check if this node has been edited. */
|
|
748
|
-
get hasChanges() {
|
|
749
|
-
marshalNode(this);
|
|
750
|
-
return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
|
|
506
|
+
return (this._flags & 262144) !== 0;
|
|
751
507
|
}
|
|
752
508
|
/**
|
|
753
509
|
* Check if this node represents a syntax error or contains any syntax
|
|
754
510
|
* errors anywhere within it.
|
|
755
511
|
*/
|
|
756
512
|
get hasError() {
|
|
757
|
-
|
|
758
|
-
return C._ts_node_has_error_wasm(this.tree[0]) === 1;
|
|
513
|
+
return (this._flags & 524288) !== 0;
|
|
759
514
|
}
|
|
760
515
|
/** Get the byte index where this node ends. */
|
|
761
516
|
get endIndex() {
|
|
762
|
-
|
|
763
|
-
return C._ts_node_end_index_wasm(this.tree[0]);
|
|
517
|
+
return this._endIndex;
|
|
764
518
|
}
|
|
765
519
|
/** Get the position where this node ends. */
|
|
766
520
|
get endPosition() {
|
|
767
|
-
|
|
768
|
-
C._ts_node_end_point_wasm(this.tree[0]);
|
|
769
|
-
return unmarshalPoint(TRANSFER_BUFFER);
|
|
521
|
+
return { row: this._endRow, column: this._endColumn };
|
|
770
522
|
}
|
|
771
523
|
/** Get the string content of this node. */
|
|
772
524
|
get text() {
|
|
773
525
|
const { textSource } = this.tree;
|
|
774
|
-
return typeof textSource === "string" ? textSource.slice(this.startIndex, this.
|
|
775
|
-
}
|
|
776
|
-
/** Get this node's parse state. */
|
|
777
|
-
get parseState() {
|
|
778
|
-
marshalNode(this);
|
|
779
|
-
return C._ts_node_parse_state_wasm(this.tree[0]);
|
|
780
|
-
}
|
|
781
|
-
/** Get the parse state after this node. */
|
|
782
|
-
get nextParseState() {
|
|
783
|
-
marshalNode(this);
|
|
784
|
-
return C._ts_node_next_parse_state_wasm(this.tree[0]);
|
|
526
|
+
return typeof textSource === "string" ? textSource.slice(this.startIndex, this._endIndex) : getCallbackText(textSource, this.startIndex, this._endIndex, this.startPosition);
|
|
785
527
|
}
|
|
786
528
|
/** Check if this node is equal to another node. */
|
|
787
529
|
equals(other) {
|
|
@@ -957,23 +699,10 @@ var Node = class {
|
|
|
957
699
|
* Additionally, a `startPosition` and `endPosition` can be passed in to restrict the search to a byte range.
|
|
958
700
|
*/
|
|
959
701
|
descendantsOfType(types, startPosition = ZERO_POINT, endPosition = ZERO_POINT) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
const typesBySymbol = this.tree.language.types;
|
|
963
|
-
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
964
|
-
if (types.includes(typesBySymbol[i2])) {
|
|
965
|
-
symbols.push(i2);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
if (types.includes("ERROR")) {
|
|
969
|
-
symbols.push(65535);
|
|
970
|
-
}
|
|
702
|
+
const symbols = symbolsForTypes(this.tree.language, types);
|
|
703
|
+
if (symbols.length === 0) return [];
|
|
971
704
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
972
|
-
|
|
973
|
-
const symbolsBase = symbolsAddress >>> 2;
|
|
974
|
-
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
975
|
-
symbolsHeap[symbolsBase + i2] = symbols[i2];
|
|
976
|
-
}
|
|
705
|
+
C.HEAPU32.set(symbols, symbolsAddress >>> 2);
|
|
977
706
|
marshalNode(this);
|
|
978
707
|
const pointAddress = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
979
708
|
marshalPoint(pointAddress, startPosition);
|
|
@@ -1106,20 +835,6 @@ var Node = class {
|
|
|
1106
835
|
const address = C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
1107
836
|
return new TreeCursor(INTERNAL, this.tree, address);
|
|
1108
837
|
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Edit this node to keep it in-sync with source code that has been edited.
|
|
1111
|
-
*
|
|
1112
|
-
* This function is only rarely needed. When you edit a syntax tree with
|
|
1113
|
-
* the {@link Tree#edit} method, all of the nodes that you retrieve from
|
|
1114
|
-
* the tree afterward will already reflect the edit. You only need to
|
|
1115
|
-
* use {@link Node#edit} when you have a specific {@link Node} instance that
|
|
1116
|
-
* you want to keep and continue to use after an edit.
|
|
1117
|
-
*/
|
|
1118
|
-
edit(edit) {
|
|
1119
|
-
const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
|
|
1120
|
-
this.startPosition = point;
|
|
1121
|
-
this.startIndex = index;
|
|
1122
|
-
}
|
|
1123
838
|
/** Get the S-expression representation of this node. */
|
|
1124
839
|
toString() {
|
|
1125
840
|
marshalNode(this);
|
|
@@ -1129,6 +844,44 @@ var Node = class {
|
|
|
1129
844
|
return result;
|
|
1130
845
|
}
|
|
1131
846
|
};
|
|
847
|
+
function symbolsForTypes(language, types) {
|
|
848
|
+
if (typeof types === "string") {
|
|
849
|
+
return symbolsForSingleType(language, types);
|
|
850
|
+
}
|
|
851
|
+
if (types.length === 1) {
|
|
852
|
+
return symbolsForSingleType(language, types[0]);
|
|
853
|
+
}
|
|
854
|
+
return collectSymbolsForTypes(language, types);
|
|
855
|
+
}
|
|
856
|
+
__name(symbolsForTypes, "symbolsForTypes");
|
|
857
|
+
function symbolsForSingleType(language, type) {
|
|
858
|
+
let byType = singleTypeSymbolsCache.get(language);
|
|
859
|
+
if (!byType) {
|
|
860
|
+
byType = /* @__PURE__ */ new Map();
|
|
861
|
+
singleTypeSymbolsCache.set(language, byType);
|
|
862
|
+
}
|
|
863
|
+
let cached = byType.get(type);
|
|
864
|
+
if (!cached) {
|
|
865
|
+
cached = collectSymbolsForTypes(language, [type]);
|
|
866
|
+
byType.set(type, cached);
|
|
867
|
+
}
|
|
868
|
+
return cached;
|
|
869
|
+
}
|
|
870
|
+
__name(symbolsForSingleType, "symbolsForSingleType");
|
|
871
|
+
function collectSymbolsForTypes(language, types) {
|
|
872
|
+
const symbols = [];
|
|
873
|
+
const typesBySymbol = language.types;
|
|
874
|
+
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
875
|
+
if (types.includes(typesBySymbol[i2])) {
|
|
876
|
+
symbols.push(i2);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
if (types.includes("ERROR")) {
|
|
880
|
+
symbols.push(65535);
|
|
881
|
+
}
|
|
882
|
+
return Uint32Array.from(symbols);
|
|
883
|
+
}
|
|
884
|
+
__name(collectSymbolsForTypes, "collectSymbolsForTypes");
|
|
1132
885
|
|
|
1133
886
|
// src/marshal.ts
|
|
1134
887
|
function marshalNode(node, index = 0) {
|
|
@@ -1152,7 +905,11 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
|
1152
905
|
tree,
|
|
1153
906
|
startIndex: heapU32[base + 1],
|
|
1154
907
|
startPosition: { row: heapU32[base + 2], column: heapU32[base + 3] },
|
|
1155
|
-
other: heap[base + 4]
|
|
908
|
+
other: heap[base + 4],
|
|
909
|
+
endIndex: heapU32[base + 5],
|
|
910
|
+
endRow: heapU32[base + 6],
|
|
911
|
+
endColumn: heapU32[base + 7],
|
|
912
|
+
flags: heapU32[base + 8]
|
|
1156
913
|
});
|
|
1157
914
|
}
|
|
1158
915
|
__name(unmarshalNode, "unmarshalNode");
|
|
@@ -1194,20 +951,6 @@ function unmarshalRange(address) {
|
|
|
1194
951
|
};
|
|
1195
952
|
}
|
|
1196
953
|
__name(unmarshalRange, "unmarshalRange");
|
|
1197
|
-
function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
1198
|
-
const base = address >>> 2;
|
|
1199
|
-
const heap = C.HEAP32;
|
|
1200
|
-
heap[base] = edit.startPosition.row;
|
|
1201
|
-
heap[base + 1] = edit.startPosition.column;
|
|
1202
|
-
heap[base + 2] = edit.oldEndPosition.row;
|
|
1203
|
-
heap[base + 3] = edit.oldEndPosition.column;
|
|
1204
|
-
heap[base + 4] = edit.newEndPosition.row;
|
|
1205
|
-
heap[base + 5] = edit.newEndPosition.column;
|
|
1206
|
-
heap[base + 6] = edit.startIndex;
|
|
1207
|
-
heap[base + 7] = edit.oldEndIndex;
|
|
1208
|
-
heap[base + 8] = edit.newEndIndex;
|
|
1209
|
-
}
|
|
1210
|
-
__name(marshalEdit, "marshalEdit");
|
|
1211
954
|
function unmarshalLanguageMetadata(address) {
|
|
1212
955
|
const base = address >>> 2;
|
|
1213
956
|
const heap = C.HEAP32;
|
|
@@ -1400,33 +1143,6 @@ var Language = class {
|
|
|
1400
1143
|
C._ts_language_subtypes_wasm(this[0], supertype);
|
|
1401
1144
|
return unmarshalSymbols();
|
|
1402
1145
|
}
|
|
1403
|
-
/**
|
|
1404
|
-
* Get the next state id for a given state id and node type id.
|
|
1405
|
-
*/
|
|
1406
|
-
nextState(stateId, typeId) {
|
|
1407
|
-
return C._ts_language_next_state(this[0], stateId, typeId);
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Create a new lookahead iterator for this language and parse state.
|
|
1411
|
-
*
|
|
1412
|
-
* This returns `null` if state is invalid for this language.
|
|
1413
|
-
*
|
|
1414
|
-
* Iterating {@link LookaheadIterator} will yield valid symbols in the given
|
|
1415
|
-
* parse state. A newly created iterator is not positioned on a symbol, so
|
|
1416
|
-
* {@link LookaheadIterator#currentType} returns `null` until the first
|
|
1417
|
-
* iteration step.
|
|
1418
|
-
*
|
|
1419
|
-
* Lookahead iterators can be useful for generating suggestions and improving
|
|
1420
|
-
* syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
|
|
1421
|
-
* lookahead iterator on its first leaf node state. For `MISSING` nodes, a
|
|
1422
|
-
* lookahead iterator created on the previous non-extra leaf node may be
|
|
1423
|
-
* appropriate.
|
|
1424
|
-
*/
|
|
1425
|
-
lookaheadIterator(stateId) {
|
|
1426
|
-
const address = C._ts_lookahead_iterator_new(this[0], stateId);
|
|
1427
|
-
if (address) return new LookaheadIterator(INTERNAL, address, this);
|
|
1428
|
-
return null;
|
|
1429
|
-
}
|
|
1430
1146
|
/**
|
|
1431
1147
|
* Load a language from a WebAssembly module.
|
|
1432
1148
|
* The module can be provided as a path to a file, a `URL` to a file, a
|
|
@@ -1764,7 +1480,7 @@ async function Module2(moduleArg = {}) {
|
|
|
1764
1480
|
if (Module["wasmMemory"]) {
|
|
1765
1481
|
wasmMemory = Module["wasmMemory"];
|
|
1766
1482
|
} else {
|
|
1767
|
-
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] ||
|
|
1483
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 524288;
|
|
1768
1484
|
assert(INITIAL_MEMORY >= 65536, "INITIAL_MEMORY should be larger than STACK_SIZE, was " + INITIAL_MEMORY + "! (STACK_SIZE=65536)");
|
|
1769
1485
|
wasmMemory = new WebAssembly.Memory({
|
|
1770
1486
|
"initial": INITIAL_MEMORY / 65536,
|
|
@@ -2218,7 +1934,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2218
1934
|
newDSO("__main__", 0, wasmImports);
|
|
2219
1935
|
}
|
|
2220
1936
|
};
|
|
2221
|
-
var ___heap_base =
|
|
1937
|
+
var ___heap_base = 81968;
|
|
2222
1938
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
|
|
2223
1939
|
assert(alignment, "alignment argument is required");
|
|
2224
1940
|
return Math.ceil(size / alignment) * alignment;
|
|
@@ -2313,7 +2029,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2313
2029
|
}, "convertJsFunctionToWasm");
|
|
2314
2030
|
var wasmTableMirror = [];
|
|
2315
2031
|
var wasmTable = new WebAssembly.Table({
|
|
2316
|
-
"initial":
|
|
2032
|
+
"initial": 58,
|
|
2317
2033
|
"element": "anyfunc"
|
|
2318
2034
|
});
|
|
2319
2035
|
var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
|
|
@@ -2849,12 +2565,12 @@ async function Module2(moduleArg = {}) {
|
|
|
2849
2565
|
"value": "i32",
|
|
2850
2566
|
"mutable": false
|
|
2851
2567
|
}, 1024);
|
|
2852
|
-
var ___stack_high =
|
|
2853
|
-
var ___stack_low =
|
|
2568
|
+
var ___stack_high = 81968;
|
|
2569
|
+
var ___stack_low = 16432;
|
|
2854
2570
|
var ___stack_pointer = new WebAssembly.Global({
|
|
2855
2571
|
"value": "i32",
|
|
2856
2572
|
"mutable": true
|
|
2857
|
-
},
|
|
2573
|
+
}, 81968);
|
|
2858
2574
|
var ___table_base = new WebAssembly.Global({
|
|
2859
2575
|
"value": "i32",
|
|
2860
2576
|
"mutable": false
|
|
@@ -3151,22 +2867,15 @@ async function Module2(moduleArg = {}) {
|
|
|
3151
2867
|
var _ts_language_abi_version = Module["_ts_language_abi_version"] = makeInvalidEarlyAccess("_ts_language_abi_version");
|
|
3152
2868
|
var _ts_language_name = Module["_ts_language_name"] = makeInvalidEarlyAccess("_ts_language_name");
|
|
3153
2869
|
var _ts_language_field_count = Module["_ts_language_field_count"] = makeInvalidEarlyAccess("_ts_language_field_count");
|
|
3154
|
-
var _ts_language_next_state = Module["_ts_language_next_state"] = makeInvalidEarlyAccess("_ts_language_next_state");
|
|
3155
2870
|
var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = makeInvalidEarlyAccess("_ts_language_symbol_name");
|
|
3156
2871
|
var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = makeInvalidEarlyAccess("_ts_language_symbol_for_name");
|
|
3157
2872
|
var _strncmp = Module["_strncmp"] = makeInvalidEarlyAccess("_strncmp");
|
|
3158
2873
|
var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = makeInvalidEarlyAccess("_ts_language_symbol_type");
|
|
3159
2874
|
var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = makeInvalidEarlyAccess("_ts_language_field_name_for_id");
|
|
3160
|
-
var
|
|
3161
|
-
var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_delete");
|
|
3162
|
-
var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset_state");
|
|
3163
|
-
var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset");
|
|
3164
|
-
var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_next");
|
|
3165
|
-
var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_current_symbol");
|
|
2875
|
+
var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
|
|
3166
2876
|
var _ts_parser_delete = Module["_ts_parser_delete"] = makeInvalidEarlyAccess("_ts_parser_delete");
|
|
3167
2877
|
var _ts_parser_set_language = Module["_ts_parser_set_language"] = makeInvalidEarlyAccess("_ts_parser_set_language");
|
|
3168
2878
|
var _ts_parser_reset = Module["_ts_parser_reset"] = makeInvalidEarlyAccess("_ts_parser_reset");
|
|
3169
|
-
var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
|
|
3170
2879
|
var _ts_tree_cursor_current_descendant_index = Module["_ts_tree_cursor_current_descendant_index"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index");
|
|
3171
2880
|
var _ts_tree_cursor_current_depth = Module["_ts_tree_cursor_current_depth"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth");
|
|
3172
2881
|
var _ts_tree_copy = Module["_ts_tree_copy"] = makeInvalidEarlyAccess("_ts_tree_copy");
|
|
@@ -3190,9 +2899,7 @@ async function Module2(moduleArg = {}) {
|
|
|
3190
2899
|
var _ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = makeInvalidEarlyAccess("_ts_language_subtypes_wasm");
|
|
3191
2900
|
var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_root_node_wasm");
|
|
3192
2901
|
var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = makeInvalidEarlyAccess("_ts_tree_root_node_with_offset_wasm");
|
|
3193
|
-
var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = makeInvalidEarlyAccess("_ts_tree_edit_wasm");
|
|
3194
2902
|
var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_tree_included_ranges_wasm");
|
|
3195
|
-
var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = makeInvalidEarlyAccess("_ts_tree_get_changed_ranges_wasm");
|
|
3196
2903
|
var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_new_wasm");
|
|
3197
2904
|
var _ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_copy_wasm");
|
|
3198
2905
|
var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_delete_wasm");
|
|
@@ -3206,14 +2913,10 @@ async function Module2(moduleArg = {}) {
|
|
|
3206
2913
|
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_previous_sibling_wasm");
|
|
3207
2914
|
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_descendant_wasm");
|
|
3208
2915
|
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_parent_wasm");
|
|
3209
|
-
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");
|
|
3210
2916
|
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_id_wasm");
|
|
3211
2917
|
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_position_wasm");
|
|
3212
2918
|
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
|
|
3213
|
-
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
|
|
3214
|
-
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
|
|
3215
2919
|
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
|
|
3216
|
-
var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = makeInvalidEarlyAccess("_ts_node_symbol_wasm");
|
|
3217
2920
|
var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_child_wasm");
|
|
3218
2921
|
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");
|
|
3219
2922
|
var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = makeInvalidEarlyAccess("_ts_node_children_by_field_id_wasm");
|
|
@@ -3236,20 +2939,10 @@ async function Module2(moduleArg = {}) {
|
|
|
3236
2939
|
var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_index_wasm");
|
|
3237
2940
|
var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_for_position_wasm");
|
|
3238
2941
|
var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_position_wasm");
|
|
3239
|
-
var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = makeInvalidEarlyAccess("_ts_node_end_point_wasm");
|
|
3240
|
-
var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = makeInvalidEarlyAccess("_ts_node_end_index_wasm");
|
|
3241
2942
|
var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = makeInvalidEarlyAccess("_ts_node_to_string_wasm");
|
|
3242
2943
|
var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = makeInvalidEarlyAccess("_ts_node_children_wasm");
|
|
3243
2944
|
var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = makeInvalidEarlyAccess("_ts_node_named_children_wasm");
|
|
3244
2945
|
var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = makeInvalidEarlyAccess("_ts_node_descendants_of_type_wasm");
|
|
3245
|
-
var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = makeInvalidEarlyAccess("_ts_node_is_named_wasm");
|
|
3246
|
-
var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = makeInvalidEarlyAccess("_ts_node_has_changes_wasm");
|
|
3247
|
-
var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = makeInvalidEarlyAccess("_ts_node_has_error_wasm");
|
|
3248
|
-
var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = makeInvalidEarlyAccess("_ts_node_is_error_wasm");
|
|
3249
|
-
var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = makeInvalidEarlyAccess("_ts_node_is_missing_wasm");
|
|
3250
|
-
var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = makeInvalidEarlyAccess("_ts_node_is_extra_wasm");
|
|
3251
|
-
var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_parse_state_wasm");
|
|
3252
|
-
var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_next_parse_state_wasm");
|
|
3253
2946
|
var _memcpy = Module["_memcpy"] = makeInvalidEarlyAccess("_memcpy");
|
|
3254
2947
|
var _memmove = Module["_memmove"] = makeInvalidEarlyAccess("_memmove");
|
|
3255
2948
|
var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
|
|
@@ -3291,22 +2984,15 @@ async function Module2(moduleArg = {}) {
|
|
|
3291
2984
|
Module["_ts_language_abi_version"] = _ts_language_abi_version = createExportWrapper("ts_language_abi_version", 1);
|
|
3292
2985
|
Module["_ts_language_name"] = _ts_language_name = createExportWrapper("ts_language_name", 1);
|
|
3293
2986
|
Module["_ts_language_field_count"] = _ts_language_field_count = createExportWrapper("ts_language_field_count", 1);
|
|
3294
|
-
Module["_ts_language_next_state"] = _ts_language_next_state = createExportWrapper("ts_language_next_state", 3);
|
|
3295
2987
|
Module["_ts_language_symbol_name"] = _ts_language_symbol_name = createExportWrapper("ts_language_symbol_name", 2);
|
|
3296
2988
|
Module["_ts_language_symbol_for_name"] = _ts_language_symbol_for_name = createExportWrapper("ts_language_symbol_for_name", 4);
|
|
3297
2989
|
Module["_strncmp"] = _strncmp = createExportWrapper("strncmp", 3);
|
|
3298
2990
|
Module["_ts_language_symbol_type"] = _ts_language_symbol_type = createExportWrapper("ts_language_symbol_type", 2);
|
|
3299
2991
|
Module["_ts_language_field_name_for_id"] = _ts_language_field_name_for_id = createExportWrapper("ts_language_field_name_for_id", 2);
|
|
3300
|
-
Module["
|
|
3301
|
-
Module["_ts_lookahead_iterator_delete"] = _ts_lookahead_iterator_delete = createExportWrapper("ts_lookahead_iterator_delete", 1);
|
|
3302
|
-
Module["_ts_lookahead_iterator_reset_state"] = _ts_lookahead_iterator_reset_state = createExportWrapper("ts_lookahead_iterator_reset_state", 2);
|
|
3303
|
-
Module["_ts_lookahead_iterator_reset"] = _ts_lookahead_iterator_reset = createExportWrapper("ts_lookahead_iterator_reset", 3);
|
|
3304
|
-
Module["_ts_lookahead_iterator_next"] = _ts_lookahead_iterator_next = createExportWrapper("ts_lookahead_iterator_next", 1);
|
|
3305
|
-
Module["_ts_lookahead_iterator_current_symbol"] = _ts_lookahead_iterator_current_symbol = createExportWrapper("ts_lookahead_iterator_current_symbol", 1);
|
|
2992
|
+
Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
|
|
3306
2993
|
Module["_ts_parser_delete"] = _ts_parser_delete = createExportWrapper("ts_parser_delete", 1);
|
|
3307
2994
|
Module["_ts_parser_set_language"] = _ts_parser_set_language = createExportWrapper("ts_parser_set_language", 2);
|
|
3308
2995
|
Module["_ts_parser_reset"] = _ts_parser_reset = createExportWrapper("ts_parser_reset", 1);
|
|
3309
|
-
Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
|
|
3310
2996
|
Module["_ts_tree_cursor_current_descendant_index"] = _ts_tree_cursor_current_descendant_index = createExportWrapper("ts_tree_cursor_current_descendant_index", 1);
|
|
3311
2997
|
Module["_ts_tree_cursor_current_depth"] = _ts_tree_cursor_current_depth = createExportWrapper("ts_tree_cursor_current_depth", 1);
|
|
3312
2998
|
Module["_ts_tree_copy"] = _ts_tree_copy = createExportWrapper("ts_tree_copy", 1);
|
|
@@ -3318,7 +3004,7 @@ async function Module2(moduleArg = {}) {
|
|
|
3318
3004
|
Module["_ts_scanner_realloc_wasm"] = _ts_scanner_realloc_wasm = createExportWrapper("ts_scanner_realloc_wasm", 2);
|
|
3319
3005
|
Module["_ts_parser_new_wasm"] = _ts_parser_new_wasm = createExportWrapper("ts_parser_new_wasm", 0);
|
|
3320
3006
|
Module["_ts_parser_enable_logger_wasm"] = _ts_parser_enable_logger_wasm = createExportWrapper("ts_parser_enable_logger_wasm", 2);
|
|
3321
|
-
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm",
|
|
3007
|
+
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 2);
|
|
3322
3008
|
Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm", 2);
|
|
3323
3009
|
Module["_ts_parser_last_parse_operations_wasm"] = _ts_parser_last_parse_operations_wasm = createExportWrapper("ts_parser_last_parse_operations_wasm", 1);
|
|
3324
3010
|
Module["_ts_parser_abort_limited_wasm"] = _ts_parser_abort_limited_wasm = createExportWrapper("ts_parser_abort_limited_wasm", 0);
|
|
@@ -3330,9 +3016,7 @@ async function Module2(moduleArg = {}) {
|
|
|
3330
3016
|
Module["_ts_language_subtypes_wasm"] = _ts_language_subtypes_wasm = createExportWrapper("ts_language_subtypes_wasm", 2);
|
|
3331
3017
|
Module["_ts_tree_root_node_wasm"] = _ts_tree_root_node_wasm = createExportWrapper("ts_tree_root_node_wasm", 1);
|
|
3332
3018
|
Module["_ts_tree_root_node_with_offset_wasm"] = _ts_tree_root_node_with_offset_wasm = createExportWrapper("ts_tree_root_node_with_offset_wasm", 1);
|
|
3333
|
-
Module["_ts_tree_edit_wasm"] = _ts_tree_edit_wasm = createExportWrapper("ts_tree_edit_wasm", 1);
|
|
3334
3019
|
Module["_ts_tree_included_ranges_wasm"] = _ts_tree_included_ranges_wasm = createExportWrapper("ts_tree_included_ranges_wasm", 1);
|
|
3335
|
-
Module["_ts_tree_get_changed_ranges_wasm"] = _ts_tree_get_changed_ranges_wasm = createExportWrapper("ts_tree_get_changed_ranges_wasm", 2);
|
|
3336
3020
|
Module["_ts_tree_cursor_new_wasm"] = _ts_tree_cursor_new_wasm = createExportWrapper("ts_tree_cursor_new_wasm", 1);
|
|
3337
3021
|
Module["_ts_tree_cursor_copy_wasm"] = _ts_tree_cursor_copy_wasm = createExportWrapper("ts_tree_cursor_copy_wasm", 1);
|
|
3338
3022
|
Module["_ts_tree_cursor_delete_wasm"] = _ts_tree_cursor_delete_wasm = createExportWrapper("ts_tree_cursor_delete_wasm", 1);
|
|
@@ -3346,14 +3030,10 @@ async function Module2(moduleArg = {}) {
|
|
|
3346
3030
|
Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
|
|
3347
3031
|
Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
|
|
3348
3032
|
Module["_ts_tree_cursor_goto_parent_wasm"] = _ts_tree_cursor_goto_parent_wasm = createExportWrapper("ts_tree_cursor_goto_parent_wasm", 1);
|
|
3349
|
-
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);
|
|
3350
3033
|
Module["_ts_tree_cursor_current_node_id_wasm"] = _ts_tree_cursor_current_node_id_wasm = createExportWrapper("ts_tree_cursor_current_node_id_wasm", 1);
|
|
3351
3034
|
Module["_ts_tree_cursor_start_position_wasm"] = _ts_tree_cursor_start_position_wasm = createExportWrapper("ts_tree_cursor_start_position_wasm", 1);
|
|
3352
3035
|
Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
|
|
3353
|
-
Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
|
|
3354
|
-
Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
|
|
3355
3036
|
Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
|
|
3356
|
-
Module["_ts_node_symbol_wasm"] = _ts_node_symbol_wasm = createExportWrapper("ts_node_symbol_wasm", 1);
|
|
3357
3037
|
Module["_ts_node_field_name_for_child_wasm"] = _ts_node_field_name_for_child_wasm = createExportWrapper("ts_node_field_name_for_child_wasm", 2);
|
|
3358
3038
|
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);
|
|
3359
3039
|
Module["_ts_node_children_by_field_id_wasm"] = _ts_node_children_by_field_id_wasm = createExportWrapper("ts_node_children_by_field_id_wasm", 2);
|
|
@@ -3376,20 +3056,10 @@ async function Module2(moduleArg = {}) {
|
|
|
3376
3056
|
Module["_ts_node_named_descendant_for_index_wasm"] = _ts_node_named_descendant_for_index_wasm = createExportWrapper("ts_node_named_descendant_for_index_wasm", 1);
|
|
3377
3057
|
Module["_ts_node_descendant_for_position_wasm"] = _ts_node_descendant_for_position_wasm = createExportWrapper("ts_node_descendant_for_position_wasm", 1);
|
|
3378
3058
|
Module["_ts_node_named_descendant_for_position_wasm"] = _ts_node_named_descendant_for_position_wasm = createExportWrapper("ts_node_named_descendant_for_position_wasm", 1);
|
|
3379
|
-
Module["_ts_node_end_point_wasm"] = _ts_node_end_point_wasm = createExportWrapper("ts_node_end_point_wasm", 1);
|
|
3380
|
-
Module["_ts_node_end_index_wasm"] = _ts_node_end_index_wasm = createExportWrapper("ts_node_end_index_wasm", 1);
|
|
3381
3059
|
Module["_ts_node_to_string_wasm"] = _ts_node_to_string_wasm = createExportWrapper("ts_node_to_string_wasm", 1);
|
|
3382
3060
|
Module["_ts_node_children_wasm"] = _ts_node_children_wasm = createExportWrapper("ts_node_children_wasm", 1);
|
|
3383
3061
|
Module["_ts_node_named_children_wasm"] = _ts_node_named_children_wasm = createExportWrapper("ts_node_named_children_wasm", 1);
|
|
3384
3062
|
Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 3);
|
|
3385
|
-
Module["_ts_node_is_named_wasm"] = _ts_node_is_named_wasm = createExportWrapper("ts_node_is_named_wasm", 1);
|
|
3386
|
-
Module["_ts_node_has_changes_wasm"] = _ts_node_has_changes_wasm = createExportWrapper("ts_node_has_changes_wasm", 1);
|
|
3387
|
-
Module["_ts_node_has_error_wasm"] = _ts_node_has_error_wasm = createExportWrapper("ts_node_has_error_wasm", 1);
|
|
3388
|
-
Module["_ts_node_is_error_wasm"] = _ts_node_is_error_wasm = createExportWrapper("ts_node_is_error_wasm", 1);
|
|
3389
|
-
Module["_ts_node_is_missing_wasm"] = _ts_node_is_missing_wasm = createExportWrapper("ts_node_is_missing_wasm", 1);
|
|
3390
|
-
Module["_ts_node_is_extra_wasm"] = _ts_node_is_extra_wasm = createExportWrapper("ts_node_is_extra_wasm", 1);
|
|
3391
|
-
Module["_ts_node_parse_state_wasm"] = _ts_node_parse_state_wasm = createExportWrapper("ts_node_parse_state_wasm", 1);
|
|
3392
|
-
Module["_ts_node_next_parse_state_wasm"] = _ts_node_next_parse_state_wasm = createExportWrapper("ts_node_next_parse_state_wasm", 1);
|
|
3393
3063
|
Module["_memcpy"] = _memcpy = createExportWrapper("memcpy", 3);
|
|
3394
3064
|
Module["_memmove"] = _memmove = createExportWrapper("memmove", 3);
|
|
3395
3065
|
Module["_memset"] = _memset = createExportWrapper("memset", 3);
|
|
@@ -3457,8 +3127,6 @@ async function Module2(moduleArg = {}) {
|
|
|
3457
3127
|
/** @export */
|
|
3458
3128
|
invoke_iiii,
|
|
3459
3129
|
/** @export */
|
|
3460
|
-
invoke_iiiii,
|
|
3461
|
-
/** @export */
|
|
3462
3130
|
invoke_ji,
|
|
3463
3131
|
/** @export */
|
|
3464
3132
|
invoke_vi,
|
|
@@ -3531,17 +3199,6 @@ async function Module2(moduleArg = {}) {
|
|
|
3531
3199
|
}
|
|
3532
3200
|
}
|
|
3533
3201
|
__name(invoke_iiii, "invoke_iiii");
|
|
3534
|
-
function invoke_iiiii(index, a1, a2, a3, a4) {
|
|
3535
|
-
var sp = stackSave();
|
|
3536
|
-
try {
|
|
3537
|
-
return getWasmTableEntry(index)(a1, a2, a3, a4);
|
|
3538
|
-
} catch (e) {
|
|
3539
|
-
stackRestore(sp);
|
|
3540
|
-
if (e !== e + 0) throw e;
|
|
3541
|
-
_setThrew(1, 0);
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
__name(invoke_iiiii, "invoke_iiiii");
|
|
3545
3202
|
function invoke_iii(index, a1, a2) {
|
|
3546
3203
|
var sp = stackSave();
|
|
3547
3204
|
try {
|
|
@@ -3582,7 +3239,7 @@ async function Module2(moduleArg = {}) {
|
|
|
3582
3239
|
}
|
|
3583
3240
|
__name(callMain, "callMain");
|
|
3584
3241
|
function stackCheckInit() {
|
|
3585
|
-
_emscripten_stack_set_limits(
|
|
3242
|
+
_emscripten_stack_set_limits(81968, 16432);
|
|
3586
3243
|
writeStackCookie();
|
|
3587
3244
|
}
|
|
3588
3245
|
__name(stackCheckInit, "stackCheckInit");
|
|
@@ -3705,7 +3362,7 @@ function assertSupportedLanguage(language) {
|
|
|
3705
3362
|
}
|
|
3706
3363
|
}
|
|
3707
3364
|
__name(assertSupportedLanguage, "assertSupportedLanguage");
|
|
3708
|
-
var
|
|
3365
|
+
var finalizer3 = newFinalizer((addresses) => {
|
|
3709
3366
|
C._ts_parser_delete(addresses[0]);
|
|
3710
3367
|
C._free(addresses[1]);
|
|
3711
3368
|
});
|
|
@@ -3746,7 +3403,7 @@ var Parser = class {
|
|
|
3746
3403
|
*/
|
|
3747
3404
|
constructor() {
|
|
3748
3405
|
this.initialize();
|
|
3749
|
-
|
|
3406
|
+
finalizer3?.register(this, [this[0], this[1]], this);
|
|
3750
3407
|
}
|
|
3751
3408
|
/** @internal */
|
|
3752
3409
|
initialize() {
|
|
@@ -3761,7 +3418,7 @@ var Parser = class {
|
|
|
3761
3418
|
}
|
|
3762
3419
|
/** Delete the parser, freeing its resources. */
|
|
3763
3420
|
delete() {
|
|
3764
|
-
|
|
3421
|
+
finalizer3?.unregister(this);
|
|
3765
3422
|
C._ts_parser_delete(this[0]);
|
|
3766
3423
|
C._free(this[1]);
|
|
3767
3424
|
this[0] = 0;
|
|
@@ -3796,10 +3453,6 @@ var Parser = class {
|
|
|
3796
3453
|
*
|
|
3797
3454
|
* @param {string | ParseCallback} callback - The UTF8-encoded text to parse or a callback function.
|
|
3798
3455
|
*
|
|
3799
|
-
* @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the
|
|
3800
|
-
* document has changed since `oldTree` was created, then you must edit `oldTree` to match
|
|
3801
|
-
* the new text using {@link Tree#edit}.
|
|
3802
|
-
*
|
|
3803
3456
|
* @param {ParseOptions} [options] - Options for parsing the text.
|
|
3804
3457
|
* This can be used to set the included ranges, or a progress callback.
|
|
3805
3458
|
*
|
|
@@ -3808,7 +3461,7 @@ var Parser = class {
|
|
|
3808
3461
|
* - The progress callback returned true.
|
|
3809
3462
|
* - The memory limit was reached or the operation limit was exceeded.
|
|
3810
3463
|
*/
|
|
3811
|
-
parse(callback,
|
|
3464
|
+
parse(callback, options) {
|
|
3812
3465
|
const maxMemoryBytes = validateMemoryLimit(options?.maxMemoryBytes);
|
|
3813
3466
|
const maxOperations = validateOperationLimit(options?.maxOperations);
|
|
3814
3467
|
if (typeof callback !== "string" && typeof callback !== "function") {
|
|
@@ -3820,7 +3473,7 @@ var Parser = class {
|
|
|
3820
3473
|
this.syncLogger();
|
|
3821
3474
|
this.lastParseOperations = 0;
|
|
3822
3475
|
try {
|
|
3823
|
-
const treeAddress = this.runParse(
|
|
3476
|
+
const treeAddress = this.runParse(options, maxMemoryBytes, maxOperations);
|
|
3824
3477
|
if (!treeAddress) return null;
|
|
3825
3478
|
if (!this.language) throw new Error("Parser must have a language to parse");
|
|
3826
3479
|
return new Tree2(INTERNAL, treeAddress, this.language, callback);
|
|
@@ -3845,7 +3498,7 @@ var Parser = class {
|
|
|
3845
3498
|
}
|
|
3846
3499
|
}
|
|
3847
3500
|
/** @internal */
|
|
3848
|
-
runParse(
|
|
3501
|
+
runParse(options, maxMemoryBytes, maxOperations) {
|
|
3849
3502
|
if (maxMemoryBytes !== void 0 && !C.treeSitterSetMemoryLimit(maxMemoryBytes)) {
|
|
3850
3503
|
return 0;
|
|
3851
3504
|
}
|
|
@@ -3854,7 +3507,7 @@ var Parser = class {
|
|
|
3854
3507
|
if (rangeCount && !rangeAddress) return 0;
|
|
3855
3508
|
marshalParseInputs(maxOperations, rangeAddress, rangeCount, options?.progressCallback ? 1 : 0);
|
|
3856
3509
|
try {
|
|
3857
|
-
return maxMemoryBytes === void 0 ? this.executeOrdinaryParse(
|
|
3510
|
+
return maxMemoryBytes === void 0 ? this.executeOrdinaryParse() : this.executeLimitedParse();
|
|
3858
3511
|
} finally {
|
|
3859
3512
|
this.lastParseOperations = unmarshalOperationCount();
|
|
3860
3513
|
}
|
|
@@ -3863,9 +3516,9 @@ var Parser = class {
|
|
|
3863
3516
|
}
|
|
3864
3517
|
}
|
|
3865
3518
|
/** @internal */
|
|
3866
|
-
executeOrdinaryParse(
|
|
3519
|
+
executeOrdinaryParse() {
|
|
3867
3520
|
try {
|
|
3868
|
-
return C._ts_parser_parse_wasm(this[0], this[1]
|
|
3521
|
+
return C._ts_parser_parse_wasm(this[0], this[1]);
|
|
3869
3522
|
} catch (error) {
|
|
3870
3523
|
C._ts_parser_last_parse_operations_wasm(this[0]);
|
|
3871
3524
|
throw error;
|
|
@@ -3967,10 +3620,8 @@ function clearCallbacks() {
|
|
|
3967
3620
|
}
|
|
3968
3621
|
__name(clearCallbacks, "clearCallbacks");
|
|
3969
3622
|
export {
|
|
3970
|
-
Edit,
|
|
3971
3623
|
LANGUAGE_VERSION,
|
|
3972
3624
|
Language,
|
|
3973
|
-
LookaheadIterator,
|
|
3974
3625
|
MIN_COMPATIBLE_VERSION,
|
|
3975
3626
|
Node,
|
|
3976
3627
|
Parser,
|