IJPL-149042 use LighterAST from one thread only

LighterAST is not thread-safe, so we have to build classes and symbols in a single thread only

GitOrigin-RevId: bc578d797bd9eb29dd58ed3b294826331d11490f
This commit is contained in:
Max Medvedev
2024-10-02 14:40:36 +02:00
committed by intellij-monorepo-bot
parent b31852a5f0
commit 513f3fa1ee

View File

@@ -161,15 +161,15 @@ internal class VFSBasedEmbeddingEntitiesIndexer(private val cs: CoroutineScope)
content.putUserData(PSI_FILE, psiFile) // todo I think we can avoid explicit passing of file
content.setSubstituteFileType(fileType) // todo we don't want to infer the substituted file type, do we?
// we can't run processing concurrently because LighterAST is not thread-safe
if (classesChannel != null) {
launch {
readActionUndispatched { ClassesProvider.extractClasses(content) }.forEach { classesChannel.send(it) }
}
val classes = readActionUndispatched { ClassesProvider.extractClasses(content) }
classes.forEach { classesChannel.send(it) }
}
if (symbolsChannel != null) {
launch {
readActionUndispatched { SymbolsProvider.extractSymbols(content) }.forEach { symbolsChannel.send(it) }
}
val symbols = readActionUndispatched { SymbolsProvider.extractSymbols(content) }
symbols.forEach { symbolsChannel.send(it) }
}
}
}