Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore all non-TeXiFy indexing exceptions #3309

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nl.hannahsten.texifyidea.index

import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
Expand All @@ -11,6 +10,7 @@ import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.psi.stubs.StubIndexKey
import com.intellij.refactoring.suggested.createSmartPointer
import nl.hannahsten.texifyidea.util.Log
import nl.hannahsten.texifyidea.util.files.documentClassFileInProject
import nl.hannahsten.texifyidea.util.files.findRootFile
import nl.hannahsten.texifyidea.util.files.referencedFileSet
Expand Down Expand Up @@ -139,9 +139,10 @@ abstract class IndexUtilBase<T : PsiElement>(
try {
return runReadAction { StubIndex.getElements(indexKey, name, project, scope, elementClass) }
}
catch (e: RuntimeExceptionWithAttachments) {
// Ignore, because we've seen it only four times so far (#1375, #1446, #1591, #2086) but I fail to see how this would be a bug in TeXiFy.
if (e.message?.contains("PSI and index do not match") == false) throw e
catch (e: Exception) {
// For some reason, any issue from any plugin that causes an exception will be raised here and will be attributed to TeXiFy, flooding the backlog
// Hence, we just ignore all of them and hope it's not important
Log.warn(e.toString())
}
return emptySet()
}
Expand All @@ -153,12 +154,16 @@ abstract class IndexUtilBase<T : PsiElement>(
* The project instance.
*/
private fun getKeys(project: Project): Array<String> {
return if (!DumbService.isDumb(project) && !project.isDefault) {
runReadAction { StubIndex.getInstance().getAllKeys(indexKey, project).toTypedArray() }
}
else {
emptyArray()
if (!DumbService.isDumb(project) && !project.isDefault) {
try {
return runReadAction { StubIndex.getInstance().getAllKeys(indexKey, project).toTypedArray() }
}
catch (e: Exception) {
// See above
Log.warn(e.toString())
}
}
return emptyArray()
}

/**
Expand Down
Loading