1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Code cleanup.

This commit is contained in:
Sergey Prigogin 2010-03-22 05:33:59 +00:00
parent a06882508c
commit 03cbd47472

View file

@ -70,9 +70,6 @@ import org.eclipse.osgi.util.NLS;
* @since 4.0 * @since 4.0
*/ */
abstract public class PDOMWriter { abstract public class PDOMWriter {
// TODO(sprigogin): Remove SEMI_TRANSACTIONAL_UPDATES and ALLOW_LOCK_YIELDING constants and simplify the code.
public static boolean SEMI_TRANSACTIONAL_UPDATES = true;
public static boolean ALLOW_LOCK_YIELDING = true;
public static int SKIP_ALL_REFERENCES= -1; public static int SKIP_ALL_REFERENCES= -1;
public static int SKIP_TYPE_REFERENCES= 1; public static int SKIP_TYPE_REFERENCES= 1;
public static int SKIP_MACRO_REFERENCES= 2; public static int SKIP_MACRO_REFERENCES= 2;
@ -140,8 +137,8 @@ abstract public class PDOMWriter {
/** /**
* Extracts symbols from the given AST and adds them to the index. * Extracts symbols from the given AST and adds them to the index.
* *
* When flushIndex is set to <code>false</code>, you must make sure to flush the * When flushIndex is set to <code>false</code>, you must make sure to flush
* index after your last write operation. * the index after your last write operation.
* @since 4.0 * @since 4.0
*/ */
public void addSymbols(IASTTranslationUnit ast, IIndexFileLocation[] ifls, IWritableIndex index, public void addSymbols(IASTTranslationUnit ast, IIndexFileLocation[] ifls, IWritableIndex index,
@ -465,11 +462,10 @@ abstract public class PDOMWriter {
Set<IIndexFileLocation> clearedContexts= Collections.emptySet(); Set<IIndexFileLocation> clearedContexts= Collections.emptySet();
IIndexFragmentFile file; IIndexFragmentFile file;
long timestamp = fResolver.getLastModified(location); long timestamp = fResolver.getLastModified(location);
if (SEMI_TRANSACTIONAL_UPDATES) { // We create a temporary PDOMFile with zero timestamp, add names to it, then replace contents
// In fine grained locking mode we create a temporary PDOMFile with zero timestamp, // of the old file from the temporary one, then delete the temporary file. The write lock on
// add names to it, then replace contents of the old file from the temporary one, then // the index can be yielded between adding names to the temporary file, if another thread
// delete the temporary file. The write lock on the index is periodically yielded while // is waiting for a read lock.
// adding names to the temporary file, if the process takes long time.
IIndexFragmentFile oldFile = index.getWritableFile(linkageID, location); IIndexFragmentFile oldFile = index.getWritableFile(linkageID, location);
if (oldFile != null) { if (oldFile != null) {
IIndexInclude[] includedBy = index.findIncludedBy(oldFile); IIndexInclude[] includedBy = index.findIncludedBy(oldFile);
@ -481,16 +477,6 @@ abstract public class PDOMWriter {
} }
} }
file= index.addUncommittedFile(linkageID, location); file= index.addUncommittedFile(linkageID, location);
} else {
file= index.getWritableFile(linkageID, location);
if (file != null) {
clearedContexts= new HashSet<IIndexFileLocation>();
index.clearFile(file, clearedContexts);
} else {
file= index.addFile(linkageID, location);
}
file.setTimestamp(timestamp);
}
try { try {
file.setScannerConfigurationHashcode(configHash); file.setScannerConfigurationHashcode(configHash);
Symbols lists= symbolMap.get(location); Symbols lists= symbolMap.get(location);
@ -515,14 +501,11 @@ abstract public class PDOMWriter {
(contextIncludes.contains(include) || clearedContexts.contains(info.fLocation)); (contextIncludes.contains(include) || clearedContexts.contains(info.fLocation));
} }
} }
index.setFileContent(file, linkageID, includeInfos, macros, names, fResolver, index.setFileContent(file, linkageID, includeInfos, macros, names, fResolver, lock);
SEMI_TRANSACTIONAL_UPDATES && ALLOW_LOCK_YIELDING ? lock : null);
} }
if (SEMI_TRANSACTIONAL_UPDATES) {
file.setTimestamp(timestamp); file.setTimestamp(timestamp);
file.setContentsHash(fileContentsHash); file.setContentsHash(fileContentsHash);
file = index.commitUncommittedFile(); file = index.commitUncommittedFile();
}
} finally { } finally {
index.clearUncommittedFile(); index.clearUncommittedFile();
} }