-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update executeInterminal with TerminalExecutionConsole (#108)
* feat: update executeInterminal with TerminalExecutionConsole Signed-off-by: Luca Stocchi <lstocchi@redhat.com> * add check for waitForProcessExit Signed-off-by: Luca Stocchi <lstocchi@redhat.com> * add custom input stream reader to fix wrong indentation on ij-rsp Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
- Loading branch information
Showing
4 changed files
with
324 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/com/redhat/devtools/intellij/common/utils/ExecProcessHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. | ||
******************************************************************************/ | ||
package com.redhat.devtools.intellij.common.utils; | ||
|
||
import com.intellij.execution.process.OSProcessHandler; | ||
import com.intellij.util.io.BaseDataReader; | ||
import com.intellij.util.io.BaseOutputReader; | ||
import java.io.Reader; | ||
import java.nio.charset.Charset; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ExecProcessHandler extends OSProcessHandler { | ||
|
||
/** | ||
* | ||
* @param process process | ||
* @param commandLine must not be empty (for correct thread attribution in the stacktrace) | ||
* @param charset charset | ||
*/ | ||
public ExecProcessHandler(@NotNull Process process, /*@NotNull*/ String commandLine, @Nullable Charset charset) { | ||
super(process, commandLine, charset); | ||
} | ||
|
||
@Override | ||
protected BaseOutputReader.Options readerOptions() { | ||
return new BaseOutputReader.Options() { | ||
@Override | ||
public BaseDataReader.SleepingPolicy policy() { | ||
return BaseDataReader.SleepingPolicy.BLOCKING; | ||
} | ||
|
||
@Override | ||
public boolean splitToLines() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean sendIncompleteLines() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean withSeparators() { | ||
return true; | ||
} | ||
}; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
protected Reader createProcessOutReader() { | ||
return new ExecReader(myProcess.getInputStream()); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
protected Reader createProcessErrReader() { | ||
return new ExecReader(myProcess.getErrorStream()); | ||
} | ||
} |
Oops, something went wrong.