use of com.intellij.execution.filters.RegexpFilter in project intellij-community by JetBrains.
the class ToolRunProfile method getState.
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
final Project project = env.getProject();
if (myCommandLine == null) {
// can return null if creation of cmd line has been cancelled
return null;
}
final CommandLineState commandLineState = new CommandLineState(env) {
GeneralCommandLine createCommandLine() {
return myCommandLine;
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final GeneralCommandLine commandLine = createCommandLine();
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
@Override
@NotNull
public ExecutionResult execute(@NotNull final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ExecutionResult result = super.execute(executor, runner);
final ProcessHandler processHandler = result.getProcessHandler();
if (processHandler != null) {
processHandler.addProcessListener(new ToolProcessAdapter(project, myTool.synchronizeAfterExecution(), getName()));
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if ((outputType == ProcessOutputTypes.STDOUT && myTool.isShowConsoleOnStdOut()) || (outputType == ProcessOutputTypes.STDERR && myTool.isShowConsoleOnStdErr())) {
ExecutionManager.getInstance(project).getContentManager().toFrontRunContent(executor, processHandler);
}
}
});
}
return result;
}
};
TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
final FilterInfo[] outputFilters = myTool.getOutputFilters();
for (FilterInfo outputFilter : outputFilters) {
builder.addFilter(new RegexpFilter(project, outputFilter.getRegExp()));
}
commandLineState.setConsoleBuilder(builder);
return commandLineState;
}
use of com.intellij.execution.filters.RegexpFilter in project intellij-community by JetBrains.
the class MavenConsoleImpl method createConsoleBuilder.
public static TextConsoleBuilder createConsoleBuilder(final Project project) {
TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
builder.addFilter(new RegexpFilter(project, CONSOLE_FILTER_REGEXP) {
@Nullable
@Override
protected HyperlinkInfo createOpenFileHyperlink(String fileName, int line, int column) {
HyperlinkInfo res = super.createOpenFileHyperlink(fileName, line, column);
if (res == null && fileName.startsWith("\\") && SystemInfo.isWindows) {
// Maven cut prefix 'C:\' from paths on Windows
VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots();
if (roots.length > 0) {
String projectPath = roots[0].getPath();
if (projectPath.matches("[A-Z]:[\\\\/].+")) {
res = super.createOpenFileHyperlink(projectPath.charAt(0) + ":" + fileName, line, column);
}
}
}
return res;
}
});
builder.addFilter(new MavenGroovyConsoleFilter(project));
builder.addFilter(new MavenScalaConsoleFilter(project));
builder.addFilter(new MavenTestConsoleFilter());
return builder;
}
use of com.intellij.execution.filters.RegexpFilter in project intellij-community by JetBrains.
the class GradleConsoleFilterProvider method getDefaultFilters.
@NotNull
@Override
public Filter[] getDefaultFilters(@NotNull Project project) {
return new Filter[] { new GradleConsoleFilter(project), new RegexpFilter(project, RegexpFilter.FILE_PATH_MACROS + ":" + RegexpFilter.LINE_MACROS) {
private CachedValue<Boolean> myIsGradleProject = new CachedValueImpl<>(() -> CachedValueProvider.Result.create(isGradleProject(), ProjectRootModificationTracker.getInstance(project)));
@Override
public Result applyFilter(String line, int entireLength) {
if (line == null || !FileUtil.isAbsolutePlatformIndependent(line))
return null;
if (Boolean.FALSE.equals(myIsGradleProject.getValue()))
return null;
Result result = super.applyFilter(line, entireLength);
if (result == null)
return null;
Pattern pattern = getPattern();
Matcher matcher = pattern.matcher(StringUtil.newBombedCharSequence(line, 100));
if (!matcher.lookingAt())
return result;
int lineStart = entireLength - line.length();
int start = lineStart + matcher.start();
int end = lineStart + matcher.end();
return new Result(start, end, result.getFirstHyperlinkInfo());
}
private boolean isGradleProject() {
return !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty();
}
} };
}
Aggregations