Java Code Examples for com.intellij.execution.process.ProcessOutputTypes#STDOUT

The following examples show how to use com.intellij.execution.process.ProcessOutputTypes#STDOUT . 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: BuckQueryCommandHandler.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
protected void notifyLines(Key outputType, Iterable<String> lines) {
  super.notifyLines(outputType, lines);
  if (outputType == ProcessOutputTypes.STDOUT) {
    List<String> targetList = new LinkedList<String>();
    for (String outputLine : lines) {
      if (!outputLine.isEmpty()) {
        JsonElement jsonElement = new JsonParser().parse(outputLine);
        if (jsonElement.isJsonArray()) {
          JsonArray targets = jsonElement.getAsJsonArray();

          for (JsonElement target : targets) {
            targetList.add(target.getAsString());
          }
        }
      }
    }
    actionsToExecute.apply(targetList);
  }
}
 
Example 2
Source File: OutputLineSplitterTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  mySplitter = new OutputLineSplitter(false) {
    @Override
    protected void onLineAvailable(@Nonnull String text, @Nonnull Key outputType, boolean tcLikeFakeOutput) {
      if (ProcessOutputTypes.STDERR != outputType && ProcessOutputTypes.SYSTEM != outputType) outputType = ProcessOutputTypes.STDOUT;
      synchronized (myOutput) {
        List<String> list = myOutput.get(outputType);
        if (list == null) {
          myOutput.put(outputType, list = new ArrayList<String>());
        }
        list.add(text);
      }
    }
  };
}
 
Example 3
Source File: LogView.java    From logviewer with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public MyProcessingResult processLine(String line) {
    LogCatMessage message = null;
    String continuation = null;
    boolean validContinuation = false;
    try {
        message = AndroidLogcatFormatter.tryParseMessage(line);
        continuation = message == null ? AndroidLogcatFormatter.tryParseContinuation(line) : null;
        validContinuation = continuation != null && this.myPrevHeader != null;
    } catch (Exception ignored) {
    }

    if (message == null && !validContinuation) {
        return new MyProcessingResult(ProcessOutputTypes.STDOUT, canAcceptMessage(line), null);
    } else {
        if (message != null) {
            this.myPrevHeader = message.getHeader();
            this.myCustomApplicable = this.isMessageApplicable(message);
            this.myMessageSoFar.setLength(0);
        }

        boolean isApplicable = this.myCustomApplicable;
        if (!isApplicable) {
            this.myMessageSoFar.append(line);
            this.myMessageSoFar.append('\n');
        }

        Key key = AndroidLogcatUtils.getProcessOutputType(this.myPrevHeader.getLogLevel());
        MyProcessingResult result = new MyProcessingResult(key, isApplicable, this.myMessageSoFar.toString());
        if (isApplicable) {
            this.myMessageSoFar.setLength(0);
        }

        return result;
    }
}
 
Example 4
Source File: BlazeConsoleServiceImpl.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void print(String text, ConsoleViewContentType contentType) {
  Key<?> key =
      contentType == ConsoleViewContentType.ERROR_OUTPUT
          ? ProcessOutputTypes.STDERR
          : ProcessOutputTypes.STDOUT;
  ansiEscapeDecoder.escapeText(text, key, this);
}
 
Example 5
Source File: PantsIntegrationTestCase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
protected RunResult runWithConfiguration(RunConfiguration configuration) {
  PantsMakeBeforeRun.replaceDefaultMakeWithPantsMake(configuration);
  PantsMakeBeforeRun.setRunConfigurationWorkingDirectory(configuration);
  PantsJUnitRunnerAndConfigurationSettings runnerAndConfigurationSettings =
    new PantsJUnitRunnerAndConfigurationSettings(configuration);
  ExecutionEnvironmentBuilder environmentBuilder =
    ExecutionUtil.createEnvironment(DefaultRunExecutor.getRunExecutorInstance(), runnerAndConfigurationSettings);
  ExecutionEnvironment environment = environmentBuilder.build();

  List<String> output = new ArrayList<>();
  List<String> errors = new ArrayList<>();
  ProcessAdapter processAdapter = new ProcessAdapter() {
    @Override
    public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
      if (outputType == ProcessOutputTypes.STDOUT) {
        output.add(event.getText());
      }
      else if (outputType == ProcessOutputTypes.STDERR) {
        errors.add(event.getText());
      }
    }
  };

  ProgramRunnerUtil.executeConfiguration(environment, false, false);
  OSProcessHandler handler = (OSProcessHandler) environment.getContentToReuse().getProcessHandler();
  handler.addProcessListener(processAdapter);
  assertTrue(handler.waitFor());

  return new RunResult(handler.getExitCode(), output, errors);
}
 
