Skip to content

Commit ce937cb

Browse files
IndexNotReadyException thrown in IDEA with installed UnitTestBot plugin #273
1 parent c85accc commit ce937cb

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ object UtTestsDialogProcessor {
147147
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) {
148148
it.member !is SyntheticElement
149149
}
150-
findMethodsInClassMatchingSelected(clazz, srcMethods)
150+
findMethodsInClassMatchingSelected(project, clazz, srcMethods)
151151
}.executeSynchronously()
152152

153153
val className = srcClass.name
@@ -241,8 +241,8 @@ object UtTestsDialogProcessor {
241241
appendLine("Alternatively, you could try to increase current timeout $timeout sec for generating tests in generation dialog.")
242242
}
243243

244-
private fun findMethodsInClassMatchingSelected(clazz: KClass<*>, selectedMethods: List<MemberInfo>): List<UtMethod<*>> {
245-
val selectedSignatures = selectedMethods.map { it.signature() }
244+
private fun findMethodsInClassMatchingSelected(project: Project, clazz: KClass<*>, selectedMethods: List<MemberInfo>): List<UtMethod<*>> {
245+
val selectedSignatures = selectedMethods.map { it.signature(project) }
246246
return clazz.functions
247247
.sortedWith(compareBy { selectedSignatures.indexOf(it.signature()) })
248248
.filter { it.signature().normalized() in selectedSignatures }

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

Lines changed: 8 additions & 3 deletions
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)