We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
walkTreeCollecting
1 parent 5b55ec8 commit bb8a4cfCopy full SHA for bb8a4cf
server/src/server.ts
@@ -271,6 +271,25 @@ function walkTree(
271
}
272
273
274
+function walkTreeCollecting<R>(
275
+ node: SyntaxNode,
276
+ callback: (node: SyntaxNode) => R,
277
+): R[] {
278
+ let results: R[] = [];
279
+ let stack: SyntaxNode[] = [node];
280
+ while (stack.length > 0) {
281
+ let node: SyntaxNode = stack.pop() as SyntaxNode;
282
+ results.push(callback(node));
283
+ for (let i = node.namedChildCount - 1; i >= 0; i--) {
284
+ const child = node.namedChild(i);
285
+ if (child) {
286
+ stack.push(child);
287
+ }
288
289
290
+ return results;
291
+}
292
+
293
function limitDiagnostics(
294
diagnostics: Diagnostic[],
295
maxNumberOfProblems: number
0 commit comments