@SuppressWarnings({"unchecked", "rawtypes"})
  private <T> void doImportData(@NotNull Key<T> key,
                                @NotNull Collection<? extends DataNode<?>> nodes,
                                @Nullable ProjectSystemId projectSystemId,
                                @Nullable final ProjectData projectData,
                                @NotNull final Project project,
                                @NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
                                @NotNull final List<Runnable> postImportTasks,
                                @NotNull final List<Runnable> onSuccessImportTasks,
                                @NotNull final List<Runnable> onFailureImportTasks) {
    if (project.isDisposed()) {
      return;
    }

    final Collection<DataNode<?>> toImport = new SmartList<>();
    final Collection<DataNode<?>> toIgnore = new SmartList<>();

    for (DataNode<?> node : nodes) {
      if (!key.equals(node.getKey())) continue;

      if (node.isIgnored()) {
        toIgnore.add(node);
      }
      else {
        toImport.add(node);
      }
    }

    ensureTheDataIsReadyToUse(toImport);

    @NotNull List<ProjectDataService<?, ?>> services = findService(key);
    @NotNull List<WorkspaceDataService<?>> workspaceServices = findWorkspaceService(key);
    if (services.isEmpty() && workspaceServices.isEmpty()) {
      LOG.debug(String.format("No data service is registered for %s", key));
    }
    else {
      for (ProjectDataService<?, ?> service : services) {
        final long importStartTime = System.currentTimeMillis();
        String dataServiceName = service.getClass().getSimpleName();
        ExternalSystemTelemetryUtil.runWithSpan(projectSystemId, dataServiceName,
                                                (span) -> ((ProjectDataService)service).importData(toImport, projectData, project,
                                                                                                   modifiableModelsProvider));
        if (LOG.isDebugEnabled()) {
          final long importTimeInMs = (System.currentTimeMillis() - importStartTime);
          LOG.debug(String.format("Service %s imported data in %d ms", dataServiceName, importTimeInMs));
        }

        if (projectData != null) {
          ensureTheDataIsReadyToUse(toIgnore);
          final long removeStartTime = System.currentTimeMillis();
          final Computable<Collection<?>> orphanIdeDataComputable =
            ((ProjectDataService)service).computeOrphanData(toImport, projectData, project, modifiableModelsProvider);
          ((ProjectDataService)service).removeData(orphanIdeDataComputable, toIgnore, projectData, project, modifiableModelsProvider);
          if (LOG.isDebugEnabled()) {
            final long removeTimeInMs = (System.currentTimeMillis() - removeStartTime);
            LOG.debug(String.format("Service %s computed and removed data in %d ms", dataServiceName, removeTimeInMs));
          }
        }
      }

      for (WorkspaceDataService<?> service : workspaceServices) {
        final long importStartTime = System.currentTimeMillis();
        if (modifiableModelsProvider instanceof IdeModifiableModelsProviderImpl) {
          MutableEntityStorage mutableStorage = ((IdeModifiableModelsProviderImpl)modifiableModelsProvider).getActualStorageBuilder();
          ((WorkspaceDataService)service).importData(toImport, projectData, project, mutableStorage);
        }
        else {
          LOG.warn(String.format("MutableEntityStorage missing, models provider is %s", modifiableModelsProvider.getClass().getName()));
        }
        if (LOG.isDebugEnabled()) {
          final long importTimeInMs = (System.currentTimeMillis() - importStartTime);
          LOG.debug(String.format("Workspace service %s imported data in %d ms", service.getClass().getSimpleName(), importTimeInMs));
        }
      }
    }

    if (!services.isEmpty() && projectData != null) {
      postImportTasks.add(() -> {
        for (ProjectDataService<?, ?> service : services) {
          final long taskStartTime = System.currentTimeMillis();
          ((ProjectDataService)service).postProcess(toImport, projectData, project, modifiableModelsProvider);
          if (LOG.isDebugEnabled()) {
            final long taskTimeInMs = (System.currentTimeMillis() - taskStartTime);
            LOG.debug(String.format("Service %s run post import task in %d ms", service.getClass().getSimpleName(), taskTimeInMs));
          }
        }
      });
      onFailureImportTasks.add(() -> {
        for (ProjectDataService<?, ?> service : services) {
          final long taskStartTime = System.currentTimeMillis();
          service.onFailureImport(project);
          if (LOG.isDebugEnabled()) {
            final long taskTimeInMs = (System.currentTimeMillis() - taskStartTime);
            LOG.debug(String.format("Service %s run failure import task in %d ms", service.getClass().getSimpleName(), taskTimeInMs));
          }
        }
      });
      onSuccessImportTasks.add(() -> {
        IdeModelsProvider modelsProvider = new IdeModelsProviderImpl(project);
        for (ProjectDataService<?, ?> service : services) {
          final long taskStartTime = System.currentTimeMillis();
          ((ProjectDataService)service).onSuccessImport(toImport, projectData, project, modelsProvider);
          if (LOG.isDebugEnabled()) {
            final long taskTimeInMs = (System.currentTimeMillis() - taskStartTime);
            LOG.debug(String.format("Service %s run success import task in %d ms", service.getClass().getSimpleName(), taskTimeInMs));
          }
        }
      });
    }
  }
@SuppressWarnings({"unchecked", "rawtypes"})
  private <T> void doImportData(@NotNull Key<T> key,
                                @NotNull Collection<? extends DataNode<?>> nodes,
                                @Nullable ProjectSystemId projectSystemId,
                                @Nullable final ProjectData projectData,
                                @NotNull final Project project,
                                @NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
                                @NotNull final List<Runnable> postImportTasks,
                                @NotNull final List<Runnable> onSuccessImportTasks,
                                @NotNull final List<Runnable> onFailureImportTasks)