summaryrefslogtreecommitdiff
path: root/platform/lang-api
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-api')
-rw-r--r--platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java26
-rw-r--r--platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java8
-rw-r--r--platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java2
-rw-r--r--platform/lang-api/src/com/intellij/execution/ExecutionManager.java41
-rw-r--r--platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java9
-rw-r--r--platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java9
-rw-r--r--platform/lang-api/src/com/intellij/execution/RunnerRegistry.java2
-rw-r--r--platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java7
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java80
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java179
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java74
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java3
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java71
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java59
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentWithExecutorListener.java (renamed from platform/lang-api/src/com/intellij/codeInsight/controlflow/Instruction.java)22
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java3
-rw-r--r--platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java27
-rw-r--r--platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java6
-rw-r--r--platform/lang-api/src/com/intellij/ide/IdeView.java4
-rw-r--r--platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java9
-rw-r--r--platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java18
-rw-r--r--platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java40
-rw-r--r--platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java20
23 files changed, 485 insertions, 234 deletions
diff --git a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java b/platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
deleted file mode 100644
index daea33cd1e9a..000000000000
--- a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2000-2010 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.codeInsight.controlflow;
-
-import com.intellij.psi.PsiElement;
-
-/**
- * @author oleg
- */
-public interface ConditionalInstruction extends Instruction {
- boolean getResult();
- PsiElement getCondition();
-}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java b/platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
deleted file mode 100644
index 99e7c2887d01..000000000000
--- a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.intellij.codeInsight.controlflow;
-
-/**
- * @author oleg
- */
-public interface ControlFlow {
- Instruction[] getInstructions();
-}
diff --git a/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java b/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java
index f3331f899ff1..6799cfd7e6da 100644
--- a/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java
+++ b/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java
@@ -80,7 +80,7 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
@Nullable
public static <T extends BeforeRunTask> BeforeRunTaskProvider<T> getProvider(Project project, Key<T> key) {
- BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, project);
+ BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(EXTENSION_POINT_NAME, project);
for (BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
if (provider.getId() == key)
return (BeforeRunTaskProvider<T>)provider;
diff --git a/platform/lang-api/src/com/intellij/execution/ExecutionManager.java b/platform/lang-api/src/com/intellij/execution/ExecutionManager.java
index 5e9029ebf93f..183d6ada5ad2 100644
--- a/platform/lang-api/src/com/intellij/execution/ExecutionManager.java
+++ b/platform/lang-api/src/com/intellij/execution/ExecutionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -21,6 +21,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManager;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
@@ -30,11 +31,11 @@ import org.jetbrains.annotations.Nullable;
* Manages the execution of run configurations and the relationship between running processes and Run/Debug toolwindow tabs.
*/
public abstract class ExecutionManager {
- public static final Topic<ExecutionListener> EXECUTION_TOPIC
- = new Topic<ExecutionListener>("configuration executed", ExecutionListener.class, Topic.BroadcastDirection.TO_PARENT);
+ public static final Topic<ExecutionListener> EXECUTION_TOPIC =
+ Topic.create("configuration executed", ExecutionListener.class, Topic.BroadcastDirection.TO_PARENT);
- public static ExecutionManager getInstance(final Project project) {
- return project.getComponent(ExecutionManager.class);
+ public static ExecutionManager getInstance(@NotNull Project project) {
+ return ServiceManager.getService(project, ExecutionManager.class);
}
/**
@@ -49,12 +50,12 @@ public abstract class ExecutionManager {
* Executes the before launch tasks for a run configuration.
*
* @param startRunnable the runnable to actually start the process for the run configuration.
- * @param env the execution environment describing the process to be started.
+ * @param environment the execution environment describing the process to be started.
* @param state the ready-to-start process
* @param onCancelRunnable the callback to call if one of the before launch tasks cancels the process execution.
*/
public abstract void compileAndRun(@NotNull Runnable startRunnable,
- @NotNull ExecutionEnvironment env,
+ @NotNull ExecutionEnvironment environment,
@Nullable RunProfileState state,
@Nullable Runnable onCancelRunnable);
@@ -63,27 +64,19 @@ public abstract class ExecutionManager {
*
* @return the list of processes.
*/
+ @NotNull
public abstract ProcessHandler[] getRunningProcesses();
/**
- * @deprecated use {@link #startRunProfile(RunProfileStarter, com.intellij.execution.configurations.RunProfileState, com.intellij.execution.runners.ExecutionEnvironment)}
- */
- public abstract void startRunProfile(@NotNull RunProfileStarter starter,
- @NotNull RunProfileState state,
- @NotNull Project project,
- @NotNull Executor executor,
- @NotNull ExecutionEnvironment env);
-
- /**
* Prepares the run or debug tab for running the specified process and calls a callback to start it.
*
* @param starter the callback to start the process execution.
* @param state the ready-to-start process
- * @param env the execution environment describing the process to be started.
+ * @param environment the execution environment describing the process to be started.
*/
public abstract void startRunProfile(@NotNull RunProfileStarter starter,
@NotNull RunProfileState state,
- @NotNull ExecutionEnvironment env);
+ @NotNull ExecutionEnvironment environment);
public abstract void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@@ -91,9 +84,10 @@ public abstract class ExecutionManager {
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable ProcessHandler processHandler);
- //currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
/**
- * @deprecated use {@link #restartRunProfile(com.intellij.execution.runners.ProgramRunner, com.intellij.execution.runners.ExecutionEnvironment, com.intellij.execution.ui.RunContentDescriptor)}
+ * currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
+ * @deprecated use {@link #restartRunProfile(com.intellij.execution.runners.ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
public abstract void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@@ -101,7 +95,14 @@ public abstract class ExecutionManager {
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable RunContentDescriptor currentDescriptor);
+ /**
+ * currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
+ * @deprecated use {@link #restartRunProfile(com.intellij.execution.runners.ExecutionEnvironment)}
+ * to remove in IDEA 15
+ */
public abstract void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor currentDescriptor);
+
+ public abstract void restartRunProfile(@NotNull ExecutionEnvironment environment);
}
diff --git a/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java b/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java
index b48a2e8919fb..612c9c1c80ea 100644
--- a/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java
+++ b/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java
@@ -15,6 +15,8 @@
*/
package com.intellij.execution;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
@@ -26,10 +28,9 @@ import java.util.List;
public abstract class ExecutionTargetManager {
public static final Topic<ExecutionTargetListener> TOPIC = Topic.create("ExecutionTarget topic", ExecutionTargetListener.class);
-
@NotNull
public static ExecutionTargetManager getInstance(@NotNull Project project) {
- return project.getComponent(ExecutionTargetManager.class);
+ return ServiceManager.getService(project, ExecutionTargetManager.class);
}
@NotNull
@@ -57,6 +58,10 @@ public abstract class ExecutionTargetManager {
return settings != null && target != null && settings.canRunOn(target) && target.canRun(settings);
}
+ public static boolean canRun(@NotNull ExecutionEnvironment environment) {
+ return canRun(environment.getRunnerAndConfigurationSettings(), environment.getExecutionTarget());
+ }
+
public static void update(@NotNull Project project) {
getInstance(project).update();
}
diff --git a/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java b/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java
index 49139be54e58..31d39087d1f1 100644
--- a/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java
+++ b/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,6 +16,7 @@
package com.intellij.execution;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.project.Project;
@@ -25,7 +26,6 @@ import org.jetbrains.annotations.NotNull;
* @author spleaner
*/
public abstract class ExecutorRegistry implements ApplicationComponent {
-
public static ExecutorRegistry getInstance() {
return ApplicationManager.getApplication().getComponent(ExecutorRegistry.class);
}
@@ -35,5 +35,10 @@ public abstract class ExecutorRegistry implements ApplicationComponent {
public abstract Executor getExecutorById(final String executorId);
+ /**
+ * Consider to use {@link #isStarting(com.intellij.execution.runners.ExecutionEnvironment)}
+ */
public abstract boolean isStarting(Project project, String executorId, String runnerId);
+
+ public abstract boolean isStarting(@NotNull ExecutionEnvironment environment);
}
diff --git a/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java b/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java
index 39eb47de921d..fec7223b1721 100644
--- a/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java
+++ b/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java
@@ -30,7 +30,7 @@ public abstract class RunnerRegistry implements ApplicationComponent {
public abstract boolean hasRunner(@NotNull final String executorId, @NotNull final RunProfile settings);
@Nullable
- public abstract ProgramRunner getRunner(@NotNull final String executorId, final RunProfile settings);
+ public abstract ProgramRunner getRunner(@NotNull String executorId, @Nullable RunProfile settings);
public abstract ProgramRunner[] getRegisteredRunners();
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java b/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java
index d159fa03ac3a..6f23831c9e3a 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java
@@ -123,11 +123,8 @@ public class LogFileOptions implements JDOMExternalizable {
final File[] dirs = root.listFiles();
if (dirs == null) return;
for (File dir : dirs) {
- if (dir.isFile()) {
- final String path = FileUtil.toSystemIndependentName(FileUtil.getRelativePath(root, dir));
- if (pattern.matcher(path).matches()) {
- files.add(dir);
- }
+ if (pattern.matcher(dir.getName()).matches() && dir.isFile()) {
+ files.add(dir);
}
}
}
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
index 6acc467249e3..e85e36669f2c 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.runners;
import com.intellij.execution.*;
@@ -39,9 +38,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.intellij.openapi.actionSystem.LangDataKeys.*;
-
-public class ExecutionEnvironment extends UserDataHolderBase {
-
+public class ExecutionEnvironment extends UserDataHolderBase implements Disposable {
private static final AtomicLong myIdHolder = new AtomicLong(1L);
@NotNull private final Project myProject;
@@ -54,7 +51,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
@Nullable private ConfigurationPerRunnerSettings myConfigurationSettings;
@Nullable private final RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private RunContentDescriptor myContentToReuse;
- @Nullable private String myRunnerId;
+ private final ProgramRunner<?> myRunner;
private long myExecutionId = 0;
@Nullable private DataContext myDataContext;
@@ -64,11 +61,12 @@ public class ExecutionEnvironment extends UserDataHolderBase {
myContentToReuse = null;
myRunnerAndConfigurationSettings = null;
myExecutor = null;
+ myRunner = null;
}
public ExecutionEnvironment(@NotNull Executor executor,
- @NotNull final ProgramRunner runner,
- @NotNull final RunnerAndConfigurationSettings configuration,
+ @NotNull ProgramRunner runner,
+ @NotNull RunnerAndConfigurationSettings configuration,
@NotNull Project project) {
this(configuration.getConfiguration(),
executor,
@@ -78,11 +76,12 @@ public class ExecutionEnvironment extends UserDataHolderBase {
configuration.getConfigurationSettings(runner),
null,
null,
- runner.getRunnerId());
+ runner);
}
/**
* @deprecated, use {@link com.intellij.execution.runners.ExecutionEnvironmentBuilder} instead
+ * to remove in IDEA 14
*/
@TestOnly
public ExecutionEnvironment(@NotNull Executor executor,
@@ -97,45 +96,46 @@ public class ExecutionEnvironment extends UserDataHolderBase {
configuration.getRunnerSettings(runner),
configuration.getConfigurationSettings(runner),
null,
- configuration, runner.getRunnerId());
+ configuration,
+ runner);
}
/**
* @deprecated, use {@link com.intellij.execution.runners.ExecutionEnvironmentBuilder} instead
+ * to remove in IDEA 15
*/
public ExecutionEnvironment(@NotNull RunProfile runProfile,
@NotNull Executor executor,
@NotNull Project project,
@Nullable RunnerSettings runnerSettings) {
- this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, null);
+ //noinspection ConstantConditions
+ this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, RunnerRegistry.getInstance().getRunner(executor.getId(), runProfile));
}
- public ExecutionEnvironment(@NotNull RunProfile runProfile,
- @NotNull Executor executor,
- @NotNull ExecutionTarget target,
- @NotNull Project project,
- @Nullable RunnerSettings runnerSettings,
- @Nullable ConfigurationPerRunnerSettings configurationSettings,
- @Nullable RunContentDescriptor contentToReuse,
- @Nullable RunnerAndConfigurationSettings settings,
- @Nullable String runnerId) {
+ ExecutionEnvironment(@NotNull RunProfile runProfile,
+ @NotNull Executor executor,
+ @NotNull ExecutionTarget target,
+ @NotNull Project project,
+ @Nullable RunnerSettings runnerSettings,
+ @Nullable ConfigurationPerRunnerSettings configurationSettings,
+ @Nullable RunContentDescriptor contentToReuse,
+ @Nullable RunnerAndConfigurationSettings settings,
+ @NotNull ProgramRunner<?> runner) {
myExecutor = executor;
myTarget = target;
myRunProfile = runProfile;
myRunnerSettings = runnerSettings;
myConfigurationSettings = configurationSettings;
myProject = project;
- myContentToReuse = contentToReuse;
+ setContentToReuse(contentToReuse);
myRunnerAndConfigurationSettings = settings;
- myRunnerId = runnerId;
- if (myContentToReuse != null) {
- Disposer.register(myContentToReuse, new Disposable() {
- @Override
- public void dispose() {
- myContentToReuse = null;
- }
- });
- }
+
+ myRunner = runner;
+ }
+
+ @Override
+ public void dispose() {
+ myContentToReuse = null;
}
@NotNull
@@ -163,9 +163,27 @@ public class ExecutionEnvironment extends UserDataHolderBase {
return myContentToReuse;
}
+ public void setContentToReuse(@Nullable RunContentDescriptor contentToReuse) {
+ myContentToReuse = contentToReuse;
+
+ if (contentToReuse != null) {
+ Disposer.register(contentToReuse, this);
+ }
+ }
+
@Nullable
+ @Deprecated
+ /**
+ * Use {@link #getRunner()} instead
+ * to remove in IDEA 15
+ */
public String getRunnerId() {
- return myRunnerId;
+ return myRunner.getRunnerId();
+ }
+
+ @NotNull
+ public ProgramRunner<?> getRunner() {
+ return myRunner;
}
@Nullable
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java
index cb5891a0040e..6bdb1942171e 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,16 +15,13 @@
*/
package com.intellij.execution.runners;
-import com.intellij.execution.DefaultExecutionTarget;
-import com.intellij.execution.ExecutionTarget;
-import com.intellij.execution.Executor;
-import com.intellij.execution.RunnerAndConfigurationSettings;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
+import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunnerSettings;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
* User: Vassiliy.Kudryashov
*/
public final class ExecutionEnvironmentBuilder {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.runners.ExecutionEnvironmentBuilder");
@NotNull private RunProfile myRunProfile;
@NotNull private ExecutionTarget myTarget = DefaultExecutionTarget.INSTANCE;
@@ -44,6 +40,7 @@ public final class ExecutionEnvironmentBuilder {
@Nullable private RunContentDescriptor myContentToReuse;
@Nullable private RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private String myRunnerId;
+ private ProgramRunner<?> myRunner;
private boolean myAssignNewId;
@NotNull private Executor myExecutor;
@Nullable private DataContext myDataContext;
@@ -53,83 +50,224 @@ public final class ExecutionEnvironmentBuilder {
myExecutor = executor;
}
+ @NotNull
+ public static ExecutionEnvironmentBuilder create(@NotNull Project project, @NotNull Executor executor, @NotNull RunProfile runProfile) throws ExecutionException {
+ ExecutionEnvironmentBuilder builder = createOrNull(project, executor, runProfile);
+ if (builder == null) {
+ throw new ExecutionException("Cannot find runner for " + runProfile.getName());
+ }
+ return builder;
+ }
+
+ @Nullable
+ public static ExecutionEnvironmentBuilder createOrNull(@NotNull Project project, @NotNull Executor executor, @NotNull RunProfile runProfile) {
+ ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), runProfile);
+ if (runner == null) {
+ return null;
+ }
+ return new ExecutionEnvironmentBuilder(project, executor).runner(runner).runProfile(runProfile);
+ }
+
+ @Nullable
+ public static ExecutionEnvironmentBuilder createOrNull(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) {
+ ExecutionEnvironmentBuilder builder = createOrNull(settings.getConfiguration().getProject(), executor, settings.getConfiguration());
+ return builder == null ? null : builder.runnerAndSettings(builder.myRunner, settings);
+ }
+
+ @NotNull
+ public static ExecutionEnvironmentBuilder create(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) throws ExecutionException {
+ ExecutionEnvironmentBuilder builder = create(settings.getConfiguration().getProject(), executor, settings.getConfiguration());
+ return builder.runnerAndSettings(builder.myRunner, settings);
+ }
+
+ @NotNull
+ public static ExecutionEnvironmentBuilder create(@NotNull Executor executor, @NotNull RunConfiguration configuration) {
+ return new ExecutionEnvironmentBuilder(configuration.getProject(), executor).runProfile(configuration);
+ }
+
+ @NotNull
+ Executor getExecutor() {
+ return myExecutor;
+ }
+
/**
* Creates an execution environment builder initialized with a copy of the specified environment.
*
* @param copySource the environment to copy from.
*/
public ExecutionEnvironmentBuilder(@NotNull ExecutionEnvironment copySource) {
- setTarget(copySource.getExecutionTarget());
+ myTarget = copySource.getExecutionTarget();
myProject = copySource.getProject();
myRunnerAndConfigurationSettings = copySource.getRunnerAndConfigurationSettings();
myRunProfile = copySource.getRunProfile();
myRunnerSettings = copySource.getRunnerSettings();
myConfigurationSettings = copySource.getConfigurationSettings();
- myRunnerId = copySource.getRunnerId();
- setContentToReuse(copySource.getContentToReuse());
+ //noinspection deprecation
+ myRunner = copySource.getRunner();
+ myContentToReuse = copySource.getContentToReuse();
myExecutor = copySource.getExecutor();
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setTarget(@NotNull ExecutionTarget target) {
- myTarget = target;
+ return target(target);
+ }
+
+ public ExecutionEnvironmentBuilder target(@Nullable ExecutionTarget target) {
+ if (target != null) {
+ myTarget = target;
+ }
+ return this;
+ }
+
+ public ExecutionEnvironmentBuilder activeTarget() {
+ myTarget = ExecutionTargetManager.getActiveTarget(myProject);
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunnerAndSettings(@NotNull ProgramRunner programRunner,
@NotNull RunnerAndConfigurationSettings settings) {
+ return runnerAndSettings(programRunner, settings);
+ }
+
+ public ExecutionEnvironmentBuilder runnerAndSettings(@NotNull ProgramRunner runner,
+ @NotNull RunnerAndConfigurationSettings settings) {
myRunnerAndConfigurationSettings = settings;
- setRunProfile(settings.getConfiguration());
- setRunnerSettings(settings.getRunnerSettings(programRunner));
- setConfigurationSettings(settings.getConfigurationSettings(programRunner));
- setRunnerId(programRunner.getRunnerId());
+ myRunProfile = settings.getConfiguration();
+ myRunnerSettings = settings.getRunnerSettings(runner);
+ myConfigurationSettings = settings.getConfigurationSettings(runner);
+ myRunner = runner;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunnerSettings(@Nullable RunnerSettings runnerSettings) {
myRunnerSettings = runnerSettings;
return this;
}
+ public ExecutionEnvironmentBuilder runnerSettings(@Nullable RunnerSettings runnerSettings) {
+ myRunnerSettings = runnerSettings;
+ return this;
+ }
+
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setConfigurationSettings(@Nullable ConfigurationPerRunnerSettings configurationSettings) {
myConfigurationSettings = configurationSettings;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setContentToReuse(@Nullable RunContentDescriptor contentToReuse) {
+ contentToReuse(contentToReuse);
+ return this;
+ }
+
+ public ExecutionEnvironmentBuilder contentToReuse(@Nullable RunContentDescriptor contentToReuse) {
myContentToReuse = contentToReuse;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunProfile(@NotNull RunProfile runProfile) {
+ return runProfile(runProfile);
+ }
+
+ public ExecutionEnvironmentBuilder runProfile(@NotNull RunProfile runProfile) {
myRunProfile = runProfile;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunnerId(@Nullable String runnerId) {
myRunnerId = runnerId;
return this;
}
+ public ExecutionEnvironmentBuilder runner(@NotNull ProgramRunner<?> runner) {
+ myRunner = runner;
+ return this;
+ }
+
public ExecutionEnvironmentBuilder assignNewId() {
myAssignNewId = true;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setDataContext(@Nullable DataContext dataContext) {
+ return dataContext(dataContext);
+ }
+
+ public ExecutionEnvironmentBuilder dataContext(@Nullable DataContext dataContext) {
myDataContext = dataContext;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setExecutor(@NotNull Executor executor) {
+ return executor(executor);
+ }
+
+ public ExecutionEnvironmentBuilder executor(@NotNull Executor executor) {
myExecutor = executor;
return this;
}
@NotNull
public ExecutionEnvironment build() {
- ExecutionEnvironment environment =
- new ExecutionEnvironment(myRunProfile, myExecutor, myTarget, myProject, myRunnerSettings, myConfigurationSettings, myContentToReuse,
- myRunnerAndConfigurationSettings, myRunnerId);
+ if (myRunner == null) {
+ if (myRunnerId == null) {
+ myRunner = RunnerRegistry.getInstance().getRunner(myExecutor.getId(), myRunProfile);
+ }
+ else {
+ myRunner = RunnerRegistry.getInstance().findRunnerById(myRunnerId);
+ }
+ }
+
+ if (myRunner == null) {
+ throw new IllegalStateException("Runner must be specified");
+ }
+
+ ExecutionEnvironment environment = new ExecutionEnvironment(myRunProfile, myExecutor, myTarget, myProject, myRunnerSettings, myConfigurationSettings, myContentToReuse,
+ myRunnerAndConfigurationSettings, myRunner);
if (myAssignNewId) {
environment.assignNewExecutionId();
}
@@ -138,4 +276,9 @@ public final class ExecutionEnvironmentBuilder {
}
return environment;
}
+
+ public void buildAndExecute() throws ExecutionException {
+ ExecutionEnvironment environment = build();
+ myRunner.execute(environment);
+ }
}
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
index f0d67274d61a..0d15a272498c 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
@@ -16,24 +16,29 @@
package com.intellij.execution.runners;
-import com.intellij.execution.ExecutionBundle;
-import com.intellij.execution.ExecutionException;
-import com.intellij.execution.RunCanceledByUserException;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.process.ProcessNotCreatedException;
+import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.ide.DataManager;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.wm.ToolWindowManager;
+import com.intellij.ui.content.Content;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
@@ -52,6 +57,10 @@ public class ExecutionUtil {
handleExecutionError(project, toolWindowId, runProfile.getName(), e);
}
+ public static void handleExecutionError(@NotNull ExecutionEnvironment environment, @NotNull ExecutionException e) {
+ handleExecutionError(environment.getProject(), environment.getExecutor().getToolWindowId(), environment.getRunProfile().getName(), e);
+ }
+
public static void handleExecutionError(@NotNull final Project project,
@NotNull final String toolWindowId,
@NotNull String taskName,
@@ -59,15 +68,15 @@ public class ExecutionUtil {
if (e instanceof RunCanceledByUserException) return;
LOG.debug(e);
-
+
String description = e.getMessage();
HyperlinkListener listener = null;
-
+
if (description == null) {
LOG.warn("Execution error without description", e);
description = "Unknown error";
}
-
+
if ((description.contains("87") || description.contains("111") || description.contains("206")) &&
e instanceof ProcessNotCreatedException &&
!PropertiesComponent.getInstance(project).isTrueValue("dynamic.classpath")) {
@@ -107,4 +116,57 @@ public class ExecutionUtil {
}
});
}
+
+ public static void restartIfActive(@NotNull RunContentDescriptor descriptor) {
+ ProcessHandler processHandler = descriptor.getProcessHandler();
+ if (processHandler != null
+ && processHandler.isStartNotified()
+ && !processHandler.isProcessTerminating()
+ && !processHandler.isProcessTerminated()) {
+ restart(descriptor);
+ }
+ }
+
+ public static void restart(@NotNull RunContentDescriptor descriptor) {
+ restart(descriptor.getComponent());
+ }
+
+ public static void restart(@NotNull Content content) {
+ restart(content.getComponent());
+ }
+
+ private static void restart(@Nullable JComponent component) {
+ if (component != null) {
+ ExecutionEnvironment environment = LangDataKeys.EXECUTION_ENVIRONMENT.getData(DataManager.getInstance().getDataContext(component));
+ if (environment != null) {
+ restart(environment);
+ }
+ }
+ }
+
+ public static void restart(@NotNull ExecutionEnvironment environment) {
+ if (!ExecutorRegistry.getInstance().isStarting(environment)) {
+ ExecutionManager.getInstance(environment.getProject()).restartRunProfile(environment);
+ }
+ }
+
+ public static void runConfiguration(@NotNull RunnerAndConfigurationSettings configuration, @NotNull Executor executor) {
+ ExecutionEnvironmentBuilder builder = createEnvironment(executor, configuration);
+ if (builder != null) {
+ ExecutionManager.getInstance(configuration.getConfiguration().getProject()).restartRunProfile(builder
+ .activeTarget()
+ .build());
+ }
+ }
+
+ @Nullable
+ public static ExecutionEnvironmentBuilder createEnvironment(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) {
+ try {
+ return ExecutionEnvironmentBuilder.create(executor, settings);
+ }
+ catch (ExecutionException e) {
+ handleExecutionError(settings.getConfiguration().getProject(), executor.getToolWindowId(), settings.getConfiguration().getName(), e);
+ return null;
+ }
+ }
}
diff --git a/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java b/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
index ec8ec49a790b..adbd04e822e6 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
@@ -51,7 +51,8 @@ public abstract class GenericProgramRunner<Settings extends RunnerSettings> exte
}
@Nullable
- protected abstract RunContentDescriptor doExecute(@NotNull Project project, @NotNull RunProfileState state,
+ protected abstract RunContentDescriptor doExecute(@NotNull Project project,
+ @NotNull RunProfileState state,
@Nullable RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment environment) throws ExecutionException;
diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
index 8d4d3b29b088..60e7f03d54db 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,23 +15,20 @@
*/
package com.intellij.execution.ui;
+import com.intellij.execution.ExecutionResult;
+import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessHandler;
-import com.intellij.ide.DataManager;
import com.intellij.ide.HelpIdProvider;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.DataProvider;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.ui.content.Content;
-import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class RunContentDescriptor implements Disposable {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.ui.RunContentDescriptor");
-
private ExecutionConsole myExecutionConsole;
private ProcessHandler myProcessHandler;
private JComponent myComponent;
@@ -45,37 +42,33 @@ public class RunContentDescriptor implements Disposable {
private Computable<JComponent> myFocusComputable = null;
private boolean myAutoFocusContent = false;
- /**
- * Used to hack {@link com.intellij.execution.runners.RestartAction}
- */
private Content myContent;
private Runnable myRestarter;
- public RunContentDescriptor(final ExecutionConsole executionConsole,
- final ProcessHandler processHandler, final JComponent component, final String displayName, final Icon icon) {
+ public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
+ @Nullable ProcessHandler processHandler,
+ @NotNull JComponent component,
+ String displayName,
+ @Nullable Icon icon) {
myExecutionConsole = executionConsole;
myProcessHandler = processHandler;
myComponent = component;
myDisplayName = displayName;
myIcon = icon;
myHelpId = myExecutionConsole instanceof HelpIdProvider ? ((HelpIdProvider)myExecutionConsole).getHelpId() : null;
- DataManager.registerDataProvider(myComponent, new DataProvider() {
-
- @Override
- public Object getData(@NonNls final String dataId) {
- if (RunContentManager.RUN_CONTENT_DESCRIPTOR.is(dataId)) {
- return RunContentDescriptor.this;
- }
- return null;
- }
- });
}
- public RunContentDescriptor(final ExecutionConsole executionConsole,
- final ProcessHandler processHandler, final JComponent component, final String displayName) {
+ public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
+ @Nullable ProcessHandler processHandler,
+ @NotNull JComponent component,
+ String displayName) {
this(executionConsole, processHandler, component, displayName, null);
}
+ public RunContentDescriptor(@NotNull RunProfile profile, @NotNull ExecutionResult executionResult, @NotNull RunnerLayoutUi ui) {
+ this(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), ui.getComponent(), profile.getName(), profile.getIcon());
+ }
+
public ExecutionConsole getExecutionConsole() {
return myExecutionConsole;
}
@@ -86,10 +79,7 @@ public class RunContentDescriptor implements Disposable {
Disposer.dispose(myExecutionConsole);
myExecutionConsole = null;
}
- if (myComponent != null) {
- DataManager.removeDataProvider(myComponent);
- myComponent = null;
- }
+ myComponent = null;
myRestarter = null;
}
@@ -128,25 +118,30 @@ public class RunContentDescriptor implements Disposable {
return myHelpId;
}
- /**
- * @see #myContent
- */
- public void setAttachedContent(final Content content) {
- myContent = content;
- }
-
- /**
- * @see #myContent
- */
+ @Nullable
public Content getAttachedContent() {
return myContent;
}
+ public void setAttachedContent(@NotNull Content content) {
+ myContent = content;
+ }
+
@Nullable
+ @Deprecated
+ /**
+ * @deprecated Use {@link com.intellij.execution.runners.ExecutionUtil#restart(RunContentDescriptor)} instead
+ * to remove in IDEA 15
+ */
public Runnable getRestarter() {
return myRestarter;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated to remove in IDEA 15
+ */
public void setRestarter(@Nullable Runnable runnable) {
myRestarter = runnable;
}
diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
index 4f192197b0f9..5a2b53c97bc8 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
@@ -20,15 +20,24 @@ import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface RunContentManager {
+ Topic<RunContentWithExecutorListener> TOPIC =
+ Topic.create("Run Content", RunContentWithExecutorListener.class);
- DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = DataKey.create("RUN_CONTENT_DESCRIPTOR");
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link LangDataKeys#RUN_CONTENT_DESCRIPTOR} instead
+ */
+ DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = LangDataKeys.RUN_CONTENT_DESCRIPTOR;
@Nullable
RunContentDescriptor getSelectedContent();
@@ -38,28 +47,35 @@ public interface RunContentManager {
@NotNull
List<RunContentDescriptor> getAllDescriptors();
+
/**
- * to reduce number of open contents RunContentManager reuses
- * some of them during showRunContent (for ex. if a process was stopped)
- * @return content that will be reused by showRunContent
- * @deprecated use {@link #getReuseContent(com.intellij.execution.Executor, ExecutionEnvironment)}
+ * @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
+ @Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, @Nullable RunContentDescriptor contentToReuse);
/**
* @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
@Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, @NotNull ExecutionEnvironment executionEnvironment);
@Nullable
+ /**
+ * To reduce number of open contents RunContentManager reuses
+ * some of them during showRunContent (for ex. if a process was stopped)
+ */
RunContentDescriptor getReuseContent(@NotNull ExecutionEnvironment executionEnvironment);
/**
* @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
+ @SuppressWarnings("UnusedDeclaration")
@Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, DataContext dataContext);
@@ -67,19 +83,42 @@ public interface RunContentManager {
@Nullable
RunContentDescriptor findContentDescriptor(Executor requestor, ProcessHandler handler);
- void showRunContent(@NotNull Executor executor, RunContentDescriptor descriptor, RunContentDescriptor contentToReuse);
- void showRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
+ void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse);
+
+ void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor);
+
void hideRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
+
boolean removeRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
void toFrontRunContent(Executor requestor, RunContentDescriptor descriptor);
+
void toFrontRunContent(Executor requestor, ProcessHandler handler);
- void addRunContentListener(RunContentListener listener);
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link RunContentManager#TOPIC} instead
+ * to remove in IDEA 15
+ */
+ void addRunContentListener(@NotNull RunContentListener listener);
+
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link RunContentManager#TOPIC} instead
+ * to remove in IDEA 15
+ */
void removeRunContentListener(RunContentListener listener);
- void addRunContentListener(RunContentListener myContentListener, Executor executor);
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link RunContentManager#TOPIC} instead
+ * to remove in IDEA 15
+ */
+ void addRunContentListener(@NotNull RunContentListener myContentListener, Executor executor);
@Nullable
ToolWindow getToolWindowByDescriptor(@NotNull RunContentDescriptor descriptor);
-} \ No newline at end of file
+}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/controlflow/Instruction.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentWithExecutorListener.java
index 26ecfcca2a5d..ef18d75ab699 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/controlflow/Instruction.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentWithExecutorListener.java
@@ -13,25 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.codeInsight.controlflow;
+package com.intellij.execution.ui;
-import com.intellij.psi.PsiElement;
+import com.intellij.execution.Executor;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.Collection;
-
/**
- * @author oleg
+ * @author nik
*/
-public interface Instruction {
- @Nullable
- PsiElement getElement();
-
- Collection<Instruction> allSucc();
-
- Collection<Instruction> allPred();
-
- String getElementPresentation();
+public interface RunContentWithExecutorListener {
+ void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor);
- int num();
+ void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor);
}
diff --git a/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java b/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java
index 90dfad98dbbc..7fdb851514fe 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -53,6 +53,7 @@ public interface ViewContext extends Disposable {
ContentManager getContentManager();
+ @NotNull
ActionManager getActionManager();
IdeFocusManager getFocusManager();
diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java b/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java
index e896c9f14246..cb3518834423 100644
--- a/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java
+++ b/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java
@@ -17,10 +17,12 @@ package com.intellij.facet.frameworks;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.containers.hash.HashMap;
+import com.intellij.util.containers.ContainerUtil;
import org.jdom.Document;
import org.jdom.Element;
+import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -65,18 +67,23 @@ public abstract class SettingsConnectionService {
@Nullable
private Map<String, String> readSettings(String... attributes) {
- Map<String, String> settings = new HashMap<String, String>();
+ Map<String, String> settings = ContainerUtil.newLinkedHashMap();
try {
- final URL url = new URL(getSettingsUrl());
- final InputStream is = getStream(url);
- final Document document = JDOMUtil.loadDocument(is);
- final Element root = document.getRootElement();
- for (String s : attributes) {
- final String attributeValue = root.getAttributeValue(s);
- if (StringUtil.isNotEmpty(attributeValue)) {
- settings.put(s, attributeValue);
+ URL url = new URL(getSettingsUrl());
+ String text = FileUtil.loadTextAndClose(getStream(url));
+ try {
+ Document document = JDOMUtil.loadDocument(text);
+ Element root = document.getRootElement();
+ for (String s : attributes) {
+ String attributeValue = root.getAttributeValue(s);
+ if (StringUtil.isNotEmpty(attributeValue)) {
+ settings.put(s, attributeValue);
+ }
}
}
+ catch (JDOMException e) {
+ LOG.error("", e, text);
+ }
}
catch (MalformedURLException e) {
LOG.error(e);
diff --git a/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java b/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java
index f3a6d087da35..c04efa50ba33 100644
--- a/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java
+++ b/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.facet.ui;
+import org.jetbrains.annotations.NotNull;
+
/**
* @author nik
*/
public abstract class FacetEditorValidator {
+ @NotNull
public abstract ValidationResult check();
}
diff --git a/platform/lang-api/src/com/intellij/ide/IdeView.java b/platform/lang-api/src/com/intellij/ide/IdeView.java
index 7ee910f0925f..8f2dc5ce51a8 100644
--- a/platform/lang-api/src/com/intellij/ide/IdeView.java
+++ b/platform/lang-api/src/com/intellij/ide/IdeView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,7 @@ package com.intellij.ide;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -41,6 +42,7 @@ public interface IdeView {
*
* @return the list of directories, or an empty array if nothing is selected.
*/
+ @NotNull
PsiDirectory[] getDirectories();
/**
diff --git a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java
index c3f1bc3cb2fd..0dd1683899f4 100644
--- a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java
+++ b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java
@@ -16,7 +16,10 @@
package com.intellij.openapi.actionSystem;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.ConsoleView;
+import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.IdeView;
import com.intellij.lang.Language;
import com.intellij.openapi.module.ModifiableModuleModel;
@@ -54,10 +57,14 @@ public class LangDataKeys extends PlatformDataKeys {
public static final DataKey<PsiElement> PASTE_TARGET_PSI_ELEMENT = DataKey.create("psi.pasteTargetElement");
public static final DataKey<ConsoleView> CONSOLE_VIEW = DataKey.create("consoleView");
-
+
public static final DataKey<JBPopup> POSITION_ADJUSTER_POPUP = DataKey.create("chooseByNameDropDown");
public static final DataKey<JBPopup> PARENT_POPUP = DataKey.create("chooseByNamePopup");
public static final DataKey<Library> LIBRARY = DataKey.create("project.model.library");
+
+ public static final DataKey<RunProfile> RUN_PROFILE = DataKey.create("runProfile");
+ public static final DataKey<ExecutionEnvironment> EXECUTION_ENVIRONMENT = DataKey.create("executionEnvironment");
+ public static final DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = DataKey.create("RUN_CONTENT_DESCRIPTOR");
}
diff --git a/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java b/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java
index 2c38cd057b2b..11bf87e7a2cd 100644
--- a/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java
+++ b/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,11 +18,10 @@ package com.intellij.psi;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.util.NotNullLazyValue;
import com.intellij.util.KeyedLazyInstance;
+import com.intellij.util.ReflectionUtil;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.NotNull;
-import java.lang.reflect.Constructor;
-
/**
* @author peter
*/
@@ -44,24 +43,13 @@ public class WeigherExtensionPoint extends AbstractExtensionPointBean implements
protected final Weigher compute() {
try {
Class<Weigher> tClass = findClass(implementationClass);
- Constructor<Weigher> constructor = tClass.getConstructor();
- constructor.setAccessible(true);
- final Weigher weigher = tClass.newInstance();
+ final Weigher weigher = ReflectionUtil.newInstance(tClass);
weigher.setDebugName(id);
return weigher;
}
- catch (InstantiationException e) {
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
- catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
}
};
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
index d858bfc01fcb..2683db2a846d 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
@@ -113,7 +113,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
}
}
- public <T extends CustomCodeStyleSettings> T getCustomSettings(Class<T> aClass) {
+ public <T extends CustomCodeStyleSettings> T getCustomSettings(@NotNull Class<T> aClass) {
synchronized (myCustomSettings) {
return (T)myCustomSettings.get(aClass);
}
@@ -127,7 +127,9 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
}
private void copyCustomSettingsFrom(@NotNull CodeStyleSettings from) {
- myCustomSettings.clear();
+ synchronized (myCustomSettings) {
+ myCustomSettings.clear();
+ }
for (final CustomCodeStyleSettings settings : from.getCustomSettingsValues()) {
addCustomSettings((CustomCodeStyleSettings) settings.clone());
}
@@ -247,6 +249,10 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
public int INNER_CLASSES_ORDER_WEIGHT = 7;
//----------------- WRAPPING ---------------------------
+ /**
+ * @deprecated Use get/setRightMargin() methods instead.
+ */
+ @Deprecated
public int RIGHT_MARGIN = 120;
public boolean WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = false;
@@ -435,6 +441,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
private CodeStyleSettings myParentSettings;
private boolean myLoadedAdditionalIndentOptions;
+ @NotNull
private Collection<CustomCodeStyleSettings> getCustomSettingsValues() {
synchronized (myCustomSettings) {
return Collections.unmodifiableCollection(myCustomSettings.values());
@@ -524,7 +531,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
@NonNls Element option = (Element)option1;
@NonNls final String name = option.getAttributeValue("name");
if ("TAB_SIZE".equals(name)) {
- final int value = Integer.valueOf(option.getAttributeValue("value")).intValue();
+ final int value = Integer.parseInt(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.TAB_SIZE = value;
JSP_INDENT_OPTIONS.TAB_SIZE = value;
XML_INDENT_OPTIONS.TAB_SIZE = value;
@@ -532,7 +539,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("INDENT_SIZE".equals(name)) {
- final int value = Integer.valueOf(option.getAttributeValue("value")).intValue();
+ final int value = Integer.parseInt(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.INDENT_SIZE = value;
JSP_INDENT_OPTIONS.INDENT_SIZE = value;
XML_INDENT_OPTIONS.INDENT_SIZE = value;
@@ -540,7 +547,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("CONTINUATION_INDENT_SIZE".equals(name)) {
- final int value = Integer.valueOf(option.getAttributeValue("value")).intValue();
+ final int value = Integer.parseInt(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value;
JSP_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value;
XML_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value;
@@ -548,7 +555,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("USE_TAB_CHARACTER".equals(name)) {
- final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue();
+ final boolean value = Boolean.parseBoolean(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.USE_TAB_CHARACTER = value;
JSP_INDENT_OPTIONS.USE_TAB_CHARACTER = value;
XML_INDENT_OPTIONS.USE_TAB_CHARACTER = value;
@@ -556,14 +563,15 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("SMART_TABS".equals(name)) {
- final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue();
+ final boolean value = Boolean.parseBoolean(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.SMART_TABS = value;
JSP_INDENT_OPTIONS.SMART_TABS = value;
XML_INDENT_OPTIONS.SMART_TABS = value;
OTHER_INDENT_OPTIONS.SMART_TABS = value;
optionsImported = true;
- } else if ("SPACE_AFTER_UNARY_OPERATOR".equals(name)) {
- SPACE_AROUND_UNARY_OPERATOR = Boolean.valueOf(option.getAttributeValue("value")).booleanValue();
+ }
+ else if ("SPACE_AFTER_UNARY_OPERATOR".equals(name)) {
+ SPACE_AROUND_UNARY_OPERATOR = Boolean.parseBoolean(option.getAttributeValue("value"));
optionsImported = true;
}
}
@@ -751,6 +759,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
myNames.addAll(from.myNames);
}
+ @Override
public boolean equals(Object other) {
if (other instanceof TypeToNameMap) {
TypeToNameMap otherMap = (TypeToNameMap)other;
@@ -759,6 +768,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
return false;
}
+ @Override
public int hashCode() {
int code = 0;
for (String myPattern : myPatterns) {
@@ -900,7 +910,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
if (langSettings.RIGHT_MARGIN >= 0) return langSettings.RIGHT_MARGIN;
}
}
- return RIGHT_MARGIN;
+ return getDefaultRightMargin();
}
/**
@@ -917,6 +927,16 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
return;
}
}
+ setDefaultRightMargin(rightMargin);
+ }
+
+ @SuppressWarnings("deprecation")
+ public int getDefaultRightMargin() {
+ return RIGHT_MARGIN;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setDefaultRightMargin(int rightMargin) {
RIGHT_MARGIN = rightMargin;
}
}
diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
index 56fe91a0dc28..13f84cb1dc4f 100644
--- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
+++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
@@ -32,6 +32,7 @@ import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
@@ -221,12 +222,13 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
* Tries to find editor for the given element.
* <p/>
* There are at least two approaches to achieve the target. Current method is intended to encapsulate both of them:
- * <pre>
* <ul>
* <li>target editor works with a real file that remains at file system;</li>
* <li>target editor works with a virtual file;</li>
* </ul>
- * </pre>
+ * <p/>
+ * Please don't use this method for finding an editor for quick fix.
+ * @see {@link com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement}
*
* @param element target element
* @return editor that works with a given element if the one is found; <code>null</code> otherwise
@@ -234,30 +236,28 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
@Nullable
public static Editor findEditor(@NotNull PsiElement element) {
PsiFile psiFile = element.getContainingFile();
- if (psiFile == null) {
- return null;
- }
- VirtualFile virtualFile = psiFile.getOriginalFile().getVirtualFile();
+ VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
if (virtualFile == null) {
return null;
}
- if (virtualFile.isInLocalFileSystem()) {
+ Project project = psiFile.getProject();
+ if (virtualFile.isInLocalFileSystem() || virtualFile.getFileSystem() instanceof NonPhysicalFileSystem) {
// Try to find editor for the real file.
- final FileEditor[] editors = FileEditorManager.getInstance(psiFile.getProject()).getEditors(virtualFile);
+ final FileEditor[] editors = FileEditorManager.getInstance(project).getEditors(virtualFile);
for (FileEditor editor : editors) {
if (editor instanceof TextEditor) {
return ((TextEditor)editor).getEditor();
}
}
}
- else if (SwingUtilities.isEventDispatchThread()) {
+ if (SwingUtilities.isEventDispatchThread()) {
// We assume that data context from focus-based retrieval should success if performed from EDT.
AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
if (asyncResult.isDone()) {
Editor editor = CommonDataKeys.EDITOR.getData(asyncResult.getResult());
if (editor != null) {
- Document cachedDocument = PsiDocumentManager.getInstance(psiFile.getProject()).getCachedDocument(psiFile);
+ Document cachedDocument = PsiDocumentManager.getInstance(project).getCachedDocument(psiFile);
// Ensure that target editor is found by checking its document against the one from given PSI element.
if (cachedDocument == editor.getDocument()) {
return editor;