mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Fix for 178995, handling of PDOM Properties.
This commit is contained in:
parent
6b8088e349
commit
c7cf10ab41
5 changed files with 59 additions and 21 deletions
|
@ -17,6 +17,7 @@ public class Messages extends NLS {
|
|||
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.messages"; //$NON-NLS-1$
|
||||
public static String Checksums_taskComputeChecksums;
|
||||
public static String PDOMManager_ClosePDOMJob;
|
||||
public static String PDOMManager_creationOfIndexInterrupted;
|
||||
public static String PDOMManager_ExistingFileCollides;
|
||||
public static String PDOMManager_indexMonitorDetail;
|
||||
public static String PDOMManager_JoinIndexerTask;
|
||||
|
|
|
@ -200,6 +200,13 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pdom for the project. The call to the method may cause
|
||||
* opening the database. In case there is a version mismatch the data
|
||||
* base is cleared, in case it does not exist it is created. In any
|
||||
* case a pdom ready to use is returned.
|
||||
* @throws CoreException
|
||||
*/
|
||||
public IPDOM getPDOM(ICProject project) throws CoreException {
|
||||
synchronized (fProjectToPDOM) {
|
||||
IProject rproject = project.getProject();
|
||||
|
@ -227,16 +234,30 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
}
|
||||
|
||||
if (pdom == null) {
|
||||
boolean fromScratch= false;
|
||||
if (dbName == null) {
|
||||
dbName = createNewDatabaseName(project);
|
||||
dbFile= fileFromDatabaseName(dbName);
|
||||
storeDatabaseName(rproject, dbName);
|
||||
fromScratch= true;
|
||||
}
|
||||
|
||||
boolean newPDOM= !dbFile.exists();
|
||||
pdom = new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(rproject));
|
||||
if(newPDOM) {
|
||||
pdom= new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(rproject));
|
||||
if (pdom.versionMismatch() || fromScratch) {
|
||||
try {
|
||||
pdom.acquireWriteLock();
|
||||
} catch (InterruptedException e) {
|
||||
throw new CoreException(CCorePlugin.createStatus(Messages.PDOMManager_creationOfIndexInterrupted, e));
|
||||
}
|
||||
if (fromScratch) {
|
||||
pdom.setCreatedFromScratch(true);
|
||||
}
|
||||
else {
|
||||
pdom.clear();
|
||||
pdom.setClearedBecauseOfVersionMismatch(true);
|
||||
}
|
||||
writeProjectPDOMProperties(pdom, rproject);
|
||||
pdom.releaseWriteLock();
|
||||
}
|
||||
pdom.addListener(this);
|
||||
}
|
||||
|
@ -367,24 +388,22 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
IProject prj= project.getProject();
|
||||
try {
|
||||
synchronized (fIndexerMutex) {
|
||||
PDOM pdom= (PDOM) getPDOM(project);
|
||||
WritablePDOM pdom= (WritablePDOM) getPDOM(project);
|
||||
Properties props= IndexerPreferences.getProperties(prj);
|
||||
IPDOMIndexer indexer= createIndexer(project, getIndexerId(project), props);
|
||||
|
||||
boolean performImport= false;
|
||||
boolean rebuild= false;
|
||||
if (!IPDOMManager.ID_NO_INDEXER.equals(indexer.getID()) && pdom.isEmpty()) {
|
||||
performImport= true;
|
||||
}
|
||||
else if (pdom.versionMismatch()) {
|
||||
rebuild= true;
|
||||
}
|
||||
|
||||
if (!performImport) {
|
||||
registerIndexer(project, indexer);
|
||||
if (rebuild) {
|
||||
enqueue(new PDOMRebuildTask(indexer));
|
||||
boolean rebuild=
|
||||
pdom.isClearedBecauseOfVersionMismatch() ||
|
||||
pdom.isCreatedFromScratch();
|
||||
if (rebuild) {
|
||||
if (IPDOMManager.ID_NO_INDEXER.equals(indexer.getID())) {
|
||||
rebuild= false;
|
||||
}
|
||||
pdom.setClearedBecauseOfVersionMismatch(false);
|
||||
pdom.setCreatedFromScratch(false);
|
||||
}
|
||||
if (!rebuild) {
|
||||
registerIndexer(project, indexer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||
public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||
private boolean fClearedBecauseOfVersionMismatch= false;
|
||||
private boolean fCreatedFromScratch= false;
|
||||
|
||||
public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter) throws CoreException {
|
||||
this(dbPath, locationConverter, ChunkCache.getSharedInstance());
|
||||
|
@ -125,4 +127,20 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
|||
|
||||
return notConverted;
|
||||
}
|
||||
|
||||
boolean isClearedBecauseOfVersionMismatch() {
|
||||
return fClearedBecauseOfVersionMismatch;
|
||||
}
|
||||
|
||||
void setClearedBecauseOfVersionMismatch(boolean clearedBecauseOfVersionMismatch) {
|
||||
fClearedBecauseOfVersionMismatch = clearedBecauseOfVersionMismatch;
|
||||
}
|
||||
|
||||
boolean isCreatedFromScratch() {
|
||||
return fCreatedFromScratch;
|
||||
}
|
||||
|
||||
void setCreatedFromScratch(boolean createdFromScratch) {
|
||||
fCreatedFromScratch = createdFromScratch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,12 +122,11 @@ public class Database {
|
|||
int version= getVersion();
|
||||
removeChunksFromCache();
|
||||
|
||||
// clear out memory headers
|
||||
// clear the first chunk.
|
||||
Chunk header= getChunk(0);
|
||||
header.clear(0, CHUNK_SIZE);
|
||||
setVersion(version);
|
||||
header.clear(4, DATA_AREA - 4);
|
||||
chunks = new Chunk[] {header};
|
||||
|
||||
try {
|
||||
getChannel().truncate(CHUNK_SIZE);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ PDOMManager_ClosePDOMJob=Close database
|
|||
PDOMManager_notifyTask_message=Notify Listeners
|
||||
PDOMManager_indexMonitorDetail={0}/{1} sources, {2} headers
|
||||
PDOMManager_ExistingFileCollides=A pdom already exists at location {0}
|
||||
PDOMManager_creationOfIndexInterrupted=Creation of index was interrupted
|
||||
Checksums_taskComputeChecksums=Computing checksums
|
||||
TeamPDOMExportOperation_errorCreatingTempFile=Cannot create temp file
|
||||
TeamPDOMExportOperation_taskExportIndex=Export team shared index
|
||||
|
|
Loading…
Add table
Reference in a new issue