private static void applyFSEvent(ProjectDescriptor pd, @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent event, final boolean saveEventStamp) throws IOException {
    if (event == null) {
      return;
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("applyFSEvent ordinal=" + event.getOrdinal());
    }

    final BuildRootIndex buildRootIndex = pd.getBuildRootIndex();
    final StampsStorage<? extends StampsStorage.Stamp> stampsStorage = pd.getProjectStamps().getStampStorage();
    for (String deleted : event.getDeletedPathsList()) {
      final File file = new File(deleted);
      Collection<BuildRootDescriptor> descriptor = buildRootIndex.findAllParentDescriptors(file, null, null);
      if (!descriptor.isEmpty()) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Applying deleted path from fs event: " + file.getPath());
        }
        for (BuildRootDescriptor rootDescriptor : descriptor) {
          pd.fsState.registerDeleted(null, rootDescriptor.getTarget(), file, stampsStorage);
        }
      }
      else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Skipping deleted path: " + file.getPath());
        }
      }
    }
    for (String changed : event.getChangedPathsList()) {
      final File file = new File(changed);
      Collection<BuildRootDescriptor> descriptors = ContainerUtil.filter(
        // ignore generates sources as they are processed at the time of generation
        buildRootIndex.findAllParentDescriptors(file, null, null), d -> !d.isGenerated()
      );
      if (!descriptors.isEmpty()) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Applying dirty path from fs event: " + file.getPath());
        }
        for (BuildRootDescriptor descriptor : descriptors) {
          StampsStorage.Stamp stamp = stampsStorage.getPreviousStamp(file, descriptor.getTarget());
          if (stampsStorage.isDirtyStamp(stamp, file)) {
            pd.fsState.markDirty(null, file, descriptor, stampsStorage, saveEventStamp);
          }
          else {
            if (LOG.isDebugEnabled()) {
              LOG.debug(descriptor.getTarget() + ": Path considered up-to-date: " + file.getPath() + "; stamp= " + stamp);
            }
          }
        }
      }
      else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Skipping dirty path: " + file.getPath());
        }
      }
    }
  }
private static void applyFSEvent(ProjectDescriptor pd, @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent event, final boolean saveEventStamp)