diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionExFilterFactory.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionExFilterFactory.java index 9b42c38d990c..722fb066ac1b 100644 --- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionExFilterFactory.java +++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionExFilterFactory.java @@ -86,7 +86,7 @@ public class ExceptionExFilterFactory implements ExceptionFilterFactory { worker.execute(text, lineEndOffset); Result result = worker.getResult(); if (result == null) continue; - HyperlinkInfo hyperlinkInfo = result.hyperlinkInfo; + HyperlinkInfo hyperlinkInfo = result.getHyperlinkInfo(); if (!(hyperlinkInfo instanceof FileHyperlinkInfo)) continue; OpenFileDescriptor descriptor = ((FileHyperlinkInfo)hyperlinkInfo).getDescriptor(); diff --git a/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java b/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java index 867c78c37b2a..fb782db28cd4 100644 --- a/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java +++ b/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java @@ -33,7 +33,7 @@ public class CompositeFilter implements Filter, FilterMixin { private final List myFilters = new ArrayList(); private boolean myIsAnyHeavy; - private boolean forceUseAllFilters = true; + private boolean forceUseAllFilters = false; private final DumbService myDumbService; public CompositeFilter(@NotNull Project project) { @@ -85,8 +85,8 @@ public class CompositeFilter implements Filter, FilterMixin { } if (resultItems.size() == 1) { ResultItem resultItem = resultItems.get(0); - return new Result(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.hyperlinkInfo, - resultItem.highlightAttributes); + return new Result(resultItem.getHighlightStartOffset(), resultItem.getHighlightEndOffset(), resultItem.getHyperlinkInfo(), + resultItem.getHighlightAttributes()); } return new Result(resultItems); } @@ -104,7 +104,7 @@ public class CompositeFilter implements Filter, FilterMixin { List newItems = newResult.getResultItems(); for (int i = 0; i < newItems.size(); i++) { ResultItem item = newItems.get(i); - if (item.hyperlinkInfo == null || !intersects(resultItems, item)) { + if (item.getHyperlinkInfo() == null || !intersects(resultItems, item)) { resultItems.add(item); } } @@ -117,7 +117,7 @@ public class CompositeFilter implements Filter, FilterMixin { for (int i = 0; i < items.size(); i++) { ResultItem item = items.get(i); - if (item.hyperlinkInfo != null) { + if (item.getHyperlinkInfo() != null) { if (newItemTextRange == null) { newItemTextRange = new TextRange(newItem.highlightStartOffset, newItem.highlightEndOffset); } diff --git a/platform/lang-api/src/com/intellij/execution/filters/Filter.java b/platform/lang-api/src/com/intellij/execution/filters/Filter.java index 1e375acaeb8c..0f9e09b81eff 100644 --- a/platform/lang-api/src/com/intellij/execution/filters/Filter.java +++ b/platform/lang-api/src/com/intellij/execution/filters/Filter.java @@ -34,20 +34,23 @@ public interface Filter { protected NextAction myNextAction = NextAction.EXIT; protected final List myResultItems; - public Result(final int highlightStartOffset, final int highlightEndOffset, final HyperlinkInfo hyperlinkInfo) { + public Result(final int highlightStartOffset, final int highlightEndOffset, @Nullable final HyperlinkInfo hyperlinkInfo) { this(highlightStartOffset, highlightEndOffset, hyperlinkInfo, null); } - public Result(final int highlightStartOffset, final int highlightEndOffset, final HyperlinkInfo hyperlinkInfo, final TextAttributes highlightAttributes) { + public Result(final int highlightStartOffset, + final int highlightEndOffset, + @Nullable final HyperlinkInfo hyperlinkInfo, + @Nullable final TextAttributes highlightAttributes) { super(highlightStartOffset, highlightEndOffset, hyperlinkInfo, highlightAttributes); myResultItems = null; } - + public Result(@NotNull List resultItems) { super(-1, -1, null, null); myResultItems = resultItems; } - + public List getResultItems() { List resultItems = myResultItems; if (resultItems == null) { @@ -56,6 +59,59 @@ public interface Filter { return resultItems; } + /** + * @deprecated Result may be constructed using ResultItems, in that case this method will return incorrect value. Use {@link #getResultItems()} instead. + */ + @Deprecated + @Override + public int getHighlightStartOffset() { + return super.getHighlightStartOffset(); + } + + /** + * @deprecated Result may be constructed using ResultItems, in that case this method will return incorrect value. Use {@link #getResultItems()} instead. + */ + @Deprecated + @Override + public int getHighlightEndOffset() { + return super.getHighlightEndOffset(); + } + + /** + * @deprecated Result may be constructed using ResultItems, in that case this method will return incorrect value. Use {@link #getResultItems()} instead. + */ + @Deprecated + @Nullable + @Override + public TextAttributes getHighlightAttributes() { + return super.getHighlightAttributes(); + } + + /** + * @deprecated Result may be constructed using ResultItems, in that case this method will return incorrect value. Use {@link #getResultItems()} or {@link #getFirstHyperlinkInfo()} instead. + */ + @Deprecated + @Nullable + @Override + public HyperlinkInfo getHyperlinkInfo() { + return super.getHyperlinkInfo(); + } + + @Nullable + public HyperlinkInfo getFirstHyperlinkInfo() { + HyperlinkInfo info = super.getHyperlinkInfo(); + if (info == null && myResultItems != null) { + //noinspection ForLoopReplaceableByForEach + for (int i = 0; i < myResultItems.size(); i++) { + ResultItem resultItem = myResultItems.get(i); + if (resultItem.getHyperlinkInfo() != null) { + return resultItem.getHyperlinkInfo(); + } + } + } + return info; + } + public NextAction getNextAction() { return myNextAction; } @@ -70,36 +126,73 @@ public interface Filter { } class ResultItem { + /** + * @deprecated use getter, the visibility of this field will be decreased. + */ + @Deprecated public final int highlightStartOffset; + /** + * @deprecated use getter, the visibility of this field will be decreased. + */ + @Deprecated public final int highlightEndOffset; + /** + * @deprecated use getter, the visibility of this field will be decreased. + */ + @Deprecated @Nullable public final TextAttributes highlightAttributes; + /** + * @deprecated use getter, the visibility of this field will be decreased. + */ + @Deprecated @Nullable public final HyperlinkInfo hyperlinkInfo; - public ResultItem(final int highlightStartOffset, final int highlightEndOffset, final HyperlinkInfo hyperlinkInfo) { + @SuppressWarnings("deprecation") + public ResultItem(final int highlightStartOffset, final int highlightEndOffset, @Nullable final HyperlinkInfo hyperlinkInfo) { this(highlightStartOffset, highlightEndOffset, hyperlinkInfo, null); } - public ResultItem(final int highlightStartOffset, final int highlightEndOffset, final HyperlinkInfo hyperlinkInfo, final TextAttributes highlightAttributes) { + @SuppressWarnings("deprecation") + public ResultItem(final int highlightStartOffset, + final int highlightEndOffset, + @Nullable final HyperlinkInfo hyperlinkInfo, + @Nullable final TextAttributes highlightAttributes) { this.highlightStartOffset = highlightStartOffset; this.highlightEndOffset = highlightEndOffset; this.hyperlinkInfo = hyperlinkInfo; this.highlightAttributes = highlightAttributes; } + + public int getHighlightStartOffset() { + //noinspection deprecation + return highlightStartOffset; + } + + public int getHighlightEndOffset() { + //noinspection deprecation + return highlightEndOffset; + } + + @Nullable + public TextAttributes getHighlightAttributes() { + //noinspection deprecation + return highlightAttributes; + } + + @Nullable + public HyperlinkInfo getHyperlinkInfo() { + //noinspection deprecation + return hyperlinkInfo; + } } /** * Filters line by creating an instance of {@link Result}. * - * - * @param line - * The line to be filtered. Note that the line must contain a line - * separator at the end. - * - * @param entireLength - * The length of the entire text including the line passed for filtration. - * - * @return - * null, if there was no match, otherwise, an instance of {@link Result} + * @param line The line to be filtered. Note that the line must contain a line + * separator at the end. + * @param entireLength The length of the entire text including the line passed for filtration. + * @return null, if there was no match, otherwise, an instance of {@link Result} */ @Nullable Result applyFilter(String line, int entireLength); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 5fc2fe2cccea..12eff1bd76e6 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -297,6 +297,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo } } } + myFilters.setForceUseAllFilters(true); myHeavyUpdateTicket = 0; myHeavyAlarm = myFilters.isAnyHeavy() ? new Alarm(Alarm.ThreadToUse.SHARED_THREAD, this) : null; diff --git a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java index d99a38c199b4..26429fc0e896 100644 --- a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java +++ b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java @@ -265,11 +265,11 @@ public class EditorHyperlinkSupport { Filter.Result result = customFilter.applyFilter(text, endOffset); if (result != null) { for (Filter.ResultItem resultItem : result.getResultItems()) { - if (resultItem.hyperlinkInfo != null) { - createHyperlink(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes, resultItem.hyperlinkInfo); + if (resultItem.getHyperlinkInfo() != null) { + createHyperlink(resultItem.getHighlightStartOffset(), resultItem.getHighlightEndOffset(), resultItem.getHighlightAttributes(), resultItem.getHyperlinkInfo()); } - else if (resultItem.highlightAttributes != null) { - addHighlighter(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes); + else if (resultItem.getHighlightAttributes() != null) { + addHighlighter(resultItem.getHighlightStartOffset(), resultItem.getHighlightEndOffset(), resultItem.getHighlightAttributes()); } } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java index 977a28fb14e7..6bc2f72ea45e 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java @@ -94,15 +94,15 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements final int stacktraceLength = stacktrace.length(); final String[] lines = StringUtil.splitByLines(stacktrace); for (String line : lines) { - final Filter.Result result; + Filter.Result result; try { result = myCustomFilter.applyFilter(line, stacktraceLength); } catch (Throwable t) { - throw new RuntimeException("Error while applying " + myCustomFilter + " to '"+line+"'", t); + throw new RuntimeException("Error while applying " + myCustomFilter + " to '" + line + "'", t); } - if (result != null) { - final HyperlinkInfo info = result.hyperlinkInfo; + final HyperlinkInfo info = result != null ? result.getFirstHyperlinkInfo() : null; + if (info != null) { // covers 99% use existing cases if (info instanceof FileHyperlinkInfo) { @@ -113,7 +113,7 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements return new Navigatable() { @Override public void navigate(boolean requestFocus) { - result.hyperlinkInfo.navigate(project); + info.navigate(project); } @Override diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java index 769a5225e58d..7368321924f8 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java @@ -103,10 +103,10 @@ public final class TestProxyPrinterProvider { throw new RuntimeException("Error while applying " + myFilter + " to '"+line+"'", t); } 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); + 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);