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.IEclipsePreferences;
|
||||||
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
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
|
* The PDOM Provider. This is likely temporary since I hope
|
||||||
|
@ -131,14 +131,27 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
break;
|
break;
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
// Find the appropriate indexer and pass the delta on
|
// Find the appropriate indexer and pass the delta on
|
||||||
ICProject project = (ICProject)delta.getElement();
|
final ICProject project = (ICProject)delta.getElement();
|
||||||
if (delta.getKind() != ICElementDelta.REMOVED) {
|
switch (delta.getKind()) {
|
||||||
if (project.getProject().exists()) {
|
case ICElementDelta.ADDED:
|
||||||
IPDOMIndexer indexer = getIndexer(project);
|
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||||
if (indexer != null)
|
prefs.addNodeChangeListener(new IEclipsePreferences.INodeChangeListener() {
|
||||||
// TODO project delete, should do something fancier here.
|
public void added(NodeChangeEvent event) {
|
||||||
indexer.handleDelta(delta);
|
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)
|
||||||
|
indexer.handleDelta(delta);
|
||||||
}
|
}
|
||||||
// TODO handle delete too.
|
// TODO handle delete too.
|
||||||
}
|
}
|
||||||
|
@ -162,10 +175,6 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
return; // TODO why would this be null?
|
return; // TODO why would this be null?
|
||||||
|
|
||||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||||
try {
|
|
||||||
prefs.flush();
|
|
||||||
} catch (BackingStoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexerId(ICProject project) throws CoreException {
|
public String getIndexerId(ICProject project) throws CoreException {
|
||||||
|
@ -196,17 +205,12 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexerId == null || indexerId.equals(CtagsIndexer.ID))
|
// if Indexer still null schedule a job to get it
|
||||||
// make it the default, ctags is gone
|
if (indexerId == null || indexerId.equals(CtagsIndexer.ID))
|
||||||
indexerId = getDefaultIndexerId();
|
// make it the default, ctags is gone
|
||||||
|
indexerId = getDefaultIndexerId();
|
||||||
// Start a job to set the id.
|
|
||||||
new SetIndexerId(project, indexerId).schedule();
|
// Start a job to set the id.
|
||||||
} 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();
|
new SetIndexerId(project, indexerId).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,10 +227,13 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.indexerId = indexerId;
|
this.indexerId = indexerId;
|
||||||
setSystem(true);
|
setSystem(true);
|
||||||
|
setRule(project.getProject());
|
||||||
}
|
}
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
setIndexerId(project, indexerId);
|
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;
|
return Status.OK_STATUS;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
|
@ -242,11 +249,6 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
String oldId = prefs.get(INDEXER_ID_KEY, null);
|
String oldId = prefs.get(INDEXER_ID_KEY, null);
|
||||||
if (!indexerId.equals(oldId)) {
|
if (!indexerId.equals(oldId)) {
|
||||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||||
try {
|
|
||||||
prefs.flush();
|
|
||||||
} catch (BackingStoreException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
createIndexer(project, indexerId).reindex();
|
createIndexer(project, indexerId).reindex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$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) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue