run configuration: ability to avoid adding "Make" Before Launch task by default on...
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 31 Jul 2015 17:34:54 +0000 (20:34 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 31 Jul 2015 17:34:54 +0000 (20:34 +0300)
java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java
java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRunNoErrorCheck.java
platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java

index b0d878f9bea9a0eaa451f651456421c00b60aa12..06862f7b66d37c4fd7940fffc9187c2cc9204778 100644 (file)
@@ -83,10 +83,20 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
     return AllIcons.Actions.Compile;
   }
 
-  public MakeBeforeRunTask createTask(RunConfiguration runConfiguration) {
-    return !(runConfiguration instanceof RemoteConfiguration) && runConfiguration instanceof RunProfileWithCompileBeforeLaunchOption
-           ? new MakeBeforeRunTask()
-           : null;
+  @Nullable
+  public MakeBeforeRunTask createTask(RunConfiguration configuration) {
+    MakeBeforeRunTask task = null;
+    if (shouldCreateTask(configuration)) {
+      task = new MakeBeforeRunTask();
+      if (configuration instanceof RunConfigurationBase) {
+        task.setEnabled(((RunConfigurationBase)configuration).isCompileBeforeLaunchAddedByDefault());
+      }
+    }
+    return task;
+  }
+
+  static boolean shouldCreateTask(RunConfiguration configuration) {
+    return !(configuration instanceof RemoteConfiguration) && configuration instanceof RunProfileWithCompileBeforeLaunchOption;
   }
 
   public boolean configureTask(RunConfiguration runConfiguration, MakeBeforeRunTask task) {
index 3a68639a7b4e36ef2200e2950713023c6d435c73..dd8c17ab9361d347acb296e1d371f9adac2a79f4 100644 (file)
@@ -19,8 +19,6 @@ import com.intellij.execution.BeforeRunTask;
 import com.intellij.execution.BeforeRunTaskProvider;
 import com.intellij.execution.ExecutionBundle;
 import com.intellij.execution.configurations.RunConfiguration;
-import com.intellij.execution.configurations.RunProfileWithCompileBeforeLaunchOption;
-import com.intellij.execution.remote.RemoteConfiguration;
 import com.intellij.execution.runners.ExecutionEnvironment;
 import com.intellij.icons.AllIcons;
 import com.intellij.openapi.actionSystem.DataContext;
@@ -63,9 +61,7 @@ public class CompileStepBeforeRunNoErrorCheck
 
   @Override
   public MakeBeforeRunTaskNoErrorCheck createTask(RunConfiguration runConfiguration) {
-    return !(runConfiguration instanceof RemoteConfiguration) && runConfiguration instanceof RunProfileWithCompileBeforeLaunchOption
-           ? new MakeBeforeRunTaskNoErrorCheck()
-           : null;
+    return CompileStepBeforeRun.shouldCreateTask(runConfiguration) ? new MakeBeforeRunTaskNoErrorCheck() : null;
   }
 
   @Override
index e8994958b49239daf86715059d202dcef2eaa8f4..3f79afe7b6f1f310a2dc7be1fc36171deb74379d 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.JDOMExternalizerUtil;
 import com.intellij.openapi.util.UserDataHolderBase;
 import com.intellij.openapi.util.WriteExternalException;
-import com.intellij.psi.PsiElement;
 import com.intellij.util.xmlb.annotations.Attribute;
 import com.intellij.util.xmlb.annotations.Transient;
 import org.jdom.Element;
@@ -295,6 +294,14 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
     return false;
   }
 
+  /**
+   * @return true if "Make" Before Launch task should be added automatically on run configuration creation
+   * @see RunProfileWithCompileBeforeLaunchOption
+   */
+  public boolean isCompileBeforeLaunchAddedByDefault() {
+    return true;
+  }
+
   @Override
   public String toString() {
     return getType().getDisplayName() + ": " + getName();