Java 类com.intellij.util.io.BaseDataReader 实例源码

项目:intellij-ce-playground    文件:BaseOSProcessHandler.java   
private BaseDataReader.SleepingPolicy getPolicy() {
  if (useNonBlockingRead()) {
    return useAdaptiveSleepingPolicyWhenReadingOutput() ? new AdaptiveSleepingPolicy() : BaseDataReader.SleepingPolicy.SIMPLE;
  }
  else {
    //use blocking read policy
    return BaseDataReader.SleepingPolicy.BLOCKING;
  }
}
项目:intellij-ce-playground    文件:EmulatorProcessHandler.java   
@Override
public void startNotify() {
  // Wait for both the stdout and stderr reader threads to finish and then indicate that the process has terminated
  addProcessListener(new ProcessAdapter() {
    @Override
    public void startNotified(final ProcessEvent event) {
      try {
        final BaseDataReader stdoutReader = new EmulatorOutputReader(myProcess.getInputStream(), ProcessOutputTypes.STDOUT);
        final BaseDataReader stderrReader = new EmulatorOutputReader(myProcess.getErrorStream(), ProcessOutputTypes.STDERR);

        executeTask(new Runnable() {
          @Override
          public void run() {
            try {
              stderrReader.waitFor();
              stdoutReader.waitFor();
            }
            catch (InterruptedException ignore) {
            }
            finally {
              notifyProcessTerminated(0);
            }
          }
        });
      }
      finally {
        removeProcessListener(this);
      }
    }
  });

  super.startNotify();
}
项目:intellij-ce-playground    文件:EmulatorProcessHandler.java   
private EmulatorOutputReader(@NotNull InputStream stream, @NotNull Key processOutputType) {
  super(BaseDataReader.SleepingPolicy.SIMPLE);

  // TODO: charset for the input stream reader?
  myBufferedReader = new BufferedReader(new InputStreamReader(stream));
  myProcessOutputType = processOutputType;

  start();
}
项目:intellij-ce-playground    文件:SvnProcessHandler.java   
@NotNull
@Override
protected BaseDataReader createOutputDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) {
  if (myForceBinary) {
    return new SimpleBinaryOutputReader(myProcess.getInputStream(), sleepingPolicy);
  }
  return super.createOutputDataReader(sleepingPolicy);
}
项目:TheRPlugin    文件:TheRXProcessHandler.java   
@NotNull
@Override
protected BaseDataReader createOutputDataReader(@NotNull final BaseDataReader.SleepingPolicy sleepingPolicy) {
  myOutputReader = super.createProcessOutReader();

  return new TheRXBaseOutputReader(myOutputReader, sleepingPolicy, myOutputBuffer, "output stream of " + myCommandLine);
}
项目:TheRPlugin    文件:TheRXProcessHandler.java   
@NotNull
@Override
protected BaseDataReader createErrorDataReader(@NotNull final BaseDataReader.SleepingPolicy sleepingPolicy) {
  myErrorReader = super.createProcessErrReader();

  return new TheRXBaseOutputReader(myErrorReader, sleepingPolicy, myErrorBuffer, "error stream of " + myCommandLine);
}
项目:intellij-ce-playground    文件:BaseOSProcessHandler.java   
@Override
public void startNotify() {
  if (myCommandLine != null) {
    notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM);
  }

  addProcessListener(new ProcessAdapter() {
    @Override
    public void startNotified(final ProcessEvent event) {
      try {
        final BaseDataReader stdOutReader = createOutputDataReader(getPolicy());
        final BaseDataReader stdErrReader = processHasSeparateErrorStream() ? createErrorDataReader(getPolicy()) : null;

        myWaitFor.setTerminationCallback(new Consumer<Integer>() {
          @Override
          public void consume(Integer exitCode) {
            try {
              // tell readers that no more attempts to read process' output should be made
              if (stdErrReader != null) stdErrReader.stop();
              stdOutReader.stop();

              try {
                if (stdErrReader != null) stdErrReader.waitFor();
                stdOutReader.waitFor();
              }
              catch (InterruptedException ignore) { }
            }
            finally {
              onOSProcessTerminated(exitCode);
            }
          }
        });
      }
      finally {
        removeProcessListener(this);
      }
    }
  });

  super.startNotify();
}
项目:intellij-ce-playground    文件:BaseOSProcessHandler.java   
@NotNull
protected BaseDataReader createErrorDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) {
  return new SimpleOutputReader(createProcessErrReader(), ProcessOutputTypes.STDERR, sleepingPolicy);
}
项目:intellij-ce-playground    文件:BaseOSProcessHandler.java   
@NotNull
protected BaseDataReader createOutputDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) {
  return new SimpleOutputReader(createProcessOutReader(), ProcessOutputTypes.STDOUT, sleepingPolicy);
}
项目:intellij-ce-playground    文件:HgCommandProcessHandler.java   
@NotNull
@Override
protected BaseDataReader createOutputDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) {
  return myBinary ? new MyBinaryOutputReader(myProcess.getInputStream(), sleepingPolicy) : super.createOutputDataReader(sleepingPolicy);
}
项目:intellij-ce-playground    文件:HgCommandProcessHandler.java   
public MyBinaryOutputReader(@NotNull InputStream stream, @Nullable BaseDataReader.SleepingPolicy simple) {
  super(stream, simple);
  start();
}
项目:consulo    文件:BinaryOSProcessHandler.java   
@Nonnull
@Override
protected BaseDataReader createOutputDataReader() {
  return new SimpleBinaryReader(myProcess.getInputStream(), readerOptions().policy());
}
项目:consulo    文件:BaseOSProcessHandler.java   
@Override
public BaseDataReader.SleepingPolicy policy() {
  return new BaseDataReader.AdaptiveSleepingPolicy();
}
项目:consulo    文件:BaseOSProcessHandler.java   
@Override
public void startNotify() {
  if (myCommandLine != null) {
    notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM);
  }

  addProcessListener(new ProcessAdapter() {
    @Override
    public void startNotified(final ProcessEvent event) {
      try {
        Options options = readerOptions();
        @SuppressWarnings("deprecation") final BaseDataReader stdOutReader = createOutputDataReader(options.policy());
        @SuppressWarnings("deprecation") final BaseDataReader stdErrReader = processHasSeparateErrorStream() ? createErrorDataReader(options.policy()) : null;

        myWaitFor.setTerminationCallback(new Consumer<Integer>() {
          @Override
          public void consume(Integer exitCode) {
            try {
              // tell readers that no more attempts to read process' output should be made
              if (stdErrReader != null) stdErrReader.stop();
              stdOutReader.stop();

              try {
                if (stdErrReader != null) stdErrReader.waitFor();
                stdOutReader.waitFor();
              }
              catch (InterruptedException ignore) { }
            }
            finally {
              onOSProcessTerminated(exitCode);
            }
          }
        });
      }
      finally {
        removeProcessListener(this);
      }
    }
  });

  super.startNotify();
}
项目:consulo    文件:BaseOSProcessHandler.java   
/** @deprecated override {@link #createOutputDataReader()} (to be removed in IDEA 18) */
protected BaseDataReader createErrorDataReader(@SuppressWarnings("UnusedParameters") BaseDataReader.SleepingPolicy policy) {
  return createErrorDataReader();
}
项目:consulo    文件:BaseOSProcessHandler.java   
/** @deprecated override {@link #createOutputDataReader()} (to be removed in IDEA 18) */
protected BaseDataReader createOutputDataReader(@SuppressWarnings("UnusedParameters") BaseDataReader.SleepingPolicy policy) {
  return createOutputDataReader();
}
项目:consulo    文件:BaseOSProcessHandler.java   
@Nonnull
protected BaseDataReader createErrorDataReader() {
  return new SimpleOutputReader(createProcessErrReader(), ProcessOutputTypes.STDERR, readerOptions(), "error stream of " + myPresentableName);
}
项目:consulo    文件:BaseOSProcessHandler.java   
@Nonnull
protected BaseDataReader createOutputDataReader() {
  return new SimpleOutputReader(createProcessOutReader(), ProcessOutputTypes.STDOUT, readerOptions(), "output stream of " + myPresentableName);
}