From cbfb20c2aeca9368ca8a0fb2638361443dc856aa Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Tue, 24 Apr 2012 21:41:36 +0200 Subject: [PATCH] Coverage: report generation fixed. --- .../process/CapturingProcessAdapter.java | 47 +++++++++++++++++++ .../process/CapturingProcessHandler.java | 13 +---- 2 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/execution/process/CapturingProcessAdapter.java diff --git a/platform/platform-api/src/com/intellij/execution/process/CapturingProcessAdapter.java b/platform/platform-api/src/com/intellij/execution/process/CapturingProcessAdapter.java new file mode 100644 index 000000000000..d0fc159abad1 --- /dev/null +++ b/platform/platform-api/src/com/intellij/execution/process/CapturingProcessAdapter.java @@ -0,0 +1,47 @@ +/* + * 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.execution.process; + +import com.intellij.openapi.util.Key; + +/** + * @author traff + */ +public class CapturingProcessAdapter extends ProcessAdapter { + private ProcessOutput myOutput; + + public CapturingProcessAdapter(ProcessOutput output) { + myOutput = output; + } + + public CapturingProcessAdapter() { + this(new ProcessOutput()); + } + + @Override + public void onTextAvailable(ProcessEvent event, Key outputType) { + if (outputType == ProcessOutputTypes.STDOUT) { + myOutput.appendStdout(event.getText()); + } + if (outputType == ProcessOutputTypes.STDERR) { + myOutput.appendStderr(event.getText()); + } + } + + public ProcessOutput getOutput() { + return myOutput; + } +} diff --git a/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java b/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java index 6969c06863bb..65f78d4f524b 100644 --- a/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java +++ b/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java @@ -16,7 +16,6 @@ package com.intellij.execution.process; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Key; import java.nio.charset.Charset; @@ -41,17 +40,7 @@ public class CapturingProcessHandler extends OSProcessHandler { public CapturingProcessHandler(final Process process, final Charset charset, final String commandLine) { super(process, commandLine, charset); myCharset = charset; - addProcessListener(new ProcessAdapter() { - @Override - public void onTextAvailable(ProcessEvent event, Key outputType) { - if (outputType == ProcessOutputTypes.STDOUT) { - myOutput.appendStdout(event.getText()); - } - if (outputType == ProcessOutputTypes.STDERR) { - myOutput.appendStderr(event.getText()); - } - } - }); + addProcessListener(new CapturingProcessAdapter(myOutput)); } public ProcessOutput runProcess() {