mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 141509 - Handle project import where the project gets added and then later the project preferences get loaded.
This commit is contained in:
parent
8edd645f62
commit
48740f50ec
2 changed files with 33 additions and 31 deletions
|
@ -43,7 +43,7 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent;
|
||||
|
||||
/**
|
||||
* The PDOM Provider. This is likely temporary since I hope
|
||||
|
@ -131,15 +131,28 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
break;
|
||||
case ICElement.C_PROJECT:
|
||||
// Find the appropriate indexer and pass the delta on
|
||||
ICProject project = (ICProject)delta.getElement();
|
||||
if (delta.getKind() != ICElementDelta.REMOVED) {
|
||||
if (project.getProject().exists()) {
|
||||
final ICProject project = (ICProject)delta.getElement();
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
prefs.addNodeChangeListener(new IEclipsePreferences.INodeChangeListener() {
|
||||
public void added(NodeChangeEvent event) {
|
||||
String indexerId = event.getParent().get(INDEXER_ID_KEY, null);
|
||||
try {
|
||||
createIndexer(project, indexerId);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
public void removed(NodeChangeEvent event) {
|
||||
}
|
||||
});
|
||||
break;
|
||||
case ICElementDelta.CHANGED:
|
||||
IPDOMIndexer indexer = getIndexer(project);
|
||||
if (indexer != null)
|
||||
// TODO project delete, should do something fancier here.
|
||||
indexer.handleDelta(delta);
|
||||
}
|
||||
}
|
||||
// TODO handle delete too.
|
||||
}
|
||||
}
|
||||
|
@ -162,10 +175,6 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
return; // TODO why would this be null?
|
||||
|
||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public String getIndexerId(ICProject project) throws CoreException {
|
||||
|
@ -196,16 +205,11 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
// if Indexer still null schedule a job to get it
|
||||
if (indexerId == null || indexerId.equals(CtagsIndexer.ID))
|
||||
// make it the default, ctags is gone
|
||||
indexerId = getDefaultIndexerId();
|
||||
|
||||
// Start a job to set the id.
|
||||
new SetIndexerId(project, indexerId).schedule();
|
||||
} else if (indexerId.equals(CtagsIndexer.ID)) {
|
||||
// make it the default, ctags is gone
|
||||
indexerId = getDefaultIndexerId();
|
||||
|
||||
// Start a job to set the id.
|
||||
new SetIndexerId(project, indexerId).schedule();
|
||||
}
|
||||
|
@ -223,9 +227,12 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
this.project = project;
|
||||
this.indexerId = indexerId;
|
||||
setSystem(true);
|
||||
setRule(project.getProject());
|
||||
}
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs == null || prefs.get(INDEXER_ID_KEY, null) == null)
|
||||
setIndexerId(project, indexerId);
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
|
@ -242,11 +249,6 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
String oldId = prefs.get(INDEXER_ID_KEY, null);
|
||||
if (!indexerId.equals(oldId)) {
|
||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
|
||||
createIndexer(project, indexerId).reindex();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
|||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
||||
System.out.println("PDOM Full Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||
System.out.println("PDOM Fast Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
|
Loading…
Add table
Reference in a new issue