MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / UnifiedLanguageLoader

Class UnifiedLanguageLoader

packages/code-map/src/languages.ts:210–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208/* 8. Unified runtime loader */
209/* ------------------------------------------------------------------ */
210class UnifiedLanguageLoader implements RuntimeLanguageLoader {
211 private parserReady: Promise<void>
212
213 constructor() {
214 this.parserReady = initTreeSitterForNode()
215 }
216
217 async initParser(): Promise<void> {
218 await this.parserReady
219 }
220
221 async loadLanguage(wasmFile: string): Promise<Language> {
222 // Resolve WASM file path
223 let wasmPath = resolveWasmPath(wasmFile)
224
225 // Try to load the language using Node.js-specific method if available
226 let lang: Language
227 try {
228 lang = await Language.load(wasmPath)
229 } catch (err) {
230 // Fallback: try resolving from the original package (development)
231 const fallbackPath = tryResolveFromPackage(wasmFile)
232 if (fallbackPath) {
233 lang = await Language.load(fallbackPath)
234 } else {
235 throw err
236 }
237 }
238
239 return lang
240 }
241}
242
243/* ------------------------------------------------------------------ */
244/* 9. Helper functions */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected