mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[grazie] IJPL-228233 Make local cache language dependant
Merge-request: IJ-MR-191688 Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com> GitOrigin-RevId: 8a7e6d4fe97a43863ed89fe0907b5fdcabb41b43
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7bb876b50c
commit
2c48ac1258
@@ -38,7 +38,7 @@ import org.languagetool.language.English
|
||||
|
||||
object DependencyParser {
|
||||
private val LOG = Logger.getInstance(DependencyParser::class.java)
|
||||
private val cachedTrees: MutableMap<String, Tree> = createConcurrentSoftKeySoftValueMap()
|
||||
private val cachedTrees: MutableMap<SentenceWithLanguage, Tree> = createConcurrentSoftKeySoftValueMap()
|
||||
|
||||
@JvmStatic
|
||||
fun getParser(context: ProofreadingContext, minimal: Boolean): AsyncBatchParser<Tree>? {
|
||||
@@ -75,7 +75,7 @@ object DependencyParser {
|
||||
(ltLanguage?.disambiguator as? LazyCachingConcurrentDisambiguator)?.ensureInitializedAsync()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return sentences.associateWith {
|
||||
cachedTrees.getOrPut(it.sentence) {
|
||||
cachedTrees.getOrPut(SentenceWithLanguage(it.sentence, language)) {
|
||||
ensureActive()
|
||||
Tree.createFlatTree(support, it.sentence)
|
||||
}
|
||||
@@ -172,3 +172,5 @@ object DependencyParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private data class SentenceWithLanguage(val sentence: String, val language: Language)
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.testFramework.PerformanceUnitTest
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
||||
import com.intellij.tools.ide.metrics.benchmark.Benchmark
|
||||
import org.junit.jupiter.api.assertDoesNotThrow
|
||||
import java.util.function.Consumer
|
||||
|
||||
|
||||
@@ -295,6 +296,18 @@ class JavaSupportTest : GrazieTestBase() {
|
||||
assertNull(myFixture.getAvailableIntention("Accept all writing suggestions…"))
|
||||
}
|
||||
|
||||
fun `test dependency parser creates correct trees based on text content language`() {
|
||||
enableProofreadingFor(setOf(Lang.GERMANY_GERMAN, Lang.AMERICAN_ENGLISH))
|
||||
myFixture.configureByText("a.java", """
|
||||
// In der tiefen Winternacht saß der alte Mann am Feuer. Die fast.
|
||||
|
||||
// Hello. This is really English text. Nothing to see here. Die fast.
|
||||
""".trimIndent())
|
||||
assertDoesNotThrow {
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
}
|
||||
|
||||
fun `test asian-english mixed texts`() {
|
||||
runHighlightTestForFile("ide/language/java/Mixed.java")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user