mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EmptyIndicator must conform to at least some simple lifecycle constraints
GitOrigin-RevId: 3c3babd3a60826b38765c392f5801aff32ffa798
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c2a001f7e9
commit
b6aab58eb9
@@ -41,6 +41,7 @@ class AutoMakeMessageHandler extends DefaultMessageHandler {
|
||||
myBuildStatus = CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status.SUCCESS;
|
||||
myWolf = WolfTheProblemSolver.getInstance(project);
|
||||
myContext = new AutomakeCompileContext(project);
|
||||
myContext.getProgressIndicator().start();
|
||||
}
|
||||
|
||||
public boolean unprocessedFSChangesDetected() {
|
||||
|
||||
@@ -21,9 +21,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EmptyProgressIndicator implements StandardProgressIndicator {
|
||||
@NotNull private final ModalityState myModalityState;
|
||||
@NotNull
|
||||
private final ModalityState myModalityState;
|
||||
|
||||
private volatile boolean myIsRunning;
|
||||
@NotNull
|
||||
private volatile RunState myRunState = RunState.VIRGIN;
|
||||
private enum RunState {
|
||||
VIRGIN, STARTED, STOPPED
|
||||
}
|
||||
private volatile boolean myIsCanceled;
|
||||
private volatile int myNonCancelableSectionCount;
|
||||
|
||||
@@ -37,18 +42,29 @@ public class EmptyProgressIndicator implements StandardProgressIndicator {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
myIsRunning = true;
|
||||
if (myRunState == RunState.STARTED) {
|
||||
throw new IllegalStateException("Indicator already started");
|
||||
}
|
||||
myRunState = RunState.STARTED;
|
||||
myIsCanceled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
myIsRunning = false;
|
||||
switch (myRunState) {
|
||||
case VIRGIN:
|
||||
throw new IllegalStateException("Indicator can't be stopped because it wasn't started");
|
||||
case STARTED:
|
||||
myRunState = RunState.STOPPED;
|
||||
break;
|
||||
case STOPPED:
|
||||
throw new IllegalStateException("Indicator already stopped");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return myIsRunning;
|
||||
return myRunState == RunState.STARTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-2
@@ -19,7 +19,6 @@ import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.concurrency.SensitiveProgressWrapper;
|
||||
import com.intellij.ide.util.DelegatingProgressIndicator;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
@@ -29,7 +28,6 @@ import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.diagnostic.DefaultLogger;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.progress.util.*;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
|
||||
import com.intellij.testFramework.BombedProgressIndicator;
|
||||
@@ -865,4 +863,15 @@ public class ProgressIndicatorTest extends LightPlatformTestCase {
|
||||
catch (ProcessCanceledException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testEmptyIndicatorMustConformToAtLeastSomeSimpleLifecycleConstrains() {
|
||||
ProgressIndicator indicator = new EmptyProgressIndicator();
|
||||
for (int i=0; i<2; i++) {
|
||||
assertThrows(IllegalStateException.class, indicator::stop);
|
||||
indicator.start();
|
||||
assertThrows(IllegalStateException.class, indicator::start);
|
||||
indicator.stop();
|
||||
assertThrows(IllegalStateException.class, indicator::stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user