mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-61945 Run and Debug commands should ignore compile errors not related to the main being run.
This commit is contained in:
@@ -35,7 +35,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -71,9 +70,6 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
|
||||
@Override
|
||||
public String getDescription(MakeBeforeRunTask task) {
|
||||
if (task.myNoErrorCheck) {
|
||||
return ExecutionBundle.message("before.launch.compile.step.no.error.check");
|
||||
}
|
||||
return ExecutionBundle.message("before.launch.compile.step");
|
||||
}
|
||||
|
||||
@@ -94,15 +90,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
}
|
||||
|
||||
public boolean configureTask(RunConfiguration runConfiguration, MakeBeforeRunTask task) {
|
||||
if (task == null)
|
||||
return false;
|
||||
task.myNoErrorCheck = !task.myNoErrorCheck;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean skipFirstConfiguration() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,10 +98,11 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean executeTask(DataContext context,
|
||||
final RunConfiguration configuration,
|
||||
final ExecutionEnvironment env,
|
||||
final MakeBeforeRunTask task) {
|
||||
public boolean executeTask(DataContext context, final RunConfiguration configuration, final ExecutionEnvironment env, MakeBeforeRunTask task) {
|
||||
return doMake(myProject, configuration, env, false);
|
||||
}
|
||||
|
||||
static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors) {
|
||||
if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
|
||||
return true;
|
||||
}
|
||||
@@ -130,7 +119,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
done.down();
|
||||
final CompileStatusNotification callback = new CompileStatusNotification() {
|
||||
public void finished(final boolean aborted, final int errors, final int warnings, CompileContext compileContext) {
|
||||
if ((errors == 0 || task.myNoErrorCheck) && !aborted) {
|
||||
if ((errors == 0 || ignoreErrors) && !aborted) {
|
||||
result.set(Boolean.TRUE);
|
||||
}
|
||||
done.up();
|
||||
@@ -182,7 +171,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
}
|
||||
|
||||
public boolean isConfigurable() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -196,25 +185,9 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
}
|
||||
|
||||
public static class MakeBeforeRunTask extends BeforeRunTask<MakeBeforeRunTask> {
|
||||
boolean myNoErrorCheck;
|
||||
|
||||
private MakeBeforeRunTask() {
|
||||
super(ID);
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
if (myNoErrorCheck) {
|
||||
element.setAttribute("no.error.check", String.valueOf(myNoErrorCheck));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
super.readExternal(element);
|
||||
myNoErrorCheck = Boolean.parseBoolean(element.getAttributeValue("no.error.check", "false"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.options;
|
||||
|
||||
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;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* User: Vassiliy.Kudryashov
|
||||
*/
|
||||
public class CompileStepBeforeRunNoErrorCheck
|
||||
extends BeforeRunTaskProvider<CompileStepBeforeRunNoErrorCheck.MakeBeforeRunTaskNoErrorCheck> {
|
||||
public static final Key<MakeBeforeRunTaskNoErrorCheck> ID = Key.create("MakeNoErrorCheck");
|
||||
@NotNull private final Project myProject;
|
||||
|
||||
public CompileStepBeforeRunNoErrorCheck(@NotNull Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public Key<MakeBeforeRunTaskNoErrorCheck> getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(MakeBeforeRunTaskNoErrorCheck task) {
|
||||
return ExecutionBundle.message("before.launch.compile.step.no.error.check");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return AllIcons.Actions.Compile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTaskIcon(MakeBeforeRunTaskNoErrorCheck task) {
|
||||
return AllIcons.Actions.Compile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MakeBeforeRunTaskNoErrorCheck createTask(RunConfiguration runConfiguration) {
|
||||
return !(runConfiguration instanceof RemoteConfiguration) && runConfiguration instanceof RunProfileWithCompileBeforeLaunchOption
|
||||
? new MakeBeforeRunTaskNoErrorCheck()
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configureTask(RunConfiguration runConfiguration, MakeBeforeRunTaskNoErrorCheck task) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ExecutionBundle.message("before.launch.compile.step.no.error.check");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecuteTask(RunConfiguration configuration, MakeBeforeRunTaskNoErrorCheck task) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeTask(DataContext context,
|
||||
RunConfiguration configuration,
|
||||
ExecutionEnvironment env,
|
||||
MakeBeforeRunTaskNoErrorCheck task) {
|
||||
return CompileStepBeforeRun.doMake(myProject, configuration, env, true);
|
||||
}
|
||||
|
||||
public static class MakeBeforeRunTaskNoErrorCheck extends BeforeRunTask<MakeBeforeRunTaskNoErrorCheck> {
|
||||
private MakeBeforeRunTaskNoErrorCheck() {
|
||||
super(ID);
|
||||
setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,13 +57,6 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
|
||||
|
||||
public abstract boolean isConfigurable();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if just created task must be configured by user.
|
||||
*/
|
||||
public boolean skipFirstConfiguration() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 'before run' task for the configuration or null, if the task from this provider is not applicable to the specified configuration
|
||||
*/
|
||||
|
||||
@@ -85,4 +85,21 @@ public abstract class RunManagerEx extends RunManager {
|
||||
|
||||
public abstract void addRunManagerListener(RunManagerListener listener);
|
||||
public abstract void removeRunManagerListener(RunManagerListener listener);
|
||||
|
||||
public static void disableTasks(Project project, RunConfiguration settings, Key<? extends BeforeRunTask>... keys) {
|
||||
for (Key<? extends BeforeRunTask> key : keys) {
|
||||
List<? extends BeforeRunTask> tasks = getInstanceEx(project).getBeforeRunTasks(settings, key);
|
||||
for (BeforeRunTask task : tasks) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getTasksCount(Project project, RunConfiguration settings, Key<? extends BeforeRunTask>... keys) {
|
||||
int result = 0;
|
||||
for (Key<? extends BeforeRunTask> key : keys) {
|
||||
result += getInstanceEx(project).getBeforeRunTasks(settings, key).size();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -271,8 +271,7 @@ class BeforeRunStepsPanel extends JPanel {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
BeforeRunTask task = provider.createTask(myRunConfiguration);
|
||||
if (task != null) {
|
||||
if (!provider.skipFirstConfiguration())
|
||||
provider.configureTask(myRunConfiguration, task);
|
||||
provider.configureTask(myRunConfiguration, task);
|
||||
if (!provider.canExecuteTask(myRunConfiguration, task))
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.gradle.config;
|
||||
|
||||
import com.intellij.compiler.options.CompileStepBeforeRun;
|
||||
import com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
@@ -60,7 +61,6 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -97,12 +97,7 @@ public class GradleScriptType extends GroovyScriptType {
|
||||
configuration.setScriptParameters(target);
|
||||
configuration.setName(configuration.getName() + "." + target);
|
||||
}
|
||||
|
||||
final List<CompileStepBeforeRun.MakeBeforeRunTask> runTasks =
|
||||
RunManagerEx.getInstanceEx(file.getProject()).getBeforeRunTasks(configuration, CompileStepBeforeRun.ID);
|
||||
for (CompileStepBeforeRun.MakeBeforeRunTask task : runTasks) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
RunManagerEx.disableTasks(file.getProject(), configuration, CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.gant;
|
||||
|
||||
import com.intellij.compiler.options.CompileStepBeforeRun;
|
||||
import com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck;
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.RunManagerEx;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -97,11 +98,7 @@ public class GantScriptType extends GroovyScriptType {
|
||||
configuration.setScriptParameters(target);
|
||||
configuration.setName(configuration.getName() + "." + target);
|
||||
}
|
||||
final List<CompileStepBeforeRun.MakeBeforeRunTask> runTasks =
|
||||
RunManagerEx.getInstanceEx(file.getProject()).getBeforeRunTasks(configuration, CompileStepBeforeRun.ID);
|
||||
for (CompileStepBeforeRun.MakeBeforeRunTask task : runTasks) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
RunManagerEx.disableTasks(file.getProject(), configuration, CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
|
||||
}
|
||||
|
||||
public static List<VirtualFile> additionalScopeFiles(@NotNull GroovyFile file) {
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.plugins.groovy.griffon;
|
||||
|
||||
import com.intellij.compiler.options.CompileStepBeforeRun;
|
||||
import com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck;
|
||||
import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
@@ -43,7 +44,7 @@ public class GriffonRunConfigurationType implements ConfigurationType {
|
||||
|
||||
@Override
|
||||
public void configureBeforeRunTaskDefaults(Key<? extends BeforeRunTask> providerID, BeforeRunTask task) {
|
||||
if (providerID == CompileStepBeforeRun.ID) {
|
||||
if (providerID == CompileStepBeforeRun.ID || providerID == CompileStepBeforeRunNoErrorCheck.ID) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.plugins.groovy.mvc;
|
||||
|
||||
import com.intellij.compiler.options.CompileStepBeforeRun;
|
||||
import com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck;
|
||||
import com.intellij.execution.CantRunException;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.RunManagerEx;
|
||||
@@ -358,10 +359,7 @@ public abstract class MvcFramework {
|
||||
runManager.addConfiguration(runSettings, false);
|
||||
runManager.setActiveConfiguration(runSettings);
|
||||
|
||||
final List<CompileStepBeforeRun.MakeBeforeRunTask> runTasks = runManager.getBeforeRunTasks(configuration, CompileStepBeforeRun.ID);
|
||||
for (CompileStepBeforeRun.MakeBeforeRunTask task : runTasks) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
RunManagerEx.disableTasks(module.getProject(), configuration, CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
|
||||
}
|
||||
|
||||
public abstract String getFrameworkName();
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.compiler.options.CompileStepBeforeRun;
|
||||
import com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
@@ -90,7 +91,7 @@ public class MavenRunConfigurationType implements ConfigurationType {
|
||||
|
||||
@Override
|
||||
public void configureBeforeRunTaskDefaults(Key<? extends BeforeRunTask> providerID, BeforeRunTask task) {
|
||||
if (providerID == CompileStepBeforeRun.ID) {
|
||||
if (providerID == CompileStepBeforeRun.ID || providerID == CompileStepBeforeRunNoErrorCheck.ID) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,8 @@
|
||||
|
||||
|
||||
<stepsBeforeRunProvider implementation="com.intellij.compiler.options.CompileStepBeforeRun" id="compileBeforeRun"/>
|
||||
<stepsBeforeRunProvider implementation="com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTaskProvider" order="after compileBeforeRun"/>
|
||||
<stepsBeforeRunProvider implementation="com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck" id="compileBeforeRunNoErrorCheck" order="after compileBeforeRun"/>
|
||||
<stepsBeforeRunProvider implementation="com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTaskProvider" order="after compileBeforeRunNoErrorCheck"/>
|
||||
<stepsBeforeRunProvider implementation="com.intellij.execution.impl.RunConfigurationBeforeRunProvider"/>
|
||||
<programRunner id="defaultRunRunner" implementation="com.intellij.execution.impl.DefaultJavaProgramRunner"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user