1
0
Fork 0
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:
Markus Schorn 2007-05-15 12:15:56 +00:00
parent cd1c1d926f
commit 416223100d
4 changed files with 52 additions and 59 deletions

View file

@ -277,7 +277,6 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
private static CProjectDescriptionManager fInstance; private static CProjectDescriptionManager fInstance;
private CProjectDescriptionManager(){ private CProjectDescriptionManager(){
fDescriptorManager= CConfigBasedDescriptorManager.getInstance();
} }
public static CProjectDescriptionManager getInstance(){ public static CProjectDescriptionManager getInstance(){
@ -292,25 +291,28 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
return fInstance; return fInstance;
} }
public Job startup(){
if(fRcChangeHandler == null){
fRcChangeHandler = new ResourceChangeHandler();
public void registerResourceListener() { ResourcesPlugin.getWorkspace().addResourceChangeListener(
assert fRcChangeHandler == null; fRcChangeHandler,
fRcChangeHandler = new ResourceChangeHandler(); IResourceChangeEvent.POST_CHANGE
| IResourceChangeEvent.PRE_DELETE
ResourcesPlugin.getWorkspace().addResourceChangeListener( | IResourceChangeEvent.PRE_CLOSE
fRcChangeHandler, /*| IResourceChangeEvent.POST_BUILD*/);
IResourceChangeEvent.POST_CHANGE
| IResourceChangeEvent.PRE_DELETE if(fDescriptorManager == null){
| IResourceChangeEvent.PRE_CLOSE fDescriptorManager = CConfigBasedDescriptorManager.getInstance();
/*| IResourceChangeEvent.POST_BUILD*/); fDescriptorManager.startup();
}
CExternalSettingsManager.getInstance().startup();
}
return createPostStartupJob();
} }
public void startup(){ private Job createPostStartupJob() {
assert fRcChangeHandler != null;
fDescriptorManager.startup();
CExternalSettingsManager.getInstance().startup();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Job rcJob = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.0")){ //$NON-NLS-1$ Job rcJob = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.0")){ //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
@ -332,7 +334,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
rcJob.setRule(root); rcJob.setRule(root);
rcJob.setPriority(Job.INTERACTIVE); rcJob.setPriority(Job.INTERACTIVE);
rcJob.setSystem(true); rcJob.setSystem(true);
rcJob.schedule(); return rcJob;
} }
/* /*

View file

@ -47,7 +47,7 @@ import org.eclipse.core.runtime.Platform;
*/ */
public final class IndexProviderManager implements IElementChangedListener { public final class IndexProviderManager implements IElementChangedListener {
public static final String READ_ONLY_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$ public static final String READ_ONLY_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$
private IIndexFragmentProvider[] allProviders; private IIndexFragmentProvider[] allProviders= {};
private Map provisionMap= new HashMap(); private Map provisionMap= new HashMap();
public IndexProviderManager() { public IndexProviderManager() {

View file

@ -166,11 +166,24 @@ public class PDOMManager implements IWritableIndexManager, IListener {
private HashMap fUpdatePolicies= new HashMap(); private HashMap fUpdatePolicies= new HashMap();
private HashMap fPrefListeners= new HashMap(); private HashMap fPrefListeners= new HashMap();
/** public Job startup() {
* Startup the PDOM. This mainly sets us up to handle model Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$
* change events. 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 // the model listener is attached outside of the job in
// order to avoid a race condition where its not noticed // order to avoid a race condition where its not noticed
// that new projects are being created // that new projects are being created
@ -899,7 +912,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
} }
try { try {
try { try {
CCorePlugin.getDefault().joinStartup(monitor);
Job.getJobManager().join(this, monitor); Job.getJobManager().join(this, monitor);
return true; return true;
} catch (OperationCanceledException e1) { } catch (OperationCanceledException e1) {

View file

@ -336,49 +336,32 @@ public class CCorePlugin extends Plugin {
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
super.start(context); 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= CProjectDescriptionManager.getInstance();
fNewCProjectDescriptionManager.registerResourceListener(); final Job post1= fNewCProjectDescriptionManager.startup();
fPathEntryVariableManager = new CdtVarPathEntryVariableManager(); fPathEntryVariableManager = new CdtVarPathEntryVariableManager();
cdtLog = new CDTLogWriter(CCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$ fPathEntryVariableManager.startup();
fCoreModel = CoreModel.getDefault(); fCoreModel = CoreModel.getDefault();
fCoreModel.startup();
// Fire up the PDOM
pdomManager = new PDOMManager(); pdomManager = new PDOMManager();
final Job post2= pdomManager.startup();
//Set debug tracing options
configurePluginDebugOptions();
// 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 // 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 // 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. // sure we don't trigger a concurrent plugin activation from within the job.
Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$ post1.schedule();
protected IStatus run(IProgressMonitor monitor) { post2.schedule();
postStart();
return Status.OK_STATUS;
}
public boolean belongsTo(Object family) {
return family == CCorePlugin.this;
}
};
postStartupJob.setSystem(true);
postStartupJob.schedule();
} }
protected void postStart() {
fNewCProjectDescriptionManager.startup();
fPathEntryVariableManager.startup();
CoreModel.getDefault().startup();
pdomManager.startup();
}
/** /**
* TODO: Add all options here * TODO: Add all options here
* Returns a table of all known configurable options with their default values. * Returns a table of all known configurable options with their default values.
@ -1263,8 +1246,4 @@ public class CCorePlugin extends Plugin {
public ICProjectDescriptionManager getProjectDescriptionManager(){ public ICProjectDescriptionManager getProjectDescriptionManager(){
return fNewCProjectDescriptionManager; return fNewCProjectDescriptionManager;
} }
public void joinStartup(IProgressMonitor monitor) throws OperationCanceledException, InterruptedException {
Job.getJobManager().join(this, monitor);
}
} }