@Override
  protected void reportFileWrittenToIndex(FileInAST file, IIndexFragmentFile ifile)
      throws CoreException {
    final FileContentKey fck = file.fileContentKey;
    final IIndexFileLocation location = fck.getLocation();
    boolean wasCounted = false;
    UpdateKind kind = UpdateKind.OTHER_HEADER;
    LinkageTask map = findRequestMap(fck.getLinkageID());
    LocationTask locTask = null;
    if (map != null) {
      locTask = map.find(location);
      if (locTask != null) {
        kind = locTask.fKind;
        FileVersionTask v = locTask.findVersion(ifile);
        if (v != null) {
          wasCounted = v.fOutdated;
          v.setUpdated();
        } else {
          // We have added a version, the request is fulfilled.
          wasCounted = locTask.fCountedUnknownVersion;
          locTask.fCountedUnknownVersion = false;
        }
        locTask.fStoredAVersion = true;
      }
    }
    fIndexContentCache.remove(ifile);
    fIndexFilesCache.remove(file.fileContentKey.getLocation());

    LocationTask task = fOneLinkageTasks.remove(location);
    if (task != null && task != locTask) {
      if (task.fKind == UpdateKind.ONE_LINKAGE_HEADER && !task.isCompleted()) {
        task.fKind = UpdateKind.OTHER_HEADER;
        if (task.isCompleted()) {
          if (!wasCounted) {
            kind = UpdateKind.ONE_LINKAGE_HEADER;
            wasCounted = true;
          } else {
            reportFile(wasCounted, UpdateKind.ONE_LINKAGE_HEADER);
          }
        }
      }
    }
    reportFile(wasCounted, kind);
  }
  @Override
  public IIndexFragmentFile commitUncommittedFile() throws CoreException {
    if (uncommittedFile == null) return null;

    int defectiveStateChange = uncommittedFile.getTimestamp() == 0 ? 1 : 0;
    int unresolvedIncludeStateChange = uncommittedFile.hasUnresolvedInclude() ? 1 : 0;

    PDOMFile file;
    if (fileBeingUpdated == null) {
      // New file, insert it into the index.
      file = uncommittedFile;
      getFileIndex().insert(file.getRecord());
    } else {
      // Existing file.
      if (fileBeingUpdated.getTimestamp() == 0) defectiveStateChange -= 1;
      if (fileBeingUpdated.hasUnresolvedInclude()) unresolvedIncludeStateChange -= 1;
      fileBeingUpdated.replaceContentsFrom(uncommittedFile);
      file = fileBeingUpdated;
      fileBeingUpdated = null;
    }
    if (defectiveStateChange > 0) {
      getIndexOfDefectiveFiles().insert(file.getRecord());
    } else if (defectiveStateChange < 0) {
      getIndexOfDefectiveFiles().delete(file.getRecord());
    }
    if (unresolvedIncludeStateChange > 0) {
      getIndexOfFilesWithUnresolvedIncludes().insert(file.getRecord());
    } else if (unresolvedIncludeStateChange < 0) {
      getIndexOfFilesWithUnresolvedIncludes().delete(file.getRecord());
    }

    fEvent.fFilesWritten.add(uncommittedKey.getLocation());
    uncommittedFile = null;
    uncommittedKey = null;
    return file;
  }