Java Code Examples for com.intellij.execution.ui.ConsoleView#print()
The following examples show how to use
com.intellij.execution.ui.ConsoleView#print() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompilerAction.java From reasonml-idea-plugin with MIT License | 6 votes |
private static void compileDirectory(@NotNull Project project, CliType cliType) { ORCompilerManager compilerManager = ServiceManager.getService(project, ORCompilerManager.class); Optional<Compiler> compilerOptional = compilerManager.getCompiler(cliType); if (!compilerOptional.isPresent()) { return; } Compiler compiler = compilerOptional.get(); ConsoleView consoleView = compiler.getConsoleView(); if (consoleView == null) { return; } Optional<VirtualFile> baseDir = compiler.findFirstContentRoot(project); if (baseDir.isPresent()) { consoleView.print("No active text editor found, using root directory " + baseDir.get().getPath() + "\n", ConsoleViewContentType.NORMAL_OUTPUT); compiler.run(baseDir.get(), cliType, null); } else { consoleView.print("Can't find content root\n", ConsoleViewContentType.NORMAL_OUTPUT); } }
Example 2
Source File: LogView.java From logviewer with Apache License 2.0 | 6 votes |
/** * Prints the message to console */ private void printMessageToConsole(String line) { final ConsoleView console = getConsole(); final LogFilterModel.MyProcessingResult processingResult = myLogFilterModel.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 = logFormatter.formatPrefix(messagePrefix); if (console != null) { console.print(formattedPrefix, type); } } String formattedMessage = logFormatter.formatMessage(line); if (console != null) { console.print(formattedMessage + "\n", type); } } } } }
Example 3
Source File: FreeRunConfiguration.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 6 votes |
private ExecutionResult buildExecutionResult() throws ExecutionException { GeneralCommandLine commandLine = createDefaultCommandLine(); ProcessHandler processHandler = createProcessHandler(commandLine); ProcessTerminatedListener.attach(processHandler); ConsoleView console = new TerminalExecutionConsole(getProject(), processHandler); console.print( "Welcome to React Native Console, now please click one button on top toolbar to start.\n", ConsoleViewContentType.SYSTEM_OUTPUT); console.attachToProcess(processHandler); console.print( "Give a Star or Suggestion:\n", ConsoleViewContentType.NORMAL_OUTPUT); processHandler.destroyProcess(); return new DefaultExecutionResult(console, processHandler); }
Example 4
Source File: EOFAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull 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) { } }
Example 5
Source File: ConsoleViewUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void printWithHighlighting(@Nonnull ConsoleView console, @Nonnull String text, @Nonnull SyntaxHighlighter highlighter, Runnable doOnNewLine) { Lexer lexer = highlighter.getHighlightingLexer(); lexer.start(text, 0, text.length(), 0); IElementType tokenType; while ((tokenType = lexer.getTokenType()) != null) { ConsoleViewContentType contentType = getContentTypeForToken(tokenType, highlighter); StringTokenizer eolTokenizer = new StringTokenizer(lexer.getTokenText(), "\n", true); while (eolTokenizer.hasMoreTokens()) { String tok = eolTokenizer.nextToken(); console.print(tok, contentType); if (doOnNewLine != null && "\n".equals(tok)) { doOnNewLine.run(); } } lexer.advance(); } }
Example 6
Source File: LogConsoleBase.java From consulo with Apache License 2.0 | 5 votes |
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) { console.print(fragment.getText(), 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) { console.print(messagePrefix, type); } console.print(line + "\n", type); return (messagePrefix != null ? messagePrefix.length() : 0) + line.length() + 1; } } } return 0; } }
Example 7
Source File: ConsoleViewUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void printAsFileType(@Nonnull ConsoleView console, @Nonnull String text, @Nonnull FileType fileType) { SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); if (highlighter != null) { printWithHighlighting(console, text, highlighter); } else { console.print(text, ConsoleViewContentType.NORMAL_OUTPUT); } }
Example 8
Source File: UnityDebugProcess.java From consulo-unity3d with Apache License 2.0 | 5 votes |
private void print(String text, String stacktrace, ConsoleView view, ConsoleViewContentType contentType) { view.print(text + "\n", contentType); if(contentType == ConsoleViewContentType.ERROR_OUTPUT && !StringUtil.isEmpty(stacktrace)) { StringBuilder builder = new StringBuilder(); String[] strings = StringUtil.splitByLines(stacktrace); for(String line : strings) { builder.append(" at ").append(line).append("\n"); } view.print(builder.toString(), contentType); } }
Example 9
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onAppDebugPort(@NotNull DaemonEvent.AppDebugPort debugInfo) { app.setWsUrl(debugInfo.wsUri); // Print the conneciton info to the console. final ConsoleView console = app.getConsole(); if (console != null) { console.print("Debug service listening on " + debugInfo.wsUri + "\n", ConsoleViewContentType.NORMAL_OUTPUT); } String uri = debugInfo.baseUri; if (uri != null) { if (uri.startsWith("file:")) { // Convert the file: url to a path. try { uri = new URL(uri).getPath(); if (uri.endsWith(File.separator)) { uri = uri.substring(0, uri.length() - 1); } } catch (MalformedURLException e) { // ignore } } app.setBaseUri(uri); } }
Example 10
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onDaemonLog(@NotNull DaemonEvent.DaemonLog message) { final ConsoleView console = app.getConsole(); if (console == null) return; if (message.log != null) { console.print(message.log + "\n", message.error ? ConsoleViewContentType.ERROR_OUTPUT : ConsoleViewContentType.NORMAL_OUTPUT); } }
Example 11
Source File: FlutterConsoleLogManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void printStackTraceToConsole( @NotNull ConsoleView console, String padding, @NotNull InstanceRef stackTrace) { if (stackTrace.isNull()) return; final String out = stackTrace.getValueAsString(); console.print( padding + out.replaceAll("\n", "\n" + padding), ERROR_CONTENT_TYPE); }
Example 12
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onAppDebugPort(@NotNull DaemonEvent.AppDebugPort debugInfo) { app.setWsUrl(debugInfo.wsUri); // Print the conneciton info to the console. final ConsoleView console = app.getConsole(); if (console != null) { console.print("Debug service listening on " + debugInfo.wsUri + "\n", ConsoleViewContentType.NORMAL_OUTPUT); } String uri = debugInfo.baseUri; if (uri != null) { if (uri.startsWith("file:")) { // Convert the file: url to a path. try { uri = new URL(uri).getPath(); if (uri.endsWith(File.separator)) { uri = uri.substring(0, uri.length() - 1); } } catch (MalformedURLException e) { // ignore } } app.setBaseUri(uri); } }
Example 13
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onDaemonLog(@NotNull DaemonEvent.DaemonLog message) { final ConsoleView console = app.getConsole(); if (console == null) return; if (message.log != null) { console.print(message.log + "\n", message.error ? ConsoleViewContentType.ERROR_OUTPUT : ConsoleViewContentType.NORMAL_OUTPUT); } }
Example 14
Source File: FlutterConsoleLogManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void printStackTraceToConsole( @NotNull ConsoleView console, String padding, @NotNull InstanceRef stackTrace) { if (stackTrace.isNull()) return; final String out = stackTrace.getValueAsString(); console.print( padding + out.replaceAll("\n", "\n" + padding), ERROR_CONTENT_TYPE); }
Example 15
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onAppLog(@NotNull DaemonEvent.AppLog message) { final ConsoleView console = app.getConsole(); if (console == null) return; console.print(message.log + "\n", message.error ? ConsoleViewContentType.ERROR_OUTPUT : ConsoleViewContentType.NORMAL_OUTPUT); }
Example 16
Source File: ParsingUtils.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static void reportBadGrammar(VirtualFile grammarFile, ConsoleView console) { String msg = "Empty or bad grammar in file "+grammarFile.getName(); console.print(msg+"\n", ConsoleViewContentType.ERROR_OUTPUT); }
Example 17
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onAppLog(@NotNull DaemonEvent.AppLog message) { final ConsoleView console = app.getConsole(); if (console == null) return; console.print(message.log + "\n", message.error ? ConsoleViewContentType.ERROR_OUTPUT : ConsoleViewContentType.NORMAL_OUTPUT); }
Example 18
Source File: AnalyzeStacktraceUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void printStacktrace(final ConsoleView consoleView, final String unscrambledTrace) { consoleView.clear(); consoleView.print(unscrambledTrace + "\n", ConsoleViewContentType.ERROR_OUTPUT); consoleView.scrollTo(0); }