public RefResolveServiceImpl(
      final Project project,
      final MessageBus messageBus,
      final PsiManager psiManager,
      StartupManager startupManager,
      ApplicationEx application,
      ProjectFileIndex projectFileIndex)
      throws IOException {
    super(project);
    ((FutureTask) resolveProcess).run();
    myApplication = application;
    myProjectFileIndex = projectFileIndex;
    if (ENABLED) {
      log = new FileWriter(new File(getStorageDirectory(), "log.txt"));

      File dataFile = new File(getStorageDirectory(), "data");
      fileIsResolved = ConcurrentBitSet.readFrom(new File(getStorageDirectory(), "bitSet"));
      log("Read resolved file bitset: " + fileIsResolved);

      int maxId = FSRecords.getMaxId();
      PersistentIntList list = new PersistentIntList(dataFile, dataFile.exists() ? 0 : maxId);
      if (list.getSize() == maxId) {
        storage = list;
      } else {
        // just to be safe, re-resolve all if VFS files count changes since last restart
        list.dispose();
        storage = new PersistentIntList(dataFile, maxId);
        log(
            "VFS maxId changed: was "
                + list.getSize()
                + "; now: "
                + maxId
                + "; re-resolving everything");
        fileIsResolved.clear();
      }
      Disposer.register(this, storage);
      if (!application.isUnitTestMode()) {
        startupManager.runWhenProjectIsInitialized(
            () -> {
              initListeners(messageBus, psiManager);
              startThread();
            });
      }
      Disposer.register(
          this,
          new Disposable() {
            @Override
            public void dispose() {
              try {
                save();
                log.close();
              } catch (IOException e) {
                LOG.error(e);
              }
            }
          });
    } else {
      log = null;
      fileIsResolved = null;
      storage = null;
    }
  }
 private void save() throws IOException {
   log("Saving resolved file bitset: " + fileIsResolved);
   fileIsResolved.writeTo(new File(getStorageDirectory(), "bitSet"));
   log("list.size = " + storage.getSize());
 }