diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineStateUtil.java b/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineStateUtil.java index 750d5b6dfca2..4917af0fdee8 100644 --- a/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineStateUtil.java +++ b/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineStateUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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,31 +15,26 @@ */ package com.intellij.execution.configurations; +import com.intellij.execution.ExecutionException; import com.intellij.execution.process.ColoredProcessHandler; -import com.intellij.execution.process.DefaultJavaProcessHandler; import com.intellij.execution.process.OSProcessHandler; import com.intellij.execution.process.ProcessTerminatedListener; -import com.intellij.execution.ExecutionException; import org.jetbrains.annotations.NotNull; /** * @author spleaner */ public class JavaCommandLineStateUtil { - private JavaCommandLineStateUtil() { - } + private JavaCommandLineStateUtil() { } @NotNull - public static OSProcessHandler startProcess(@NotNull final GeneralCommandLine commandLine) throws ExecutionException { + public static OSProcessHandler startProcess(@NotNull GeneralCommandLine commandLine) throws ExecutionException { return startProcess(commandLine, false); } @NotNull - public static OSProcessHandler startProcess(@NotNull final GeneralCommandLine commandLine, - final boolean ansiColoring) throws ExecutionException { - - final OSProcessHandler processHandler = ansiColoring ? new ColoredProcessHandler(commandLine) - : new DefaultJavaProcessHandler(commandLine); + public static OSProcessHandler startProcess(@NotNull GeneralCommandLine commandLine, boolean ansiColoring) throws ExecutionException { + OSProcessHandler processHandler = ansiColoring ? new ColoredProcessHandler(commandLine) : new OSProcessHandler(commandLine); ProcessTerminatedListener.attach(processHandler); return processHandler; } diff --git a/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java b/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java index b6721ac58fed..424a9f911e2a 100644 --- a/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java +++ b/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -20,27 +20,22 @@ import com.intellij.execution.configurations.CommandLineBuilder; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.JavaParameters; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.nio.charset.Charset; +/** @deprecated use {@link OSProcessHandler} (to be removed in IDEA 17) */ +@SuppressWarnings("unused") public class DefaultJavaProcessHandler extends OSProcessHandler { - private final Charset myCharset; - - public DefaultJavaProcessHandler(final JavaParameters javaParameters) throws ExecutionException { - this(CommandLineBuilder.createFromJavaParameters(javaParameters)); + public DefaultJavaProcessHandler(@NotNull JavaParameters javaParameters) throws ExecutionException { + super(CommandLineBuilder.createFromJavaParameters(javaParameters)); } - public DefaultJavaProcessHandler(final GeneralCommandLine commandLine) throws ExecutionException { - this(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset()); + public DefaultJavaProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException { + super(commandLine); } - public DefaultJavaProcessHandler(final Process process, final String commandLine, @NotNull final Charset charset) { - super(process, commandLine); - myCharset = charset; - } - - @Override - public Charset getCharset() { - return myCharset; + public DefaultJavaProcessHandler(@NotNull Process process, @Nullable String commandLine, @NotNull Charset charset) { + super(process, commandLine, charset); } } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java index 43d6ee4d04c0..39d0cbf52acb 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -68,7 +68,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.nio.charset.Charset; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.util.List; @@ -199,17 +198,9 @@ public class RemoteExternalSystemCommunicationManager implements ExternalSystemC throw new ExecutionException("No sdk is defined. Params: " + params); } - final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine( - ((JavaSdkType)sdk.getSdkType()).getVMExecutablePath(sdk), - params, - false - ); - final OSProcessHandler processHandler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString()) { - @Override - public Charset getCharset() { - return commandLine.getCharset(); - } - }; + String executablePath = ((JavaSdkType)sdk.getSdkType()).getVMExecutablePath(sdk); + GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(executablePath, params, false); + OSProcessHandler processHandler = new OSProcessHandler(commandLine); ProcessTerminatedListener.attach(processHandler); return processHandler; } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/SimpleJavaParameters.java b/platform/lang-api/src/com/intellij/execution/configurations/SimpleJavaParameters.java index f6522e450b60..67cf6f9fea99 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/SimpleJavaParameters.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/SimpleJavaParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -114,12 +114,7 @@ public class SimpleJavaParameters extends SimpleProgramParameters { assert sdk != null : "SDK should be defined"; final String exePath = ((JavaSdkType)sdk.getSdkType()).getVMExecutablePath(sdk); final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(exePath, this, myUseDynamicClasspath); - final OSProcessHandler processHandler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString()) { - @Override - public Charset getCharset() { - return commandLine.getCharset(); - } - }; + final OSProcessHandler processHandler = new OSProcessHandler(commandLine); ProcessTerminatedListener.attach(processHandler); return processHandler; } diff --git a/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java b/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java index 078a4327e74c..9887964a4b0c 100644 --- a/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java +++ b/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java @@ -18,10 +18,10 @@ package com.intellij.execution.process; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; -import com.intellij.execution.configurations.PtyCommandLine; import com.intellij.openapi.util.Key; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.nio.charset.Charset; import java.util.List; @@ -35,18 +35,15 @@ public class ColoredProcessHandler extends OSProcessHandler implements AnsiEscap private final List myColoredTextListeners = ContainerUtil.newArrayList(); - public ColoredProcessHandler(final GeneralCommandLine commandLine) throws ExecutionException { - super(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset()); - setHasPty(commandLine instanceof PtyCommandLine); + public ColoredProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException { + super(commandLine); } - public ColoredProcessHandler(Process process, String commandLine) { + public ColoredProcessHandler(@NotNull Process process, @Nullable String commandLine) { super(process, commandLine); } - public ColoredProcessHandler(final Process process, - final String commandLine, - @NotNull final Charset charset) { + public ColoredProcessHandler(@NotNull Process process, @Nullable String commandLine, @NotNull Charset charset) { super(process, commandLine, charset); } diff --git a/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java b/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java index 7ccba0e8355a..11228a9650a7 100644 --- a/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java +++ b/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java @@ -50,7 +50,7 @@ public class KillableColoredProcessHandler extends ColoredProcessHandler impleme * Starts a process with a {@link RunnerMediator mediator} when {@code withMediator} is set to {@code true} and the platform is Windows. */ public KillableColoredProcessHandler(@NotNull GeneralCommandLine commandLine, boolean withMediator) throws ExecutionException { - super(mediate(commandLine, withMediator).createProcess(), commandLine.getCommandLineString(), commandLine.getCharset()); + super(mediate(commandLine, withMediator)); myMediatedProcess = withMediator && MEDIATOR_KEY.get(commandLine) == Boolean.TRUE; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java index e5f6d085a7c3..ecbc76436191 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java @@ -20,7 +20,7 @@ import com.intellij.execution.CantRunException; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.JavaParameters; -import com.intellij.execution.process.DefaultJavaProcessHandler; +import com.intellij.execution.process.OSProcessHandler; import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.notification.NotificationDisplayType; import com.intellij.notification.NotificationGroup; @@ -209,8 +209,7 @@ public class GrabDependencies implements IntentionAction { lines.put(grabText, JdkUtil.setupJVMCommandLine(exePath, javaParameters, true)); } - ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing @Grab annotations") { - + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing @Grab Annotations") { @Override public void run(@NotNull ProgressIndicator indicator) { int jarCount = 0; @@ -276,7 +275,7 @@ public class GrabDependencies implements IntentionAction { return false; } - private static class GrapeProcessHandler extends DefaultJavaProcessHandler { + private static class GrapeProcessHandler extends OSProcessHandler { private final StringBuilder myStdOut = new StringBuilder(); private final StringBuilder myStdErr = new StringBuilder(); private final Module myModule; diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandProcessHandler.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandProcessHandler.java index dbf77fd9aba6..7a88a49117f0 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandProcessHandler.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandProcessHandler.java @@ -15,6 +15,8 @@ */ package org.zmlx.hg4idea.execution; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.process.OSProcessHandler; import com.intellij.util.io.BaseDataReader; import com.intellij.util.io.BinaryOutputReader; @@ -23,7 +25,6 @@ import org.jetbrains.annotations.Nullable; import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.nio.charset.Charset; import java.util.concurrent.Future; class HgCommandProcessHandler extends OSProcessHandler { @@ -31,12 +32,9 @@ class HgCommandProcessHandler extends OSProcessHandler { private final boolean myBinary; private final ByteArrayOutputStream myBinaryOutput; - public HgCommandProcessHandler(@NotNull final Process process, - @Nullable final String commandLine, - @Nullable final Charset charset, - boolean isBinary) { - super(process, commandLine, charset); - myBinary = isBinary; + public HgCommandProcessHandler(@NotNull GeneralCommandLine commandLine, boolean binary) throws ExecutionException { + super(commandLine); + myBinary = binary; myBinaryOutput = new ByteArrayOutputStream(); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/ShellCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/ShellCommand.java index 54ab043d4224..568a56f72f94 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/ShellCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/ShellCommand.java @@ -56,9 +56,7 @@ public final class ShellCommand { public HgCommandResult execute(final boolean showTextOnIndicator, boolean isBinary) throws ShellCommandException, InterruptedException { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); try { - final Process process = myCommandLine.createProcess(); - HgCommandProcessHandler processHandler = - new HgCommandProcessHandler(process, myCommandLine.toString(), myCommandLine.getCharset(), isBinary); + HgCommandProcessHandler processHandler = new HgCommandProcessHandler(myCommandLine, isBinary); CapturingProcessAdapter outputAdapter = new CapturingProcessAdapter() { @Override diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalExecutor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalExecutor.java index dee6065e8e34..f837f3205854 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalExecutor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalExecutor.java @@ -19,8 +19,8 @@ package org.jetbrains.idea.maven.execution; import com.intellij.execution.ExecutionException; +import com.intellij.execution.configurations.CommandLineBuilder; import com.intellij.execution.configurations.JavaParameters; -import com.intellij.execution.process.DefaultJavaProcessHandler; import com.intellij.execution.process.OSProcessHandler; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressIndicator; @@ -51,7 +51,7 @@ public class MavenExternalExecutor extends MavenExecutor { super(parameters, RunnerBundle.message("external.executor.caption"), console); try { - myJavaParameters = MavenExternalParameters.createJavaParameters(project, myParameters, coreSettings, runnerSettings); + myJavaParameters = MavenExternalParameters.createJavaParameters(project, myParameters, coreSettings, runnerSettings, null); } catch (ExecutionException e) { myParameterCreationError = e; @@ -67,7 +67,8 @@ public class MavenExternalExecutor extends MavenExecutor { } myProcessHandler = - new DefaultJavaProcessHandler(myJavaParameters) { + new OSProcessHandler(CommandLineBuilder.createFromJavaParameters(myJavaParameters)) { + @Override public void notifyTextAvailable(String text, Key outputType) { // todo move this logic to ConsoleAdapter class if (!myConsole.isSuppressed(text)) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java index 6b6381aafc51..1eafd66d831a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -356,8 +356,7 @@ public class MavenServerManager extends RemoteObjectWrapper impleme GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(exePath, params, false); - OSProcessHandler processHandler = - new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset()); + OSProcessHandler processHandler = new OSProcessHandler(commandLine); processHandler.setShouldDestroyProcessRecursively(false);