void (@NotNull CompletionPhase phase) { // wrap explicitly with client id for the case when some called API depends on ClientId.current try (AccessToken ignored = ClientId.withClientId(myAppSession.getClientId())) { ThreadingAssertions.assertEventDispatchThread(); CompletionPhase oldPhase = getCompletionPhase(); CompletionProgressIndicator oldIndicator = oldPhase.indicator; if (oldIndicator != null && !(phase instanceof CompletionPhase.BgCalculation) && oldIndicator.isRunning() && !oldIndicator.isCanceled()) { LOG.error("don't change phase during running completion: oldPhase=" + oldPhase); } boolean wasCompletionRunning = isRunningPhase(oldPhase); boolean isCompletionRunning = isRunningPhase(phase); if (isCompletionRunning != wasCompletionRunning) { ApplicationManager.getApplication().getMessageBus().syncPublisher(CompletionPhaseListener.TOPIC) .completionPhaseChanged(isCompletionRunning); } Disposer.dispose(oldPhase); Throwable phaseTrace = new Throwable(); myPhaseHolder = new CompletionPhaseHolder(phase, phaseTrace); } }