MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / parseCheck

Method parseCheck

src/orchestration/qa-node.ts:125–140  ·  view source on GitHub ↗

Parse a file with tree-sitter; return an error string if it fails to parse.

(rel: string, content: string)

Source from the content-addressed store, hash-verified

123
124 /** Parse a file with tree-sitter; return an error string if it fails to parse. */
125 private async parseCheck(rel: string, content: string): Promise<string | null> {
126 const lang = detectLanguage(rel);
127 if (!lang) return null; // unknown language — skip (don't block on e.g. .md)
128 let parser;
129 try { parser = await getParser(lang); } catch { return null; }
130 if (!parser) return null;
131 let tree;
132 try { tree = parser.parser.parse(content); } catch (e: any) {
133 return `${rel}: parser threw — ${e?.message ?? 'unknown'}`;
134 }
135 if (this.hasError(tree.rootNode)) {
136 const loc = this.firstErrorLine(tree.rootNode, content);
137 return `${rel}: syntax error${loc ? ` near line ${loc}` : ''} (worker emitted unparseable code)`;
138 }
139 return null;
140 }
141
142 private hasError(node: any): boolean {
143 if (node.type === 'ERROR' || node.isMissing?.()) return true;

Callers 1

reviewMethod · 0.95

Calls 4

hasErrorMethod · 0.95
firstErrorLineMethod · 0.95
detectLanguageFunction · 0.85
getParserFunction · 0.85

Tested by

no test coverage detected