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 static CProjectDescriptionManager fInstance;
|
||||||
|
|
||||||
private CProjectDescriptionManager(){
|
private CProjectDescriptionManager(){
|
||||||
fDescriptorManager= CConfigBasedDescriptorManager.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CProjectDescriptionManager getInstance(){
|
public static CProjectDescriptionManager getInstance(){
|
||||||
|
@ -292,9 +291,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Job startup(){
|
||||||
public void registerResourceListener() {
|
if(fRcChangeHandler == null){
|
||||||
assert fRcChangeHandler == null;
|
|
||||||
fRcChangeHandler = new ResourceChangeHandler();
|
fRcChangeHandler = new ResourceChangeHandler();
|
||||||
|
|
||||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(
|
ResourcesPlugin.getWorkspace().addResourceChangeListener(
|
||||||
|
@ -303,14 +301,18 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
| IResourceChangeEvent.PRE_DELETE
|
| IResourceChangeEvent.PRE_DELETE
|
||||||
| IResourceChangeEvent.PRE_CLOSE
|
| IResourceChangeEvent.PRE_CLOSE
|
||||||
/*| IResourceChangeEvent.POST_BUILD*/);
|
/*| IResourceChangeEvent.POST_BUILD*/);
|
||||||
|
|
||||||
|
if(fDescriptorManager == null){
|
||||||
|
fDescriptorManager = CConfigBasedDescriptorManager.getInstance();
|
||||||
|
fDescriptorManager.startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startup(){
|
|
||||||
assert fRcChangeHandler != null;
|
|
||||||
fDescriptorManager.startup();
|
|
||||||
|
|
||||||
CExternalSettingsManager.getInstance().startup();
|
CExternalSettingsManager.getInstance().startup();
|
||||||
|
}
|
||||||
|
return createPostStartupJob();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Job createPostStartupJob() {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -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() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startup the PDOM. This mainly sets us up to handle model
|
* Called from a job after plugin start.
|
||||||
* change events.
|
|
||||||
*/
|
*/
|
||||||
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) {
|
||||||
|
|
|
@ -336,47 +336,30 @@ 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue