private void updateChangesForDocumentInner(@NotNull Document document) {
    ApplicationManager.getApplication().assertWriteIntentLockAcquired();
    if (myProject.isDisposed()) return;
    List<Change> toUpdate = changedElements.get(document);
    if (toUpdate == null) {
      // The document has been changed, but psi hasn't
      // We may still need to rehighlight the file if there were changes inside highlighted ranges.
      if (UpdateHighlightersUtil.isWhitespaceOptimizationAllowed(document)) return;

      // don't create PSI for files in other projects
      PsiElement file = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(document);
      if (file == null) return;

      toUpdate = Collections.singletonList(new Change(file, true, true));
    }
    Application application = ApplicationManager.getApplication();
    Editor selectedEditor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
    PsiFile selectedFile = selectedEditor == null ? null : PsiDocumentManager.getInstance(myProject).getCachedPsiFile(selectedEditor.getDocument());
    if (selectedFile != null && !application.isUnitTestMode()) {
      application.invokeLater(() -> {
        if (!selectedEditor.isDisposed() &&
            selectedEditor.getMarkupModel() instanceof EditorMarkupModel markupModel) {
          ErrorStripeUpdateManager.getInstance(myProject).setOrRefreshErrorStripeRenderer(markupModel, selectedFile);
        }
      }, ModalityState.stateForComponent(selectedEditor.getComponent()), myProject.getDisposed());
    }

    for (Change change : toUpdate) {
      PsiElement element = change.psiElement();
      boolean whiteSpaceOptimizationAllowed = change.whiteSpaceOptimizationAllowed();
      if (change.referenceWasChanged()) {
        myFileStatusMap.markAllFilesDirty(change);
      }
      updateByChange(element, document, whiteSpaceOptimizationAllowed);
    }
    changedElements.remove(document);
  }
private void updateChangesForDocumentInner(@NotNull Document document)