mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CompositeFilter#forceUseAllFilters=false by default to restore previous behaviour
Deprecated public fields in Filter#Result and getters to give warning about possible danger
This commit is contained in:
+1
-1
@@ -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();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CompositeFilter implements Filter, FilterMixin {
|
||||
|
||||
private final List<Filter> myFilters = new ArrayList<Filter>();
|
||||
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<ResultItem> 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);
|
||||
}
|
||||
|
||||
@@ -34,20 +34,23 @@ public interface Filter {
|
||||
protected NextAction myNextAction = NextAction.EXIT;
|
||||
protected final List<ResultItem> 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<ResultItem> resultItems) {
|
||||
super(-1, -1, null, null);
|
||||
myResultItems = resultItems;
|
||||
}
|
||||
|
||||
|
||||
public List<ResultItem> getResultItems() {
|
||||
List<ResultItem> 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
|
||||
* <tt>null</tt>, 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 <tt>null</tt>, if there was no match, otherwise, an instance of {@link Result}
|
||||
*/
|
||||
@Nullable
|
||||
Result applyFilter(String line, int entireLength);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -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
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user