コード例 #1
0
 private static void afterItemInsertion(
     final CompletionProgressIndicator indicator, final Runnable laterRunnable) {
   if (laterRunnable != null) {
     final Runnable runnable1 =
         new Runnable() {
           @Override
           public void run() {
             if (!indicator.getProject().isDisposed()) {
               laterRunnable.run();
             }
             indicator.disposeIndicator();
           }
         };
     if (ApplicationManager.getApplication().isUnitTestMode()) {
       runnable1.run();
     } else {
       ApplicationManager.getApplication().invokeLater(runnable1);
     }
   } else {
     indicator.disposeIndicator();
   }
 }
コード例 #2
0
    @Override
    public void itemSelected(LookupEvent event) {
      LookupElement item = event.getItem();
      if (item == null) return;

      char c = event.getCompletionChar();
      if (myCheckCompletionChar && !LookupEvent.isSpecialCompletionChar(c)) {
        return;
      }

      final Project project = myContext.getProject();
      if (project == null) {
        return;
      }

      Runnable runnable =
          () ->
              new WriteCommandAction(project) {
                @Override
                protected void run(@NotNull com.intellij.openapi.application.Result result)
                    throws Throwable {
                  Editor editor = myContext.getEditor();
                  if (editor != null) {
                    TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
                    if (templateState != null) {
                      templateState.considerNextTabOnLookupItemSelected(item);
                    }
                  }
                }
              }.execute();
      if (ApplicationManager.getApplication().isUnitTestMode()) {
        runnable.run();
      } else {
        ApplicationManager.getApplication()
            .invokeLater(runnable, ModalityState.current(), project.getDisposed());
      }
    }