当前位置: 首页>>代码示例>>Java>>正文


Java Filter.Result方法代码示例

本文整理汇总了Java中com.intellij.execution.filters.Filter.Result方法的典型用法代码示例。如果您正苦于以下问题:Java Filter.Result方法的具体用法?Java Filter.Result怎么用?Java Filter.Result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.execution.filters.Filter的用法示例。


在下文中一共展示了Filter.Result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printLine

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
private void printLine(@NotNull String line, @NotNull ConsoleViewContentType contentType) {
  Filter.Result result = null;
  try {
    result = myFilter.applyFilter(line, line.length());
  }
  catch (Throwable t) {
    throw new RuntimeException("Error while applying " + myFilter + " to '"+line+"'", t);
  }
  if (result != null) {
    defaultPrint(line.substring(0, result.getHighlightStartOffset()), contentType);
    String linkText = line.substring(result.getHighlightStartOffset(), result.getHighlightEndOffset());
    printHyperlink(linkText, result.getHyperlinkInfo());
    defaultPrint(line.substring(result.getHighlightEndOffset()), contentType);
  }
  else {
    defaultPrint(line, contentType);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TestProxyPrinterProvider.java

示例2: passLine

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
private List<String> passLine(String line) {
  if (!line.endsWith("\n")) {
    line += '\n';
  }

  Filter.Result result = myFilter.applyFilter(line, line.length());
  if (result == null) return Collections.emptyList();

  List<String> res = new ArrayList<String>();

  for (Filter.ResultItem item : result.getResultItems()) {
    res.add(line.substring(item.highlightStartOffset, item.highlightEndOffset));
  }

  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MavenSurefireReportInConsoleTest.java

示例3: highlightHyperlinks

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
void highlightHyperlinks(@Nonnull Filter.Result result, int offsetDelta) {
  Document document = myEditor.getDocument();
  for (Filter.ResultItem resultItem : result.getResultItems()) {
    int start = resultItem.getHighlightStartOffset() + offsetDelta;
    int end = resultItem.getHighlightEndOffset() + offsetDelta;
    if (start < 0 || end < start || end > document.getTextLength()) {
      continue;
    }

    TextAttributes attributes = resultItem.getHighlightAttributes();
    if (resultItem.getHyperlinkInfo() != null) {
      createHyperlink(start, end, attributes, resultItem.getHyperlinkInfo(), resultItem.getFollowedHyperlinkAttributes());
    }
    else if (attributes != null) {
      addHighlighter(start, end, attributes);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:EditorHyperlinkSupport.java

示例4: highlightHyperlinksAsync

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
@Nonnull
private Computable<FilterResults> highlightHyperlinksAsync(Filter filter, int startLine, int endLine) {
  Document document = myEditor.getDocument();
  int markerOffset = document.getLineEndOffset(endLine);
  RangeMarker marker = document.createRangeMarker(markerOffset, markerOffset);
  List<LineHighlighter> tasks = new ArrayList<>();
  for (int i = startLine; i <= endLine; i++) {
     tasks.add(processLine(document, filter, i));
  }
  return () -> {
    List<Filter.Result> results = new ArrayList<>();
    for (LineHighlighter task : tasks) {
      ProgressManager.checkCanceled();
      if (!marker.isValid()) return FilterResults.EMPTY;
      ContainerUtil.addIfNotNull(results, task.compute());
    }
    return new FilterResults(markerOffset, marker, results);
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:AsyncFilterRunner.java

示例5: highlightHyperlinks

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
public void highlightHyperlinks(final Filter customFilter, final int line1, final int endLine) {
  final Document document = myEditor.getDocument();

  final int startLine = Math.max(0, line1);

  for (int line = startLine; line <= endLine; line++) {
    int endOffset = document.getLineEndOffset(line);
    if (endOffset < document.getTextLength()) {
      endOffset++; // add '\n'
    }
    final String text = getLineText(document, line, true);
    Filter.Result result = customFilter.applyFilter(text, endOffset);
    if (result != null) {
      for (Filter.ResultItem resultItem : result.getResultItems()) {
        int start = resultItem.getHighlightStartOffset();
        int end = resultItem.getHighlightEndOffset();
        if (end < start || end > document.getTextLength()) {
          LOG.error("Filter returned wrong range: start=" + start + "; end=" + end + "; length=" + document.getTextLength() + "; filter=" + customFilter);
          continue;
        }

        TextAttributes attributes = resultItem.getHighlightAttributes();
        if (resultItem.getHyperlinkInfo() != null) {
          createHyperlink(start, end, attributes, resultItem.getHyperlinkInfo(), resultItem.getFollowedHyperlinkAttributes());
        }
        else if (attributes != null) {
          addHighlighter(start, end, attributes);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:EditorHyperlinkSupport.java

示例6: writeOutput

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
private void writeOutput(ConsoleViewContentType type, StringBuilder text, Filter filter) throws SAXException {
  StringBuilder output = new StringBuilder();
  StringTokenizer t = new StringTokenizer(text.toString(), "\n");
  while (t.hasMoreTokens()) {
    String line = StringUtil.escapeXml(t.nextToken()) + "\n";
    Filter.Result result = null;//filter.applyFilter(line, line.length());
    if (result != null && result.hyperlinkInfo instanceof OpenFileHyperlinkInfo) {
      output.append(line.substring(0, result.highlightStartOffset));
      OpenFileDescriptor descriptor = ((OpenFileHyperlinkInfo)result.hyperlinkInfo).getDescriptor();
      output.append("<a href=\"javascript://\" onclick=\"Activator.doOpen('file?file=");
      output.append(descriptor.getFile().getPresentableUrl());
      output.append("&line=");
      output.append(descriptor.getLine());
      output.append("')\">");
      output.append(line.substring(result.highlightStartOffset, result.highlightEndOffset));
      output.append("</a>");
      output.append(line.substring(result.highlightEndOffset));
    }
    else {
      output.append(line);
    }
  }

  Map<String, String> a = new HashMap<String, String>();
  a.put(ATTR_OUTPUT_TYPE, getTypeString(type));
  startElement(ELEM_OUTPUT, a);
  writeText(output.toString());
  text.delete(0, text.length());
  endElement(ELEM_OUTPUT);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:TestResultsXmlFormatter.java

示例7: printLine

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
private void printLine(@NotNull String line, @NotNull ConsoleViewContentType contentType) {
  Filter.Result result = myFilter.applyFilter(line, line.length());
  if (result != null) {
    defaultPrint(line.substring(0, result.highlightStartOffset), contentType);
    String linkText = line.substring(result.highlightStartOffset, result.highlightEndOffset);
    printHyperlink(linkText, result.hyperlinkInfo);
    defaultPrint(line.substring(result.highlightEndOffset), contentType);
  }
  else {
    defaultPrint(line, contentType);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:TestProxyPrinterProvider.java

示例8: highlightHyperlinks

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
public void highlightHyperlinks(final Filter customFilter, final Filter predefinedMessageFilter, final int line1, final int endLine) {
  final Document document = myEditor.getDocument();

  final int startLine = Math.max(0, line1);

  for (int line = startLine; line <= endLine; line++) {
    int endOffset = document.getLineEndOffset(line);
    if (endOffset < document.getTextLength()) {
      endOffset++; // add '\n'
    }
    final String text = getLineText(document, line, true);
    Filter.Result result = customFilter.applyFilter(text, endOffset);
    if (result == null) {
      result = predefinedMessageFilter.applyFilter(text, endOffset);
    }
    if (result != null) {
      for (Filter.ResultItem resultItem : result.getResultItems()) {
        if (resultItem.hyperlinkInfo != null) {
          addHyperlink(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes, resultItem.hyperlinkInfo);
        }
        else if (resultItem.highlightAttributes != null) {
          addHighlighter(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes);
        }
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:EditorHyperlinkSupport.java

示例9: testLink

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
@Test
public void testLink() {
  // This tests whether hyperlinks (Filter.Result) are created properly,
  // not whether error parsing or filters work.

  String expression = "ERR: CoordinatesDetectionTest.hx:22(by.rovar.iso.model.CoordinatesDetectionTest.test2x2) - expected true but was false";
  ErrorFilter filter = createFilter();
  String fileName = "by/rovar/iso/model/CoordinatesDetectionTest.hx";
  Filter.Result result = filter.applyFilter(expression, expression.length());
  assertEquals("ERR: ".length(), result.highlightStartOffset);
  assertEquals("ERR: CoordinatesDetectionTest.hx:22".length(), result.highlightEndOffset);
  HLInfo info = (HLInfo) result.hyperlinkInfo;
  info.checkInfo(fileName, 22);
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:15,代码来源:ErrorFilterTest.java

示例10: printLine

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
private void printLine(@Nonnull String line, @Nonnull ConsoleViewContentType contentType) {
  Filter.Result result = myFilter.applyFilter(line, line.length());
  if (result != null) {
    defaultPrint(line.substring(0, result.highlightStartOffset), contentType);
    String linkText = line.substring(result.highlightStartOffset, result.highlightEndOffset);
    printHyperlink(linkText, result.hyperlinkInfo);
    defaultPrint(line.substring(result.highlightEndOffset), contentType);
  }
  else {
    defaultPrint(line, contentType);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:TestProxyPrinterProvider.java

示例11: checkRange

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
private static Filter.Result checkRange(Filter filter, int endOffset, Filter.Result result) {
  if (result != null) {
    for (Filter.ResultItem resultItem : result.getResultItems()) {
      int start = resultItem.getHighlightStartOffset();
      int end = resultItem.getHighlightEndOffset();
      if (end < start || end > endOffset) {
        LOG.error("Filter returned wrong range: start=" + start + "; end=" + end + "; max=" + endOffset + "; filter=" + filter);
      }
    }
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:AsyncFilterRunner.java

示例12: applyHighlights

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
void applyHighlights(EditorHyperlinkSupport hyperlinks) {
  if (myResults.isEmpty() || !myMarker.isValid()) return;

  int delta = myMarker.getStartOffset() - myInitialMarkerOffset;
  for (Filter.Result result : myResults) {
    hyperlinks.highlightHyperlinks(result, delta);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:AsyncFilterRunner.java

示例13: getErrorNavigatable

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
@Nullable
@Override
public Navigatable getErrorNavigatable(@NotNull final Project project, final @NotNull String stacktrace) {
  if (myCustomFilter.isEmpty()) {
    return null;
  }

  // iterate stacktrace lines find first navigatable line using
  // stacktrace filters
  final int stacktraceLength = stacktrace.length();
  final String[] lines = StringUtil.splitByLines(stacktrace);
  for (String line : lines) {
    Filter.Result result;
    try {
      result = myCustomFilter.applyFilter(line, stacktraceLength);
    }
    catch (Throwable t) {
      throw new RuntimeException("Error while applying " + myCustomFilter + " to '" + line + "'", t);
    }
    final HyperlinkInfo info = result != null ? result.getFirstHyperlinkInfo() : null;
    if (info != null) {

      // covers 99% use existing cases
      if (info instanceof FileHyperlinkInfo) {
        return ((FileHyperlinkInfo)info).getDescriptor();
      }

      // otherwise
      return new Navigatable() {
        @Override
        public void navigate(boolean requestFocus) {
          info.navigate(project);
        }

        @Override
        public boolean canNavigate() {
          return true;
        }

        @Override
        public boolean canNavigateToSource() {
          return true;
        }
      };
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:SMTRunnerConsoleProperties.java

示例14: getErrorNavigatable

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
@Override
public Navigatable getErrorNavigatable(@NotNull final Project project, final @NotNull String stacktrace) {
  if (myCustomFilter.isEmpty()) {
    return null;
  }

  // iterate stacktrace lines find first navigatable line using
  // stacktrace filters
  final int stacktraceLength = stacktrace.length();
  final String[] lines = StringUtil.splitByLines(stacktrace);
  for (String line : lines) {
    final Filter.Result result = myCustomFilter.applyFilter(line, stacktraceLength);
    if (result != null) {
      final HyperlinkInfo info = result.hyperlinkInfo;

      // covers 99% use existing cases
      if (info instanceof FileHyperlinkInfo) {
        return ((FileHyperlinkInfo)info).getDescriptor();
      }

      // otherwise
      return new Navigatable() {
        @Override
        public void navigate(boolean requestFocus) {
          result.hyperlinkInfo.navigate(project);
        }

        @Override
        public boolean canNavigate() {
          return true;
        }

        @Override
        public boolean canNavigateToSource() {
          return true;
        }
      };
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:SMTRunnerConsoleProperties.java

示例15: getErrorNavigatable

import com.intellij.execution.filters.Filter; //导入方法依赖的package包/类
@javax.annotation.Nullable
@Override
public Navigatable getErrorNavigatable(@Nonnull final Project project, final @Nonnull String stacktrace) {
  if (myCustomFilter.isEmpty()) {
    return null;
  }

  // iterate stacktrace lines find first navigatable line using
  // stacktrace filters
  final int stacktraceLength = stacktrace.length();
  final String[] lines = StringUtil.splitByLines(stacktrace);
  for (String line : lines) {
    Filter.Result result;
    try {
      result = myCustomFilter.applyFilter(line, stacktraceLength);
    }
    catch (Throwable t) {
      throw new RuntimeException("Error while applying " + myCustomFilter + " to '" + line + "'", t);
    }
    final HyperlinkInfo info = result != null ? result.getFirstHyperlinkInfo() : null;
    if (info != null) {

      // covers 99% use existing cases
      if (info instanceof FileHyperlinkInfo) {
        return ((FileHyperlinkInfo)info).getDescriptor();
      }

      // otherwise
      return new Navigatable() {
        @Override
        public void navigate(boolean requestFocus) {
          info.navigate(project);
        }

        @Override
        public boolean canNavigate() {
          return true;
        }

        @Override
        public boolean canNavigateToSource() {
          return true;
        }
      };
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:49,代码来源:SMTRunnerConsoleProperties.java


注:本文中的com.intellij.execution.filters.Filter.Result方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。