mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
wait for pending filters in cmake console
This commit is contained in:
@@ -94,25 +94,35 @@ class AsyncFilterRunner {
|
||||
return applyResults.get();
|
||||
}
|
||||
|
||||
private void handleSynchronouslyIfQuick(AtomicBoolean handled, Future<FilterResults> future, int timeout) {
|
||||
private boolean handleSynchronouslyIfQuick(AtomicBoolean handled, Future<FilterResults> future, long timeout) {
|
||||
try {
|
||||
future.get(timeout, TimeUnit.MILLISECONDS).applyHighlights(myHyperlinks);
|
||||
handled.set(true);
|
||||
myPendingFilterResults.remove(handled);
|
||||
return true;
|
||||
}
|
||||
catch (TimeoutException ignored) {
|
||||
return false;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void waitForPendingFilters() {
|
||||
public boolean waitForPendingFilters(long timeoutMs) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
long started = System.currentTimeMillis();
|
||||
while(!myPendingFilterResults.isEmpty()) {
|
||||
Map.Entry<AtomicBoolean, Future<FilterResults>> next = myPendingFilterResults.entrySet().iterator().next();
|
||||
handleSynchronouslyIfQuick(next.getKey(), next.getValue(), 1000);
|
||||
|
||||
timeoutMs -= System.currentTimeMillis() - started;
|
||||
if (timeoutMs < 1) return false;
|
||||
|
||||
if (!handleSynchronouslyIfQuick(next.getKey(), next.getValue(), timeoutMs)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -110,8 +110,9 @@ public class EditorHyperlinkSupport {
|
||||
}
|
||||
}
|
||||
|
||||
public void waitForPendingFilters() {
|
||||
myFilterRunner.waitForPendingFilters();
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public void waitForPendingFilters(long timeoutMs) {
|
||||
myFilterRunner.waitForPendingFilters(timeoutMs);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
Reference in New Issue
Block a user