本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
}
示例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);
};
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}