mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +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$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.messages"; //$NON-NLS-1$
|
||||||
public static String Checksums_taskComputeChecksums;
|
public static String Checksums_taskComputeChecksums;
|
||||||
public static String PDOMManager_ClosePDOMJob;
|
public static String PDOMManager_ClosePDOMJob;
|
||||||
|
public static String PDOMManager_creationOfIndexInterrupted;
|
||||||
public static String PDOMManager_ExistingFileCollides;
|
public static String PDOMManager_ExistingFileCollides;
|
||||||
public static String PDOMManager_indexMonitorDetail;
|
public static String PDOMManager_indexMonitorDetail;
|
||||||
public static String PDOMManager_JoinIndexerTask;
|
public static String PDOMManager_JoinIndexerTask;
|
||||||
|
|
|
@ -200,6 +200,13 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
return manager;
|
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 {
|
public IPDOM getPDOM(ICProject project) throws CoreException {
|
||||||
synchronized (fProjectToPDOM) {
|
synchronized (fProjectToPDOM) {
|
||||||
IProject rproject = project.getProject();
|
IProject rproject = project.getProject();
|
||||||
|
@ -227,16 +234,30 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdom == null) {
|
if (pdom == null) {
|
||||||
|
boolean fromScratch= false;
|
||||||
if (dbName == null) {
|
if (dbName == null) {
|
||||||
dbName = createNewDatabaseName(project);
|
dbName = createNewDatabaseName(project);
|
||||||
dbFile= fileFromDatabaseName(dbName);
|
dbFile= fileFromDatabaseName(dbName);
|
||||||
storeDatabaseName(rproject, dbName);
|
storeDatabaseName(rproject, dbName);
|
||||||
|
fromScratch= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean newPDOM= !dbFile.exists();
|
pdom= new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(rproject));
|
||||||
pdom = new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(rproject));
|
if (pdom.versionMismatch() || fromScratch) {
|
||||||
if(newPDOM) {
|
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);
|
writeProjectPDOMProperties(pdom, rproject);
|
||||||
|
pdom.releaseWriteLock();
|
||||||
}
|
}
|
||||||
pdom.addListener(this);
|
pdom.addListener(this);
|
||||||
}
|
}
|
||||||
|
@ -367,24 +388,22 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
IProject prj= project.getProject();
|
IProject prj= project.getProject();
|
||||||
try {
|
try {
|
||||||
synchronized (fIndexerMutex) {
|
synchronized (fIndexerMutex) {
|
||||||
PDOM pdom= (PDOM) getPDOM(project);
|
WritablePDOM pdom= (WritablePDOM) getPDOM(project);
|
||||||
Properties props= IndexerPreferences.getProperties(prj);
|
Properties props= IndexerPreferences.getProperties(prj);
|
||||||
IPDOMIndexer indexer= createIndexer(project, getIndexerId(project), props);
|
IPDOMIndexer indexer= createIndexer(project, getIndexerId(project), props);
|
||||||
|
|
||||||
boolean performImport= false;
|
boolean rebuild=
|
||||||
boolean rebuild= false;
|
pdom.isClearedBecauseOfVersionMismatch() ||
|
||||||
if (!IPDOMManager.ID_NO_INDEXER.equals(indexer.getID()) && pdom.isEmpty()) {
|
pdom.isCreatedFromScratch();
|
||||||
performImport= true;
|
if (rebuild) {
|
||||||
}
|
if (IPDOMManager.ID_NO_INDEXER.equals(indexer.getID())) {
|
||||||
else if (pdom.versionMismatch()) {
|
rebuild= false;
|
||||||
rebuild= true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!performImport) {
|
|
||||||
registerIndexer(project, indexer);
|
|
||||||
if (rebuild) {
|
|
||||||
enqueue(new PDOMRebuildTask(indexer));
|
|
||||||
}
|
}
|
||||||
|
pdom.setClearedBecauseOfVersionMismatch(false);
|
||||||
|
pdom.setCreatedFromScratch(false);
|
||||||
|
}
|
||||||
|
if (!rebuild) {
|
||||||
|
registerIndexer(project, indexer);
|
||||||
return;
|
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.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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 {
|
public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter) throws CoreException {
|
||||||
this(dbPath, locationConverter, ChunkCache.getSharedInstance());
|
this(dbPath, locationConverter, ChunkCache.getSharedInstance());
|
||||||
|
@ -125,4 +127,20 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
|
|
||||||
return notConverted;
|
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();
|
int version= getVersion();
|
||||||
removeChunksFromCache();
|
removeChunksFromCache();
|
||||||
|
|
||||||
// clear out memory headers
|
// clear the first chunk.
|
||||||
Chunk header= getChunk(0);
|
Chunk header= getChunk(0);
|
||||||
|
header.clear(0, CHUNK_SIZE);
|
||||||
setVersion(version);
|
setVersion(version);
|
||||||
header.clear(4, DATA_AREA - 4);
|
|
||||||
chunks = new Chunk[] {header};
|
chunks = new Chunk[] {header};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getChannel().truncate(CHUNK_SIZE);
|
getChannel().truncate(CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ PDOMManager_ClosePDOMJob=Close database
|
||||||
PDOMManager_notifyTask_message=Notify Listeners
|
PDOMManager_notifyTask_message=Notify Listeners
|
||||||
PDOMManager_indexMonitorDetail={0}/{1} sources, {2} headers
|
PDOMManager_indexMonitorDetail={0}/{1} sources, {2} headers
|
||||||
PDOMManager_ExistingFileCollides=A pdom already exists at location {0}
|
PDOMManager_ExistingFileCollides=A pdom already exists at location {0}
|
||||||
|
PDOMManager_creationOfIndexInterrupted=Creation of index was interrupted
|
||||||
Checksums_taskComputeChecksums=Computing checksums
|
Checksums_taskComputeChecksums=Computing checksums
|
||||||
TeamPDOMExportOperation_errorCreatingTempFile=Cannot create temp file
|
TeamPDOMExportOperation_errorCreatingTempFile=Cannot create temp file
|
||||||
TeamPDOMExportOperation_taskExportIndex=Export team shared index
|
TeamPDOMExportOperation_taskExportIndex=Export team shared index
|
||||||
|
|
Loading…
Add table
Reference in a new issue