void () { if (documentChanged(modificationStampBefore) || myProject.isDisposed()) { return; } // have to instantiate new indicator because the old one (progress) might have already been canceled DaemonProgressIndicator indicator = new DaemonProgressIndicator(); BackgroundTaskUtil.runUnderDisposeAwareIndicator(myProject, () -> { // run annotators outside the read action because they could start OSProcessHandler runChangeAware(myDocument, () -> doAnnotate()); ReadAction.run(() -> { ProgressManager.checkCanceled(); if (!documentChanged(modificationStampBefore)) { doApply(annotationHolder); doFinish(convertToHighlights(annotationHolder)); } }); }, indicator); }