@kerebron/tree-sitter 0.4.6
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/LICENSE +23 -0
- package/README.md +4 -0
- package/esm/_dnt.polyfills.d.ts +101 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +127 -0
- package/esm/deno-tree-sitter/main/extended/base_node.d.ts +48 -0
- package/esm/deno-tree-sitter/main/extended/base_node.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extended/base_node.js +154 -0
- package/esm/deno-tree-sitter/main/extended/node_extended.d.ts +237 -0
- package/esm/deno-tree-sitter/main/extended/node_extended.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extended/node_extended.js +665 -0
- package/esm/deno-tree-sitter/main/extended/parser.d.ts +37 -0
- package/esm/deno-tree-sitter/main/extended/parser.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extended/parser.js +86 -0
- package/esm/deno-tree-sitter/main/extended/soft_node.d.ts +15 -0
- package/esm/deno-tree-sitter/main/extended/soft_node.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extended/soft_node.js +32 -0
- package/esm/deno-tree-sitter/main/extended/soft_text_node.d.ts +10 -0
- package/esm/deno-tree-sitter/main/extended/soft_text_node.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extended/soft_text_node.js +10 -0
- package/esm/deno-tree-sitter/main/extended/whitespace_node.d.ts +10 -0
- package/esm/deno-tree-sitter/main/extended/whitespace_node.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extended/whitespace_node.js +10 -0
- package/esm/deno-tree-sitter/main/extras/misc.d.ts +2 -0
- package/esm/deno-tree-sitter/main/extras/misc.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/extras/misc.js +13 -0
- package/esm/deno-tree-sitter/main/tree_sitter/bindings.d.ts +14 -0
- package/esm/deno-tree-sitter/main/tree_sitter/bindings.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/bindings.js +21 -0
- package/esm/deno-tree-sitter/main/tree_sitter/constants.d.ts +60 -0
- package/esm/deno-tree-sitter/main/tree_sitter/constants.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/constants.js +66 -0
- package/esm/deno-tree-sitter/main/tree_sitter/language.d.ts +137 -0
- package/esm/deno-tree-sitter/main/tree_sitter/language.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/language.js +296 -0
- package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.d.ts +41 -0
- package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.js +75 -0
- package/esm/deno-tree-sitter/main/tree_sitter/marshal.d.ts +85 -0
- package/esm/deno-tree-sitter/main/tree_sitter/marshal.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/marshal.js +173 -0
- package/esm/deno-tree-sitter/main/tree_sitter/node.d.ts +260 -0
- package/esm/deno-tree-sitter/main/tree_sitter/node.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/node.js +592 -0
- package/esm/deno-tree-sitter/main/tree_sitter/parser.d.ts +124 -0
- package/esm/deno-tree-sitter/main/tree_sitter/parser.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/parser.js +272 -0
- package/esm/deno-tree-sitter/main/tree_sitter/query.d.ts +134 -0
- package/esm/deno-tree-sitter/main/tree_sitter/query.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/query.js +670 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree.d.ts +49 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree.js +145 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.d.ts +165 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.js +305 -0
- package/esm/deno-tree-sitter/main/tree_sitter_wasm.d.ts +3 -0
- package/esm/deno-tree-sitter/main/tree_sitter_wasm.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/tree_sitter_wasm.js +0 -0
- package/esm/deno-tree-sitter/main/wasm_loader.d.ts +29 -0
- package/esm/deno-tree-sitter/main/wasm_loader.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/wasm_loader.js +1709 -0
- package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.d.ts +3 -0
- package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.d.ts.map +1 -0
- package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.js +8 -0
- package/esm/mod.d.ts +8 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +8 -0
- package/esm/package.json +3 -0
- package/package.json +16 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/** A single node within a syntax {@link Tree}. */
|
|
2
|
+
export class Node {
|
|
3
|
+
/** @internal */
|
|
4
|
+
constructor(internal: any, { id, tree, startIndex, startPosition, other }: {
|
|
5
|
+
id: any;
|
|
6
|
+
tree: any;
|
|
7
|
+
startIndex: any;
|
|
8
|
+
startPosition: any;
|
|
9
|
+
other: any;
|
|
10
|
+
});
|
|
11
|
+
/** @internal */
|
|
12
|
+
0: number;
|
|
13
|
+
/** @internal */
|
|
14
|
+
_children: any;
|
|
15
|
+
/** @internal */
|
|
16
|
+
_namedChildren: any;
|
|
17
|
+
/**
|
|
18
|
+
* The numeric id for this node that is unique.
|
|
19
|
+
*
|
|
20
|
+
* Within a given syntax tree, no two nodes have the same id. However:
|
|
21
|
+
*
|
|
22
|
+
* * If a new tree is created based on an older tree, and a node from the old tree is reused in
|
|
23
|
+
* the process, then that node will have the same id in both trees.
|
|
24
|
+
*
|
|
25
|
+
* * A node not marked as having changes does not guarantee it was reused.
|
|
26
|
+
*
|
|
27
|
+
* * If a node is marked as having changed in the old tree, it will not be reused.
|
|
28
|
+
*/
|
|
29
|
+
id: any;
|
|
30
|
+
/** The tree that this node belongs to. */
|
|
31
|
+
tree: any;
|
|
32
|
+
/** The byte index where this node starts. */
|
|
33
|
+
startIndex: any;
|
|
34
|
+
/** The position where this node starts. */
|
|
35
|
+
startPosition: any;
|
|
36
|
+
/** Get this node's type as a numerical id. */
|
|
37
|
+
get typeId(): any;
|
|
38
|
+
/**
|
|
39
|
+
* Get the node's type as a numerical id as it appears in the grammar,
|
|
40
|
+
* ignoring aliases.
|
|
41
|
+
*/
|
|
42
|
+
get grammarId(): any;
|
|
43
|
+
/** Get this node's type as a string. */
|
|
44
|
+
get type(): any;
|
|
45
|
+
/**
|
|
46
|
+
* Get this node's symbol name as it appears in the grammar, ignoring
|
|
47
|
+
* aliases as a string.
|
|
48
|
+
*/
|
|
49
|
+
get grammarType(): any;
|
|
50
|
+
/**
|
|
51
|
+
* Check if this node is *named*.
|
|
52
|
+
*
|
|
53
|
+
* Named nodes correspond to named rules in the grammar, whereas
|
|
54
|
+
* *anonymous* nodes correspond to string literals in the grammar.
|
|
55
|
+
*/
|
|
56
|
+
get isNamed(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Check if this node is *extra*.
|
|
59
|
+
*
|
|
60
|
+
* Extra nodes represent things like comments, which are not required
|
|
61
|
+
* by the grammar, but can appear anywhere.
|
|
62
|
+
*/
|
|
63
|
+
get isExtra(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Check if this node represents a syntax error.
|
|
66
|
+
*
|
|
67
|
+
* Syntax errors represent parts of the code that could not be incorporated
|
|
68
|
+
* into a valid syntax tree.
|
|
69
|
+
*/
|
|
70
|
+
get isError(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Check if this node is *missing*.
|
|
73
|
+
*
|
|
74
|
+
* Missing nodes are inserted by the parser in order to recover from
|
|
75
|
+
* certain kinds of syntax errors.
|
|
76
|
+
*/
|
|
77
|
+
get isMissing(): boolean;
|
|
78
|
+
/** Check if this node has been edited. */
|
|
79
|
+
get hasChanges(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Check if this node represents a syntax error or contains any syntax
|
|
82
|
+
* errors anywhere within it.
|
|
83
|
+
*/
|
|
84
|
+
get hasError(): boolean;
|
|
85
|
+
/** Get the byte index where this node ends. */
|
|
86
|
+
get endIndex(): any;
|
|
87
|
+
/** Get the position where this node ends. */
|
|
88
|
+
get endPosition(): {
|
|
89
|
+
row: number;
|
|
90
|
+
column: number;
|
|
91
|
+
};
|
|
92
|
+
/** Get the string content of this node. */
|
|
93
|
+
get text(): any;
|
|
94
|
+
/** Get this node's parse state. */
|
|
95
|
+
get parseState(): any;
|
|
96
|
+
/** Get the parse state after this node. */
|
|
97
|
+
get nextParseState(): any;
|
|
98
|
+
/** Check if this node is equal to another node. */
|
|
99
|
+
equals(other: any): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Get the node's child at the given index, where zero represents the first child.
|
|
102
|
+
*
|
|
103
|
+
* This method is fairly fast, but its cost is technically log(n), so if
|
|
104
|
+
* you might be iterating over a long list of children, you should use
|
|
105
|
+
* {@link Node#children} instead.
|
|
106
|
+
*/
|
|
107
|
+
child(index: any): any;
|
|
108
|
+
/**
|
|
109
|
+
* Get this node's *named* child at the given index.
|
|
110
|
+
*
|
|
111
|
+
* See also {@link Node#isNamed}.
|
|
112
|
+
* This method is fairly fast, but its cost is technically log(n), so if
|
|
113
|
+
* you might be iterating over a long list of children, you should use
|
|
114
|
+
* {@link Node#namedChildren} instead.
|
|
115
|
+
*/
|
|
116
|
+
namedChild(index: any): any;
|
|
117
|
+
/**
|
|
118
|
+
* Get this node's child with the given numerical field id.
|
|
119
|
+
*
|
|
120
|
+
* See also {@link Node#childForFieldName}. You can
|
|
121
|
+
* convert a field name to an id using {@link Language#fieldIdForName}.
|
|
122
|
+
*/
|
|
123
|
+
childForFieldId(fieldId: any): any;
|
|
124
|
+
/**
|
|
125
|
+
* Get the first child with the given field name.
|
|
126
|
+
*
|
|
127
|
+
* If multiple children may have the same field name, access them using
|
|
128
|
+
* {@link Node#childrenForFieldName}.
|
|
129
|
+
*/
|
|
130
|
+
childForFieldName(fieldName: any): any;
|
|
131
|
+
/** Get the field name of this node's child at the given index. */
|
|
132
|
+
fieldNameForChild(index: any): any;
|
|
133
|
+
/** Get the field name of this node's named child at the given index. */
|
|
134
|
+
fieldNameForNamedChild(index: any): any;
|
|
135
|
+
/**
|
|
136
|
+
* Get an array of this node's children with a given field name.
|
|
137
|
+
*
|
|
138
|
+
* See also {@link Node#children}.
|
|
139
|
+
*/
|
|
140
|
+
childrenForFieldName(fieldName: any): any[];
|
|
141
|
+
/**
|
|
142
|
+
* Get an array of this node's children with a given field id.
|
|
143
|
+
*
|
|
144
|
+
* See also {@link Node#childrenForFieldName}.
|
|
145
|
+
*/
|
|
146
|
+
childrenForFieldId(fieldId: any): any[];
|
|
147
|
+
/** Get the node's first child that contains or starts after the given byte offset. */
|
|
148
|
+
firstChildForIndex(index: any): any;
|
|
149
|
+
/** Get the node's first named child that contains or starts after the given byte offset. */
|
|
150
|
+
firstNamedChildForIndex(index: any): any;
|
|
151
|
+
/** Get this node's number of children. */
|
|
152
|
+
get childCount(): any;
|
|
153
|
+
/**
|
|
154
|
+
* Get this node's number of *named* children.
|
|
155
|
+
*
|
|
156
|
+
* See also {@link Node#isNamed}.
|
|
157
|
+
*/
|
|
158
|
+
get namedChildCount(): any;
|
|
159
|
+
/** Get this node's first child. */
|
|
160
|
+
get firstChild(): any;
|
|
161
|
+
/**
|
|
162
|
+
* Get this node's first named child.
|
|
163
|
+
*
|
|
164
|
+
* See also {@link Node#isNamed}.
|
|
165
|
+
*/
|
|
166
|
+
get firstNamedChild(): any;
|
|
167
|
+
/** Get this node's last child. */
|
|
168
|
+
get lastChild(): any;
|
|
169
|
+
/**
|
|
170
|
+
* Get this node's last named child.
|
|
171
|
+
*
|
|
172
|
+
* See also {@link Node#isNamed}.
|
|
173
|
+
*/
|
|
174
|
+
get lastNamedChild(): any;
|
|
175
|
+
/**
|
|
176
|
+
* Iterate over this node's children.
|
|
177
|
+
*
|
|
178
|
+
* If you're walking the tree recursively, you may want to use the
|
|
179
|
+
* {@link TreeCursor} APIs directly instead.
|
|
180
|
+
*/
|
|
181
|
+
get children(): any;
|
|
182
|
+
/**
|
|
183
|
+
* Iterate over this node's named children.
|
|
184
|
+
*
|
|
185
|
+
* See also {@link Node#children}.
|
|
186
|
+
*/
|
|
187
|
+
get namedChildren(): any;
|
|
188
|
+
/**
|
|
189
|
+
* Get the descendants of this node that are the given type, or in the given types array.
|
|
190
|
+
*
|
|
191
|
+
* The types array should contain node type strings, which can be retrieved from {@link Language#types}.
|
|
192
|
+
*
|
|
193
|
+
* Additionally, a `startPosition` and `endPosition` can be passed in to restrict the search to a byte range.
|
|
194
|
+
*/
|
|
195
|
+
descendantsOfType(types: any, startPosition?: {
|
|
196
|
+
row: number;
|
|
197
|
+
column: number;
|
|
198
|
+
}, endPosition?: {
|
|
199
|
+
row: number;
|
|
200
|
+
column: number;
|
|
201
|
+
}): any[];
|
|
202
|
+
/** Get this node's next sibling. */
|
|
203
|
+
get nextSibling(): any;
|
|
204
|
+
/** Get this node's previous sibling. */
|
|
205
|
+
get previousSibling(): any;
|
|
206
|
+
/**
|
|
207
|
+
* Get this node's next *named* sibling.
|
|
208
|
+
*
|
|
209
|
+
* See also {@link Node#isNamed}.
|
|
210
|
+
*/
|
|
211
|
+
get nextNamedSibling(): any;
|
|
212
|
+
/**
|
|
213
|
+
* Get this node's previous *named* sibling.
|
|
214
|
+
*
|
|
215
|
+
* See also {@link Node#isNamed}.
|
|
216
|
+
*/
|
|
217
|
+
get previousNamedSibling(): any;
|
|
218
|
+
/** Get the node's number of descendants, including one for the node itself. */
|
|
219
|
+
get descendantCount(): any;
|
|
220
|
+
/**
|
|
221
|
+
* Get this node's immediate parent.
|
|
222
|
+
* Prefer {@link Node#childWithDescendant} for iterating over this node's ancestors.
|
|
223
|
+
*/
|
|
224
|
+
get parent(): any;
|
|
225
|
+
/**
|
|
226
|
+
* Get the node that contains `descendant`.
|
|
227
|
+
*
|
|
228
|
+
* Note that this can return `descendant` itself.
|
|
229
|
+
*/
|
|
230
|
+
childWithDescendant(descendant: any): any;
|
|
231
|
+
/** Get the smallest node within this node that spans the given byte range. */
|
|
232
|
+
descendantForIndex(start: any, end?: any): any;
|
|
233
|
+
/** Get the smallest named node within this node that spans the given byte range. */
|
|
234
|
+
namedDescendantForIndex(start: any, end?: any): any;
|
|
235
|
+
/** Get the smallest node within this node that spans the given point range. */
|
|
236
|
+
descendantForPosition(start: any, end?: any): any;
|
|
237
|
+
/** Get the smallest named node within this node that spans the given point range. */
|
|
238
|
+
namedDescendantForPosition(start: any, end?: any): any;
|
|
239
|
+
/**
|
|
240
|
+
* Create a new {@link TreeCursor} starting from this node.
|
|
241
|
+
*
|
|
242
|
+
* Note that the given node is considered the root of the cursor,
|
|
243
|
+
* and the cursor cannot walk outside this node.
|
|
244
|
+
*/
|
|
245
|
+
walk(): TreeCursor;
|
|
246
|
+
/**
|
|
247
|
+
* Edit this node to keep it in-sync with source code that has been edited.
|
|
248
|
+
*
|
|
249
|
+
* This function is only rarely needed. When you edit a syntax tree with
|
|
250
|
+
* the {@link Tree#edit} method, all of the nodes that you retrieve from
|
|
251
|
+
* the tree afterward will already reflect the edit. You only need to
|
|
252
|
+
* use {@link Node#edit} when you have a specific {@link Node} instance that
|
|
253
|
+
* you want to keep and continue to use after an edit.
|
|
254
|
+
*/
|
|
255
|
+
edit(edit: any): void;
|
|
256
|
+
/** Get the S-expression representation of this node. */
|
|
257
|
+
toString(): any;
|
|
258
|
+
}
|
|
259
|
+
import { TreeCursor } from "./tree_cursor.js";
|
|
260
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/deno-tree-sitter/main/tree_sitter/node.js"],"names":[],"mappings":"AAQA,kDAA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