(content: string, language: string = "typescript")
| 111 | |
| 112 | // Helper function to inspect tree structure |
| 113 | export async function inspectTreeStructure(content: string, language: string = "typescript"): Promise<string> { |
| 114 | const { Parser, Language } = await initializeTreeSitter() |
| 115 | const parser = new Parser() |
| 116 | const wasmPath = path.join(process.cwd(), `dist/tree-sitter-${language}.wasm`) |
| 117 | const lang = await Language.load(wasmPath) |
| 118 | parser.setLanguage(lang) |
| 119 | |
| 120 | // Parse the content |
| 121 | const tree = parser.parse(content) |
| 122 | |
| 123 | // Print the tree structure |
| 124 | debugLog(`TREE STRUCTURE (${language}):\n${tree?.rootNode.toString()}`) |
| 125 | return tree?.rootNode.toString() || "" |
| 126 | } |
no test coverage detected