Java Code Examples for com.intellij.execution.filters.TextConsoleBuilder#addFilter()

The following examples show how to use com.intellij.execution.filters.TextConsoleBuilder#addFilter() . 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: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
static FlutterConsole create(@NotNull Project project, @Nullable Module module) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.setViewer(true);
  if (module != null) {
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  final ConsoleView view = builder.getConsole();

  final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
  panel.setContent(view.getComponent());

  final String title = module != null ? "[" + module.getName() + "] Flutter" : "Flutter";
  final Content content = ContentFactory.SERVICE.getInstance().createContent(panel.getComponent(), title, true);
  Disposer.register(content, view);

  return new FlutterConsole(view, content, project, module);
}
 
Example 2
Source File: SdkRunConfig.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void addConsoleFilters(@NotNull LaunchState launcher,
                                 @NotNull ExecutionEnvironment env,
                                 @NotNull MainFile mainFile,
                                 @Nullable Module module) {
  // Set up additional console filters.
  final TextConsoleBuilder builder = launcher.getConsoleBuilder();
  // file:, package:, and dart: references
  builder.addFilter(new DartConsoleFilter(env.getProject(), mainFile.getFile()));
  //// links often found when running tests
  //builder.addFilter(new DartRelativePathsConsoleFilter(env.getProject(), mainFile.getAppDir().getPath()));
  if (module != null) {
    // various flutter run links
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  // general urls
  builder.addFilter(new UrlFilter());
}
 
Example 3
Source File: DaemonConsoleView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Sets up a launcher to use a DaemonConsoleView.
 */
public static void install(@NotNull CommandLineState launcher, @NotNull ExecutionEnvironment env, @NotNull VirtualFile workDir) {
  // Create our own console builder.
  //
  // We need to filter input to this console without affecting other consoles, so we cannot use
  // a consoleFilterInputProvider.
  final GlobalSearchScope searchScope = SearchScopeProvider.createSearchScope(env.getProject(), env.getRunProfile());
  final TextConsoleBuilder builder = new TextConsoleBuilderImpl(env.getProject(), searchScope) {
    @NotNull
    @Override
    protected ConsoleView createConsole() {
      return new DaemonConsoleView(env.getProject(), searchScope);
    }
  };

  // Set up basic console filters. (More may be added later.)
  // TODO(devoncarew): Do we need this filter? What about DartConsoleFilter (for package: uris)?
  builder.addFilter(new DartRelativePathsConsoleFilter(env.getProject(), workDir.getPath()));
  launcher.setConsoleBuilder(builder);
}
 
Example 4
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
static FlutterConsole create(@NotNull Project project, @Nullable Module module) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.setViewer(true);
  if (module != null) {
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  final ConsoleView view = builder.getConsole();

  final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
  panel.setContent(view.getComponent());

  final String title = module != null ? "[" + module.getName() + "] Flutter" : "Flutter";
  final Content content = ContentFactory.SERVICE.getInstance().createContent(panel.getComponent(), title, true);
  Disposer.register(content, view);

  return new FlutterConsole(view, content, project, module);
}
 
Example 5
Source File: SdkRunConfig.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void addConsoleFilters(@NotNull LaunchState launcher,
                                 @NotNull ExecutionEnvironment env,
                                 @NotNull MainFile mainFile,
                                 @Nullable Module module) {
  // Set up additional console filters.
  final TextConsoleBuilder builder = launcher.getConsoleBuilder();
  // file:, package:, and dart: references
  builder.addFilter(new DartConsoleFilter(env.getProject(), mainFile.getFile()));
  //// links often found when running tests
  //builder.addFilter(new DartRelativePathsConsoleFilter(env.getProject(), mainFile.getAppDir().getPath()));
  if (module != null) {
    // various flutter run links
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  // general urls
  builder.addFilter(new UrlFilter());
}
 
Example 6
Source File: DaemonConsoleView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Sets up a launcher to use a DaemonConsoleView.
 */
public static void install(@NotNull CommandLineState launcher, @NotNull ExecutionEnvironment env, @NotNull VirtualFile workDir) {
  // Create our own console builder.
  //
  // We need to filter input to this console without affecting other consoles, so we cannot use
  // a consoleFilterInputProvider.
  final GlobalSearchScope searchScope = SearchScopeProvider.createSearchScope(env.getProject(), env.getRunProfile());
  final TextConsoleBuilder builder = new TextConsoleBuilderImpl(env.getProject(), searchScope) {
    @NotNull
    @Override
    protected ConsoleView createConsole() {
      return new DaemonConsoleView(env.getProject(), searchScope);
    }
  };

  // Set up basic console filters. (More may be added later.)
  // TODO(devoncarew): Do we need this filter? What about DartConsoleFilter (for package: uris)?
  builder.addFilter(new DartRelativePathsConsoleFilter(env.getProject(), workDir.getPath()));
  launcher.setConsoleBuilder(builder);
}
 
Example 7
Source File: HaxeTestsRunner.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(@NotNull final Project project,
                                         @NotNull RunProfileState state,
                                         final RunContentDescriptor descriptor,
                                         @NotNull final ExecutionEnvironment environment) throws ExecutionException {

  final HaxeTestsConfiguration profile = (HaxeTestsConfiguration)environment.getRunProfile();
  final Module module = profile.getConfigurationModule().getModule();

  ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  VirtualFile[] roots = rootManager.getContentRoots();

  return super.doExecute(project, new CommandLineState(environment) {
    @NotNull
    @Override
    protected ProcessHandler startProcess() throws ExecutionException {
      //actually only neko target is supported for tests
      HaxeTarget currentTarget = HaxeTarget.NEKO;
      final GeneralCommandLine commandLine = new GeneralCommandLine();
      commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath()));
      commandLine.setExePath(currentTarget.getFlag());
      final HaxeModuleSettings settings = HaxeModuleSettings.getInstance(module);
      String folder = settings.getOutputFolder() != null ? (settings.getOutputFolder() + "/release/") : "";
      commandLine.addParameter(getFileNameWithCurrentExtension(currentTarget, folder + settings.getOutputFileName()));

      final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject());
      consoleBuilder.addFilter(new ErrorFilter(module));
      setConsoleBuilder(consoleBuilder);

      return new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
    }

    private String getFileNameWithCurrentExtension(HaxeTarget haxeTarget, String fileName) {
      if (haxeTarget != null) {
        return haxeTarget.getTargetFileNameWithExtension(FileUtil.getNameWithoutExtension(fileName));
      }
      return fileName;
    }
  }, descriptor, environment);
}