Run configurations: Fix compatibility with 2018.3
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@ abstract class AbstractKotlinMultiplatformTestClassGradleConfigurationProducer :
|
||||
classes: List<PsiClass>
|
||||
) {
|
||||
val locationName = classes.singleOrNull()?.name
|
||||
val dataContext = TestTasksChooser.contextWithLocationName(context.dataContext, locationName)
|
||||
val dataContext = MultiplatformTestTasksChooser.createContext(context.dataContext, locationName)
|
||||
|
||||
mppTestTasksChooser.multiplatformChooseTasks(context.project, dataContext, classes) { tasks ->
|
||||
val configuration = fromContext.configuration as ExternalSystemRunConfiguration
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.run
|
||||
|
||||
import com.intellij.execution.Location
|
||||
import com.intellij.execution.actions.ConfigurationContext
|
||||
import com.intellij.execution.actions.ConfigurationFromContext
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.caches.project.isNewMPPModule
|
||||
import org.jetbrains.kotlin.idea.project.platform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.*
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
|
||||
abstract class AbstractKotlinMultiplatformTestClassGradleConfigurationProducer : AbstractKotlinTestClassGradleConfigurationProducer() {
|
||||
override val forceGradleRunner: Boolean get() = true
|
||||
override val hasTestFramework: Boolean get() = true
|
||||
|
||||
abstract fun isApplicable(module: Module, platform: TargetPlatform): Boolean
|
||||
|
||||
final override fun isApplicable(module: Module): Boolean {
|
||||
if (!module.isNewMPPModule) {
|
||||
return false
|
||||
}
|
||||
|
||||
val platform = module.platform ?: return false
|
||||
return isApplicable(module, platform)
|
||||
}
|
||||
|
||||
override fun isPreferredConfiguration(self: ConfigurationFromContext?, other: ConfigurationFromContext): Boolean {
|
||||
return other.isJpsJunitConfiguration()
|
||||
}
|
||||
|
||||
override fun shouldReplace(self: ConfigurationFromContext, other: ConfigurationFromContext): Boolean {
|
||||
return other.isJpsJunitConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractKotlinTestClassGradleConfigurationProducer
|
||||
: TestClassGradleConfigurationProducer(), KotlinGradleConfigurationProducer
|
||||
{
|
||||
override fun isConfigurationFromContext(configuration: ExternalSystemRunConfiguration, context: ConfigurationContext): Boolean {
|
||||
if (!context.check()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!forceGradleRunner) {
|
||||
return super.isConfigurationFromContext(configuration, context)
|
||||
}
|
||||
|
||||
if (GradleConstants.SYSTEM_ID != configuration.settings.externalSystemId) return false
|
||||
return doIsConfigurationFromContext(configuration, context)
|
||||
}
|
||||
|
||||
override fun setupConfigurationFromContext(
|
||||
configuration: ExternalSystemRunConfiguration,
|
||||
context: ConfigurationContext,
|
||||
sourceElement: Ref<PsiElement>
|
||||
): Boolean {
|
||||
if (!context.check()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!forceGradleRunner) {
|
||||
return super.setupConfigurationFromContext(configuration, context, sourceElement)
|
||||
}
|
||||
|
||||
if (GradleConstants.SYSTEM_ID != configuration.settings.externalSystemId) return false
|
||||
if (sourceElement.isNull) return false
|
||||
|
||||
(configuration as? GradleRunConfiguration)?.isScriptDebugEnabled = false
|
||||
return doSetupConfigurationFromContext(configuration, context, sourceElement)
|
||||
}
|
||||
|
||||
private fun ConfigurationContext.check(): Boolean {
|
||||
return hasTestFramework && module != null && isApplicable(module)
|
||||
}
|
||||
|
||||
override fun getPsiClassForLocation(contextLocation: Location<*>) = getTestClassForKotlinTest(contextLocation)
|
||||
override fun getPsiMethodForLocation(contextLocation: Location<*>) = getTestMethodForKotlinTest(contextLocation)
|
||||
}
|
||||
+1
-2
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.idea.caches.project.isNewMPPModule
|
||||
import org.jetbrains.kotlin.idea.project.platform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.TestTasksChooser
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.applyTestConfiguration
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
@@ -74,7 +73,7 @@ abstract class AbstractKotlinMultiplatformTestMethodGradleConfigurationProducer
|
||||
psiMethod: PsiMethod,
|
||||
vararg classes: PsiClass
|
||||
) {
|
||||
val dataContext = TestTasksChooser.contextWithLocationName(context.dataContext, psiMethod.name)
|
||||
val dataContext = MultiplatformTestTasksChooser.createContext(context.dataContext, psiMethod.name)
|
||||
|
||||
mppTestTasksChooser.multiplatformChooseTasks(context.project, dataContext, classes.asList()) { tasks ->
|
||||
val configuration = fromContext.configuration as ExternalSystemRunConfiguration
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.run
|
||||
|
||||
import com.intellij.execution.Location
|
||||
import com.intellij.execution.actions.ConfigurationContext
|
||||
import com.intellij.execution.actions.ConfigurationFromContext
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.caches.project.isNewMPPModule
|
||||
import org.jetbrains.kotlin.idea.project.platform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
|
||||
abstract class AbstractKotlinMultiplatformTestMethodGradleConfigurationProducer : AbstractKotlinTestMethodGradleConfigurationProducer() {
|
||||
override val forceGradleRunner: Boolean get() = true
|
||||
override val hasTestFramework: Boolean get() = true
|
||||
|
||||
abstract fun isApplicable(module: Module, platform: TargetPlatform): Boolean
|
||||
|
||||
final override fun isApplicable(module: Module): Boolean {
|
||||
if (!module.isNewMPPModule) {
|
||||
return false
|
||||
}
|
||||
|
||||
val platform = module.platform ?: return false
|
||||
return isApplicable(module, platform)
|
||||
}
|
||||
|
||||
override fun isPreferredConfiguration(self: ConfigurationFromContext?, other: ConfigurationFromContext): Boolean {
|
||||
return other.isJpsJunitConfiguration()
|
||||
}
|
||||
|
||||
override fun shouldReplace(self: ConfigurationFromContext, other: ConfigurationFromContext): Boolean {
|
||||
return other.isJpsJunitConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractKotlinTestMethodGradleConfigurationProducer
|
||||
: TestMethodGradleConfigurationProducer(), KotlinGradleConfigurationProducer
|
||||
{
|
||||
override fun isConfigurationFromContext(configuration: ExternalSystemRunConfiguration, context: ConfigurationContext): Boolean {
|
||||
if (!context.check()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!forceGradleRunner) {
|
||||
return super.isConfigurationFromContext(configuration, context)
|
||||
}
|
||||
|
||||
if (GradleConstants.SYSTEM_ID != configuration.settings.externalSystemId) return false
|
||||
return doIsConfigurationFromContext(configuration, context)
|
||||
}
|
||||
|
||||
override fun setupConfigurationFromContext(
|
||||
configuration: ExternalSystemRunConfiguration,
|
||||
context: ConfigurationContext,
|
||||
sourceElement: Ref<PsiElement>
|
||||
): Boolean {
|
||||
if (!context.check()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!forceGradleRunner) {
|
||||
return super.setupConfigurationFromContext(configuration, context, sourceElement)
|
||||
}
|
||||
|
||||
if (GradleConstants.SYSTEM_ID != configuration.settings.externalSystemId) return false
|
||||
if (sourceElement.isNull) return false
|
||||
|
||||
(configuration as? GradleRunConfiguration)?.isScriptDebugEnabled = false
|
||||
return doSetupConfigurationFromContext(configuration, context, sourceElement)
|
||||
}
|
||||
|
||||
private fun ConfigurationContext.check(): Boolean {
|
||||
return hasTestFramework && module != null && isApplicable(module)
|
||||
}
|
||||
|
||||
override fun getPsiMethodForLocation(contextLocation: Location<*>) = getTestMethodForKotlinTest(contextLocation)
|
||||
}
|
||||
@@ -18,6 +18,12 @@ import java.util.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
class MultiplatformTestTasksChooser : TestTasksChooser() {
|
||||
companion object {
|
||||
fun createContext(context: DataContext, locationName: String?): DataContext {
|
||||
return contextWithLocationName(context, locationName)
|
||||
}
|
||||
}
|
||||
|
||||
fun multiplatformChooseTasks(
|
||||
project: Project,
|
||||
dataContext: DataContext,
|
||||
|
||||
Reference in New Issue
Block a user