show the real reason why highlighting is paused: ignore VFS refresh background heavy process

GitOrigin-RevId: ff43812636a8b2b67ce6e2d822457096ac4fc10f
This commit is contained in:
Alexey Kudravtsev
2021-04-16 15:31:12 +02:00
committed by intellij-monorepo-bot
parent 415ca39535
commit a0b11d47da
4 changed files with 18 additions and 14 deletions

View File

@@ -393,7 +393,7 @@ public final class DaemonListeners implements Disposable {
PsiManager.getInstance(myProject).dropPsiCaches();
}
}));
HeavyProcessLatch.INSTANCE.addListener(this, () ->
HeavyProcessLatch.INSTANCE.addListener(this, __ ->
myDaemonCodeAnalyzer.stopProcess(true, "re-scheduled to execute after heavy processing finished"));
}

View File

@@ -244,7 +244,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
}
if (HeavyProcessLatch.INSTANCE.isRunning()) {
HeavyProcessLatch.Operation op = HeavyProcessLatch.INSTANCE.getAnyRunningOperation();
HeavyProcessLatch.Operation op = ContainerUtil.find(HeavyProcessLatch.INSTANCE.getRunningOperations(), o -> o.getType() != HeavyProcessLatch.Type.Syncing);
if (op == null) {
status.reasonWhySuspended = DaemonBundle.message("process.title.heavy.operation.is.running");
status.heavyProcessType = HeavyProcessLatch.Type.Processing;

View File

@@ -10,10 +10,7 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.EventListener;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
@@ -60,11 +57,11 @@ public final class HeavyProcessLatch {
public @NotNull AccessToken processStarted(@NotNull @Nls String displayName) {
Op op = new Op(Type.Processing, displayName);
myHeavyProcesses.add(op);
myEventDispatcher.getMulticaster().processStarted();
myEventDispatcher.getMulticaster().processStarted(op);
return new AccessToken() {
@Override
public void finish() {
myEventDispatcher.getMulticaster().processFinished();
myEventDispatcher.getMulticaster().processFinished(op);
myHeavyProcesses.remove(op);
executeHandlers();
}
@@ -77,12 +74,12 @@ public final class HeavyProcessLatch {
public void performOperation(@NotNull Type type, @NotNull @Nls String displayName, @NotNull Runnable runnable) {
Op op = new Op(type, displayName);
myHeavyProcesses.add(op);
myEventDispatcher.getMulticaster().processStarted();
myEventDispatcher.getMulticaster().processStarted(op);
try {
runnable.run();
}
finally {
myEventDispatcher.getMulticaster().processFinished();
myEventDispatcher.getMulticaster().processFinished(op);
myHeavyProcesses.remove(op);
executeHandlers();
}
@@ -130,11 +127,18 @@ public final class HeavyProcessLatch {
return iterator.hasNext() ? iterator.next() : null;
}
/**
* @return all heavy operations currently running (or empty collection if none), in undefined order
*/
public @NotNull Collection<Operation> getRunningOperations() {
return new ArrayList<>(myHeavyProcesses);
}
public interface HeavyProcessListener extends EventListener {
default void processStarted() {
default void processStarted(@NotNull Operation op) {
}
void processFinished();
void processFinished(@NotNull Operation op);
}
public interface Operation {

View File

@@ -109,12 +109,12 @@ public class HeavyAwareExecutor implements Disposable {
}
@Override
public void processStarted() {
public void processStarted(@NotNull HeavyProcessLatch.Operation op) {
scheduleCancel();
}
@Override
public void processFinished() {
public void processFinished(@NotNull HeavyProcessLatch.Operation op) {
doNotCancel();
}