From 0bbd5519cf172075202b4b98a5572e5a30d9d63d Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 14 May 2007 13:32:48 +0000 Subject: [PATCH] Fix for 186755 activation of CorePlugin --- .../model/CProjectDescriptionManager.java | 8 +-- .../index/provider/IndexProviderManager.java | 4 ++ .../cdt/internal/core/pdom/PDOMManager.java | 3 + .../src/org/eclipse/cdt/core/CCorePlugin.java | 63 ++++++++++++------- .../core/CCorePluginResources.properties | 1 + 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 63837b10c24..aaa44e1895a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -7,6 +7,7 @@ * * Contributors: * Intel Corporation - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; @@ -276,7 +277,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { private static CProjectDescriptionManager fInstance; private CProjectDescriptionManager(){ - + fDescriptorManager= CConfigBasedDescriptorManager.getInstance(); } public static CProjectDescriptionManager getInstance(){ @@ -296,10 +297,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { | IResourceChangeEvent.PRE_CLOSE /*| IResourceChangeEvent.POST_BUILD*/); - if(fDescriptorManager == null){ - fDescriptorManager = CConfigBasedDescriptorManager.getInstance(); - fDescriptorManager.startup(); - } + fDescriptorManager.startup(); CExternalSettingsManager.getInstance().startup(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java index 6343148500f..ddc8f0b8aeb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java @@ -7,6 +7,7 @@ * * Contributors: * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.provider; @@ -50,6 +51,9 @@ public final class IndexProviderManager implements IElementChangedListener { private Map provisionMap= new HashMap(); public IndexProviderManager() { + } + + public void startup() { List providers = new ArrayList(); IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 74c271e81d2..2c3d51a3842 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -176,6 +176,8 @@ public class PDOMManager implements IWritableIndexManager, IListener { // that new projects are being created initializeDatabaseCache(); + fIndexProviderManager.startup(); + final CoreModel model = CoreModel.getDefault(); ResourcesPlugin.getWorkspace().addResourceChangeListener(fCModelListener, IResourceChangeEvent.POST_BUILD); model.addElementChangedListener(fCModelListener); @@ -897,6 +899,7 @@ public class PDOMManager implements IWritableIndexManager, IListener { } try { try { + CCorePlugin.getDefault().joinStartup(monitor); Job.getJobManager().join(this, monitor); return true; } catch (OperationCanceledException e1) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index fa60279a3fb..622cbfa1bbc 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -41,7 +41,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.util.CDataUtil; -import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager; import org.eclipse.cdt.internal.core.CContentTypes; import org.eclipse.cdt.internal.core.CDTLogWriter; import org.eclipse.cdt.internal.core.CdtVarPathEntryVariableManager; @@ -76,6 +75,7 @@ import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.core.runtime.jobs.Job; import org.osgi.framework.BundleContext; public class CCorePlugin extends Plugin { @@ -191,9 +191,7 @@ public class CCorePlugin extends Plugin { private static CCorePlugin fgCPlugin; private static ResourceBundle fgResourceBundle; - private CConfigBasedDescriptorManager/*CDescriptorManager*/ fDescriptorManager;// = new CDescriptorManager(); - - private CProjectDescriptionManager fNewCProjectDescriptionManager = CProjectDescriptionManager.getInstance(); + private CProjectDescriptionManager fNewCProjectDescriptionManager; private CoreModel fCoreModel; @@ -325,7 +323,6 @@ public class CCorePlugin extends Plugin { } fNewCProjectDescriptionManager.shutdown(); - fDescriptorManager = null; savePluginPreferences(); } finally { @@ -339,37 +336,51 @@ public class CCorePlugin extends Plugin { public void start(BundleContext context) throws Exception { super.start(context); - fNewCProjectDescriptionManager.startup(); - fDescriptorManager = fNewCProjectDescriptionManager.getDescriptorManager(); + fNewCProjectDescriptionManager= CProjectDescriptionManager.getInstance(); // Start file type manager first !! fPathEntryVariableManager = new CdtVarPathEntryVariableManager(); - fPathEntryVariableManager.startup(); cdtLog = new CDTLogWriter(CCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$ - - //Set debug tracing options - configurePluginDebugOptions(); - -// fDescriptorManager.startup(); -// CProjectDescriptionManager.getInstance().startup(); - - // Fired up the model. + fCoreModel = CoreModel.getDefault(); - fCoreModel.startup(); // Fire up the PDOM pdomManager = new PDOMManager(); - 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 + // 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(); } - /** + 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. * These options allow to configure the behaviour of the underlying components. @@ -705,7 +716,7 @@ public class CCorePlugin extends Plugin { * @deprecated use getCProjetDescription(IProject project, boolean create) */ public ICDescriptor getCProjectDescription(IProject project) throws CoreException { - return fDescriptorManager.getDescriptor(project); + return fNewCProjectDescriptionManager.getDescriptorManager().getDescriptor(project); } /** @@ -718,19 +729,19 @@ public class CCorePlugin extends Plugin { * @throws CoreException */ public ICDescriptor getCProjectDescription(IProject project, boolean create) throws CoreException { - return fDescriptorManager.getDescriptor(project, create); + return fNewCProjectDescriptionManager.getDescriptorManager().getDescriptor(project, create); } public void mapCProjectOwner(IProject project, String id, boolean override) throws CoreException { if (!override) { - fDescriptorManager.configure(project, id); + fNewCProjectDescriptionManager.getDescriptorManager().configure(project, id); } else { - fDescriptorManager.convert(project, id); + fNewCProjectDescriptionManager.getDescriptorManager().convert(project, id); } } public ICDescriptorManager getCDescriptorManager() { - return fDescriptorManager; + return fNewCProjectDescriptionManager.getDescriptorManager(); } /** @@ -1253,4 +1264,8 @@ public class CCorePlugin extends Plugin { public ICProjectDescriptionManager getProjectDescriptionManager(){ return fNewCProjectDescriptionManager; } + + public void joinStartup(IProgressMonitor monitor) throws OperationCanceledException, InterruptedException { + Job.getJobManager().join(this, monitor); + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties index 7f773c65389..36862fbdf75 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties @@ -84,3 +84,4 @@ CConfigBasedDescriptorManager.2=can not perform descriptor operation based on th CConfigBasedDescriptorManager.3=Failed to create descriptor CConfigBasedDescriptorManager.4=error: read-only configuration can not be used for CDescriptor CConfigBasedDescriptorManager.5=the project does not contain valid configurations +CCorePlugin.startupJob=CDT Startup