mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[grazie] IJPL-252933 Better handling of words that don't have suggestions in cloud
Merge-request: IJ-MR-218532 Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com> Merge-request: IJ-MR-218560 Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com> GitOrigin-RevId: 80e1a10b05d7650a85d611fb700e29afab9b543c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ec5e10adf0
commit
9ae7249ee2
+10
-12
@@ -27,7 +27,6 @@ import com.intellij.grazie.utils.EXTRACTOR_SOURCE
|
||||
import com.intellij.grazie.utils.NaturalTextDetector
|
||||
import com.intellij.grazie.utils.getGrazieTracker
|
||||
import com.intellij.grazie.utils.getProblems
|
||||
import com.intellij.grazie.utils.toLinkedSet
|
||||
import com.intellij.grazie.utils.toSpellingProblems
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.Service
|
||||
@@ -199,20 +198,19 @@ internal class SpellingTextChecker : ExternalTextChecker() {
|
||||
}
|
||||
|
||||
private fun toCloudProblems(context: ProofreadingContext, problems: List<Problem>, manager: SpellCheckerManager): List<TypoProblem> =
|
||||
problems
|
||||
.mapNotNull {
|
||||
val parts = it.fixes.flatMap { fix -> fix.parts.toList() }
|
||||
problems.mapNotNull { problem ->
|
||||
val range = problem.highlighting.always.single()
|
||||
val word = range.substring(context.text.toString())
|
||||
if (!manager.hasProblem(word)) return@mapNotNull null
|
||||
|
||||
TypoProblem(context.text, range, word, true) {
|
||||
problem.fixes.asSequence()
|
||||
.flatMap { fix -> fix.parts.toList() }
|
||||
.filterIsInstance<ProblemFix.Part.Change>()
|
||||
.filter { part -> part.type == ProblemFix.Part.Change.ChangeType.REPLACE }
|
||||
if (parts.isEmpty()) return@mapNotNull null
|
||||
|
||||
val word = parts.first().range.substring(context.text.toString())
|
||||
if (!manager.hasProblem(word)) return@mapNotNull null
|
||||
|
||||
TypoProblem(context.text, parts.first().range, word, true) {
|
||||
parts.map { part -> part.text }.toLinkedSet()
|
||||
}
|
||||
.mapTo(LinkedHashSet()) { part -> part.text }
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkText(context: ProofreadingContext, project: Project): List<Typo> {
|
||||
val textSpeller = getTextSpeller(project) ?: return emptyList()
|
||||
|
||||
+10
-1
@@ -6,7 +6,7 @@ import com.intellij.grazie.spellcheck.GrazieSpellCheckingInspection
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class CloudTextLevelSpellcheckingTest: BaseTestCase() {
|
||||
class CloudSpellcheckingTest: BaseTestCase() {
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
myFixture.enableInspections(GrazieSpellCheckingInspection())
|
||||
@@ -49,4 +49,13 @@ class CloudTextLevelSpellcheckingTest: BaseTestCase() {
|
||||
""".trimIndent())
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
|
||||
@NeedsCloud
|
||||
@Test
|
||||
fun `test typos without suggestions are highlighted`() {
|
||||
myFixture.configureByText("a.md", """
|
||||
English text about <TYPO descr="Typo: In word 'asdkjasjdhasjdasjdhajdzxc'">asdkjasjdhasjdasjdhajdzxc</TYPO>
|
||||
""".trimIndent())
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user