private void addLibrary(@NotNull Project project, @Nullable Editor editor, Library library) {
    ModalityState modality = ModalityState.defaultModalityState();
    JavaProjectModelModificationService.getInstance(project)
      .addDependency(myCurrentModule, library, myScope, myExported)
      .onSuccess(__ -> {
        if (editor == null) return;
        ReadAction.nonBlocking(() -> {
            PsiReference reference = restoreReference();
            String qName = myLibraries.get(library);
            if (qName.isEmpty() || reference == null) return null;
            return AddImportAction.create(editor, myCurrentModule, reference, qName);
          })
          .expireWhen(() -> editor.isDisposed() || myCurrentModule.isDisposed())
          .finishOnUiThread(modality, action -> {
            if (action != null) {
              action.execute();
            }
          })
          .submit(AppExecutorUtil.getAppExecutorService());
      });
  }
private void addLibrary(@NotNull Project project, @Nullable Editor editor, Library library)