MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / loadGrammar

Function loadGrammar

src/core/tree-sitter.ts:124–137  ·  view source on GitHub ↗
(grammarName: string)

Source from the content-addressed store, hash-verified

122}
123
124async function loadGrammar(grammarName: string): Promise<TSLanguage | null> {
125 if (grammarCache.has(grammarName)) return grammarCache.get(grammarName)!;
126
127 try {
128 const Parser = await initParser();
129 const wasmPath = join(GRAMMAR_DIR, `tree-sitter-${grammarName}.wasm`);
130 await readFile(wasmPath);
131 const lang = await Parser.Language.load(wasmPath);
132 grammarCache.set(grammarName, lang);
133 return lang;
134 } catch {
135 return null;
136 }
137}
138
139function extractName(node: TSNode, _kind: string): string {
140 const nameNode = node.childForFieldName("name")

Callers 1

parseWithTreeSitterFunction · 0.85

Calls 1

initParserFunction · 0.85

Tested by

no test coverage detected