From cb19d69cff545bb219ce76311067b2d5c6387e93 Mon Sep 17 00:00:00 2001 From: Mikhail Sennikovsky Date: Tue, 17 Apr 2007 11:14:13 +0000 Subject: [PATCH] 1. Fix for [Bug 182711] [Project Model] CoreModel.create(IFile) cannot be used in jobs 2. External setting provider mechanism 3. other bug-fixes --- .../model/ExternalSettingsProviderTests.java | 97 ++++++++++++++++ .../settings/model/TestCfgDataProvider.java | 17 +++ .../model/TestExtSettingsProvider.java | 43 ++++++++ .../index/tests/IndexProviderManagerTest.java | 10 ++ core/org.eclipse.cdt.core.tests/plugin.xml | 17 ++- .../cdt/core/testplugin/CProjectHelper.java | 44 ++++++++ .../org/eclipse/cdt/core/model/CoreModel.java | 9 ++ .../model/CProjectDescriptionEvent.java | 9 +- .../model/ICConfigurationDescription.java | 4 + .../model/ICProjectDescriptionListener.java | 3 +- .../core/settings/model/util/CEntriesSet.java | 4 +- .../settings/model/util/KindBasedStore.java | 11 +- .../LanguageSettingEntriesSerializer.java | 8 +- .../core/model/PathEntryStoreProxy.java | 2 +- .../model/AbstractCExtensionProxy.java | 2 + .../model/CConfigurationDescription.java | 17 +++ .../model/CConfigurationDescriptionCache.java | 10 ++ .../model/CConfigurationSpecSettings.java | 9 ++ .../CExternalSettingsDeltaProcessor.java | 65 ++++++++--- .../model/CExternalSettingsHolder.java | 13 ++- .../model/CExternalSettingsManager.java | 75 +++++++++---- .../core/settings/model/CLanguageSetting.java | 5 +- .../model/CProjectDescriptionDelta.java | 4 +- .../model/CProjectDescriptionManager.java | 8 +- .../core/settings/model/CSettingsRefInfo.java | 14 +++ .../CfgExportSettingContainerFactory.java | 2 + .../model/ConfigBasedPathEntryStore.java | 2 + .../model/DescriptionScannerInfoProvider.java | 2 + .../model/ExtensionContainerFactory.java | 56 +++++++++- .../model/ScannerInfoProviderProxy.java | 1 + .../SetCProjectDescriptionOperation.java | 1 + core/org.eclipse.cdt.core/plugin.xml | 1 + .../schema/externalSettingsProvider.exsd | 104 ++++++++++++++++++ .../core/CConfigBasedDescriptorManager.java | 4 +- 34 files changed, 615 insertions(+), 58 deletions(-) create mode 100644 core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java create mode 100644 core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java create mode 100644 core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java rename core/org.eclipse.cdt.core/model/org/eclipse/cdt/{internal => }/core/settings/model/CProjectDescriptionEvent.java (92%) rename core/org.eclipse.cdt.core/model/org/eclipse/cdt/{internal => }/core/settings/model/ICProjectDescriptionListener.java (92%) create mode 100644 core/org.eclipse.cdt.core/schema/externalSettingsProvider.exsd diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java new file mode 100644 index 00000000000..f58651d90c8 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +import java.util.Arrays; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.dom.IPDOMManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; + +public class ExternalSettingsProviderTests extends BaseTestCase{ + private static final String PROJ_NAME_PREFIX = "espt_"; + ICProject p1; + + public static TestSuite suite() { + return suite(ExternalSettingsProviderTests.class, "_"); + } + + protected void setUp() throws Exception { + p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); + } + + public void testRefs() throws Exception { + CoreModel model = CoreModel.getDefault(); + IProject project = p1.getProject(); + + ICProjectDescription des = model.getProjectDescription(project); + ICConfigurationDescription cfgDes = des.getConfigurations()[0]; + ICLanguageSetting ls = cfgDes.getLanguageSettingForFile(new Path("a.c"), true); + ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + assertEquals(0, entries.length); + String[] extPIds = new String[]{CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider"}; + cfgDes.setExternalSettingsProviderIds(extPIds); + assertEquals(extPIds.length, cfgDes.getExternalSettingsProviderIds().length); + assertTrue(Arrays.equals(extPIds, cfgDes.getExternalSettingsProviderIds())); + entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + assertEquals(2, entries.length); + ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[]{ + new CIncludePathEntry("ip_a", 0), + new CIncludePathEntry("ip_b", 0), + }; + assertTrue(Arrays.equals(expectedEntries, entries)); + + ICLanguageSettingEntry[] newEntries = new ICLanguageSettingEntry[3]; + newEntries[0] = expectedEntries[1]; + newEntries[1] = new CIncludePathEntry("added", 0); + newEntries[2] = expectedEntries[0]; + + ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, newEntries); + entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + + assertEquals(3, entries.length); + assertTrue(Arrays.equals(newEntries, entries)); + + newEntries = new ICLanguageSettingEntry[1]; + newEntries[0] = expectedEntries[0]; + ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, newEntries); + entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + + assertEquals(1, entries.length); + assertTrue(Arrays.equals(newEntries, entries)); + + newEntries = new ICLanguageSettingEntry[0]; + ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, newEntries); + entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + + assertEquals(0, entries.length); + + ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, (ICLanguageSettingEntry[])null); + entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + assertEquals(2, entries.length); + assertTrue(Arrays.equals(expectedEntries, entries)); + } + + protected void tearDown() throws Exception { + try { + p1.getProject().delete(true, null); + } catch (CoreException e){ + } + } +} diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java new file mode 100644 index 00000000000..6e7aa6c2d51 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationDataProvider; + +public class TestCfgDataProvider extends CDefaultConfigurationDataProvider { + +} diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java new file mode 100644 index 00000000000..f49ffc7f6ff --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +import org.eclipse.cdt.core.settings.model.extension.CExternalSettingProvider; +import org.eclipse.core.resources.IProject; + +public class TestExtSettingsProvider extends CExternalSettingProvider { + private static CExternalSetting[] SETTINGS = new CExternalSetting[]{ + new CExternalSetting(null, null, null, new ICSettingEntry[]{ + new CIncludePathEntry("ip_a", 0), + new CIncludePathEntry("ip_b", 0), + new CIncludeFileEntry("if_a", 0), + new CIncludeFileEntry("if_b", 0), + new CMacroEntry("m_a", "mv_a", 0), + new CMacroEntry("m_b", "mv_b", 0), + new CMacroFileEntry("mf_a", 0), + new CMacroFileEntry("mf_b", 0), + new CLibraryPathEntry("lp_a", 0), + new CLibraryPathEntry("lp_b", 0), + new CLibraryFileEntry("lf_a", 0), + new CLibraryFileEntry("lf_b", 0), + new CSourceEntry("sp_a", null, 0), + new CSourceEntry("sp_b", null, 0), + new COutputEntry("op_a", null, 0), + new COutputEntry("op_b", null, 0), + }) + }; + + public CExternalSetting[] getSettings(IProject project, + ICConfigurationDescription cfg) { + return (CExternalSetting[])SETTINGS.clone(); + } + +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java index 96f628ce7cf..30537c73ce3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java @@ -449,6 +449,16 @@ class MockConfig implements ICConfigurationDescription { public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) { return null; } + + public String[] getExternalSettingsProviderIds() { + // TODO Auto-generated method stub + return null; + } + + public void setExternalSettingsProviderIds(String[] ids) { + // TODO Auto-generated method stub + + } } /* diff --git a/core/org.eclipse.cdt.core.tests/plugin.xml b/core/org.eclipse.cdt.core.tests/plugin.xml index f7ac96e4f81..1f18da7ae6e 100644 --- a/core/org.eclipse.cdt.core.tests/plugin.xml +++ b/core/org.eclipse.cdt.core.tests/plugin.xml @@ -45,5 +45,20 @@ class="org.eclipse.cdt.internal.pdom.tests.GeneratePDOMApplicationTest$TestProjectProvider4"> - + + + + + + + + + diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java index 9c9621d699c..0e32661c6c7 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java @@ -32,6 +32,9 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -104,6 +107,47 @@ public class CProjectHelper { return newProject[0]; } + /** + * Creates a ICProject. + */ + public static ICProject createNewStileCProject(final String projectName, final String indexerID) throws CoreException { + final IWorkspace ws = ResourcesPlugin.getWorkspace(); + final ICProject newProject[] = new ICProject[1]; + ws.run(new IWorkspaceRunnable() { + + public void run(IProgressMonitor monitor) throws CoreException { + IWorkspaceRoot root = ws.getRoot(); + IProject project = root.getProject(projectName); + if (indexerID != null) { + IndexerPreferences.set(project, IndexerPreferences.KEY_INDEX_ALL_FILES, "true"); + IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, indexerID); + } + if (!project.exists()) { + project.create(null); + } else { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } + if (!project.isOpen()) { + project.open(null); + } + if (!project.hasNature(CProjectNature.C_NATURE_ID)) { + + String cfgProviderId = CTestPlugin.PLUGIN_ID + ".testCfgDataProvider"; + addNatureToProject(project, CProjectNature.C_NATURE_ID, null); + ICConfigurationDescription prefCfg = CCorePlugin.getDefault().getPreferenceConfiguration(cfgProviderId); + ICProjectDescription projDes = CCorePlugin.getDefault().createProjectDescription(project, false); + projDes.createConfiguration(CDataUtil.genId(null), CDataUtil.genId("test"), prefCfg); + CCorePlugin.getDefault().setProjectDescription(project, projDes); +// CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false); + } + newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project); + } + }, null); + + return newProject[0]; + } + + private static String getMessage(IStatus status) { StringBuffer message = new StringBuffer("["); message.append(status.getMessage()); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 7cafc32220d..3aedfc592cd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.internal.core.model.APathEntry; import org.eclipse.cdt.internal.core.model.BatchOperation; @@ -1421,4 +1422,12 @@ public class CoreModel { public boolean isNewStyleProject(ICProjectDescription des){ return descriptionManager.isNewStyleProject(des); } + + public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){ + descriptionManager.addListener(listener, eventTypes); + } + + public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){ + descriptionManager.removeListener(listener); + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java similarity index 92% rename from core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java index 8707ec41f64..62424a25d8e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java @@ -8,11 +8,12 @@ * Contributors: * Intel Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.core.settings.model; +package org.eclipse.cdt.core.settings.model; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.core.settings.model.ICSettingObject; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionDelta; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta; import org.eclipse.core.resources.IProject; public final class CProjectDescriptionEvent { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java index c0f09f9b464..29b3bbceac9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java @@ -361,4 +361,8 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin * @return ICLanguageSetting or null if not found */ ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus); + + void setExternalSettingsProviderIds(String ids[]); + + String[] getExternalSettingsProviderIds(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionListener.java similarity index 92% rename from core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionListener.java index 06ff6b3559f..651519ac6c5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionListener.java @@ -8,7 +8,8 @@ * Contributors: * Intel Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.core.settings.model; +package org.eclipse.cdt.core.settings.model; + public interface ICProjectDescriptionListener { void handleEvent(CProjectDescriptionEvent event); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java index f8539fbeac2..d9901f6e5bf 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model.util; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import org.eclipse.cdt.core.settings.model.ICSettingEntry; public class CEntriesSet { - private HashMap fEntriesMap = new HashMap(); + private LinkedHashMap fEntriesMap = new LinkedHashMap(); public CEntriesSet(){ } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java index 1dbb454eda8..05fd25ce13b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java @@ -34,7 +34,16 @@ public class KindBasedStore implements Cloneable { | ICLanguageSettingEntry.LIBRARY_PATH | ICLanguageSettingEntry.LIBRARY_FILE; - + public static final int ORED_ALL_ENTRY_KINDS = + ICLanguageSettingEntry.INCLUDE_PATH + | ICLanguageSettingEntry.INCLUDE_FILE + | ICLanguageSettingEntry.MACRO + | ICLanguageSettingEntry.MACRO_FILE + | ICLanguageSettingEntry.LIBRARY_PATH + | ICLanguageSettingEntry.LIBRARY_FILE + | ICLanguageSettingEntry.SOURCE_PATH + | ICLanguageSettingEntry.OUTPUT_PATH; + private static final int LANG_ENTRY_KINDS[] = new int[]{ ICLanguageSettingEntry.INCLUDE_PATH, ICLanguageSettingEntry.INCLUDE_FILE, diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java index 689e9de8ae2..00338cfd8fc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java @@ -148,9 +148,11 @@ public class LanguageSettingEntriesSerializer { public static void serializeEntries(ICSettingEntry entries[], ICStorageElement element){ ICStorageElement child; - for(int i = 0; i < entries.length; i++){ - child = element.createChild(ELEMENT_ENTRY); - serializeEntry(entries[i], child); + if(entries != null){ + for(int i = 0; i < entries.length; i++){ + child = element.createChild(ELEMENT_ENTRY); + serializeEntry(entries[i], child); + } } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java index b148bf5d66b..7fd2b586cd7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java @@ -19,9 +19,9 @@ import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.core.settings.model.AbstractCExtensionProxy; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java index 8792658fba4..904a590e31a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java @@ -11,8 +11,10 @@ package org.eclipse.cdt.internal.core.settings.model; import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.internal.core.CConfigBasedDescriptor; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java index 92755a54b02..6c9b07291d3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java @@ -790,4 +790,21 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + public String[] getExternalSettingsProviderIds() { + try { + return getSpecSettings().getExternalSettingsProviderIds(); + } catch (CoreException e) { + CCorePlugin.log(e); + } + return new String[0]; + } + + public void setExternalSettingsProviderIds(String[] ids) { + try { + getSpecSettings().setExternalSettingsProviderIds(ids); + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java index ddced96f8ad..ecd0a3a0da3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java @@ -472,4 +472,14 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return CDataUtil.isExcluded(path, fProjSourceEntries); } + + public String[] getExternalSettingsProviderIds() { + return fSpecSettings.getExternalSettingsProviderIds(); + } + + public void setExternalSettingsProviderIds(String[] ids) { + if(!fInitializing) + throw ExceptionFactory.createIsReadOnlyException(); + fSpecSettings.setExternalSettingsProviderIds(ids); + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java index 5eff937b25c..133f2e310d5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java @@ -919,4 +919,13 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ return true; } + + public String[] getExternalSettingsProviderIds(){ + return ExtensionContainerFactory.getReferencedProviderIds(fCfg); + } + + public void setExternalSettingsProviderIds(String ids[]){ + ExtensionContainerFactory.setReferencedProviderIds(fCfg, ids); + } + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsDeltaProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsDeltaProcessor.java index 25a49600b18..d2021d6e0f1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsDeltaProcessor.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsDeltaProcessor.java @@ -29,52 +29,80 @@ import org.eclipse.cdt.core.settings.model.util.KindBasedStore; import org.eclipse.cdt.internal.core.settings.model.CExternalSettinsDeltaCalculator.ExtSettingsDelta; public class CExternalSettingsDeltaProcessor { - static void applyDelta(ICConfigurationDescription des, ExtSettingsDelta deltas[]){ + static boolean applyDelta(ICConfigurationDescription des, ExtSettingsDelta deltas[]){ + return applyDelta(des, deltas, KindBasedStore.ORED_ALL_ENTRY_KINDS); + } + + static boolean applyDelta(ICConfigurationDescription des, ExtSettingsDelta deltas[], int kindMask){ ICResourceDescription rcDess[] = des.getResourceDescriptions(); + boolean changed = false; for(int i = 0; i < rcDess.length; i++){ ICResourceDescription rcDes = rcDess[i]; - if(rcDes.getType() == ICSettingBase.SETTING_FOLDER){ - applyDelta((ICFolderDescription)rcDes, deltas); - } else { - applyDelta((ICFileDescription)rcDes, deltas); - } + if(applyDelta(rcDes, deltas, kindMask)) + changed = true; } + return changed; } - private static void applyDelta(ICFileDescription des, ExtSettingsDelta deltas[]){ + static boolean applyDelta(ICResourceDescription rcDes, ExtSettingsDelta deltas[], int kindMask){ + if(rcDes.getType() == ICSettingBase.SETTING_FOLDER){ + return applyDelta((ICFolderDescription)rcDes, deltas, kindMask); + } + return applyDelta((ICFileDescription)rcDes, deltas, kindMask); + } + + static boolean applyDelta(ICFileDescription des, ExtSettingsDelta deltas[], int kindMask){ ICLanguageSetting setting = des.getLanguageSetting(); if(setting == null) - return; + return false; + + boolean changed = false; for(int i = 0; i < deltas.length; i++){ if(isSettingCompatible(setting, deltas[i].fSetting)){ - applyDelta(setting, deltas[i]); + if(applyDelta(setting, deltas[i], kindMask)) + changed = true; } } + return changed; } - private static void applyDelta(ICFolderDescription des, ExtSettingsDelta deltas[]){ + static boolean applyDelta(ICFolderDescription des, ExtSettingsDelta deltas[], int kindMask){ ICLanguageSetting settings[] = des.getLanguageSettings(); if(settings == null || settings.length == 0) - return; + return false; ICLanguageSetting setting; + boolean changed = false; for(int k = 0; k < settings.length; k++){ setting = settings[k]; - for(int i = 0; i < deltas.length; i++){ - if(isSettingCompatible(setting, deltas[i].fSetting)){ - applyDelta(setting, deltas[i]); - } + if(applyDelta(setting, deltas, kindMask)) + changed = true; + } + return changed; + } + + static boolean applyDelta(ICLanguageSetting setting, ExtSettingsDelta[] deltas, int kindMask){ + boolean changed = false; + for(int i = 0; i < deltas.length; i++){ + if(isSettingCompatible(setting, deltas[i].fSetting)){ + if(applyDelta(setting, deltas[i], kindMask)) + changed = true; } } + return changed; } - private static void applyDelta(ICLanguageSetting setting, ExtSettingsDelta delta){ + static boolean applyDelta(ICLanguageSetting setting, ExtSettingsDelta delta, int kindMask){ int kinds[] = KindBasedStore.getLanguageEntryKinds(); int kind; ICLanguageSettingEntry entries[]; ICSettingEntry diff[][]; + boolean changed = false; for(int i = 0; i < kinds.length; i++){ kind = kinds[i]; + if((kind & kindMask) == 0) + continue; + diff = delta.getEntriesDelta(kind); if(diff == null) continue; @@ -82,9 +110,12 @@ public class CExternalSettingsDeltaProcessor { entries = setting.getSettingEntries(kind); List list = calculateUpdatedEntries(entries, diff[0], diff[1]); - if(list != null) + if(list != null){ setting.setSettingEntries(kind, list); + changed = true; + } } + return changed; } private static List calculateUpdatedEntries(ICSettingEntry current[], ICSettingEntry added[], ICSettingEntry removed[]){ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java index 62c97dd5054..9f84ff04ba3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java @@ -69,9 +69,14 @@ public class CExternalSettingsHolder extends CExternalSettingsContainer { return (CExternalSetting[])fSettingsMap.values().toArray(new CExternalSetting[fSettingsMap.size()]); return EMPTY_EXT_SETTINGS_ARRAY; } - + void setExternallSettings(CExternalSetting[] settings){ - removeExternalSettings(); + setExternalSettings(settings, false); + } + + void setExternalSettings(CExternalSetting[] settings, boolean add){ + if(!add) + removeExternalSettings(); if(settings != null){ for(int i = 0; i < settings.length; i++){ @@ -84,6 +89,10 @@ public class CExternalSettingsHolder extends CExternalSettingsContainer { } fIsModified = true; } + + void addExternalSettings(CExternalSetting[] settings){ + setExternalSettings(settings, true); + } public CExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIDs, String[] extensions, diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java index 6417f82ba67..703e1a6d7b5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java @@ -20,8 +20,11 @@ import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CExternalSetting; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.internal.core.settings.model.CExternalSettinsDeltaCalculator.ExtSettingsDelta; import org.eclipse.core.resources.IProject; @@ -43,6 +46,23 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private Map fFactoryMap = new HashMap(); private static CExternalSettingsManager fInstance; + public static class SettingsUpdateStatus { + ICProjectDescription fDes; + boolean fIsChanged; + + SettingsUpdateStatus(ICProjectDescription des, boolean isChanged){ + fDes = des; + fIsChanged = isChanged; + } + + public ICProjectDescription getCProjectDescription(){ + return fDes; + } + + public boolean isChanged(){ + return fIsChanged; + } + } private CExternalSettingsManager(){ } @@ -561,18 +581,18 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } } - private void containerContentsChanged(ICfgContainer cr, CContainerRef ref, DeltaInfo deltaInfo){ - processContainerChange(OP_CHANGED, cr, ref, deltaInfo); + private boolean containerContentsChanged(ICfgContainer cr, CContainerRef ref, DeltaInfo deltaInfo){ + return processContainerChange(OP_CHANGED, cr, ref, deltaInfo); } - private void processContainerChange(int op, + private boolean processContainerChange(int op, ICfgContainer cr, CContainerRef crInfo, DeltaInfo deltaInfo){ - processContainerChange(op, cr, new CfgContainerRefInfoContainer(cr), crInfo, deltaInfo); + return processContainerChange(op, cr, new CfgContainerRefInfoContainer(cr), crInfo, deltaInfo); } - private void processContainerChange(int op, + private boolean processContainerChange(int op, ICfgContainer cr, ICRefInfoContainer riContainer, CContainerRef crInfo, @@ -584,13 +604,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP cfg.getProjectDescription().getProject(), cfg, riContainer, crInfo); if(deltas != null){ - applyDeltas(cr, deltas); + return applyDeltas(cr, deltas); } - + return false; } - private void applyDeltas(ICfgContainer cr, ExtSettingsDelta[] deltas){ - CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas); + private boolean applyDeltas(ICfgContainer cr, ExtSettingsDelta[] deltas){ + return CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas); } private static class RefInfoContainer{ @@ -650,13 +670,17 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP checkStore(event.getNewCProjectDescription()); break; case CProjectDescriptionEvent.LOADDED: - ICProjectDescription des = update(event.getNewCProjectDescription()); - if(des.isModified()){ - try { - CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des); - } catch (CoreException e) { - CCorePlugin.log(e); - } + final SettingsUpdateStatus status = update(event.getNewCProjectDescription()); + if(status.isChanged()){ + IWorkspaceRunnable r = new IWorkspaceRunnable(){ + + public void run(IProgressMonitor monitor) throws CoreException { + ICProjectDescription des = status.getCProjectDescription(); + CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des); + } + + }; + CProjectDescriptionManager.getInstance().runWspModification(r, null); } break; } @@ -701,17 +725,19 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return info.getReferences(factoryId); } - public ICProjectDescription update(ICProjectDescription des){ + public SettingsUpdateStatus update(ICProjectDescription des){ ProjDesCfgList list = new ProjDesCfgList(des, null); + boolean changed = false; for(int i = 0; i < list.size(); i++){ CfgListCfgContainer cfgCr = new CfgListCfgContainer(list, i); CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cfgCr); CContainerRef[] refs = ric.getRefInfo(false).getReferences(); for(int k = 0; k < refs.length; k++){ - containerContentsChanged(cfgCr, refs[k], null); + if(containerContentsChanged(cfgCr, refs[k], null)) + changed = true; } } - return list.fProjDes; + return new SettingsUpdateStatus(list.fProjDes, changed); } private ExtSettingsDelta[] checkExternalSettingsChange(int op, @@ -758,4 +784,15 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private CExternalSettinsDeltaCalculator getDeltaCalculator(){ return CExternalSettinsDeltaCalculator.getInstance(); } + + public void restoreDefaults(ICLanguageSetting ls, int entryKinds){ + ICConfigurationDescription cfg = ls.getConfiguration(); + CfgContainer cr = new CfgContainer(cfg); + CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr); + CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings(); + ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null); + if(deltas != null){ + CExternalSettingsDeltaProcessor.applyDelta(ls, deltas, entryKinds); + } + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java index e21f70b47fe..c8b008d2532 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java @@ -330,8 +330,11 @@ public class CLanguageSetting extends CDataProxy implements // int kinds[] = KindBasedStore.getSupportedKinds(); for(int i = 0; i < kinds.length; i++){ ICLanguageSettingEntry sortedEntries[] = store.containsEntriesList(kinds[i]) ? store.getEntries(kinds[i]) : null; - if((kind & kinds[i]) != 0) + if((kind & kinds[i]) != 0){ data.setEntries(kinds[i], sortedEntries); + if(sortedEntries == null) + CExternalSettingsManager.getInstance().restoreDefaults(this, kind); + } } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java index 6c66486ffe1..ccf772eaeea 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java @@ -15,7 +15,7 @@ import java.util.List; import org.eclipse.cdt.core.settings.model.ICSettingObject; -class CProjectDescriptionDelta implements ICDescriptionDelta { +public class CProjectDescriptionDelta implements ICDescriptionDelta { private List fChildList = new ArrayList(); private CProjectDescriptionDelta fParent; private ICSettingObject fSetting; @@ -29,7 +29,7 @@ class CProjectDescriptionDelta implements ICDescriptionDelta { private static final int KIND_MASK = 3; private static final int FLAGS_OFFSET = 2; - CProjectDescriptionDelta(ICSettingObject newSetting, ICSettingObject oldSetting){ + public CProjectDescriptionDelta(ICSettingObject newSetting, ICSettingObject oldSetting){ fNewSetting = newSetting; fOldSetting = oldSetting; if(newSetting != null){ 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 08f90caf178..cc46ef27d92 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 @@ -46,12 +46,14 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.settings.model.CExternalSetting; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICFileDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingEntry; @@ -635,6 +637,9 @@ public class CProjectDescriptionManager { } public Job runWspModification(final IWorkspaceRunnable runnable, IProgressMonitor monitor){ + if(monitor == null) + monitor = new NullProgressMonitor(); + final IWorkspace wsp = ResourcesPlugin.getWorkspace(); boolean scheduleRule = true; if(!wsp.isTreeLocked()) { @@ -649,7 +654,8 @@ public class CProjectDescriptionManager { CCorePlugin.log(e); } catch (Exception e) { } finally { - monitor.done(); + if(!scheduleRule) + monitor.done(); mngr.endRule(rule); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java index df535a06c61..2fb47264633 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java @@ -16,6 +16,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.cdt.core.settings.model.CExternalSetting; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.internal.core.settings.model.CExternalSettingsManager.CContainerRef; @@ -100,5 +101,18 @@ class CSettingsRefInfo { CRefSettingsHolder remove(CContainerRef cRef){ return (CRefSettingsHolder)fESHolderMap.remove(cRef); } + + CExternalSetting[] createExternalSettings(){ + if(fESHolderMap.size() == 0) + return new CExternalSetting[0]; + if(fESHolderMap.size() == 1) + return ((CRefSettingsHolder)fESHolderMap.values().iterator().next()).getExternalSettings(); + CExternalSettingsHolder holder = new CExternalSettingsHolder(); + for(Iterator iter = fESHolderMap.values().iterator(); iter.hasNext();){ + CExternalSettingsHolder h = (CExternalSettingsHolder)iter.next(); + holder.setExternalSettings(h.getExternalSettings(), true); + } + return holder.getExternalSettings(); + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java index 631229378ed..027314f0abe 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java @@ -19,9 +19,11 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CExternalSetting; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICExternalSetting; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.internal.core.settings.model.CExternalSettingsManager.CContainerRef; import org.eclipse.cdt.internal.core.settings.model.CExternalSettingsManager.NullContainer; import org.eclipse.core.resources.IProject; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java index 917240845b5..2a4abbf3fd8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java @@ -25,9 +25,11 @@ import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICExternalSetting; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator; import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.PathEntryCollector; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java index d14e60b59a2..b2cd874d6cd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.ScannerInfo; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICFileDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; @@ -29,6 +30,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry; import org.eclipse.cdt.core.settings.model.ICMacroEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.core.resources.IProject; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExtensionContainerFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExtensionContainerFactory.java index a8407cd9fde..4fa1bb87d1c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExtensionContainerFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExtensionContainerFactory.java @@ -10,13 +10,18 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; +import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map; +import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CExternalSetting; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.extension.CExternalSettingProvider; +import org.eclipse.cdt.internal.core.settings.model.CExternalSettingsManager.CContainerRef; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -60,17 +65,23 @@ public class ExtensionContainerFactory extends CExternalSettingContainerFactory private IExtension fExtension; private IConfigurationElement fProviderElement; private String fId; + private String fName; private CExternalSettingProvider fProvider; CExtensionSettingProviderDescriptor(IExtension extension){ fId = extension.getUniqueIdentifier(); + fName = extension.getLabel(); fExtension = extension; } public String getId(){ return fId; } - + + public String getName(){ + return fName; + } + private CExternalSettingProvider getProvider(){ if(fProvider == null){ try { @@ -157,4 +168,47 @@ public class ExtensionContainerFactory extends CExternalSettingContainerFactory return dr.getContainer(project, cfgDes); return CExternalSettingsManager.NullContainer.INSTANCE; } + + public static String[] getReferencedProviderIds(ICConfigurationDescription cfg){ + CContainerRef[] refs = CExternalSettingsManager.getInstance().getReferences(cfg, FACTORY_ID); + String[] ids = new String[refs.length]; + for(int i = 0; i < refs.length; i++){ + ids[i] = refs[i].getContainerId(); + } + return ids; + } + + public static void setReferencedProviderIds(ICConfigurationDescription cfg, String ids[]){ + Set newIdsSet = new HashSet(Arrays.asList(ids)); + Set oldIdsSet = new HashSet(Arrays.asList(getReferencedProviderIds(cfg))); + Set newIdsSetCopy = new HashSet(newIdsSet); + newIdsSet.removeAll(oldIdsSet); + oldIdsSet.removeAll(newIdsSetCopy); + + if(oldIdsSet.size() != 0){ + for(Iterator iter = oldIdsSet.iterator(); iter.hasNext();){ + removeReference(cfg, (String)iter.next()); + } + } + + if(newIdsSet.size() != 0){ + for(Iterator iter = newIdsSet.iterator(); iter.hasNext();){ + createReference(cfg, (String)iter.next()); + } + } + } + + private static void createReference(ICConfigurationDescription cfg, String id){ + CContainerRef cr = createContainerRef(id); + CExternalSettingsManager.getInstance().addContainer(cfg, cr); + } + + private static void removeReference(ICConfigurationDescription cfg, String id){ + CContainerRef cr = createContainerRef(id); + CExternalSettingsManager.getInstance().removeContainer(cfg, cr); + } + + private static CContainerRef createContainerRef(String id){ + return new CContainerRef(FACTORY_ID, id); + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java index 35a18d23318..5a9cba03edc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.resources.ScannerProvider; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java index c63c19019ee..4ac3acb6ae6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java @@ -14,6 +14,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.internal.core.model.CModelOperation; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.CompositeWorkspaceRunnable; import org.eclipse.core.resources.IProject; diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index ef7153ebfd8..eaddf64dbfe 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -47,6 +47,7 @@ + diff --git a/core/org.eclipse.cdt.core/schema/externalSettingsProvider.exsd b/core/org.eclipse.cdt.core/schema/externalSettingsProvider.exsd new file mode 100644 index 00000000000..2f5773a5548 --- /dev/null +++ b/core/org.eclipse.cdt.core/schema/externalSettingsProvider.exsd @@ -0,0 +1,104 @@ + + + + + + + + + The external settings provider would be used to specify provider of include/macro/libraryan settings to be used/applied for the build configuration associated with this provider. +Any number of setting providers can be associated with the build configurations. +This functionality might be used, e.g. by the External SDKs to allow automatic andjustment of the project settings for the projects using thes SDKs, e.g. adding include paths, symbols, etc. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Class implementing org.eclipse.cdt.core.settings.model.extension.CExternalSettingProvider + + + + + + + + + + + + + + + 4.0 + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + + + + + diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java index 3c0cd8d5e45..f0d56bea377 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java @@ -23,19 +23,19 @@ import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.ICDescriptorListener; import org.eclipse.cdt.core.ICDescriptorManager; import org.eclipse.cdt.core.ICDescriptorOperation; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.ICSettingObject; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription; import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.CStorage; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta; -import org.eclipse.cdt.internal.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; import org.eclipse.cdt.internal.core.settings.model.InternalXmlStorageElement; import org.eclipse.cdt.internal.core.settings.model.PathEntryConfigurationDataProvider;