@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 addFile( int linkageID, IIndexFileLocation location, ISignificantMacros sigMacros) throws CoreException { if (uncommittedKey != null && uncommittedKey.equals(new FileContentKey(linkageID, location, sigMacros))) return uncommittedFile; return super.addFile(linkageID, location, sigMacros); }
public PDOMFile getFileForASTNode(int linkageID, IASTNode node) throws CoreException { if (fPathResolver != null && node != null) { IASTFileLocation loc = node.getFileLocation(); if (loc != null) { IASTPreprocessorIncludeStatement owner = loc.getContextInclusionStatement(); ISignificantMacros sigMacros = owner != null ? owner.getSignificantMacros() : ISignificantMacros.NONE; if (sigMacros != null) { IIndexFileLocation location = fPathResolver.resolveASTPath(loc.getFileName()); if (uncommittedKey != null && uncommittedKey.equals(new FileContentKey(linkageID, location, sigMacros))) return fileBeingUpdated != null ? fileBeingUpdated : uncommittedFile; return getBestFile( linkageID, location, node.getTranslationUnit().getOriginatingTranslationUnit()); } } } return null; }
@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; }