mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Follow up 186755, fixes NPE, CCorePlugin.start() as similar to M7 as possible.
This commit is contained in:
parent
cd1c1d926f
commit
416223100d
4 changed files with 52 additions and 59 deletions
|
@ -277,7 +277,6 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
private static CProjectDescriptionManager fInstance;
|
||||
|
||||
private CProjectDescriptionManager(){
|
||||
fDescriptorManager= CConfigBasedDescriptorManager.getInstance();
|
||||
}
|
||||
|
||||
public static CProjectDescriptionManager getInstance(){
|
||||
|
@ -292,25 +291,28 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
return fInstance;
|
||||
}
|
||||
|
||||
public Job startup(){
|
||||
if(fRcChangeHandler == null){
|
||||
fRcChangeHandler = new ResourceChangeHandler();
|
||||
|
||||
public void registerResourceListener() {
|
||||
assert fRcChangeHandler == null;
|
||||
fRcChangeHandler = new ResourceChangeHandler();
|
||||
|
||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(
|
||||
fRcChangeHandler,
|
||||
IResourceChangeEvent.POST_CHANGE
|
||||
| IResourceChangeEvent.PRE_DELETE
|
||||
| IResourceChangeEvent.PRE_CLOSE
|
||||
/*| IResourceChangeEvent.POST_BUILD*/);
|
||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(
|
||||
fRcChangeHandler,
|
||||
IResourceChangeEvent.POST_CHANGE
|
||||
| IResourceChangeEvent.PRE_DELETE
|
||||
| IResourceChangeEvent.PRE_CLOSE
|
||||
/*| IResourceChangeEvent.POST_BUILD*/);
|
||||
|
||||
if(fDescriptorManager == null){
|
||||
fDescriptorManager = CConfigBasedDescriptorManager.getInstance();
|
||||
fDescriptorManager.startup();
|
||||
}
|
||||
|
||||
CExternalSettingsManager.getInstance().startup();
|
||||
}
|
||||
return createPostStartupJob();
|
||||
}
|
||||
|
||||
public void startup(){
|
||||
assert fRcChangeHandler != null;
|
||||
fDescriptorManager.startup();
|
||||
|
||||
CExternalSettingsManager.getInstance().startup();
|
||||
|
||||
private Job createPostStartupJob() {
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
Job rcJob = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.0")){ //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
|
@ -332,7 +334,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
rcJob.setRule(root);
|
||||
rcJob.setPriority(Job.INTERACTIVE);
|
||||
rcJob.setSystem(true);
|
||||
rcJob.schedule();
|
||||
return rcJob;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
*/
|
||||
public final class IndexProviderManager implements IElementChangedListener {
|
||||
public static final String READ_ONLY_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$
|
||||
private IIndexFragmentProvider[] allProviders;
|
||||
private IIndexFragmentProvider[] allProviders= {};
|
||||
private Map provisionMap= new HashMap();
|
||||
|
||||
public IndexProviderManager() {
|
||||
|
|
|
@ -166,11 +166,24 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
private HashMap fUpdatePolicies= new HashMap();
|
||||
private HashMap fPrefListeners= new HashMap();
|
||||
|
||||
/**
|
||||
* Startup the PDOM. This mainly sets us up to handle model
|
||||
* change events.
|
||||
public Job startup() {
|
||||
Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
postStartup();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
public boolean belongsTo(Object family) {
|
||||
return family == PDOMManager.this;
|
||||
}
|
||||
};
|
||||
postStartupJob.setSystem(true);
|
||||
return postStartupJob;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from a job after plugin start.
|
||||
*/
|
||||
public void startup() {
|
||||
protected void postStartup() {
|
||||
// the model listener is attached outside of the job in
|
||||
// order to avoid a race condition where its not noticed
|
||||
// that new projects are being created
|
||||
|
@ -899,7 +912,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
}
|
||||
try {
|
||||
try {
|
||||
CCorePlugin.getDefault().joinStartup(monitor);
|
||||
Job.getJobManager().join(this, monitor);
|
||||
return true;
|
||||
} catch (OperationCanceledException e1) {
|
||||
|
|
|
@ -336,49 +336,32 @@ public class CCorePlugin extends Plugin {
|
|||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
|
||||
// make sure to register the resource listener as the first one in CDT:
|
||||
// do harmless stuff first.
|
||||
cdtLog = new CDTLogWriter(CCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$
|
||||
configurePluginDebugOptions();
|
||||
getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
||||
PositionTrackerManager.getInstance().install();
|
||||
|
||||
// new project model needs to register the resource listener first.
|
||||
fNewCProjectDescriptionManager= CProjectDescriptionManager.getInstance();
|
||||
fNewCProjectDescriptionManager.registerResourceListener();
|
||||
final Job post1= fNewCProjectDescriptionManager.startup();
|
||||
|
||||
fPathEntryVariableManager = new CdtVarPathEntryVariableManager();
|
||||
cdtLog = new CDTLogWriter(CCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$
|
||||
fPathEntryVariableManager.startup();
|
||||
|
||||
fCoreModel = CoreModel.getDefault();
|
||||
fCoreModel.startup();
|
||||
|
||||
// Fire up the PDOM
|
||||
pdomManager = new PDOMManager();
|
||||
|
||||
//Set debug tracing options
|
||||
configurePluginDebugOptions();
|
||||
final Job post2= pdomManager.startup();
|
||||
|
||||
// Set the default for using the structual parse mode to build the CModel
|
||||
getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
||||
|
||||
PositionTrackerManager.getInstance().install();
|
||||
|
||||
// bug 186755, when started after the platform has been started the jobmanager
|
||||
// is no longer suspended. So we have to start a job at the very end to make
|
||||
// sure we don't trigger a concurrent plugin activation from within the job.
|
||||
Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
postStart();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
public boolean belongsTo(Object family) {
|
||||
return family == CCorePlugin.this;
|
||||
}
|
||||
};
|
||||
postStartupJob.setSystem(true);
|
||||
postStartupJob.schedule();
|
||||
post1.schedule();
|
||||
post2.schedule();
|
||||
}
|
||||
|
||||
|
||||
protected void postStart() {
|
||||
fNewCProjectDescriptionManager.startup();
|
||||
fPathEntryVariableManager.startup();
|
||||
CoreModel.getDefault().startup();
|
||||
pdomManager.startup();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Add all options here
|
||||
* Returns a table of all known configurable options with their default values.
|
||||
|
@ -1263,8 +1246,4 @@ public class CCorePlugin extends Plugin {
|
|||
public ICProjectDescriptionManager getProjectDescriptionManager(){
|
||||
return fNewCProjectDescriptionManager;
|
||||
}
|
||||
|
||||
public void joinStartup(IProgressMonitor monitor) throws OperationCanceledException, InterruptedException {
|
||||
Job.getJobManager().join(this, monitor);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue