Skip to content

Commit f147a8b

Browse files
IndexNotReadyException thrown in IDEA with installed UnitTestBot plugin #273
1 parent 4f1c7f5 commit f147a8b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ object UtTestsDialogProcessor {
150150
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) {
151151
it.member !is SyntheticElement
152152
}
153-
findMethodsInClassMatchingSelected(clazz, srcMethods)
153+
findMethodsInClassMatchingSelected(project, clazz, srcMethods)
154154
}.executeSynchronously()
155155

156156
val className = srcClass.name
@@ -251,8 +251,8 @@ object UtTestsDialogProcessor {
251251
appendLine("Alternatively, you could try to increase current timeout $timeout sec for generating tests in generation dialog.")
252252
}
253253

254-
private fun findMethodsInClassMatchingSelected(clazz: KClass<*>, selectedMethods: List<MemberInfo>): List<UtMethod<*>> {
255-
val selectedSignatures = selectedMethods.map { it.signature() }
254+
private fun findMethodsInClassMatchingSelected(project: Project, clazz: KClass<*>, selectedMethods: List<MemberInfo>): List<UtMethod<*>> {
255+
val selectedSignatures = selectedMethods.map { it.signature(project) }
256256
return clazz.functions
257257
.sortedWith(compareBy { selectedSignatures.indexOf(it.signature()) })
258258
.filter { it.signature().normalized() in selectedSignatures }

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/util/SignaturesHelper.kt

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
package org.utbot.intellij.plugin.util
22

3+
import com.intellij.openapi.project.DumbService
4+
import com.intellij.openapi.project.Project
5+
import com.intellij.openapi.util.Computable
36
import com.intellij.psi.PsiMethod
47
import com.intellij.refactoring.util.classMembers.MemberInfo
58
import kotlin.reflect.KFunction
69
import kotlin.reflect.KParameter
710
import kotlin.reflect.jvm.javaType
811

9-
fun MemberInfo.signature(): Signature =
10-
(this.member as PsiMethod).signature()
12+
fun MemberInfo.signature(project: Project): Signature =
13+
DumbService.getInstance(project).runReadActionInSmartMode(Computable {
14+
(this.member as PsiMethod).signature()
15+
})
1116

12-
fun PsiMethod.signature() =
17+
private fun PsiMethod.signature() =
1318
Signature(this.name, this.parameterList.parameters.map {
1419
it.type.canonicalText
1520
.replace("...", "[]") //for PsiEllipsisType

0 commit comments

Comments
 (0)