mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
beforeRunTaks
(cherry picked from commit f9fc313746720cd09ec122982907baf90eb1cdd8)
This commit is contained in:
@@ -39,7 +39,6 @@ import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -142,12 +141,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
|
||||
}
|
||||
|
||||
protected void disposeSession(final DebuggerSession debuggerSession) throws InterruptedException, InvocationTargetException {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
debuggerSession.dispose();
|
||||
}
|
||||
});
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> debuggerSession.dispose());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,15 +255,12 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
|
||||
final RemoteConnection debugParameters =
|
||||
DebuggerManagerImpl.createDebugParameters(javaCommandLineState.getJavaParameters(), debuggerRunnerSettings, true);
|
||||
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
debuggerSession[0] = attachVirtualMachine(javaCommandLineState, javaCommandLineState.getEnvironment(), debugParameters, false);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
|
||||
try {
|
||||
debuggerSession[0] = attachVirtualMachine(javaCommandLineState, javaCommandLineState.getEnvironment(), debugParameters, false);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -338,17 +329,14 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
|
||||
final RemoteState remoteState = new RemoteStateState(myProject, remoteConnection);
|
||||
|
||||
final DebuggerSession[] debuggerSession = new DebuggerSession[1];
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
debuggerSession[0] = attachVirtualMachine(remoteState, new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance())
|
||||
.runProfile(new MockConfiguration())
|
||||
.build(), remoteConnection, pollConnection);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
|
||||
try {
|
||||
debuggerSession[0] = attachVirtualMachine(remoteState, new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance())
|
||||
.runProfile(new MockConfiguration())
|
||||
.build(), remoteConnection, pollConnection);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
});
|
||||
debuggerSession[0].getProcess().getProcessHandler().addProcessListener(new ProcessAdapter() {
|
||||
@@ -361,13 +349,10 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
|
||||
}
|
||||
|
||||
protected void createBreakpoints(final String className) {
|
||||
final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
|
||||
@Override
|
||||
public PsiFile compute() {
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass(className, GlobalSearchScope.allScope(myProject));
|
||||
assertNotNull(psiClass);
|
||||
return psiClass.getContainingFile();
|
||||
}
|
||||
final PsiFile psiFile = ApplicationManager.getApplication().runReadAction((Computable<PsiFile>)() -> {
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass(className, GlobalSearchScope.allScope(myProject));
|
||||
assertNotNull(psiClass);
|
||||
return psiClass.getContainingFile();
|
||||
});
|
||||
|
||||
createBreakpoints(psiFile);
|
||||
@@ -441,12 +426,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
|
||||
public DebuggerContextImpl createDebuggerContext(final SuspendContextImpl suspendContext, StackFrameProxyImpl stackFrame) {
|
||||
final DebuggerSession[] session = new DebuggerSession[1];
|
||||
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
session[0] = DebuggerManagerEx.getInstanceEx(myProject).getSession(suspendContext.getDebugProcess());
|
||||
}
|
||||
});
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> session[0] = DebuggerManagerEx.getInstanceEx(myProject).getSession(suspendContext.getDebugProcess()));
|
||||
|
||||
DebuggerContextImpl debuggerContext = DebuggerContextImpl.createDebuggerContext(
|
||||
session[0],
|
||||
@@ -575,9 +555,6 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration() throws RuntimeConfigurationException { }
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException { }
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
@@ -23,6 +24,9 @@ import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for run configurations which can be managed by a user and displayed in the UI.
|
||||
*
|
||||
@@ -128,11 +132,19 @@ public interface RunConfiguration extends RunProfile, Cloneable {
|
||||
* @throws RuntimeConfigurationError if the configuration settings contain a fatal problem which makes it impossible
|
||||
* to execute the run configuration.
|
||||
*/
|
||||
void checkConfiguration() throws RuntimeConfigurationException;
|
||||
default void checkConfiguration() throws RuntimeConfigurationException {
|
||||
}
|
||||
|
||||
default void readExternal(Element element) {
|
||||
}
|
||||
|
||||
default void writeExternal(Element element) {
|
||||
}
|
||||
|
||||
default List<BeforeRunTask> getBeforeRunTasks() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
default void setBeforeRunTasks(@Nullable List<BeforeRunTask> value) {
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -92,9 +92,9 @@ public class UnknownRunConfiguration implements RunConfiguration, WithoutOwnBefo
|
||||
@Override
|
||||
public RunConfiguration clone() {
|
||||
try {
|
||||
final UnknownRunConfiguration cloned = (UnknownRunConfiguration) super.clone();
|
||||
return cloned;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
return (UnknownRunConfiguration)super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ public abstract class RunManagerEx extends RunManager {
|
||||
return (RunManagerEx)project.getComponent(RunManager.class);
|
||||
}
|
||||
|
||||
//public abstract boolean isTemporary(@NotNull RunnerAndConfigurationSettings configuration);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setSelectedConfiguration(RunnerAndConfigurationSettings)} instead
|
||||
*/
|
||||
@@ -57,6 +55,10 @@ public abstract class RunManagerEx extends RunManager {
|
||||
@NotNull
|
||||
public abstract RunnerAndConfigurationSettings createConfiguration(String name, ConfigurationFactory type);
|
||||
|
||||
public void addConfiguration(RunnerAndConfigurationSettings settings, boolean isShared, List<BeforeRunTask> tasks) {
|
||||
addConfiguration(settings, isShared, tasks, false);
|
||||
}
|
||||
|
||||
public abstract void addConfiguration(RunnerAndConfigurationSettings settings,
|
||||
boolean isShared,
|
||||
List<BeforeRunTask> tasks,
|
||||
@@ -65,7 +67,7 @@ public abstract class RunManagerEx extends RunManager {
|
||||
public abstract boolean isConfigurationShared(RunnerAndConfigurationSettings settings);
|
||||
|
||||
@NotNull
|
||||
public abstract List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings);
|
||||
public abstract List<BeforeRunTask> getBeforeRunTasks(@NotNull RunConfiguration settings);
|
||||
|
||||
public abstract void setBeforeRunTasks(@NotNull RunConfiguration runConfiguration, @NotNull List<BeforeRunTask> tasks, boolean addEnabledTemplateTasksIfAbsent);
|
||||
|
||||
|
||||
+1
-2
@@ -70,8 +70,7 @@ public class CopyConfigurationAction extends RunConfigurationTreeAction {
|
||||
|
||||
if (RunDialog.editConfiguration(node.getProject(), copiedSettings,
|
||||
ExecutionBundle.message("run.dashboard.edit.configuration.dialog.title"))) {
|
||||
runManager.addConfiguration(copiedSettings, runManager.isConfigurationShared(settings),
|
||||
runManager.getBeforeRunTasks(settings.getConfiguration()), false);
|
||||
runManager.addConfiguration(copiedSettings, runManager.isConfigurationShared(settings), runManager.getBeforeRunTasks(settings.getConfiguration()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
}
|
||||
}
|
||||
|
||||
private val myTypesByName = LinkedHashMap<String, ConfigurationType>()
|
||||
private val typeByName = LinkedHashMap<String, ConfigurationType>()
|
||||
|
||||
protected val myTemplateConfigurationsMap = ConcurrentSkipListMap<String, RunnerAndConfigurationSettingsImpl>()
|
||||
private val myConfigurations = LinkedHashMap<String, RunnerAndConfigurationSettings>() // template configurations are not included here
|
||||
@@ -110,6 +110,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
private val myConfig = RunManagerConfig(propertiesComponent)
|
||||
|
||||
private var myUnknownElements: List<Element>? = null
|
||||
@Suppress("DEPRECATION")
|
||||
private val myOrder = JDOMExternalizableStringList()
|
||||
protected val myRecentlyUsedTemporaries = ArrayList<RunConfiguration>()
|
||||
private var myOrdered = true
|
||||
@@ -170,31 +171,22 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
myTypes = types.toTypedArray()
|
||||
|
||||
for (type in factories) {
|
||||
myTypesByName.put(type.id, type)
|
||||
typeByName.put(type.id, type)
|
||||
}
|
||||
|
||||
val broken = UnknownConfigurationType.INSTANCE
|
||||
myTypesByName.put(broken.id, broken)
|
||||
typeByName.put(broken.id, broken)
|
||||
}
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
override fun createConfiguration(name: String, factory: ConfigurationFactory): RunnerAndConfigurationSettings {
|
||||
return createConfiguration(doCreateConfiguration(name, factory, true), factory)
|
||||
}
|
||||
|
||||
internal fun doCreateConfiguration(name: String, factory: ConfigurationFactory, fromTemplate: Boolean): RunConfiguration {
|
||||
if (fromTemplate) {
|
||||
return factory.createConfiguration(name, getConfigurationTemplate(factory).configuration)
|
||||
}
|
||||
else {
|
||||
val configuration = factory.createTemplateConfiguration(project, this)
|
||||
configuration.name = name
|
||||
return configuration
|
||||
}
|
||||
}
|
||||
|
||||
override fun createConfiguration(runConfiguration: RunConfiguration, factory: ConfigurationFactory): RunnerAndConfigurationSettings {
|
||||
val template = getConfigurationTemplate(factory)
|
||||
return createConfiguration(factory.createConfiguration(name, template.configuration), template)
|
||||
}
|
||||
|
||||
override fun createConfiguration(runConfiguration: RunConfiguration, factory: ConfigurationFactory) = createConfiguration(runConfiguration, getConfigurationTemplate(factory))
|
||||
|
||||
private fun createConfiguration(runConfiguration: RunConfiguration, template: RunnerAndConfigurationSettingsImpl): RunnerAndConfigurationSettings {
|
||||
val settings = RunnerAndConfigurationSettingsImpl(this, runConfiguration, false)
|
||||
settings.importRunnerAndConfigurationSettings(template)
|
||||
if (!mySharedConfigurations.containsKey(settings.uniqueID)) {
|
||||
@@ -346,7 +338,11 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun runConfigurationAdded(settings: RunnerAndConfigurationSettings, shared: Boolean) {
|
||||
private fun runConfigurationAdded(settings: RunnerAndConfigurationSettings, shared: Boolean) {
|
||||
if (!shared) {
|
||||
schemeManager.addScheme(settings as RunConfigurationScheme)
|
||||
}
|
||||
|
||||
myDispatcher.multicaster.runConfigurationAdded(settings)
|
||||
}
|
||||
|
||||
@@ -586,8 +582,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
beforeRunTasks = getHardcodedBeforeRunTasks(settings.configuration)
|
||||
}
|
||||
else {
|
||||
val configurationTemplate = getConfigurationTemplate(settings.factory!!)
|
||||
beforeRunTasks = configurationTemplate.beforeRunTasks ?: emptyList()
|
||||
beforeRunTasks = getConfigurationTemplate(settings.factory!!).configuration.beforeRunTasks ?: emptyList()
|
||||
}
|
||||
for (templateTask in beforeRunTasks) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -653,6 +648,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
myRecentlyUsedTemporaries.clear()
|
||||
val recentNode = parentNode.getChild(RECENT)
|
||||
if (recentNode != null) {
|
||||
@Suppress("DEPRECATION")
|
||||
val list = JDOMExternalizableStringList()
|
||||
list.readExternal(recentNode)
|
||||
readList(list)
|
||||
@@ -672,10 +668,11 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
fireRunConfigurationSelected()
|
||||
}
|
||||
|
||||
private fun readList(list: JDOMExternalizableStringList) {
|
||||
private fun readList(@Suppress("DEPRECATION") list: JDOMExternalizableStringList) {
|
||||
for (i in list.indices) {
|
||||
for (settings in myConfigurations.values) {
|
||||
val configuration = settings.configuration
|
||||
@Suppress("DEPRECATION")
|
||||
if (configuration != null && list.get(i) == "${configuration.type.displayName}.${configuration.name}${(configuration as? UnknownRunConfiguration)?.uniqueID ?: ""}") {
|
||||
list.set(i, settings.uniqueID)
|
||||
break
|
||||
@@ -716,7 +713,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
// used by MPS, don't delete
|
||||
fun clearAll() {
|
||||
clear(true)
|
||||
myTypesByName.clear()
|
||||
typeByName.clear()
|
||||
initializeConfigurationTypes(emptyArray())
|
||||
}
|
||||
|
||||
@@ -765,51 +762,62 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
return settings
|
||||
}
|
||||
|
||||
protected fun doLoadConfiguration(element: Element, isShared: Boolean, settings: RunnerAndConfigurationSettingsImpl, factory: ConfigurationFactory) {
|
||||
val tasks = readStepsBeforeRun(element.getChild(METHOD), settings)
|
||||
private fun doLoadConfiguration(element: Element, isShared: Boolean, settings: RunnerAndConfigurationSettingsImpl, factory: ConfigurationFactory) {
|
||||
val tasks = element.getChild(METHOD)?.let { readStepsBeforeRun(it, settings) } ?: emptyList()
|
||||
if (settings.isTemplate) {
|
||||
myTemplateConfigurationsMap.put("${factory.type.id}.${factory.name}", settings)
|
||||
setBeforeRunTasks(settings.configuration, tasks, true)
|
||||
settings.configuration.beforeRunTasks = tasks
|
||||
}
|
||||
else {
|
||||
addConfiguration(settings, isShared, tasks, true)
|
||||
if (java.lang.Boolean.parseBoolean(element.getAttributeValue(SELECTED_ATTR))) {
|
||||
val configuration = settings.configuration
|
||||
if (configuration !is UnknownRunConfiguration) {
|
||||
val result = SmartList(tasks)
|
||||
addTemplateBeforeTasks(configuration, tasks, result)
|
||||
configuration.beforeRunTasks = result
|
||||
}
|
||||
|
||||
addConfiguration(settings, isShared, tasks, false)
|
||||
if (element.getAttributeValue(SELECTED_ATTR).toBoolean()) {
|
||||
// to support old style
|
||||
selectedConfiguration = settings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun readStepsBeforeRun(child: Element?, settings: RunnerAndConfigurationSettings): List<BeforeRunTask<*>> {
|
||||
private fun readStepsBeforeRun(child: Element, settings: RunnerAndConfigurationSettings): List<BeforeRunTask<*>> {
|
||||
var result: MutableList<BeforeRunTask<*>>? = null
|
||||
if (child != null) {
|
||||
for (methodElement in child.getChildren(OPTION)) {
|
||||
val id = getProviderKey(methodElement.getAttributeValue(NAME_ATTR))
|
||||
val beforeRunTask = getProvider(id).createTask(settings.configuration)
|
||||
if (beforeRunTask != null) {
|
||||
beforeRunTask.readExternal(methodElement)
|
||||
if (result == null) {
|
||||
result = SmartList()
|
||||
}
|
||||
result.add(beforeRunTask)
|
||||
for (methodElement in child.getChildren(OPTION)) {
|
||||
val id = getProviderKey(methodElement.getAttributeValue(NAME_ATTR))
|
||||
val beforeRunTask = getProvider(id).createTask(settings.configuration)
|
||||
if (beforeRunTask != null) {
|
||||
beforeRunTask.readExternal(methodElement)
|
||||
if (result == null) {
|
||||
result = SmartList()
|
||||
}
|
||||
result.add(beforeRunTask)
|
||||
}
|
||||
}
|
||||
return result ?: emptyList()
|
||||
}
|
||||
|
||||
fun getConfigurationType(typeName: String) = myTypesByName.get(typeName)
|
||||
fun getConfigurationType(typeName: String) = typeByName.get(typeName)
|
||||
|
||||
@JvmOverloads fun getFactory(typeName: String?, factoryName: String?, checkUnknown: Boolean = false): ConfigurationFactory? {
|
||||
val type = myTypesByName.get(typeName)
|
||||
if (type == null && checkUnknown && typeName != null) {
|
||||
UnknownFeaturesCollector.getInstance(project).registerUnknownRunConfiguration(typeName)
|
||||
@JvmOverloads
|
||||
fun getFactory(typeName: String?, _factoryName: String?, checkUnknown: Boolean = false): ConfigurationFactory? {
|
||||
var type = typeByName.get(typeName)
|
||||
if (type == null) {
|
||||
if (checkUnknown && typeName != null) {
|
||||
UnknownFeaturesCollector.getInstance(project).registerUnknownRunConfiguration(typeName)
|
||||
}
|
||||
type = typeByName.get(UnknownConfigurationType.NAME) ?: return null
|
||||
}
|
||||
return findFactoryOfTypeNameByName(typeName!!, factoryName ?: type?.configurationFactories?.get(0)?.name)
|
||||
}
|
||||
|
||||
private fun findFactoryOfTypeNameByName(typeName: String, factoryName: String?): ConfigurationFactory? {
|
||||
return findFactoryOfTypeByName(myTypesByName.get(typeName) ?: myTypesByName.get(UnknownConfigurationType.NAME)!!, factoryName)
|
||||
if (type is UnknownConfigurationType) {
|
||||
return type.getConfigurationFactories().get(0)
|
||||
}
|
||||
|
||||
val factoryName = _factoryName ?: type.configurationFactories.get(0).name
|
||||
return type.configurationFactories.firstOrNull { it.name == factoryName }
|
||||
}
|
||||
|
||||
override fun getComponentName() = "RunManager"
|
||||
@@ -854,12 +862,14 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
fireRunConfigurationChanged(settings)
|
||||
}
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
override fun makeStable(configuration: RunConfiguration) {
|
||||
getSettings(configuration)?.let {
|
||||
makeStable(it)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun createRunConfiguration(name: String, factory: ConfigurationFactory) = createConfiguration(name, factory)
|
||||
|
||||
override fun isConfigurationShared(settings: RunnerAndConfigurationSettings): Boolean {
|
||||
@@ -878,7 +888,8 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
for (settings in settingsList) {
|
||||
val runTasks = getBeforeRunTasks(settings.configuration)
|
||||
for (task in runTasks) {
|
||||
if (task != null && task.isEnabled && task.providerId === taskProviderID) {
|
||||
if (task.isEnabled && task.providerId === taskProviderID) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
tasks.add(task as T)
|
||||
}
|
||||
else {
|
||||
@@ -887,7 +898,8 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
checkedTemplates.add(template)
|
||||
val templateTasks = getBeforeRunTasks(template.configuration)
|
||||
for (templateTask in templateTasks) {
|
||||
if (templateTask != null && templateTask.isEnabled && templateTask.providerId === taskProviderID) {
|
||||
if (templateTask.isEnabled && templateTask.providerId === taskProviderID) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
tasks.add(templateTask as T)
|
||||
}
|
||||
}
|
||||
@@ -939,7 +951,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
return getBeforeRunTasks(settings.peer, taskProviderID)
|
||||
}
|
||||
|
||||
val tasks = getSettings(settings)?.beforeRunTasks ?: getTemplateBeforeRunTasks(settings)
|
||||
val tasks = settings.beforeRunTasks ?: getTemplateBeforeRunTasks(settings)
|
||||
val result = SmartList<T>()
|
||||
for (task in tasks) {
|
||||
if (task.providerId === taskProviderID) {
|
||||
@@ -955,7 +967,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
return getBeforeRunTasks(settings.peer)
|
||||
}
|
||||
|
||||
val tasks = getSettings(settings)?.beforeRunTasks ?: getTemplateBeforeRunTasks(settings)
|
||||
val tasks = settings.beforeRunTasks ?: getTemplateBeforeRunTasks(settings)
|
||||
return getCopies(tasks)
|
||||
}
|
||||
|
||||
@@ -966,7 +978,7 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val templateTasks = template.beforeRunTasks ?: getHardcodedBeforeRunTasks(settings)
|
||||
val templateTasks = configuration.beforeRunTasks ?: getHardcodedBeforeRunTasks(settings)
|
||||
return getCopies(templateTasks)
|
||||
}
|
||||
|
||||
@@ -1003,25 +1015,27 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
|
||||
val result = SmartList(tasks)
|
||||
if (addEnabledTemplateTasksIfAbsent) {
|
||||
val templates = getTemplateBeforeRunTasks(runConfiguration)
|
||||
val idsToSet = THashSet<Key<BeforeRunTask<*>>>()
|
||||
for (task in tasks) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
idsToSet.add(task.getProviderId() as Key<BeforeRunTask<*>>?)
|
||||
}
|
||||
var i = 0
|
||||
for (template in templates) {
|
||||
if (!idsToSet.contains(template.providerId)) {
|
||||
result.add(i, template)
|
||||
i++
|
||||
}
|
||||
}
|
||||
addTemplateBeforeTasks(runConfiguration, tasks, result)
|
||||
}
|
||||
|
||||
(getSettings(runConfiguration)!!).beforeRunTasks = result
|
||||
runConfiguration.beforeRunTasks = result
|
||||
fireBeforeRunTasksUpdated()
|
||||
}
|
||||
|
||||
private fun addTemplateBeforeTasks(configuration: RunConfiguration, tasks: List<BeforeRunTask<*>>, result: MutableList<BeforeRunTask<*>>) {
|
||||
val templates = getTemplateBeforeRunTasks(configuration)
|
||||
val idToSet = THashSet<Key<BeforeRunTask<*>>>()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
tasks.mapTo(idToSet) { it.providerId as Key<BeforeRunTask<*>>? }
|
||||
var i = 0
|
||||
for (template in templates) {
|
||||
if (!idToSet.contains(template.providerId)) {
|
||||
result.add(i, template)
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addConfiguration(settings: RunnerAndConfigurationSettings, isShared: Boolean) {
|
||||
addConfiguration(settings, isShared, getTemplateBeforeRunTasks(settings.configuration), false)
|
||||
}
|
||||
@@ -1115,25 +1129,6 @@ abstract class RunManagerImpl(internal val project: Project, propertiesComponent
|
||||
}
|
||||
}
|
||||
|
||||
private fun findFactoryOfTypeByName(type: ConfigurationType, factoryName: String?): ConfigurationFactory? {
|
||||
if (factoryName == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (type is UnknownConfigurationType) {
|
||||
return type.getConfigurationFactories()[0]
|
||||
}
|
||||
|
||||
val factories = type.configurationFactories
|
||||
for (factory in factories) {
|
||||
if (factoryName == factory.name) {
|
||||
return factory
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun getCopies(original: List<BeforeRunTask<*>>): List<BeforeRunTask<*>> {
|
||||
val result = SmartList<BeforeRunTask<*>>()
|
||||
for (task in original) {
|
||||
|
||||
+9
-17
@@ -53,7 +53,8 @@ val SINGLETON = "singleton"
|
||||
|
||||
class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val manager: RunManagerImpl,
|
||||
private var configuration: RunConfiguration? = null,
|
||||
private var isTemplate: Boolean = false) : Cloneable, RunnerAndConfigurationSettings, Comparable<Any>, RunConfigurationScheme, SerializableScheme {
|
||||
private var isTemplate: Boolean = false,
|
||||
private var singleton: Boolean = false) : Cloneable, RunnerAndConfigurationSettings, Comparable<Any>, RunConfigurationScheme, SerializableScheme {
|
||||
private val runnerSettings = object : RunnerItem<RunnerSettings>("RunnerSettings") {
|
||||
override fun createSettings(runner: ProgramRunner<*>) = runner.createConfigurationData(InfoProvider(runner))
|
||||
}
|
||||
@@ -65,11 +66,10 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
private var isTemporary = false
|
||||
private var isEditBeforeRun = false
|
||||
private var isActivateToolWindowBeforeRun = true
|
||||
private var singleton = false
|
||||
private var wasSingletonSpecifiedExplicitly = false
|
||||
private var folderName: String? = null
|
||||
|
||||
var beforeRunTasks: List<BeforeRunTask<*>>? = null
|
||||
//var beforeRunTasks: List<BeforeRunTask<*>>? = null
|
||||
|
||||
override fun getFactory() = configuration?.factory
|
||||
|
||||
@@ -130,12 +130,6 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
|
||||
override fun getFolderName() = folderName
|
||||
|
||||
private fun getFactory(element: Element): ConfigurationFactory? {
|
||||
val typeName = element.getAttributeValue(CONFIGURATION_TYPE_ATTRIBUTE)
|
||||
val factoryName = element.getAttributeValue(FACTORY_NAME_ATTRIBUTE)
|
||||
return manager.getFactory(typeName, factoryName, !isTemplate)
|
||||
}
|
||||
|
||||
fun readExternal(element: Element) {
|
||||
isTemplate = element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE).toBoolean()
|
||||
isTemporary = element.getAttributeValue(TEMPORARY_ATTRIBUTE).toBoolean() || TEMP_CONFIGURATION == element.name
|
||||
@@ -143,7 +137,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
val value = element.getAttributeValue(ACTIVATE_TOOLWINDOW_BEFORE_RUN)
|
||||
isActivateToolWindowBeforeRun = value == null || value.toBoolean()
|
||||
folderName = element.getAttributeValue(FOLDER_NAME)
|
||||
val factory = getFactory(element) ?: return
|
||||
val factory = manager.getFactory(element.getAttributeValue(CONFIGURATION_TYPE_ATTRIBUTE), element.getAttributeValue(FACTORY_NAME_ATTRIBUTE), !isTemplate) ?: return
|
||||
|
||||
wasSingletonSpecifiedExplicitly = false
|
||||
if (isTemplate) {
|
||||
@@ -151,7 +145,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
}
|
||||
else {
|
||||
val singletonStr = element.getAttributeValue(SINGLETON)
|
||||
if (StringUtil.isEmpty(singletonStr)) {
|
||||
if (singletonStr.isNullOrEmpty()) {
|
||||
singleton = factory.isConfigurationSingletonByDefault
|
||||
}
|
||||
else {
|
||||
@@ -166,7 +160,9 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
else {
|
||||
// shouldn't call createConfiguration since it calls StepBeforeRunProviders that
|
||||
// may not be loaded yet. This creates initialization order issue.
|
||||
manager.doCreateConfiguration(element.getAttributeValue(NAME_ATTR), factory, false)
|
||||
val configuration = factory.createTemplateConfiguration(manager.project, manager)
|
||||
configuration.name = element.getAttributeValue(NAME_ATTR) ?: return
|
||||
configuration
|
||||
}
|
||||
|
||||
this.configuration = configuration
|
||||
@@ -421,11 +417,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
runnerSettings.add(state)
|
||||
}
|
||||
}
|
||||
if (unloadedSettings != null) {
|
||||
for (unloadedSetting in unloadedSettings!!) {
|
||||
runnerSettings.add(unloadedSetting.clone())
|
||||
}
|
||||
}
|
||||
unloadedSettings?.mapTo(runnerSettings) { it.clone() }
|
||||
runnerSettings.sort { o1, o2 ->
|
||||
val attributeValue1 = o1.getAttributeValue(RUNNER_ID)
|
||||
if (attributeValue1 == null) 1 else StringUtil.compare(attributeValue1, o2.getAttributeValue(RUNNER_ID), false)
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jdom.Element
|
||||
|
||||
internal class WorkspaceRunManager(project: Project, propertiesComponent: PropertiesComponent) : RunManagerImpl(project, propertiesComponent) {
|
||||
class WorkspaceRunManager(project: Project, propertiesComponent: PropertiesComponent) : RunManagerImpl(project, propertiesComponent) {
|
||||
override fun loadState(parentNode: Element) {
|
||||
clear(false)
|
||||
|
||||
@@ -43,13 +43,6 @@ internal class WorkspaceRunManager(project: Project, propertiesComponent: Proper
|
||||
super.loadState(parentNode)
|
||||
}
|
||||
|
||||
override fun runConfigurationAdded(settings: RunnerAndConfigurationSettings, shared: Boolean) {
|
||||
if (!shared) {
|
||||
schemeManager.addScheme(settings as RunConfigurationScheme)
|
||||
}
|
||||
super.runConfigurationAdded(settings, shared)
|
||||
}
|
||||
|
||||
override fun removeConfiguration(settings: RunnerAndConfigurationSettings?) {
|
||||
if (settings == null) {
|
||||
return
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,8 +62,7 @@ public class DeploymentConfigurationManagerImpl extends DeploymentConfigurationM
|
||||
}
|
||||
if (RunDialog.editConfiguration(myProject, settings, "Create Deployment Configuration",
|
||||
DefaultRunExecutor.getRunExecutorInstance())) {
|
||||
runManager.addConfiguration(settings, runManager.isConfigurationShared(settings), runManager.getBeforeRunTasks(runConfiguration),
|
||||
false);
|
||||
runManager.addConfiguration(settings, runManager.isConfigurationShared(settings), runManager.getBeforeRunTasks(runConfiguration));
|
||||
runManager.setSelectedConfiguration(settings);
|
||||
ProgramRunnerUtil.executeConfiguration(myProject, settings, DefaultRunExecutor.getRunExecutorInstance());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user