@kerebron/tree-sitter 0.4.27 → 0.4.29
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/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 +155 -0
- package/esm/deno-tree-sitter/main/extended/base_node.js.map +1 -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 +573 -0
- package/esm/deno-tree-sitter/main/extended/node_extended.js.map +1 -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 +87 -0
- package/esm/deno-tree-sitter/main/extended/parser.js.map +1 -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 +28 -0
- package/esm/deno-tree-sitter/main/extended/soft_node.js.map +1 -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 +11 -0
- package/esm/deno-tree-sitter/main/extended/soft_text_node.js.map +1 -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 +11 -0
- package/esm/deno-tree-sitter/main/extended/whitespace_node.js.map +1 -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 +14 -0
- package/esm/deno-tree-sitter/main/extras/misc.js.map +1 -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 +22 -0
- package/esm/deno-tree-sitter/main/tree_sitter/bindings.js.map +1 -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 +67 -0
- package/esm/deno-tree-sitter/main/tree_sitter/constants.js.map +1 -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 +265 -0
- package/esm/deno-tree-sitter/main/tree_sitter/language.js.map +1 -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 +66 -0
- package/esm/deno-tree-sitter/main/tree_sitter/lookahead_iterator.js.map +1 -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 +174 -0
- package/esm/deno-tree-sitter/main/tree_sitter/marshal.js.map +1 -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 +558 -0
- package/esm/deno-tree-sitter/main/tree_sitter/node.js.map +1 -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 +253 -0
- package/esm/deno-tree-sitter/main/tree_sitter/parser.js.map +1 -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 +621 -0
- package/esm/deno-tree-sitter/main/tree_sitter/query.js.map +1 -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 +131 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree.js.map +1 -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 +281 -0
- package/esm/deno-tree-sitter/main/tree_sitter/tree_cursor.js.map +1 -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/tree_sitter_wasm.js.map +1 -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 +1703 -0
- package/esm/deno-tree-sitter/main/wasm_loader.js.map +1 -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 +9 -0
- package/esm/deno-tree-sitter/main/wasm_loader_with_defaults.js.map +1 -0
- package/esm/mod.d.ts +7 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +8 -0
- package/esm/mod.js.map +1 -0
- package/esm/package.json +3 -0
- package/package.json +5 -2
- package/src/deno-tree-sitter/main/extended/base_node.js +174 -0
- package/src/deno-tree-sitter/main/extended/node_extended.js +588 -0
- package/src/deno-tree-sitter/main/extended/parser.js +87 -0
- package/src/deno-tree-sitter/main/extended/soft_node.js +32 -0
- package/src/deno-tree-sitter/main/extended/soft_text_node.js +11 -0
- package/src/deno-tree-sitter/main/extended/whitespace_node.js +11 -0
- package/src/deno-tree-sitter/main/extras/misc.js +12 -0
- package/src/deno-tree-sitter/main/tree_sitter/bindings.js +26 -0
- package/src/deno-tree-sitter/main/tree_sitter/constants.js +79 -0
- package/src/deno-tree-sitter/main/tree_sitter/language.js +289 -0
- package/src/deno-tree-sitter/main/tree_sitter/lookahead_iterator.js +74 -0
- package/src/deno-tree-sitter/main/tree_sitter/marshal.js +186 -0
- package/src/deno-tree-sitter/main/tree_sitter/node.js +616 -0
- package/src/deno-tree-sitter/main/tree_sitter/parser.js +273 -0
- package/src/deno-tree-sitter/main/tree_sitter/query.js +705 -0
- package/src/deno-tree-sitter/main/tree_sitter/tree.js +145 -0
- package/src/deno-tree-sitter/main/tree_sitter/tree_cursor.js +314 -0
- package/src/deno-tree-sitter/main/tree_sitter_wasm.js +0 -0
- package/src/deno-tree-sitter/main/wasm_loader.js +1702 -0
- package/src/deno-tree-sitter/main/wasm_loader_with_defaults.js +9 -0
- package/src/mod.ts +8 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const _shadows: {};
|
|
2
|
+
export class BaseNode {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
/** @type {number} */
|
|
5
|
+
get depth(): number;
|
|
6
|
+
_depth: any;
|
|
7
|
+
/** @type {number} */
|
|
8
|
+
get length(): number;
|
|
9
|
+
get hasChildren(): boolean;
|
|
10
|
+
get hardChildren(): any;
|
|
11
|
+
get fields(): {};
|
|
12
|
+
get fieldNames(): never[];
|
|
13
|
+
/** @type {string} */
|
|
14
|
+
get indent(): string;
|
|
15
|
+
/** @type {Object} */
|
|
16
|
+
toJSON(): {
|
|
17
|
+
children: any;
|
|
18
|
+
type: any;
|
|
19
|
+
typeId: any;
|
|
20
|
+
fieldNames: never[];
|
|
21
|
+
startPosition: any;
|
|
22
|
+
startIndex: any;
|
|
23
|
+
endPosition: any;
|
|
24
|
+
endIndex: any;
|
|
25
|
+
indent: string;
|
|
26
|
+
} | {
|
|
27
|
+
text: any;
|
|
28
|
+
children: never[];
|
|
29
|
+
type: any;
|
|
30
|
+
typeId: any;
|
|
31
|
+
fieldNames: never[];
|
|
32
|
+
startPosition: any;
|
|
33
|
+
startIndex: any;
|
|
34
|
+
endPosition: any;
|
|
35
|
+
endIndex: any;
|
|
36
|
+
indent: string;
|
|
37
|
+
};
|
|
38
|
+
iterFlattened(): Generator<never, void, unknown>;
|
|
39
|
+
flattened(): never[];
|
|
40
|
+
/**
|
|
41
|
+
* Destroy the children of this node and replace the .text of this node with the given string.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} replacement - description
|
|
44
|
+
*/
|
|
45
|
+
replaceInnards(replacement: string): void;
|
|
46
|
+
[Symbol.iterator](): Generator<any, void, any>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=base_node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_node.d.ts","sourceRoot":"","sources":["../../../../src/deno-tree-sitter/main/extended/base_node.js"],"names":[],"mappings":"AAEA,0BAA0B;AAC1B;IAUI,uBAEC;IAED,qBAAqB;IACrB,aADW,MAAM,CAUhB;IANW,YAAe;IAQ3B,qBAAqB;IACrB,cADW,MAAM,CAGhB;IAMD,2BAEC;IAED,wBAEC;IAED,iBAEC;IAED,0BAEC;IAED,qBAAqB;IACrB,cADW,MAAM,CAKhB;IAED,qBAAqB;IACrB;;;;;;;;;;;;;;;;;;;;;MAgCC;IAgCD,iDAEC;IACD,qBAEC;IAED;;;;OAIG;IACH,4BAFW,MAAM,QAoChB;IA1ID,+CAEC;CAyIJ"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Node } from "../tree_sitter/node.js";
|
|
2
|
+
export const _shadows = {};
|
|
3
|
+
export class BaseNode {
|
|
4
|
+
// type = ""
|
|
5
|
+
// typeId = 0
|
|
6
|
+
// startPosition = 0
|
|
7
|
+
// startIndex = 0
|
|
8
|
+
// endPosition = 0
|
|
9
|
+
// startIndex = 0
|
|
10
|
+
// endIndex = 0
|
|
11
|
+
// indent = ""
|
|
12
|
+
constructor(data) {
|
|
13
|
+
Object.assign(this, data);
|
|
14
|
+
}
|
|
15
|
+
/** @type {number} */
|
|
16
|
+
get depth() {
|
|
17
|
+
if (this._depth == null) {
|
|
18
|
+
if (this.parent == null) {
|
|
19
|
+
this._depth = 0;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this._depth = this.parent.depth + 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return this._depth;
|
|
26
|
+
}
|
|
27
|
+
/** @type {number} */
|
|
28
|
+
get length() {
|
|
29
|
+
return this.children?.length || 0;
|
|
30
|
+
}
|
|
31
|
+
*[Symbol.iterator]() {
|
|
32
|
+
yield* this.children || [];
|
|
33
|
+
}
|
|
34
|
+
get hasChildren() {
|
|
35
|
+
return (this.children?.length || 0) > 0;
|
|
36
|
+
}
|
|
37
|
+
get hardChildren() {
|
|
38
|
+
return (this.children || []).filter(each => each instanceof Node);
|
|
39
|
+
}
|
|
40
|
+
get fields() {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
get fieldNames() {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
/** @type {string} */
|
|
47
|
+
get indent() {
|
|
48
|
+
return this.tree.codeString.match(new RegExp(`^(?:.*\\r?\\n){${this.startPosition.row}}(\\s*)`))[1];
|
|
49
|
+
// equivalent but usually faster than:
|
|
50
|
+
// return this.tree.codeString.split("\n")[this.startPosition.row].match(/^\s*/)[0]
|
|
51
|
+
}
|
|
52
|
+
/** @type {Object} */
|
|
53
|
+
toJSON() {
|
|
54
|
+
const optionalData = {};
|
|
55
|
+
if (this.children?.length) {
|
|
56
|
+
return {
|
|
57
|
+
type: this.type,
|
|
58
|
+
typeId: this.typeId,
|
|
59
|
+
fieldNames: this.fieldNames,
|
|
60
|
+
startPosition: this.startPosition,
|
|
61
|
+
startIndex: this.startIndex,
|
|
62
|
+
endPosition: this.endPosition,
|
|
63
|
+
startIndex: this.startIndex,
|
|
64
|
+
endIndex: this.endIndex,
|
|
65
|
+
indent: this.indent,
|
|
66
|
+
...optionalData,
|
|
67
|
+
children: this.children.map(each => each.toJSON()),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return {
|
|
72
|
+
type: this.type,
|
|
73
|
+
typeId: this.typeId,
|
|
74
|
+
fieldNames: this.fieldNames,
|
|
75
|
+
startPosition: this.startPosition,
|
|
76
|
+
startIndex: this.startIndex,
|
|
77
|
+
endPosition: this.endPosition,
|
|
78
|
+
startIndex: this.startIndex,
|
|
79
|
+
endIndex: this.endIndex,
|
|
80
|
+
indent: this.indent,
|
|
81
|
+
...optionalData,
|
|
82
|
+
text: this.text,
|
|
83
|
+
children: [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
[Symbol.for("Deno.customInspect")](inspect, options) {
|
|
88
|
+
const optional = {};
|
|
89
|
+
let text;
|
|
90
|
+
try {
|
|
91
|
+
text = this.text;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
text = undefined;
|
|
95
|
+
}
|
|
96
|
+
if (text == undefined) {
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
return inspect({
|
|
100
|
+
'': text.length < 60 ? text : text.slice(0, 30) + "..." + text.slice(-27),
|
|
101
|
+
type: this.type,
|
|
102
|
+
typeId: this.typeId,
|
|
103
|
+
fieldNames: this.fieldNames,
|
|
104
|
+
startPosition: this.startPosition,
|
|
105
|
+
startIndex: this.startIndex,
|
|
106
|
+
endPosition: this.endPosition,
|
|
107
|
+
startIndex: this.startIndex,
|
|
108
|
+
endIndex: this.endIndex,
|
|
109
|
+
indent: this.indent,
|
|
110
|
+
...optional,
|
|
111
|
+
hasChildren: this.hasChildren,
|
|
112
|
+
children: [...(this.children || [])],
|
|
113
|
+
}, options);
|
|
114
|
+
}
|
|
115
|
+
*iterFlattened() {
|
|
116
|
+
}
|
|
117
|
+
flattened() {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Destroy the children of this node and replace the .text of this node with the given string.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} replacement - description
|
|
124
|
+
*/
|
|
125
|
+
replaceInnards(replacement) {
|
|
126
|
+
const tree = this.tree;
|
|
127
|
+
const sourceCode = this.tree.codeString;
|
|
128
|
+
const node = _shadows[this.id] || this;
|
|
129
|
+
// clear out children (innards) because of replacement
|
|
130
|
+
node._children = [];
|
|
131
|
+
node._fields = {};
|
|
132
|
+
// get the node position info
|
|
133
|
+
const { startPosition: originalStart, endPosition: originalEnd, startIndex: originalStartIndex, endIndex: originalEndIndex, } = node;
|
|
134
|
+
// compute what the new row-column will be
|
|
135
|
+
const newNumberOfLines = replacement.match(/\n/g)?.length || 0;
|
|
136
|
+
let newEndCol = originalStart.column;
|
|
137
|
+
if (newNumberOfLines == 0) {
|
|
138
|
+
newEndCol = originalStart.column + replacement.length;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
newEndCol = replacement.split("\n").slice(-1)[0].length;
|
|
142
|
+
}
|
|
143
|
+
// updates all the indices of all the nodes
|
|
144
|
+
tree.edit({
|
|
145
|
+
startIndex: originalStartIndex,
|
|
146
|
+
oldEndIndex: originalEndIndex,
|
|
147
|
+
newEndIndex: originalStartIndex + replacement.length,
|
|
148
|
+
startPosition: originalStart,
|
|
149
|
+
oldEndPosition: originalEnd,
|
|
150
|
+
newEndPosition: { row: originalStart.row + newNumberOfLines, column: newEndCol },
|
|
151
|
+
});
|
|
152
|
+
this.tree.codeString = sourceCode.slice(0, originalStartIndex) + replacement + sourceCode.slice(originalEndIndex);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=base_node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_node.js","sourceRoot":"","sources":["../../../../src/deno-tree-sitter/main/extended/base_node.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAA;AAC1B,MAAM,OAAO,QAAQ;IACjB,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,cAAc;IAEd,YAAY,IAAI;QACZ,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IAED,qBAAqB;IACrB,IAAI,KAAK;QACL,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBACtB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;YACnB,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAA;YACvC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,qBAAqB;IACrB,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAE,CAAC,CAAA;IACnC,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACd,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAE,EAAE,CAAA;IAC5B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AAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAC3D,CAAC;QACD,2CAA2C;QAC3C,IAAI,CAAC,IAAI,CAAC;YACN,UAAU,EAAE,kBAAkB;YAC9B,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,kBAAkB,GAAG,WAAW,CAAC,MAAM;YACpD,aAAa,EAAE,aAAa;YAC5B,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,EAAE,GAAG,EAAE,aAAa,CAAC,GAAG,GAAG,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE;SACnF,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;IACrH,CAAC;CACJ"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
export class ExtendedTree extends Tree {
|
|
2
|
+
/** @type {HardNode} */
|
|
3
|
+
rootNode: HardNode;
|
|
4
|
+
}
|
|
5
|
+
export class HardNode extends BaseNode {
|
|
6
|
+
/** @internal */
|
|
7
|
+
_children: any;
|
|
8
|
+
/** @internal */
|
|
9
|
+
_fields: any;
|
|
10
|
+
/** @type {number} */
|
|
11
|
+
id: number;
|
|
12
|
+
/** @type {number} */
|
|
13
|
+
startIndex: number;
|
|
14
|
+
/** @type {Position} */
|
|
15
|
+
startPosition: Position;
|
|
16
|
+
/** @type {ExtendedTree} */
|
|
17
|
+
tree: ExtendedTree;
|
|
18
|
+
/** @type {string} */
|
|
19
|
+
type: string;
|
|
20
|
+
/** @type {Boolean} */
|
|
21
|
+
isExtra: boolean;
|
|
22
|
+
/** @type {Boolean} */
|
|
23
|
+
isError: boolean;
|
|
24
|
+
/** @type {Boolean} */
|
|
25
|
+
isMissing: boolean;
|
|
26
|
+
/** @type {Boolean} */
|
|
27
|
+
hasChanges: boolean;
|
|
28
|
+
/** @type {Boolean} */
|
|
29
|
+
hasError: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @param {HardNode} other -
|
|
32
|
+
* @returns {Boolean} output -
|
|
33
|
+
*/
|
|
34
|
+
equals: ((other: any) => boolean) | undefined;
|
|
35
|
+
/** @type {HardNode} */
|
|
36
|
+
get parent(): HardNode;
|
|
37
|
+
/** @type {string} */
|
|
38
|
+
get text(): string;
|
|
39
|
+
/** @type {Number} */
|
|
40
|
+
get endIndex(): number;
|
|
41
|
+
/** @type {Position} */
|
|
42
|
+
get endPosition(): Position;
|
|
43
|
+
set children(value: Array<HardNode | SoftNode>);
|
|
44
|
+
/** @type {Array<HardNode|SoftNode>} */
|
|
45
|
+
get children(): Array<HardNode | SoftNode>;
|
|
46
|
+
/**
|
|
47
|
+
* Yields each child
|
|
48
|
+
*
|
|
49
|
+
* @generator
|
|
50
|
+
* @yields {HardNode} The current child or grandchild in the structure.
|
|
51
|
+
*/
|
|
52
|
+
traverse(arg?: {
|
|
53
|
+
_parentNodes: never[];
|
|
54
|
+
}): Generator<any, void, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* A generator function that flattens the hierarchical structure of `children` and their descendants.
|
|
57
|
+
* It yields each child and their flattened descendants recursively.
|
|
58
|
+
*
|
|
59
|
+
* @param {Function} opts.filter - A function to filter the flattened elements.
|
|
60
|
+
* @param {Boolean} opts.includeSelf -
|
|
61
|
+
* @generator
|
|
62
|
+
* @yields {HardNode} The current child or grandchild in the structure.
|
|
63
|
+
*/
|
|
64
|
+
iterFlattened({ filter, includeSelf }?: Function): Generator<any, void, unknown>;
|
|
65
|
+
/** @internal */
|
|
66
|
+
iterFlatten(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Flattens the structure of `children` using the provided filter function.
|
|
69
|
+
* This method returns an array containing the flattened elements.
|
|
70
|
+
*
|
|
71
|
+
* @param {Function} opts.filter - A function to filter the flattened elements.
|
|
72
|
+
* @param {Boolean} opts.includeSelf -
|
|
73
|
+
* @returns {Array} An array containing the flattened elements that pass the filter.
|
|
74
|
+
*/
|
|
75
|
+
flattened({ filter, includeSelf }?: Function): any[];
|
|
76
|
+
/** @internal */
|
|
77
|
+
flatten(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Query
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```js
|
|
83
|
+
* import { createParser } from "https://deno.land/x/deno_tree_sitter/main/main.js"
|
|
84
|
+
* import javascript from "https://github.com/jeff-hykin/common_tree_sitter_languages/raw/4d8a6d34d7f6263ff570f333cdcf5ded6be89e3d/main/javascript.js"
|
|
85
|
+
* const parser = await createParser(javascript) // path or Uint8Array
|
|
86
|
+
* const tree = parser.parse('let a = 1;let b = 1;let c = 1;')
|
|
87
|
+
*
|
|
88
|
+
* tree.rootNode.query(`(identifier) @blahBlahBlah`, {matchLimit: 2})
|
|
89
|
+
* // returns:
|
|
90
|
+
* [
|
|
91
|
+
* {
|
|
92
|
+
* pattern: 0,
|
|
93
|
+
* captures: [
|
|
94
|
+
* {
|
|
95
|
+
* name: "blahBlahBlah",
|
|
96
|
+
* node: {
|
|
97
|
+
* type: "identifier",
|
|
98
|
+
* typeId: 1,
|
|
99
|
+
* startPosition: { row: 0, column: 4 },
|
|
100
|
+
* startIndex: 4,
|
|
101
|
+
* endPosition: { row: 0, column: 5 },
|
|
102
|
+
* endIndex: 5,
|
|
103
|
+
* indent: undefined,
|
|
104
|
+
* hasChildren: false,
|
|
105
|
+
* children: []
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* ]
|
|
109
|
+
* },
|
|
110
|
+
* {
|
|
111
|
+
* pattern: 0,
|
|
112
|
+
* captures: [
|
|
113
|
+
* {
|
|
114
|
+
* name: "blahBlahBlah",
|
|
115
|
+
* node: {
|
|
116
|
+
* type: "identifier",
|
|
117
|
+
* typeId: 1,
|
|
118
|
+
* startPosition: { row: 0, column: 14 },
|
|
119
|
+
* startIndex: 14,
|
|
120
|
+
* endPosition: { row: 0, column: 15 },
|
|
121
|
+
* endIndex: 15,
|
|
122
|
+
* indent: undefined,
|
|
123
|
+
* hasChildren: false,
|
|
124
|
+
* children: []
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ]
|
|
128
|
+
* },
|
|
129
|
+
* {
|
|
130
|
+
* pattern: 0,
|
|
131
|
+
* captures: [
|
|
132
|
+
* {
|
|
133
|
+
* name: "blahBlahBlah",
|
|
134
|
+
* node: {
|
|
135
|
+
* type: "identifier",
|
|
136
|
+
* typeId: 1,
|
|
137
|
+
* startPosition: { row: 0, column: 24 },
|
|
138
|
+
* startIndex: 24,
|
|
139
|
+
* endPosition: { row: 0, column: 25 },
|
|
140
|
+
* endIndex: 25,
|
|
141
|
+
* indent: undefined,
|
|
142
|
+
* hasChildren: false,
|
|
143
|
+
* children: []
|
|
144
|
+
* }
|
|
145
|
+
* }
|
|
146
|
+
* ]
|
|
147
|
+
* }
|
|
148
|
+
* ]
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @param {String} queryString - see https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax
|
|
152
|
+
* @param options.matchLimit - max number of results
|
|
153
|
+
* @param options.startPosition - {row: Number, column: number}
|
|
154
|
+
* @param options.endPosition - {row: Number, column: number}
|
|
155
|
+
* @param options.maxResultDepth - depth relative to the current node (1 = direct children, 2 = grandchildren, etc)
|
|
156
|
+
* @returns {[Object]} output
|
|
157
|
+
*
|
|
158
|
+
*/
|
|
159
|
+
query(queryString: string, options: any): [Object];
|
|
160
|
+
/**
|
|
161
|
+
* quickQuery
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```js
|
|
165
|
+
* import { createParser } from "https://deno.land/x/deno_tree_sitter/main/main.js"
|
|
166
|
+
* import javascript from "https://github.com/jeff-hykin/common_tree_sitter_languages/raw/676ffa3b93768b8ac628fd5c61656f7dc41ba413/main/javascript.js"
|
|
167
|
+
* const parser = await createParser(javascript) // path or Uint8Array
|
|
168
|
+
* const tree = parser.parse('let a = 1;let b = 1;let c = 1;')
|
|
169
|
+
* // ex1: no capture names
|
|
170
|
+
* const nodes = tree.rootNode.quickQuery(
|
|
171
|
+
* `(identifier)`, {matchLimit: 2}
|
|
172
|
+
* )
|
|
173
|
+
* // ex2: with capture names
|
|
174
|
+
* const groups = tree.rootNode.quickQuery(
|
|
175
|
+
* `'(binding (attrpath) @myKey (list_expression) @myList ("\\"")? @optionalThing )`
|
|
176
|
+
* )
|
|
177
|
+
* groups[0].myKey // node
|
|
178
|
+
* groups[0].myList // node
|
|
179
|
+
* groups[0].optionalThing // node or null
|
|
180
|
+
* groups[0][0] // node (the whole match)
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @param {String} queryString - see https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax
|
|
184
|
+
* @param options.matchLimit - max number of results
|
|
185
|
+
* @param options.startPosition - {row: Number, column: number}
|
|
186
|
+
* @param options.endPosition - {row: Number, column: number}
|
|
187
|
+
* @param options.maxResultDepth - depth relative to the current node (1 = direct children, 2 = grandchildren, etc)
|
|
188
|
+
* @returns {Array<HardNode|Record<any, HardNode>>} nodesOrObjsOfNodes
|
|
189
|
+
*/
|
|
190
|
+
quickQuery(queryString: string, options: any): Array<HardNode | Record<any, HardNode>>;
|
|
191
|
+
/**
|
|
192
|
+
* quickQueryFirst
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```js
|
|
196
|
+
* import { createParser } from "https://deno.land/x/deno_tree_sitter/main/main.js"
|
|
197
|
+
* import javascript from "https://github.com/jeff-hykin/common_tree_sitter_languages/raw/4d8a6d34d7f6263ff570f333cdcf5ded6be89e3d/main/javascript.js"
|
|
198
|
+
* const parser = await createParser(javascript) // path or Uint8Array
|
|
199
|
+
* const tree = parser.parse('let a = 1;let b = 1;let c = 1;')
|
|
200
|
+
*
|
|
201
|
+
* // ex1: no capture names
|
|
202
|
+
* const node = tree.rootNode.quickQueryFirst(`(identifier)`)
|
|
203
|
+
*
|
|
204
|
+
* // ex2: with capture names
|
|
205
|
+
* const { myKey, myList, optionalThing } = tree.rootNode.quickQueryFirst(
|
|
206
|
+
* `'(binding (attrpath) @myKey (list_expression) @myList ("\\"")? @optionalThing )`
|
|
207
|
+
* )
|
|
208
|
+
* myKey // node
|
|
209
|
+
* myList // node
|
|
210
|
+
* optionalThing // node or null
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @param {String} queryString - see https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax
|
|
214
|
+
* @param options.startPosition - {row: Number, column: number}
|
|
215
|
+
* @param options.endPosition - {row: Number, column: number}
|
|
216
|
+
* @param options.maxResultDepth - depth relative to the current node (1 = direct children, 2 = grandchildren, etc)
|
|
217
|
+
* @returns {HardNode|Record<any,HardNode>|null} nodeOrObjOfNodes
|
|
218
|
+
*/
|
|
219
|
+
quickQueryFirst(queryString: string, options: any): HardNode | Record<any, HardNode> | null;
|
|
220
|
+
get fields(): any;
|
|
221
|
+
get fieldNames(): string[];
|
|
222
|
+
getQueryForSelf(): string;
|
|
223
|
+
/** @returns {string} */
|
|
224
|
+
asLispString(): string;
|
|
225
|
+
}
|
|
226
|
+
export { Node };
|
|
227
|
+
export function _childrenWithSoftNodes(node: any, children: any, string: any): any[] | undefined;
|
|
228
|
+
import { Tree } from "../tree_sitter/tree.js";
|
|
229
|
+
import { BaseNode } from "./base_node.js";
|
|
230
|
+
declare class Position {
|
|
231
|
+
/** @type {number} */
|
|
232
|
+
row: number;
|
|
233
|
+
/** @type {number} */
|
|
234
|
+
column: number;
|
|
235
|
+
}
|
|
236
|
+
import { Node } from "../tree_sitter/node.js";
|
|
237
|
+
//# sourceMappingURL=node_extended.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_extended.d.ts","sourceRoot":"","sources":["../../../../src/deno-tree-sitter/main/extended/node_extended.js"],"names":[],"mappings":"AA2DA;IACI,uBAAuB;IACvB,UAD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