MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / queryNodes

Function queryNodes

masfactory-visualizer/src/parser/astUtils.ts:21–36  ·  view source on GitHub ↗
(node: TSNode, type: string)

Source from the content-addressed store, hash-verified

19 * Query all nodes of a specific type in the AST
20 */
21export function queryNodes(node: TSNode, type: string): TSNode[] {
22 const results: TSNode[] = [];
23
24 function traverse(n: TSNode) {
25 if (n.type === type) {
26 results.push(n);
27 }
28 for (const child of n.children) {
29 if (!child) {continue;}
30 traverse(child);
31 }
32 }
33
34 traverse(node);
35 return results;
36}
37
38/**
39 * Get base classes from a class definition node

Callers 9

parseImportsFunction · 0.90
detectBuilderFunctionFunction · 0.90
parseBuilderFunctionFunction · 0.90
parseComponentStructureFunction · 0.90
checkForComplexStructureFunction · 0.90
collectClassBasesFunction · 0.85

Calls 1

traverseFunction · 0.85

Tested by

no test coverage detected