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

Function extractSymbols

src/codegraph/extractor.ts:59–75  ·  view source on GitHub ↗
(filePath: string, source: string)

Source from the content-addressed store, hash-verified

57};
58
59export async function extractSymbols(filePath: string, source: string): Promise<ExtractedSymbol[]> {
60 const lang = detectLanguage(filePath);
61 if (!lang) return [];
62
63 // Try Tree-sitter first
64 const parserResult = await getParser(lang).catch(() => null);
65 if (parserResult) {
66 try {
67 return extractWithTreeSitter(parserResult, lang, source);
68 } catch (e: any) {
69 logger.warn('Tree-sitter extraction failed, falling back to regex', { file: filePath, err: e.message });
70 }
71 }
72
73 // Fallback: regex heuristics per language
74 return extractWithRegex(lang, source);
75}
76
77function extractWithTreeSitter(
78 parserResult: { parser: any; language: any },

Callers 4

codegraph.test.tsFile · 0.85
executeMethod · 0.85
indexAllMethod · 0.85
indexFileMethod · 0.85

Calls 5

detectLanguageFunction · 0.85
getParserFunction · 0.85
extractWithTreeSitterFunction · 0.85
extractWithRegexFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected