mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 20:31:37 -05:00
Initialize Parser only once
This commit is contained in:
@@ -26,6 +26,15 @@ async function loadLanguage(langName: string) {
|
|||||||
return await Parser.Language.load(path.join(__dirname, `tree-sitter-${langName}.wasm`))
|
return await Parser.Language.load(path.join(__dirname, `tree-sitter-${langName}.wasm`))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isParserInitialized = false
|
||||||
|
|
||||||
|
async function initializeParser() {
|
||||||
|
if (!isParserInitialized) {
|
||||||
|
await Parser.init()
|
||||||
|
isParserInitialized = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Using node bindings for tree-sitter is problematic in vscode extensions
|
Using node bindings for tree-sitter is problematic in vscode extensions
|
||||||
because of incompatibility with electron. Going the .wasm route has the
|
because of incompatibility with electron. Going the .wasm route has the
|
||||||
@@ -49,7 +58,7 @@ Sources:
|
|||||||
- https://github.com/tree-sitter/tree-sitter/blob/master/lib/binding_web/test/query-test.js
|
- https://github.com/tree-sitter/tree-sitter/blob/master/lib/binding_web/test/query-test.js
|
||||||
*/
|
*/
|
||||||
export async function loadRequiredLanguageParsers(filesToParse: string[]): Promise<LanguageParser> {
|
export async function loadRequiredLanguageParsers(filesToParse: string[]): Promise<LanguageParser> {
|
||||||
await Parser.init()
|
await initializeParser()
|
||||||
const extensionsToLoad = new Set(filesToParse.map((file) => path.extname(file).toLowerCase().slice(1)))
|
const extensionsToLoad = new Set(filesToParse.map((file) => path.extname(file).toLowerCase().slice(1)))
|
||||||
const parsers: LanguageParser = {}
|
const parsers: LanguageParser = {}
|
||||||
for (const ext of extensionsToLoad) {
|
for (const ext of extensionsToLoad) {
|
||||||
|
|||||||
Reference in New Issue
Block a user