IJPL-171917 don't allow GrazieInspection to touch indexes in dumb mode

GrazieInspection can run in dumb mode after implementation of IJPL-155874.
But unfortunately, one of its filters (CommentProblemFilter) needs indexes.
So in some situations IDE gets stuck.

The easy solution is just to avoid checks requiring indexes.
A better solution would be to detect todo comments without indexes IDEA-364846.


(cherry picked from commit bc8962287f61eade48df703b7fa25dbd78fb83aa)

IJ-CR-151765

GitOrigin-RevId: 41df36e2ee169afedd2667c923afb36f932e6685
This commit is contained in:
Max Medvedev
2024-12-17 11:15:25 +01:00
committed by intellij-monorepo-bot
parent f45c905fe2
commit 137b1d2b13

View File

@@ -4,6 +4,7 @@ import ai.grazie.nlp.tokenizer.sentence.StandardSentenceTokenizer
import com.intellij.grazie.text.TextContent.TextDomain.COMMENTS
import com.intellij.grazie.text.TextContent.TextDomain.DOCUMENTATION
import com.intellij.grazie.utils.Text
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiFile
import com.intellij.psi.search.PsiTodoSearchHelper
@@ -53,6 +54,7 @@ internal class CommentProblemFilter : ProblemFilter() {
// the _todo_ word spoils the grammar of what follows
private fun isTodoComment(file: PsiFile, text: TextContent): Boolean {
if (DumbService.getInstance(file.project).isDumb) return false
val todos = CachedValuesManager.getProjectPsiDependentCache(file) {
PsiTodoSearchHelper.getInstance(it.project).findTodoItems(it)
}