private void rebuild(final boolean updateText, @Nullable final Runnable runnable, final boolean requestFocus, final int delayMillis) {
    ThreadingAssertions.assertEventDispatchThread();
    myRebuildRequired = false;
    cancelCurrentProgress();
    PanelProgressIndicator progress = createProgressIndicator(requestFocus);
    progress.setBordersVisible(false);
    myCurrentProgress = progress;

    PatternDialectProvider provider = PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE);
    String hintMessage = provider != null ? provider.getHintMessage() : "";
    myPatternLegend.setText(new HtmlBuilder().appendRaw(hintMessage).wrapWithHtmlBody().toString());

    final Runnable request = () -> {
      if (updateText) {
        final String text = myCurrentScope != null ? myCurrentScope.getText() : null;
        SwingUtilities.invokeLater(() -> {
          try {
            myIsInUpdate = true;
            myPatternField.setText(text);
          }
          finally {
            myIsInUpdate = false;
          }
        });
      }

      if (myProject.isDisposed()) {
        return;
      }
      try {
        updateTreeModel(requestFocus, progress);
      }
      catch (ProcessCanceledException e) {
        return;
      }
      if (runnable != null) {
        runnable.run();
      }
    };
    myUpdateAlarm = AppExecutorUtil.getAppScheduledExecutorService().schedule(request, delayMillis, TimeUnit.MILLISECONDS);
  }
private void rebuild(final boolean updateText, @Nullable final Runnable runnable, final boolean requestFocus, final int delayMillis)