IDEA-155610 ModuleBasedConfiguration.createInstance() may produce wrong custom 'cloning' appcode/146.1711 clion/146.1712 dbe/146.1709 phpstorm/146.1710 pycharm/146.1716 pycharm/146.1718 rubymine/146.1717 webstorm/146.1720
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Wed, 4 May 2016 20:00:29 +0000 (23:00 +0300)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Wed, 4 May 2016 20:03:16 +0000 (23:03 +0300)
platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java
plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonRunConfiguration.java
plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java
plugins/junit/src/com/intellij/execution/junit/testDiscovery/JUnitTestDiscoveryConfiguration.java
plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java
plugins/testng/src/com/theoryinpractice/testng/configuration/testDiscovery/TestNGTestDiscoveryConfiguration.java

index 9c5e7f9613ae7132b7e981568a269adb3dccdfc6..3ead8069b3239b529f4660c8457f8782b7adc888 100644 (file)
@@ -80,6 +80,10 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
     return Arrays.asList(ModuleManager.getInstance(getProject()).getModules());
   }
 
+  /**
+   * @deprecated  method {@link com.intellij.execution.configurations.ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project)}
+   * would be used instead to avoid wrong custom 'cloning'
+   */
   protected ModuleBasedConfiguration createInstance() {
     ModuleBasedConfiguration<ConfigurationModule> configuration =
       (ModuleBasedConfiguration<ConfigurationModule>)getFactory().createTemplateConfiguration(getProject());
@@ -92,11 +96,11 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
     final Element element = new Element(TO_CLONE_ELEMENT_NAME);
     try {
       writeExternal(element);
-      final ModuleBasedConfiguration configuration = createInstance();
-
+      RunConfiguration configuration = getFactory().createTemplateConfiguration(getProject());
+      configuration.setName(getName());
       configuration.readExternal(element);
 
-      return configuration;
+      return (ModuleBasedConfiguration)configuration;
     } catch (InvalidDataException e) {
       LOG.error(e);
       return null;
index d5f14e4e3b010c96e7374a4de70d5924c9680333..64781af2557a1bac137167774f8041348e653826 100644 (file)
@@ -17,7 +17,6 @@
 package org.jetbrains.plugins.groovy.griffon;
 
 import com.intellij.execution.configurations.ConfigurationFactory;
-import com.intellij.execution.configurations.ModuleBasedConfiguration;
 import com.intellij.execution.configurations.RunConfigurationModule;
 import com.intellij.openapi.project.Project;
 import org.jetbrains.plugins.groovy.mvc.MvcRunConfiguration;
@@ -35,13 +34,4 @@ public class GriffonRunConfiguration extends MvcRunConfiguration {
   protected String getNoSdkMessage() {
     return "Griffon SDK is not configured";
   }
-
-  @Override
-  protected ModuleBasedConfiguration createInstance() {
-    GriffonRunConfiguration res = new GriffonRunConfiguration(myFactory, getConfigurationModule().getProject(), getName(), cmdLine);
-    res.envs.putAll(envs);
-    res.passParentEnv = passParentEnv;
-    return res;
-  }
-
 }
\ No newline at end of file
index 6da637dd52102f11be0011424942bfae12e20a22..21568c6702d889c61565ae445cd9349a2f2e5afb 100644 (file)
@@ -188,11 +188,6 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
     return JavaRunConfigurationModule.getModulesForClass(getProject(), myData.getMainClassName());
   }
 
-  @Override
-  protected ModuleBasedConfiguration createInstance() {
-    return new JUnitConfiguration(getName(), getProject(), myData.clone(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);// throw new RuntimeException("Should not call");
-  }
-
   @Override
   public String suggestedName() {
     return myData.getGeneratedName(getConfigurationModule());
index 70460e4ca74cb78e575770e6f0f26bd4d3ace663..dddbc7f1e08181d1c096c63a4483cd2e196b28b1 100644 (file)
@@ -45,14 +45,6 @@ public class JUnitTestDiscoveryConfiguration extends TestDiscoveryConfiguration
           new JUnitConfiguration("", project, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]));
   }
 
-  @Override
-  protected ModuleBasedConfiguration createInstance() {
-    final JUnitTestDiscoveryConfigurationType configurationType =
-      ConfigurationTypeUtil.findConfigurationType(JUnitTestDiscoveryConfigurationType.class);
-    final ConfigurationFactory[] factories = configurationType.getConfigurationFactories();
-    return new JUnitTestDiscoveryConfiguration(getName(), getProject(), factories[0]);
-  }
-
   @Nullable
   @Override
   public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
index f10fab50855af20d553a74c072253ec304b6952a..bf27fb5c462254690dbdf508d08d3de337a61dea 100644 (file)
@@ -128,12 +128,6 @@ public class TestNGConfiguration extends JavaTestConfigurationBase {
     return data;
   }
 
-  @Override
-  protected ModuleBasedConfiguration createInstance() {
-    return new TestNGConfiguration(getName(), getProject(), data.clone(),
-                                   TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
-  }
-
   @Override
   public Collection<Module> getValidModules() {
     //TODO add handling for package
index 09efc7ef06aa9e32eb33117b9c6931814336852e..9ecb0d556213474be2db102015bbee8e4856c9fd 100644 (file)
@@ -45,14 +45,6 @@ public class TestNGTestDiscoveryConfiguration extends TestDiscoveryConfiguration
           new TestNGConfiguration("", project, TestNGConfigurationType.getInstance().getConfigurationFactories()[0]));
   }
 
-  @Override
-  protected ModuleBasedConfiguration createInstance() {
-    final TestNGTestDiscoveryConfigurationType configurationType =
-      ConfigurationTypeUtil.findConfigurationType(TestNGTestDiscoveryConfigurationType.class);
-    final ConfigurationFactory[] factories = configurationType.getConfigurationFactories();
-    return new TestNGTestDiscoveryConfiguration(getName(), getProject(), factories[0]);
-  }
-
   @Nullable
   @Override
   public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {