IJPL-203663 Stmt Typing Code Analysis degradation in large files due to Grazie

Co-authored-by: Vladislav Beskrovnyi <Vladislav.Beskrovny@jetbrains.com>

Merge-request: IJ-MR-173416
Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com>

GitOrigin-RevId: 6dd927578fe6094ec53db92086977ee2c652b0ca
This commit is contained in:
Ilia Permiashkin
2025-08-25 18:37:51 +00:00
committed by intellij-monorepo-bot
co-authored by Vladislav Beskrovnyi
parent 64472cd007
commit 224cbe2f08
@@ -34,6 +34,7 @@ import org.languagetool.language.English
object DependencyParser {
private val LOG = Logger.getInstance(DependencyParser::class.java)
private val cachedTrees = ContainerUtil.createSoftKeySoftValueMap<String, Tree>()
@JvmStatic
fun getParser(text: TextContent, minimal: Boolean): AsyncBatchParser<Tree>? {
@@ -62,7 +63,11 @@ object DependencyParser {
val support = obtainSupport(language)
if (support != null) {
@Suppress("UNCHECKED_CAST")
return sentences.associateWith { Tree.createFlatTree(support, it.sentence) } as LinkedHashMap<SentenceWithExclusions, Tree?>
return sentences.associateWith {
cachedTrees.getOrPut(it.sentence) {
Tree.createFlatTree(support, it.sentence)
}
} as LinkedHashMap<SentenceWithExclusions, Tree?>
}
return LinkedHashMap()