com.intellij.execution.ui.ConsoleViewContentType Java Examples
The following examples show how to use
com.intellij.execution.ui.ConsoleViewContentType.
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: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onAppProgressStarting(@NotNull DaemonEvent.AppProgress event) { progress.start(event.message); if (event.getType().startsWith("hot.")) { // We clear the console view in order to help indicate that a reload is happening. if (app.getConsole() != null) { if (!FlutterSettings.getInstance().isVerboseLogging()) { app.getConsole().clear(); } } stopwatch.set(Stopwatch.createStarted()); } if (app.getConsole() != null) { app.getConsole().print(event.message + "\n", ConsoleViewContentType.NORMAL_OUTPUT); } }
Example #2
Source File: RunRNDebuggerAction.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean beforeAction() { File f = new File("/Applications/React Native Debugger.app/"); if(f.exists()) { return true; } else { RNConsole consoleView = terminal.getRNConsole(getText(), getIcon()); if (consoleView != null) { consoleView.print( "Can't found React Native Debugger, if you were first time running this command, make sure " + "you have React Native Debugger installed on your Mac and can be located at /Applications/React Native Debugger.app/.\n" + "To download and install, go to ", ConsoleViewContentType.ERROR_OUTPUT); consoleView.printHyperlink("https://github.com/jhen0409/react-native-debugger", new BrowserHyperlinkInfo("https://github.com/jhen0409/react-native-debugger")); } return false; } }
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: TestProxyPrinterProvider.java From consulo with Apache License 2.0 | 6 votes |
private void printLine(@Nonnull String line, @Nonnull ConsoleViewContentType contentType) { Filter.Result result; try { result = myFilter.applyFilter(line, line.length()); } catch (Throwable t) { throw new RuntimeException("Error while applying " + myFilter + " to '" + line + "'", t); } if (result != null) { List<Filter.ResultItem> items = sort(result.getResultItems()); int lastOffset = 0; for (Filter.ResultItem item : items) { defaultPrint(line.substring(lastOffset, item.getHighlightStartOffset()), contentType); String linkText = line.substring(item.getHighlightStartOffset(), item.getHighlightEndOffset()); printHyperlink(linkText, item.getHyperlinkInfo()); lastOffset = item.getHighlightEndOffset(); } defaultPrint(line.substring(lastOffset), contentType); } else { defaultPrint(line, contentType); } }
Example #5
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 #6
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 #7
Source File: ConsoleViewImpl.java From consulo with Apache License 2.0 | 6 votes |
private void doInsertUserInput(int offset, @Nonnull String text) { ApplicationManager.getApplication().assertIsDispatchThread(); final Editor editor = myEditor; final Document document = editor.getDocument(); int oldDocLength = document.getTextLength(); document.insertString(offset, text); int newStartOffset = Math.max(0, document.getTextLength() - oldDocLength + offset - text.length()); // take care of trim document int newEndOffset = document.getTextLength() - oldDocLength + offset; // take care of trim document if (findTokenMarker(newEndOffset) == null) { createTokenRangeHighlighter(ConsoleViewContentType.USER_INPUT, newStartOffset, newEndOffset); } moveScrollRemoveSelection(editor, newEndOffset); sendUserInput(text); }
Example #8
Source File: FlutterConsole.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Starts displaying the output of a different process. */ void watchProcess(@NotNull OSProcessHandler process) { if (cancelProcessSubscription != null) { cancelProcessSubscription.run(); cancelProcessSubscription = null; } view.clear(); view.attachToProcess(process); // Print exit code. final ProcessAdapter listener = new ProcessAdapter() { @Override public void processTerminated(final ProcessEvent event) { view.print( "Process finished with exit code " + event.getExitCode(), ConsoleViewContentType.SYSTEM_OUTPUT); } }; process.addProcessListener(listener); cancelProcessSubscription = () -> process.removeProcessListener(listener); }
Example #9
Source File: CompositeInputFilter.java From consulo with Apache License 2.0 | 6 votes |
@Override @javax.annotation.Nullable public List<Pair<String, ConsoleViewContentType>> applyFilter(final String text, final ConsoleViewContentType contentType) { boolean dumb = myDumbService.isDumb(); for (Pair<InputFilter, Boolean> pair : myFilters) { if (!dumb || pair.second == Boolean.TRUE) { long t0 = System.currentTimeMillis(); InputFilter filter = pair.first; List<Pair<String, ConsoleViewContentType>> result = filter.applyFilter(text, contentType); t0 = System.currentTimeMillis() - t0; if (t0 > 100) { LOG.warn(filter.getClass().getSimpleName() + ".applyFilter() took " + t0 + " ms on '''" + text + "'''"); } if (result != null) { return result; } } } return null; }
Example #10
Source File: DaemonConsoleView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void print(@NotNull String text, @NotNull ConsoleViewContentType contentType) { if (FlutterSettings.getInstance().isVerboseLogging()) { super.print(text, contentType); return; } if (contentType != ConsoleViewContentType.NORMAL_OUTPUT) { writeAvailableLines(); super.print(text, contentType); } else { stdoutParser.appendOutput(text); writeAvailableLines(); } }
Example #11
Source File: TestProxyPrinterProvider.java From consulo with Apache License 2.0 | 6 votes |
@Override public void print(String text, ConsoleViewContentType contentType) { if (contentType == null || !myContentTypeCondition.value(contentType)) { defaultPrint(text, contentType); return; } text = StringUtil.replace(text, "\r\n", NL, false); StringTokenizer tokenizer = new StringTokenizer(text, NL, true); while (tokenizer.hasMoreTokens()) { String line = tokenizer.nextToken(); if (NL.equals(line)) { defaultPrint(line, contentType); } else { printLine(line, contentType); } } }
Example #12
Source File: ProjectLevelVcsManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void addMessageToConsoleWindow(@Nullable final String message, @Nonnull final ConsoleViewContentType contentType) { if (!Registry.is("vcs.showConsole")) { return; } if (StringUtil.isEmptyOrSpaces(message)) { return; } ApplicationManager.getApplication().invokeLater(() -> { // for default and disposed projects the ContentManager is not available. if (myProject.isDisposed() || myProject.isDefault()) return; final ContentManager contentManager = getContentManager(); if (contentManager == null) { myPendingOutput.add(Pair.create(message, contentType)); } else { getOrCreateConsoleContent(contentManager); printToConsole(message, contentType); } }, ModalityState.defaultModalityState()); }
Example #13
Source File: BuckBuildManager.java From buck with Apache License 2.0 | 6 votes |
private void saveAndRun(final BuckCommandHandler handler, Runnable runnable) { if (!(handler instanceof BuckKillCommandHandler)) { currentRunningBuckCommandHandler = handler; // Save files for anything besides buck kill ApplicationManager.getApplication() .invokeAndWait( () -> FileDocumentManager.getInstance().saveAllDocuments(), ModalityState.NON_MODAL); } Project project = handler.project(); BuckDebugPanel buckDebugPanel = BuckUIManager.getInstance(project).getBuckDebugPanel(); String exec = BuckExecutableSettingsProvider.getInstance(project).resolveBuckExecutable(); if (exec == null) { buckDebugPanel.outputConsoleMessage( "Please specify the buck executable path!\n", ConsoleViewContentType.ERROR_OUTPUT); buckDebugPanel.outputConsoleMessage( "Preference -> Tools -> Buck -> Path to Buck executable\n", ConsoleViewContentType.NORMAL_OUTPUT); return; } runnable.run(); }
Example #14
Source File: DebuggerCommand.java From CppTools with Apache License 2.0 | 6 votes |
protected void processToken(String token, CppDebuggerContext context) { if(context.getBreakpointManager().processResponseLine(token, context)) return; final char c = token.charAt(0); if (Character.isDigit(c) && !context.getSession().isPaused()) { context.sendCommand(new DebuggerCommand("bt 1")); } else if (c == '#' && token.startsWith("#0")) { final CppStackFrame stackFrame = CppStackFrame.parseStackFrame(token, null, context); context.getSession().positionReached( new CppSuspendContext(stackFrame, context) ); } else if (token.indexOf("Program exited") != -1) { context.printToConsole(token, ConsoleViewContentType.SYSTEM_OUTPUT); if (!context.getSession().isStopped()) { context.getProcessHandler().detachProcess(); } } else if (token.indexOf("Program received signal") != -1) { context.printToConsole(token, ConsoleViewContentType.SYSTEM_OUTPUT); } }
Example #15
Source File: DaemonConsoleView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void print(@NotNull String text, @NotNull ConsoleViewContentType contentType) { if (FlutterSettings.getInstance().isVerboseLogging()) { super.print(text, contentType); return; } if (contentType != ConsoleViewContentType.NORMAL_OUTPUT) { writeAvailableLines(); super.print(text, contentType); } else { stdoutParser.appendOutput(text); writeAvailableLines(); } }
Example #16
Source File: BuckBuildCommandHandler.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 6 votes |
@Override protected boolean beforeCommand() { BuckBuildManager buildManager = BuckBuildManager.getInstance(project()); if (!buildManager.isBuckProject(mProject)) { BuckToolWindowFactory.outputConsoleMessage( mProject, BuckBuildManager.NOT_BUCK_PROJECT_ERROR_MESSAGE, ConsoleViewContentType.ERROR_OUTPUT); return false; } buildManager.setBuilding(mProject, true); BuckToolWindowFactory.cleanConsole(project()); String headMessage = "Running '" + command().getCommandLineString() + "'\n"; BuckToolWindowFactory.outputConsoleMessage( mProject, headMessage, GRAY_OUTPUT); return true; }
Example #17
Source File: TestComparisionFailedState.java From consulo with Apache License 2.0 | 6 votes |
@Override public void printOn(Printer printer) { printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); printer.mark(); // Error msg printer.printWithAnsiColoring(myErrorMsgPresentation, ProcessOutputTypes.STDERR); // Diff link myHyperlink.printOn(printer); // Stacktrace printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); printer.printWithAnsiColoring(myStacktracePresentation, ProcessOutputTypes.STDERR); printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); }
Example #18
Source File: BlazeConsoleScope.java From intellij with Apache License 2.0 | 6 votes |
private void print(String text, ConsoleViewContentType contentType) { blazeConsoleService.print(text, contentType); blazeConsoleService.print("\n", contentType); if (activated) { return; } boolean activate = popupBehavior == FocusBehavior.ALWAYS || (popupBehavior == FocusBehavior.ON_ERROR && contentType == ConsoleViewContentType.ERROR_OUTPUT); if (activate) { activated = true; ApplicationManager.getApplication().invokeLater(blazeConsoleService::activateConsoleWindow); } }
Example #19
Source File: EmbeddedLinuxJVMOutputForwarder.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 6 votes |
/** * Writer Parser * @param contentType * @param b * @param off * @param len */ public void write(@NotNull ConsoleViewContentType contentType, @NotNull byte[] b, int off, int len) { boolean addNewLine = false; if (contentType != myPreviousContentType) { addNewLine = myPreviousContentType != null; myPreviousContentType = contentType; } String lineSeparator = System.getProperty("line.separator"); boolean newLineAdded = false; if (addNewLine) { byte[] bytes = lineSeparator.getBytes(); myOutput.write(bytes, 0, bytes.length); myConsoleView.print(lineSeparator, contentType); newLineAdded = true; } String text = new String(b, off, len); if (lineSeparator.equals(text) && newLineAdded) { return; } myOutput.write(b, off, len); if (contentType == ERROR_OUTPUT) { myStdErr.write(b, off, len); } myConsoleView.print(text, contentType); }
Example #20
Source File: SMTRunnerConsoleView.java From consulo with Apache License 2.0 | 5 votes |
/** * Prints a given string of a given type on the root node. * Note: it's a permanent printing, as opposed to calling the same method on {@link #getConsole()} instance. * @param s given string * @param contentType given type */ @Override public void print(@Nonnull final String s, @Nonnull final ConsoleViewContentType contentType) { myResultsViewer.getRoot().addLast(new Printable() { @Override public void printOn(final Printer printer) { printer.print(s, contentType); } }); }
Example #21
Source File: SMTRunnerConsoleTest.java From consulo with Apache License 2.0 | 5 votes |
private static void sendToTestProxyStdOut(final SMTestProxy proxy, final String text) { proxy.addLast(new Printable() { @Override public void printOn(final Printer printer) { printer.print(text, ConsoleViewContentType.NORMAL_OUTPUT); } }); }
Example #22
Source File: Printer.java From consulo with Apache License 2.0 | 5 votes |
default void printWithAnsiColoring(@Nonnull String text, @Nonnull Key processOutputType) { AnsiEscapeDecoder decoder = new AnsiEscapeDecoder(); decoder.escapeText(text, ProcessOutputTypes.STDOUT, (text1, attributes) -> { ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(attributes); if (contentType == null || contentType == ConsoleViewContentType.NORMAL_OUTPUT) { contentType = ConsoleViewContentType.getConsoleViewType(processOutputType); } print(text1, contentType); }); }
Example #23
Source File: GeneralToSMTRunnerEventsConvertorTest.java From consulo with Apache License 2.0 | 5 votes |
public void testPreserveFullOutputAfterImport() throws Exception { mySuite.addChild(mySimpleTest); for (int i = 0; i < 550; i++) { String message = "line" + i + "\n"; mySimpleTest.addLast(printer -> printer.print(message, ConsoleViewContentType.NORMAL_OUTPUT)); } mySimpleTest.setFinished(); mySuite.setFinished(); SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); TransformerHandler handler = transformerFactory.newTransformerHandler(); handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes"); handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); File output = FileUtil.createTempFile("output", ""); try { FileUtilRt.createParentDirs(output); handler.setResult(new StreamResult(new FileWriter(output))); MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject()); TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler); String savedText = FileUtil.loadFile(output); assertTrue(savedText.split("\n").length > 550); myEventsProcessor.onStartTesting(); ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor); myEventsProcessor.onFinishTesting(); List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren(); assertSize(1, children); SMTestProxy testProxy = children.get(0); MockPrinter mockPrinter = new MockPrinter(); testProxy.printOn(mockPrinter); assertSize(550, mockPrinter.getAllOut().split("\n")); } finally { FileUtil.delete(output); } }
Example #24
Source File: GeneralToSMTRunnerEventsConvertorTest.java From consulo with Apache License 2.0 | 5 votes |
private MyConsoleView(final TestConsoleProperties consoleProperties, final ExecutionEnvironment environment) { super(consoleProperties); myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(MyConsoleView.this, consoleProperties, null) { @Override public void print(final String text, final ConsoleViewContentType contentType) { myMockResettablePrinter.print(text, contentType); } }; }
Example #25
Source File: DiffHyperlink.java From consulo with Apache License 2.0 | 5 votes |
public void printOn(final Printer printer) { if (!hasMoreThanOneLine(myActual.trim()) && !hasMoreThanOneLine(myExpected.trim()) && myPrintOneLine) { printer.print(NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); printer.print(ExecutionBundle.message("diff.content.expected.for.file.title"), ConsoleViewContentType.SYSTEM_OUTPUT); printer.print(myExpected + NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); printer.print(ExecutionBundle.message("junit.actual.text.label"), ConsoleViewContentType.SYSTEM_OUTPUT); printer.print(myActual + NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); } printer.print(" ", ConsoleViewContentType.ERROR_OUTPUT); printer.printHyperlink(ExecutionBundle.message("junit.click.to.see.diff.link"), myDiffHyperlink); printer.print(NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); }
Example #26
Source File: XDebugSessionImpl.java From consulo with Apache License 2.0 | 5 votes |
private void printMessage(final String message, final String hyperLinkText, @Nullable final HyperlinkInfo info) { AppUIUtil.invokeOnEdt(() -> { myConsoleView.print(message, ConsoleViewContentType.SYSTEM_OUTPUT); if (info != null) { myConsoleView.printHyperlink(hyperLinkText, info); } else if (hyperLinkText != null) { myConsoleView.print(hyperLinkText, ConsoleViewContentType.SYSTEM_OUTPUT); } myConsoleView.print("\n", ConsoleViewContentType.SYSTEM_OUTPUT); }); }
Example #27
Source File: ConsoleViewImpl.java From consulo with Apache License 2.0 | 5 votes |
protected void print(@Nonnull String text, @Nonnull ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) { text = StringUtil.convertLineSeparators(text, keepSlashR); synchronized (LOCK) { myDeferredBuffer.print(text, contentType, info); if (contentType == ConsoleViewContentType.USER_INPUT) { requestFlushImmediately(); } else if (myEditor != null) { final boolean shouldFlushNow = myDeferredBuffer.length() >= myDeferredBuffer.getCycleBufferSize(); addFlushRequest(shouldFlushNow ? 0 : DEFAULT_FLUSH_DELAY, FLUSH); } } }
Example #28
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 #29
Source File: ConsoleViewImpl.java From consulo with Apache License 2.0 | 5 votes |
private void type(@Nonnull Editor editor, @Nonnull String text) { flushDeferredText(); SelectionModel selectionModel = editor.getSelectionModel(); int lastOffset = selectionModel.hasSelection() ? selectionModel.getSelectionStart() : editor.getCaretModel().getOffset() - 1; RangeMarker marker = findTokenMarker(lastOffset); if (getTokenType(marker) != ConsoleViewContentType.USER_INPUT) { print(text, ConsoleViewContentType.USER_INPUT); moveScrollRemoveSelection(editor, editor.getDocument().getTextLength()); return; } String textToUse = StringUtil.convertLineSeparators(text); int typeOffset; if (selectionModel.hasSelection()) { Document document = editor.getDocument(); int start = selectionModel.getSelectionStart(); int end = selectionModel.getSelectionEnd(); document.deleteString(start, end); selectionModel.removeSelection(); typeOffset = end; } else { typeOffset = selectionModel.hasSelection() ? selectionModel.getSelectionStart() : editor.getCaretModel().getOffset(); } insertUserText(typeOffset, textToUse); }
Example #30
Source File: RNConsoleImpl.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void processCommandline(GeneralCommandLine commandLine) throws ExecutionException { if(myProcessHandler != null) { myProcessHandler.destroyProcess(); // ExecutionManagerImpl.stopProcess(myProcessHandler); // New Android Studio doesn't have this method anymore clear(); myProcessHandler = null; } if(commandLine.getWorkDirectory() != null) { print( "cd \"" + commandLine.getWorkDirectory().getAbsolutePath() + "\"\n" , ConsoleViewContentType.SYSTEM_OUTPUT); } final OSProcessHandler processHandler = new OSProcessHandler(commandLine); myProcessHandler = processHandler; myStopProcessAction.setProcessHandler(processHandler); ProcessTerminatedListener.attach(processHandler); processConsole(processHandler); // ApplicationManager.getApplication().invokeLater(new Runnable() { // @Override // public void run() { // processConsole(processHandler); // } // }); }