Skip to content

Commit 5de74bb

Browse files
committed
Fix ProhibitedAnalysisException in KotestStructureViewExtension
1 parent e14c67b commit 5de74bb

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/kotlin/io/kotest/plugin/intellij/intentions/SurroundSelectionWithFunctionIntention.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.kotest.plugin.intellij.intentions
22

33
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction
4+
import com.intellij.openapi.application.ApplicationManager
45
import com.intellij.openapi.editor.Editor
56
import com.intellij.openapi.project.Project
67
import com.intellij.openapi.util.TextRange
@@ -15,6 +16,9 @@ import org.jetbrains.kotlin.resolve.ImportPath
1516
abstract class SurroundSelectionWithFunctionIntention : PsiElementBaseIntentionAction() {
1617

1718
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement): Boolean {
19+
if (ApplicationManager.getApplication().isDispatchThread) {
20+
return false
21+
}
1822
return try {
1923
editor?.selectionModel?.hasSelection() == true && element.isContainedInSpec()
2024
} catch (e: Exception) {

src/main/kotlin/io/kotest/plugin/intellij/structure/KotestStructureViewExtension.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.intellij.ide.structureView.StructureViewExtension
55
import com.intellij.ide.structureView.StructureViewTreeElement
66
import com.intellij.ide.util.treeView.smartTree.TreeElement
77
import com.intellij.navigation.ItemPresentation
8+
import com.intellij.openapi.application.ApplicationManager
89
import com.intellij.openapi.editor.Editor
910
import com.intellij.openapi.project.DumbService
1011
import com.intellij.psi.NavigatablePsiElement
@@ -25,7 +26,9 @@ class KotestStructureViewExtension : StructureViewExtension {
2526
}
2627

2728
override fun getChildren(parent: PsiElement): Array<StructureViewTreeElement> {
28-
if (DumbService.isDumb(parent.project)) return emptyArray()
29+
if (ApplicationManager.getApplication().isDispatchThread) {
30+
return emptyArray()
31+
}
2932
val ktClassOrObject = parent as? KtClassOrObject ?: return emptyArray()
3033
val spec = ktClassOrObject.specStyle() ?: return emptyArray()
3134
val tests = spec.tests(parent, false)

0 commit comments

Comments
 (0)