use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class LogConsoleBase method printMessageToConsole.
private int printMessageToConsole(String line) {
final ConsoleView console = getConsoleNotNull();
if (myContentPreprocessor != null) {
List<LogFragment> fragments = myContentPreprocessor.parseLogLine(line + '\n');
for (LogFragment fragment : fragments) {
ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(fragment.getOutputType());
if (consoleViewType != null) {
String formattedText = myFormatter.formatMessage(fragment.getText());
console.print(formattedText, consoleViewType);
}
}
return line.length() + 1;
} else {
final LogFilterModel.MyProcessingResult processingResult = myModel.processLine(line);
if (processingResult.isApplicable()) {
final Key key = processingResult.getKey();
if (key != null) {
ConsoleViewContentType type = ConsoleViewContentType.getConsoleViewType(key);
if (type != null) {
final String messagePrefix = processingResult.getMessagePrefix();
if (messagePrefix != null) {
String formattedPrefix = myFormatter.formatPrefix(messagePrefix);
console.print(formattedPrefix, type);
}
String formattedMessage = myFormatter.formatMessage(line);
console.print(formattedMessage + "\n", type);
return (messagePrefix != null ? messagePrefix.length() : 0) + line.length() + 1;
}
}
}
return 0;
}
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class EOFAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(e.getDataContext());
ProcessHandler activeProcessHandler = descriptor != null ? descriptor.getProcessHandler() : null;
if (activeProcessHandler == null || activeProcessHandler.isProcessTerminated())
return;
try {
OutputStream input = activeProcessHandler.getProcessInput();
if (input != null) {
ConsoleView console = e.getData(LangDataKeys.CONSOLE_VIEW);
if (console != null) {
console.print("^D\n", ConsoleViewContentType.SYSTEM_OUTPUT);
}
input.close();
}
} catch (IOException ignored) {
}
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class PythonCommandLineState method createAndAttachConsole.
@NotNull
protected ConsoleView createAndAttachConsole(Project project, ProcessHandler processHandler, Executor executor) throws ExecutionException {
final ConsoleView consoleView = createConsoleBuilder(project).getConsole();
consoleView.addMessageFilter(createUrlFilter(processHandler));
addTracebackFilter(project, consoleView, processHandler);
consoleView.attachToProcess(processHandler);
return consoleView;
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class PyUnitTestTask method getHighlightedStrings.
/**
* Gets highlighted information from test console. Some parts of output (like file links) may be highlighted, and you need to check them.
*
* @return pair of [[ranges], [texts]] where range is [from,to] in doc. for each region, and "text" is text extracted from this region.
* For example assume that in document "spam eggs ham" words "ham" and "spam" are highlighted.
* You should have 2 ranges (0, 4) and (10, 13) and 2 strings (spam and ham)
*/
@NotNull
public final Pair<List<Pair<Integer, Integer>>, List<String>> getHighlightedStrings() {
final ConsoleView console = myConsoleView.getConsole();
assert console instanceof ConsoleViewImpl : "Console has no editor!";
final ConsoleViewImpl consoleView = (ConsoleViewImpl) console;
final Editor editor = consoleView.getEditor();
final List<String> resultStrings = new ArrayList<>();
final List<Pair<Integer, Integer>> resultRanges = new ArrayList<>();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
/**
* To fetch data from console we need to flush it first.
* It works locally, but does not work on TC (reasons are not clear yet and need to be investigated).
* So, we flush it explicitly to make test run on TC.
*/
consoleView.flushDeferredText();
for (final RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) {
if (highlighter instanceof RangeHighlighterEx) {
final int start = ((RangeHighlighterEx) highlighter).getAffectedAreaStartOffset();
final int end = ((RangeHighlighterEx) highlighter).getAffectedAreaEndOffset();
resultRanges.add(Pair.create(start, end));
resultStrings.add(editor.getDocument().getText().substring(start, end));
}
}
}
});
final String message = String.format("Following output is searched for hightlighed strings: %s \n", editor.getDocument().getText());
Logger.getInstance(getClass()).warn(message);
return Pair.create(resultRanges, resultStrings);
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class PyTestCommandLineState method createAndAttachConsole.
@NotNull
protected ConsoleView createAndAttachConsole(Project project, ProcessHandler processHandler, Executor executor) throws ExecutionException {
final ConsoleView consoleView = super.createAndAttachConsole(project, processHandler, executor);
addTracebackFilter(project, consoleView, processHandler);
return consoleView;
}
Aggregations