File tree Expand file tree Collapse file tree 5 files changed +24
-30
lines changed
IC-242/kotlin/io/kotest/plugin/intellij/psi
IC-243/kotlin/io/kotest/plugin/intellij/psi
IC-251/kotlin/io/kotest/plugin/intellij/psi
main/kotlin/io/kotest/plugin/intellij Expand file tree Collapse file tree 5 files changed +24
-30
lines changed Original file line number Diff line number Diff line change 1
1
package io.kotest.plugin.intellij.psi
2
2
3
+ import com.intellij.openapi.application.runReadAction
3
4
import org.jetbrains.kotlin.analysis.api.analyze
4
5
import org.jetbrains.kotlin.analysis.api.permissions.KaAllowAnalysisOnEdt
5
- import org.jetbrains.kotlin.analysis.api.permissions.allowAnalysisOnEdt
6
6
import org.jetbrains.kotlin.analysis.api.types.symbol
7
7
import org.jetbrains.kotlin.name.FqName
8
8
import org.jetbrains.kotlin.name.StandardClassIds
@@ -15,10 +15,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
15
15
fun KtClassOrObject.getAllSuperClasses (): List <FqName > {
16
16
return superTypeListEntries.mapNotNull { it.typeReference }
17
17
.flatMap { ref ->
18
- // SurroundSelectionWithFunctionIntention.isAvailable is called in EDT before the intention is applied
19
- // unfortunately API to avoid this was introduced in 23.2 only
20
- // this we need to move intentions to the facade or accept EDT here until 23.2- are still supported
21
- allowAnalysisOnEdt {
18
+ runReadAction {
22
19
analyze(this ) {
23
20
val kaType = ref.type
24
21
val superTypes = (kaType.allSupertypes(false ) + kaType).toList()
Original file line number Diff line number Diff line change @@ -15,17 +15,12 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
15
15
fun KtClassOrObject.getAllSuperClasses (): List <FqName > {
16
16
return superTypeListEntries.mapNotNull { it.typeReference }
17
17
.flatMap { ref ->
18
- // SurroundSelectionWithFunctionIntention.isAvailable is called in EDT before the intention is applied
19
- // unfortunately API to avoid this was introduced in 23.2 only
20
- // this we need to move intentions to the facade or accept EDT here until 23.2- are still supported
21
- allowAnalysisOnEdt {
22
- analyze(this ) {
23
- val kaType = ref.type
24
- val superTypes = (kaType.allSupertypes(false ) + kaType).toList()
25
- superTypes.mapNotNull {
26
- val classId = it.symbol?.classId?.takeIf { id -> id != StandardClassIds .Any }
27
- classId?.asSingleFqName()
28
- }
18
+ analyze(this ) {
19
+ val kaType = ref.type
20
+ val superTypes = (kaType.allSupertypes(false ) + kaType).toList()
21
+ superTypes.mapNotNull {
22
+ val classId = it.symbol?.classId?.takeIf { id -> id != StandardClassIds .Any }
23
+ classId?.asSingleFqName()
29
24
}
30
25
}
31
26
}
Original file line number Diff line number Diff line change @@ -15,17 +15,12 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
15
15
fun KtClassOrObject.getAllSuperClasses (): List <FqName > {
16
16
return superTypeListEntries.mapNotNull { it.typeReference }
17
17
.flatMap { ref ->
18
- // SurroundSelectionWithFunctionIntention.isAvailable is called in EDT before the intention is applied
19
- // unfortunately API to avoid this was introduced in 23.2 only
20
- // this we need to move intentions to the facade or accept EDT here until 23.2- are still supported
21
- allowAnalysisOnEdt {
22
- analyze(this ) {
23
- val kaType = ref.type
24
- val superTypes = (kaType.allSupertypes(false ) + kaType).toList()
25
- superTypes.mapNotNull {
26
- val classId = it.symbol?.classId?.takeIf { id -> id != StandardClassIds .Any }
27
- classId?.asSingleFqName()
28
- }
18
+ analyze(this ) {
19
+ val kaType = ref.type
20
+ val superTypes = (kaType.allSupertypes(false ) + kaType).toList()
21
+ superTypes.mapNotNull {
22
+ val classId = it.symbol?.classId?.takeIf { id -> id != StandardClassIds .Any }
23
+ classId?.asSingleFqName()
29
24
}
30
25
}
31
26
}
Original file line number Diff line number Diff line change 1
1
package io.kotest.plugin.intellij.intentions
2
2
3
3
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction
4
+ import com.intellij.openapi.application.ApplicationManager
4
5
import com.intellij.openapi.editor.Editor
5
6
import com.intellij.openapi.project.Project
6
7
import com.intellij.openapi.util.TextRange
@@ -15,6 +16,9 @@ import org.jetbrains.kotlin.resolve.ImportPath
15
16
abstract class SurroundSelectionWithFunctionIntention : PsiElementBaseIntentionAction () {
16
17
17
18
override fun isAvailable (project : Project , editor : Editor ? , element : PsiElement ): Boolean {
19
+ if (ApplicationManager .getApplication().isDispatchThread) {
20
+ return false
21
+ }
18
22
return try {
19
23
editor?.selectionModel?.hasSelection() == true && element.isContainedInSpec()
20
24
} catch (e: Exception ) {
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ import com.intellij.ide.structureView.StructureViewExtension
5
5
import com.intellij.ide.structureView.StructureViewTreeElement
6
6
import com.intellij.ide.util.treeView.smartTree.TreeElement
7
7
import com.intellij.navigation.ItemPresentation
8
+ import com.intellij.openapi.application.ApplicationManager
8
9
import com.intellij.openapi.editor.Editor
9
- import com.intellij.openapi.project.DumbService
10
10
import com.intellij.psi.NavigatablePsiElement
11
11
import com.intellij.psi.PsiElement
12
12
import io.kotest.plugin.intellij.Test
@@ -25,11 +25,14 @@ class KotestStructureViewExtension : StructureViewExtension {
25
25
}
26
26
27
27
override fun getChildren (parent : PsiElement ): Array <StructureViewTreeElement > {
28
- if (DumbService .isDumb(parent.project)) return emptyArray()
28
+ if (ApplicationManager .getApplication().isDispatchThread) {
29
+ return emptyArray()
30
+ }
29
31
val ktClassOrObject = parent as ? KtClassOrObject ? : return emptyArray()
30
32
val spec = ktClassOrObject.specStyle() ? : return emptyArray()
31
33
val tests = spec.tests(parent, false )
32
- return tests.map { KotestTestStructureViewTreeElement (it) }.toTypedArray()
34
+ val children = tests.map { KotestTestStructureViewTreeElement (it) }
35
+ return children.toTypedArray()
33
36
}
34
37
35
38
class KotestTestStructureViewTreeElement (private val testElement : TestElement ) : StructureViewTreeElement {
You can’t perform that action at this time.
0 commit comments