Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix compilation, move smart mode wrapper to upper level
  • Loading branch information
Vassiliy-Kudryashov committed Jul 27, 2022
commit 86010434d7c416960a31a6dab60a83c976c1c813
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ object CodeGenerationController {

val classUnderTest = testSets.first().method.clazz

val params = findMethodParams(classUnderTest, selectedMethods)
val params = DumbService.getInstance(model.project)
.runReadActionInSmartMode(Computable { findMethodParams(classUnderTest, selectedMethods) })

val codeGenerator = CodeGenerator(
classUnderTest = classUnderTest.java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.module.Module
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.OrderEnumerator
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.util.Computable
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiClass
import com.intellij.psi.SyntheticElement
Expand Down Expand Up @@ -150,7 +152,9 @@ object UtTestsDialogProcessor {
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) {
it.member !is SyntheticElement
}
findMethodsInClassMatchingSelected(project, clazz, srcMethods)
DumbService.getInstance(project).runReadActionInSmartMode(Computable {
findMethodsInClassMatchingSelected(clazz, srcMethods)
})
}.executeSynchronously()

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

private fun findMethodsInClassMatchingSelected(project: Project, clazz: KClass<*>, selectedMethods: List<MemberInfo>): List<UtMethod<*>> {
val selectedSignatures = selectedMethods.map { it.signature(project) }
private fun findMethodsInClassMatchingSelected(clazz: KClass<*>, selectedMethods: List<MemberInfo>): List<UtMethod<*>> {
val selectedSignatures = selectedMethods.map { it.signature() }
return clazz.functions
.sortedWith(compareBy { selectedSignatures.indexOf(it.signature()) })
.filter { it.signature().normalized() in selectedSignatures }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import kotlin.reflect.KFunction
import kotlin.reflect.KParameter
import kotlin.reflect.jvm.javaType

fun MemberInfo.signature(project: Project): Signature =
DumbService.getInstance(project).runReadActionInSmartMode(Computable {
fun MemberInfo.signature(): Signature =
(this.member as PsiMethod).signature()
})

private fun PsiMethod.signature() =
Signature(this.name, this.parameterList.parameters.map {
Expand Down