@kerebron/tree-sitter 0.4.26 → 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,252 +0,0 @@
1
- import { C, INTERNAL, SIZE_OF_INT, SIZE_OF_RANGE, setModule } from "./constants.js";
2
- import { Language } from "./language.js";
3
- import { marshalRange, unmarshalRange } from "./marshal.js";
4
- import { checkModule, initializeBinding } from "./bindings.js";
5
- import { Tree } from "./tree.js";
6
- /**
7
- * Options for parsing
8
- *
9
- * The `includedRanges` property is an array of {@link Range} objects that
10
- * represent the ranges of text that the parser should include when parsing.
11
- *
12
- * The `progressCallback` property is a function that is called periodically
13
- * during parsing to check whether parsing should be cancelled.
14
- *
15
- * See {@link Parser#parse} for more information.
16
- */
17
- /**
18
- * A stateful object that is passed into the progress callback {@link ParseOptions#progressCallback}
19
- * to provide the current state of the parser.
20
- */
21
- /**
22
- * @internal
23
- *
24
- * Global variable for transferring data across the FFI boundary
25
- */
26
- export let TRANSFER_BUFFER;
27
- /**
28
- * The latest ABI version that is supported by the current version of the
29
- * library.
30
- *
31
- * When Languages are generated by the Tree-sitter CLI, they are
32
- * assigned an ABI version number that corresponds to the current CLI version.
33
- * The Tree-sitter library is generally backwards-compatible with languages
34
- * generated using older CLI versions, but is not forwards-compatible.
35
- */
36
- export let LANGUAGE_VERSION;
37
- /**
38
- * The earliest ABI version that is supported by the current version of the
39
- * library.
40
- */
41
- export let MIN_COMPATIBLE_VERSION;
42
- /**
43
- * A stateful object that is used to produce a {@link Tree} based on some
44
- * source code.
45
- */
46
- export class Parser {
47
- /** @internal */
48
- [0] = 0; // Internal handle for Wasm
49
- /** @internal */
50
- [1] = 0; // Internal handle for Wasm
51
- /** @internal */
52
- logCallback = null;
53
- /** The parser's current language. */
54
- language = null;
55
- /**
56
- * This must always be called before creating a Parser.
57
- *
58
- * You can optionally pass in options to configure the Wasm module, the most common
59
- * one being `locateFile` to help the module find the `.wasm` file.
60
- */
61
- static async init(moduleOptions) {
62
- setModule(await initializeBinding(moduleOptions));
63
- TRANSFER_BUFFER = C._ts_init();
64
- LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, "i32");
65
- MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
66
- }
67
- /**
68
- * Create a new parser.
69
- */
70
- constructor() {
71
- this.initialize();
72
- }
73
- /** @internal */
74
- initialize() {
75
- if (!checkModule()) {
76
- throw new Error("cannot construct a Parser before calling `init()`");
77
- }
78
- C._ts_parser_new_wasm();
79
- this[0] = C.getValue(TRANSFER_BUFFER, "i32");
80
- this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
81
- }
82
- /** Delete the parser, freeing its resources. */
83
- delete() {
84
- C._ts_parser_delete(this[0]);
85
- C._free(this[1]);
86
- this[0] = 0;
87
- this[1] = 0;
88
- }
89
- /**
90
- * Set the language that the parser should use for parsing.
91
- *
92
- * If the language was not successfully assigned, an error will be thrown.
93
- * This happens if the language was generated with an incompatible
94
- * version of the Tree-sitter CLI. Check the language's version using
95
- * {@link Language#version} and compare it to this library's
96
- * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.
97
- */
98
- setLanguage(language) {
99
- let address;
100
- if (!language) {
101
- address = 0;
102
- this.language = null;
103
- }
104
- else if (language.constructor === Language) {
105
- address = language[0];
106
- const version = C._ts_language_version(address);
107
- if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
108
- throw new Error(`Incompatible language version ${version}. ` + `Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`);
109
- }
110
- this.language = language;
111
- }
112
- else {
113
- throw new Error("Argument must be a Language");
114
- }
115
- C._ts_parser_set_language(this[0], address);
116
- return this;
117
- }
118
- /**
119
- * Parse a slice of UTF8 text.
120
- *
121
- * @param {string | ParseCallback} callback - The UTF8-encoded text to parse or a callback function.
122
- *
123
- * @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the
124
- * document has changed since `oldTree` was created, then you must edit `oldTree` to match
125
- * the new text using {@link Tree#edit}.
126
- *
127
- * @param {ParseOptions} [options] - Options for parsing the text.
128
- * This can be used to set the included ranges, or a progress callback.
129
- *
130
- * @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:
131
- * - The parser has not yet had a language assigned with {@link Parser#setLanguage}.
132
- * - The progress callback returned true.
133
- */
134
- parse(callback, oldTree, options) {
135
- if (typeof callback === "string") {
136
- C.currentParseCallback = (index) => callback.slice(index);
137
- }
138
- else if (typeof callback === "function") {
139
- C.currentParseCallback = callback;
140
- }
141
- else {
142
- throw new Error("Argument must be a string or a function");
143
- }
144
- if (options?.progressCallback) {
145
- C.currentProgressCallback = options.progressCallback;
146
- }
147
- else {
148
- C.currentProgressCallback = null;
149
- }
150
- if (this.logCallback) {
151
- C.currentLogCallback = this.logCallback;
152
- C._ts_parser_enable_logger_wasm(this[0], 1);
153
- }
154
- else {
155
- C.currentLogCallback = null;
156
- C._ts_parser_enable_logger_wasm(this[0], 0);
157
- }
158
- let rangeCount = 0;
159
- let rangeAddress = 0;
160
- if (options?.includedRanges) {
161
- rangeCount = options.includedRanges.length;
162
- rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
163
- let address = rangeAddress;
164
- for (let i = 0; i < rangeCount; i++) {
165
- marshalRange(address, options.includedRanges[i]);
166
- address += SIZE_OF_RANGE;
167
- }
168
- }
169
- const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount);
170
- if (!treeAddress) {
171
- C.currentParseCallback = null;
172
- C.currentLogCallback = null;
173
- C.currentProgressCallback = null;
174
- return null;
175
- }
176
- if (!this.language) {
177
- throw new Error("Parser must have a language to parse");
178
- }
179
- const result = new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);
180
- C.currentParseCallback = null;
181
- C.currentLogCallback = null;
182
- C.currentProgressCallback = null;
183
- return result;
184
- }
185
- /**
186
- * Instruct the parser to start the next parse from the beginning.
187
- *
188
- * If the parser previously failed because of a timeout, cancellation,
189
- * or callback, then by default, it will resume where it left off on the
190
- * next call to {@link Parser#parse} or other parsing functions.
191
- * If you don't want to resume, and instead intend to use this parser to
192
- * parse some other document, you must call `reset` first.
193
- */
194
- reset() {
195
- C._ts_parser_reset(this[0]);
196
- }
197
- /** Get the ranges of text that the parser will include when parsing. */
198
- getIncludedRanges() {
199
- C._ts_parser_included_ranges_wasm(this[0]);
200
- const count = C.getValue(TRANSFER_BUFFER, "i32");
201
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
202
- const result = new Array(count);
203
- if (count > 0) {
204
- let address = buffer;
205
- for (let i = 0; i < count; i++) {
206
- result[i] = unmarshalRange(address);
207
- address += SIZE_OF_RANGE;
208
- }
209
- C._free(buffer);
210
- }
211
- return result;
212
- }
213
- /**
214
- * @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse}
215
- *
216
- * Get the duration in microseconds that parsing is allowed to take.
217
- *
218
- * This is set via {@link Parser#setTimeoutMicros}.
219
- */
220
- getTimeoutMicros() {
221
- return C._ts_parser_timeout_micros(this[0]);
222
- }
223
- /**
224
- * @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse}
225
- *
226
- * Set the maximum duration in microseconds that parsing should be allowed
227
- * to take before halting.
228
- *
229
- * If parsing takes longer than this, it will halt early, returning `null`.
230
- * See {@link Parser#parse} for more information.
231
- */
232
- setTimeoutMicros(timeout) {
233
- C._ts_parser_set_timeout_micros(this[0], 0, timeout);
234
- }
235
- /** Set the logging callback that a parser should use during parsing. */
236
- setLogger(callback) {
237
- if (!callback) {
238
- this.logCallback = null;
239
- }
240
- else if (typeof callback !== "function") {
241
- throw new Error("Logger callback must be a function");
242
- }
243
- else {
244
- this.logCallback = callback;
245
- }
246
- return this;
247
- }
248
- /** Get the parser's current logger. */
249
- getLogger() {
250
- return this.logCallback;
251
- }
252
- }
@@ -1,134 +0,0 @@
1
- export namespace CaptureQuantifier {
2
- let Zero: number;
3
- let ZeroOrOne: number;
4
- let ZeroOrMore: number;
5
- let One: number;
6
- let OneOrMore: number;
7
- }
8
- export namespace QueryErrorKind {
9
- let Syntax: number;
10
- let NodeName: number;
11
- let FieldName: number;
12
- let CaptureName: number;
13
- let PatternStructure: number;
14
- }
15
- /** An error that occurred while parsing a query string. */
16
- /** Information about a {@link QueryError}. */
17
- /** Error thrown when parsing a tree-sitter query fails */
18
- export class QueryError extends Error {
19
- /** Formats an error message based on the error kind and info */
20
- static formatMessage(kind: any, info: any): string | undefined;
21
- constructor(kind: any, info: any, index: any, length: any);
22
- }
23
- export class Query {
24
- /**
25
- * Create a new query from a string containing one or more S-expression
26
- * patterns.
27
- *
28
- * The query is associated with a particular language, and can only be run
29
- * on syntax nodes parsed with that language. References to Queries can be
30
- * shared between multiple threads.
31
- *
32
- * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
33
- */
34
- constructor(language: any, source: any);
35
- /** @internal */
36
- 0: number;
37
- /** @internal */
38
- exceededMatchLimit: boolean;
39
- /** @internal */
40
- textPredicates: any[];
41
- /** The names of the captures used in the query. */
42
- captureNames: any[];
43
- /** The quantifiers of the captures used in the query. */
44
- captureQuantifiers: any[];
45
- /**
46
- * The other user-defined predicates associated with the given index.
47
- *
48
- * This includes predicates with operators other than:
49
- * - `match?`
50
- * - `eq?` and `not-eq?`
51
- * - `any-of?` and `not-any-of?`
52
- * - `is?` and `is-not?`
53
- * - `set!`
54
- */
55
- predicates: any[];
56
- /** The properties for predicates with the operator `set!`. */
57
- setProperties: any[];
58
- /** The properties for predicates with the operator `is?`. */
59
- assertedProperties: any[];
60
- /** The properties for predicates with the operator `is-not?`. */
61
- refutedProperties: any[];
62
- /** The maximum number of in-progress matches for this cursor. */
63
- matchLimit: any;
64
- /** Delete the query, freeing its resources. */
65
- delete(): void;
66
- /**
67
- * Iterate over all of the matches in the order that they were found.
68
- *
69
- * Each match contains the index of the pattern that matched, and a list of
70
- * captures. Because multiple patterns can match the same set of nodes,
71
- * one match may contain captures that appear *before* some of the
72
- * captures from a previous match.
73
- *
74
- * @param {Node} node - The node to execute the query on.
75
- *
76
- * @param {QueryOptions} options - Options for query execution.
77
- */
78
- matches(node: Node, options?: QueryOptions): any[];
79
- /**
80
- * Iterate over all of the individual captures in the order that they
81
- * appear.
82
- *
83
- * This is useful if you don't care about which pattern matched, and just
84
- * want a single, ordered sequence of captures.
85
- *
86
- * @param {Node} node - The node to execute the query on.
87
- *
88
- * @param {QueryOptions} options - Options for query execution.
89
- */
90
- captures(node: Node, options?: QueryOptions): any[];
91
- /** Get the predicates for a given pattern. */
92
- predicatesForPattern(patternIndex: any): any;
93
- /**
94
- * Disable a certain capture within a query.
95
- *
96
- * This prevents the capture from being returned in matches, and also
97
- * avoids any resource usage associated with recording the capture.
98
- */
99
- disableCapture(captureName: any): void;
100
- /**
101
- * Disable a certain pattern within a query.
102
- *
103
- * This prevents the pattern from matching, and also avoids any resource
104
- * usage associated with the pattern. This throws an error if the pattern
105
- * index is out of bounds.
106
- */
107
- disablePattern(patternIndex: any): void;
108
- /**
109
- * Check if, on its last execution, this cursor exceeded its maximum number
110
- * of in-progress matches.
111
- */
112
- didExceedMatchLimit(): boolean;
113
- /** Get the byte offset where the given pattern starts in the query's source. */
114
- startIndexForPattern(patternIndex: any): any;
115
- /** Get the byte offset where the given pattern ends in the query's source. */
116
- endIndexForPattern(patternIndex: any): any;
117
- /** Get the number of patterns in the query. */
118
- patternCount(): any;
119
- /** Get the index for a given capture name. */
120
- captureIndexForName(captureName: any): number;
121
- /** Check if a given pattern within a query has a single root node. */
122
- isPatternRooted(patternIndex: any): boolean;
123
- /** Check if a given pattern within a query has a single root node. */
124
- isPatternNonLocal(patternIndex: any): boolean;
125
- /**
126
- * Check if a given step in a query is 'definite'.
127
- *
128
- * A query step is 'definite' if its parent pattern will be guaranteed to
129
- * match successfully once it reaches the step.
130
- */
131
- isPatternGuaranteedAtStep(byteIndex: any): boolean;
132
- }
133
- import { Node } from "./node.js";
134
- //# sourceMappingURL=query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../src/deno-tree-sitter/main/tree_sitter/query.js"],"names":[],"mappings":";;;;;;;;;;;;;;AA+EA,2DAA2D;AAC3D,8CAA8C;AAC9C,0DAA0D;AAC1D;IAMI,gEAAgE;IAChE,+DAaC;IAnBD,2DAGC;CAiBJ;AAqMD;IAwCI;;;;;;;;;OASG;IACH,wCAwGC;IAzJD,gBAAgB;IAChB,UAAO;IAEP,gBAAgB;IAChB,4BAAkB;IAElB,gBAAgB;IAChB,sBAAc;IAEd,mDAAmD;IACnD,oBAAY;IAEZ,yDAAyD;IACzD,0BAAkB;IAElB;;;;;;;;;OASG;IACH,kBAAU;IAEV,8DAA8D;IAC9D,qBAAa;IAEb,6DAA6D;IAC7D,0BAAkB;IAElB,iEAAiE;IACjE,yBAAiB;IAEjB,iEAAiE;IACjE,gBAAU;IAsHV,+CAA+C;IAC/C,eAGC;IAED;;;;;;;;;;;OAWG;IACH,cAJW,IAAI,YAEJ,YAAY,SAkEtB;IAED;;;;;;;;;;OAUG;IACH,eAJW,IAAI,YAEJ,YAAY,SAmEtB;IAED,8CAA8C;IAC9C,6CAEC;IAED;;;;;OAKG;IACH,uCAMC;IAED;;;;;;OAMG;IACH,wCAKC;IAED;;;OAGG;IACH,+BAEC;IAED,gFAAgF;IAChF,6CAKC;IAED,8EAA8E;IAC9E,2CAKC;IAED,+CAA+C;IAC/C,oBAEC;IAED,8CAA8C;IAC9C,8CAEC;IAED,sEAAsE;IACtE,4CAEC;IAED,sEAAsE;IACtE,8CAEC;IAED;;;;;OAKG;IACH,mDAEC;CACJ;qBA/rBoB,WAAW"}