Example 6
Source File: ResultCallbackBuckHandler.java    From buck with Apache License 2.0 5 votes vote down vote up
@Override
protected void notifyLines(Key outputType, Iterable<String> lines) {
  super.notifyLines(outputType, lines);
  if (outputType == ProcessOutputTypes.STDOUT) {
    for (String line : lines) {
      stdout.append(line);
    }
  }
}
 
Example 7
Source File: ThriftOutputConsumer.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
  if (outputType == ProcessOutputTypes.STDERR) {
    stdOutput.append(event.getText());
  }
  else if (outputType == ProcessOutputTypes.STDOUT) {
    stdOutput.append(event.getText());
  }
}
 
Example 8
Source File: DefaultLogFilterModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public MyProcessingResult processLine(String line) {
  final String type = LogConsolePreferences.getType(line);
  Key contentType = type != null
                    ? LogConsolePreferences.getProcessOutputTypes(type)
                    : (LogConsolePreferences.ERROR.equals(myPrevType) ? ProcessOutputTypes.STDERR : ProcessOutputTypes.STDOUT);
  if (type != null) {
    myPrevType = type;
  }
  final boolean applicable = isApplicable(line);
  return new MyProcessingResult(contentType, applicable, null);
}
 
Example 9
Source File: NativeFileWatcherImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void notifyTextAvailable(@Nonnull String line, @Nonnull Key outputType) {
  if (outputType == ProcessOutputTypes.STDERR) {
    LOG.warn(line);
  }
  if (outputType != ProcessOutputTypes.STDOUT) {
    return;
  }

  if (LOG.isTraceEnabled()) LOG.trace(">> " + line);

  if (myLastOp == null) {
    WatcherOp watcherOp;
    try {
      watcherOp = WatcherOp.valueOf(line);
    }
    catch (IllegalArgumentException e) {
      String message = "Illegal watcher command: '" + line + "'";
      if (line.length() <= 20) message += " " + Arrays.toString(line.chars().toArray());
      LOG.error(message);
      return;
    }

    if (watcherOp == WatcherOp.GIVEUP) {
      notifyOnFailure(ApplicationBundle.message("watcher.gave.up"), null);
      myIsShuttingDown = true;
    }
    else if (watcherOp == WatcherOp.RESET) {
      myNotificationSink.notifyReset(null);
    }
    else {
      myLastOp = watcherOp;
    }
  }
  else if (myLastOp == WatcherOp.MESSAGE) {
    LOG.warn(line);
    notifyOnFailure(line, NotificationListener.URL_OPENING_LISTENER);
    myLastOp = null;
  }
  else if (myLastOp == WatcherOp.REMAP || myLastOp == WatcherOp.UNWATCHEABLE) {
    if ("#".equals(line)) {
      if (myLastOp == WatcherOp.REMAP) {
        processRemap();
      }
      else {
        mySettingRoots.decrementAndGet();
        processUnwatchable();
      }
      myLines.clear();
      myLastOp = null;
    }
    else {
      myLines.add(line);
    }
  }
  else {
    String path = StringUtil.trimEnd(line.replace('\0', '\n'), File.separator);  // unescape
    processChange(path, myLastOp);
    myLastOp = null;
  }
}
 
Example 10
Source File: LogConsolePreferences.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static Key getProcessOutputTypes(String type) {
  if (type.equals(ERROR)) return ProcessOutputTypes.STDERR;
  if (type.equals(WARNING) || type.equals(INFO) || type.equals(DEBUG)) return ProcessOutputTypes.STDOUT;
  return null;
}