Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-04-04 17:52:07 +0000
committerMikhail Sennikovsky2007-04-04 17:52:07 +0000
commitcae9417adf2e1cec19b532b8b48899a71423269b (patch)
treee275186d711e991260dd72f9df6588ae7304d123
parent19a895a652af168f0607803d6f058d17e4bfa59c (diff)
downloadorg.eclipse.cdt-cae9417adf2e1cec19b532b8b48899a71423269b.tar.gz
org.eclipse.cdt-cae9417adf2e1cec19b532b8b48899a71423269b.tar.xz
org.eclipse.cdt-cae9417adf2e1cec19b532b8b48899a71423269b.zip
Fix for [Bug 179662] Implement configuration-based scanner discovery in the make.core
-rw-r--r--build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java160
-rw-r--r--build/org.eclipse.cdt.make.core/plugin.properties5
-rw-r--r--build/org.eclipse.cdt.make.core/plugin.xml24
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java2
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java1
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java59
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/ConfigSupportNature.java33
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFacroty.java44
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java81
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java35
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java59
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java1131
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java153
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java3
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java12
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java6
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java87
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java2
-rw-r--r--build/org.eclipse.cdt.make.ui/icons/obj16/define_obj.gifbin0 -> 154 bytes
-rw-r--r--build/org.eclipse.cdt.make.ui/icons/obj16/hfolder_obj.gifbin0 -> 579 bytes
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.properties8
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.xml57
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/properties/PathAndSymbolPage.java21
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java5
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java81
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java10
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationDataProvider.java93
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java46
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java6
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/AbstractEntryStorage.java98
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataSerializer.java479
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java159
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryInfo.java44
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStorageBasedLanguageData.java64
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java14
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java6
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java314
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryDataSerializer.java126
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryLanguageData.java154
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryStorage.java85
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java109
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java60
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java29
-rw-r--r--core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd38
45 files changed, 3761 insertions, 246 deletions
diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java
new file mode 100644
index 00000000000..3621ac64192
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * 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.make.builder.tests;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.CCorePlugin;
+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.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class CDataProviderTests extends TestCase {
+ /**
+ * @param name
+ */
+ public CDataProviderTests(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(CDataProviderTests.class);
+
+// // Add the relevant tests to the suite
+// suite.addTest(new StandardBuildTests("testProjectCreation"));
+// suite.addTest(new StandardBuildTests("testProjectSettings"));
+// suite.addTest(new StandardBuildTests("testProjectConversion"));
+// suite.addTest(new StandardBuildTests("testProjectCleanup"));
+//
+// suite.addTestSuite(ScannerConfigConsoleParserTests.class);
+// suite.addTestSuite(ScannerConfigDiscoveryTests.class);
+
+ return suite;
+ }
+
+ public void testCData() throws Exception {
+ IProject project = createProject("a1");
+ ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
+ assertNotNull("project description should not be null", projDes);
+
+ ICConfigurationDescription cfgs[] = projDes.getConfigurations();
+ assertEquals(1, cfgs.length);
+
+ int lssNum = cfgs[0].getRootFolderDescription().getLanguageSettings().length;
+ int rcDessNum = cfgs[0].getResourceDescriptions().length;
+ assertTrue(rcDessNum > 0);
+ ICConfigurationDescription cfg2 = projDes.createConfiguration("aasasa", "cfg2", cfgs[0]);
+ assertNotNull(cfg2);
+ assertEquals(2, projDes.getConfigurations().length);
+ assertEquals(lssNum, cfg2.getRootFolderDescription().getLanguageSettings().length);
+ assertEquals(rcDessNum, cfg2.getResourceDescriptions().length);
+
+ CCorePlugin.getDefault().setProjectDescription(project, projDes);
+
+ projDes = CCorePlugin.getDefault().getProjectDescription(project);
+ assertEquals(2, projDes.getConfigurations().length);
+ cfgs = projDes.getConfigurations();
+ assertEquals(2, cfgs.length);
+ cfg2 = cfgs[0];
+ assertNotNull(cfg2);
+ assertEquals(2, projDes.getConfigurations().length);
+ assertEquals(lssNum, cfg2.getRootFolderDescription().getLanguageSettings().length);
+ assertEquals(rcDessNum, cfg2.getResourceDescriptions().length);
+
+ projDes = CCorePlugin.getDefault().getProjectDescription(project, false);
+ assertEquals(2, projDes.getConfigurations().length);
+ cfgs = projDes.getConfigurations();
+ assertEquals(2, cfgs.length);
+ cfg2 = cfgs[0];
+ assertNotNull(cfg2);
+ assertEquals(2, projDes.getConfigurations().length);
+ assertEquals(lssNum, cfg2.getRootFolderDescription().getLanguageSettings().length);
+ assertEquals(rcDessNum, cfg2.getResourceDescriptions().length);
+
+ project.delete(false, true, new NullProgressMonitor());
+
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject("a1");
+ project.create(new NullProgressMonitor());
+ project.open(new NullProgressMonitor());
+
+ projDes = CCorePlugin.getDefault().getProjectDescription(project);
+ assertNotNull("project description should not be null", projDes);
+
+ cfgs = projDes.getConfigurations();
+ assertEquals(2, cfgs.length);
+ cfg2 = cfgs[0];
+ assertNotNull(cfg2);
+ assertEquals(2, projDes.getConfigurations().length);
+ assertEquals(lssNum, cfg2.getRootFolderDescription().getLanguageSettings().length);
+ assertEquals(rcDessNum, cfg2.getResourceDescriptions().length);
+
+ cfg2 = cfgs[1];
+ assertNotNull(cfg2);
+ assertEquals(2, projDes.getConfigurations().length);
+ assertEquals(lssNum, cfg2.getRootFolderDescription().getLanguageSettings().length);
+ assertEquals(rcDessNum, cfg2.getResourceDescriptions().length);
+ }
+
+ private IProject createProject(final String name) throws CoreException {
+ final Object[] result = new Object[1];
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ IProjectDescription description = null;
+
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+
+ description = project.getDescription();
+// ICommand[] commands = description.getBuildSpec();
+// for (int i = 0; i < commands.length; ++i) {
+// if (commands[i].getBuilderName().equals(ScannerConfigBuilder.BUILDER_ID)) {
+// return;
+// }
+// }
+// ICommand command = description.newCommand();
+// command.setBuilderName(ScannerConfigBuilder.BUILDER_ID);
+// ICommand[] newCommands = new ICommand[commands.length + 1];
+// System.arraycopy(commands, 0, newCommands, 0, commands.length);
+// newCommands[commands.length] = command;
+// description.setBuildSpec(newCommands);
+// project.setDescription(description, null);
+
+ CCorePlugin.getDefault().createCDTProject(description, project, MakeCorePlugin.CFG_DATA_PROVIDER_ID, new NullProgressMonitor());
+ result[0] = project;
+ }
+ }, null);
+ return (IProject)result[0];
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/plugin.properties b/build/org.eclipse.cdt.make.core/plugin.properties
index 655cd9036b5..0cc635e6025 100644
--- a/build/org.eclipse.cdt.make.core/plugin.properties
+++ b/build/org.eclipse.cdt.make.core/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2005 QNX Software Systems and others.
+# Copyright (c) 2003, 2007 QNX Software Systems 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
@@ -29,3 +29,6 @@ extensionGCCPerProjectProfile.name=GNU C/C++ Scanner Info per project profile
extensionGCCPerFileProfile.name=GNU C/C++ Scanner Info per file profile
makefile=Makefile
+
+CfgDataProvider.name=Make Data Provider
+natureCfg.name=Configuration Support Nature
diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml
index 5f58f276f4d..49fd70576c7 100644
--- a/build/org.eclipse.cdt.make.core/plugin.xml
+++ b/build/org.eclipse.cdt.make.core/plugin.xml
@@ -160,4 +160,28 @@
file-extensions="mk"/>
</extension>
+ <extension
+ id="cfgSupportNature"
+ name="%natureCfg.name"
+ point="org.eclipse.core.resources.natures">
+ <requires-nature
+ id="org.eclipse.cdt.core.cnature">
+ </requires-nature>
+ <runtime>
+ <run
+ class="org.eclipse.cdt.make.internal.core.dataprovider.ConfigSupportNature">
+ </run>
+ </runtime>
+ </extension>
+
+ <extension
+ id="configurationDataProvider"
+ name="%CfgDataProvider.name"
+ point="org.eclipse.cdt.core.CConfigurationDataProvider">
+ <provider
+ natures="org.eclipse.cdt.make.core.cfgSupportNature"
+ class="org.eclipse.cdt.make.internal.core.dataprovider.MakeConfigurationDataProvider"
+ />
+ </extension>
+
</plugin>
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java
index fcf67e4387d..edf52284492 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java
@@ -67,7 +67,7 @@ public class MakeCorePlugin extends Plugin {
public static final String MAKEFILE_STYLE = PLUGIN_ID + "editor_makefile_style"; //$NON-NLS-1$
public static final String MAKEFILE_DIRS = PLUGIN_ID + "editor_makefile_dirs"; //$NON-NLS-1$
-
+ public static final String CFG_DATA_PROVIDER_ID = PLUGIN_ID + ".configurationDataProvider";
private MakeTargetManager fTargetManager;
private DiscoveredPathManager fDiscoveryPathManager;
//The shared instance.
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
index 07eae64e02b..9dcd2f52524 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
@@ -14,7 +14,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
index 36d60120ce8..b2b72c33f5c 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM 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
@@ -12,7 +12,11 @@ package org.eclipse.cdt.make.core.scannerconfig;
import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.SCJobsUtil;
@@ -42,6 +46,8 @@ public class ScannerConfigBuilder extends ACBuilder {
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
// If auto discovery is disabled, do nothing
// boolean autodiscoveryEnabled;
+ if(buildNewStyle(getProject(), monitor))
+ return getProject().getReferencedProjects();
boolean autodiscoveryEnabled2;
IScannerConfigBuilderInfo2 buildInfo2 = null;
try {
@@ -76,8 +82,57 @@ public class ScannerConfigBuilder extends ACBuilder {
autodiscoveryEnabled2 = false;
MakeCorePlugin.log(e);
}
-
return getProject().getReferencedProjects();
}
+
+ protected boolean buildNewStyle(IProject project, IProgressMonitor monitor) throws CoreException{
+ ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
+ if(!CCorePlugin.getDefault().isNewStyleProject(des))
+ return false;
+
+ ICConfigurationDescription[] cfgs = des.getConfigurations();
+ IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
+ monitor.beginTask("building per-configuratin info", cfgs.length + 1);
+ boolean wasbuilt = false;
+ for(int i = 0; i < cfgs.length; i++){
+ ICConfigurationDescription cfg = cfgs[i];
+ CConfigurationData data = cfg.getConfigurationData();
+ InfoContext context = new InfoContext(project, data.getId());
+ IScannerConfigBuilderInfo2 info = container.getInfo(context);
+ if(info == null){
+// context = new InfoContext(project);
+ info = container.getInfo(new InfoContext(project));
+ }
+
+ if(build(project, context, info, new SubProgressMonitor(monitor, 1)))
+ wasbuilt = true;
+ }
+
+ if(wasbuilt)
+ CCorePlugin.getDefault().updateProjectDescriptions(new IProject[]{project}, new SubProgressMonitor(monitor, 1));
+
+ monitor.done();
+ return true;
+ }
+
+ protected boolean build(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo2, IProgressMonitor monitor){
+ boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
+
+ if (autodiscoveryEnabled2) {
+ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$
+ monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
+ getProject().getName());
+
+ // get scanner info from all external providers
+ SCJobsUtil.getProviderScannerInfo(getProject(), context, buildInfo2, new SubProgressMonitor(monitor, 70));
+
+ // update and persist scanner configuration
+ SCJobsUtil.updateScannerConfiguration(getProject(), context, buildInfo2, new SubProgressMonitor(monitor, 30));
+ return true;
+ }
+ return false;
+ }
+
+
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/ConfigSupportNature.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/ConfigSupportNature.java
new file mode 100644
index 00000000000..e9ba40b7edb
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/ConfigSupportNature.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.make.internal.core.dataprovider;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+public class ConfigSupportNature implements IProjectNature {
+ private IProject fProject;
+
+ public void configure() throws CoreException {
+ }
+
+ public void deconfigure() throws CoreException {
+ }
+
+ public IProject getProject() {
+ return fProject;
+ }
+
+ public void setProject(IProject project) {
+ fProject = project;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFacroty.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFacroty.java
new file mode 100644
index 00000000000..75af112b02f
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFacroty.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.make.internal.core.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+
+public class MakeCDataFacroty extends CDataFacroty {
+ private static MakeCDataFacroty fInstance;
+
+ public static CDataFacroty getDefault(){
+ if(fInstance == null){
+ fInstance = new MakeCDataFacroty();
+ }
+ return fInstance;
+ }
+
+ public CLanguageData createLanguageData(CConfigurationData cfg,
+ CResourceData rcBase, CLanguageData base, String id, boolean clone) {
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
+ return new MakeLanguageData(id, base);
+ }
+
+ public CLanguageData createLanguageData(CConfigurationData cfg,
+ CResourceData rcBase, String id, String name, String languageId,
+ int supportedKinds, String[] rcTypes, boolean isContentTypes) {
+ if(id == null)
+ id = CDataUtil.genId(rcBase.getId());
+ MakeLanguageData lData = new MakeLanguageData(id, name, languageId, supportedKinds, rcTypes, isContentTypes);
+ return lData;
+ }
+} \ No newline at end of file
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java
new file mode 100644
index 00000000000..f4bbd3d31da
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.make.internal.core.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationDataProvider;
+import org.eclipse.cdt.core.settings.model.util.CDataSerializer;
+import org.eclipse.cdt.core.settings.model.util.UserAndDiscoveredEntryDataSerializer;
+import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator;
+import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoProcessor;
+import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.IRcSettingInfo;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class MakeConfigurationDataProvider extends CDefaultConfigurationDataProvider {
+ private static final String STORAGE_ID = "makeConfigDataProvider";
+
+ protected CDataFacroty getDataFactory() {
+ return MakeCDataFacroty.getDefault();
+ }
+
+ protected CDataSerializer getDataSerializer() {
+ return UserAndDiscoveredEntryDataSerializer.getDefault();
+ }
+
+ protected String getStorageId() {
+ return STORAGE_ID;
+ }
+
+ public CConfigurationData applyConfiguration(
+ ICConfigurationDescription des,
+ ICConfigurationDescription baseDescription,
+ CConfigurationData base, IProgressMonitor monitor)
+ throws CoreException {
+ CConfigurationData result = super.applyConfiguration(des, baseDescription, base, monitor);
+ if(!des.isPreferenceConfiguration())
+ updateDiscoveredInfo(des.getProjectDescription().getProject(), result);
+ return result;
+ }
+
+ public CConfigurationData loadConfiguration(ICConfigurationDescription des,
+ IProgressMonitor monitor) throws CoreException {
+ CConfigurationData result = super.loadConfiguration(des, monitor);
+ if(!des.isPreferenceConfiguration())
+ updateDiscoveredInfo(des.getProjectDescription().getProject(), result);
+ return result;
+ }
+
+ protected void updateDiscoveredInfo(IProject project, CConfigurationData cfgData){
+ updateDiscoveredInfo(project, cfgData, getInfoCalculator(), getInfoProcessor());
+ }
+
+ public static void updateDiscoveredInfo(IProject project, CConfigurationData cfgData,
+ CDataDiscoveredInfoCalculator calculator,
+ CDataDiscoveredInfoProcessor processor){
+
+ IRcSettingInfo rcInfos[] = calculator.getSettingInfos(project, cfgData);
+
+ processor.applyDiscoveredInfo(cfgData, rcInfos);
+ }
+
+ protected CDataDiscoveredInfoProcessor getInfoProcessor(){
+ return MakeDiscoveredInfoProcessor.getDefault();
+ }
+
+ protected CDataDiscoveredInfoCalculator getInfoCalculator(){
+ return CDataDiscoveredInfoCalculator.getDefault();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java
new file mode 100644
index 00000000000..67b2a1780fa
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.make.internal.core.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
+import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoProcessor;
+
+public class MakeDiscoveredInfoProcessor extends CDataDiscoveredInfoProcessor {
+ private static MakeDiscoveredInfoProcessor fInstance;
+
+ public static MakeDiscoveredInfoProcessor getDefault(){
+ if(fInstance == null)
+ fInstance = new MakeDiscoveredInfoProcessor();
+ return fInstance;
+ }
+
+ protected void setInfoForData(CConfigurationData cfgData,
+ CResourceData rcData, CLanguageData data, PathInfo pi,
+ CResourceData baseRcData, CLanguageData baseLangData) {
+ MakeLanguageData mld = (MakeLanguageData)data;
+ mld.setDiscoveredInfo(pi);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java
new file mode 100644
index 00000000000..845c3c2f8b8
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.make.internal.core.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.util.UserAndDiscoveredEntryLanguageData;
+import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
+import org.eclipse.cdt.make.internal.core.scannerconfig.util.PathInfoToLangSettingsConverter;
+
+public class MakeLanguageData extends UserAndDiscoveredEntryLanguageData {
+ private PathInfo fDiscoveredCache;
+
+ public MakeLanguageData() {
+ super();
+ }
+
+ public MakeLanguageData(String id, CLanguageData base) {
+ super(id, base);
+ }
+
+ public MakeLanguageData(String id, String name, String languageId, int kinds, String[] ids,
+ boolean isContentTypes) {
+ super(id, languageId, ids, isContentTypes);
+ fName = name;
+ fSupportedKinds = kinds;
+ }
+
+ protected void copySettingsFrom(CLanguageData data) {
+ super.copySettingsFrom(data);
+ if(data instanceof MakeLanguageData){
+ fDiscoveredCache = ((MakeLanguageData)data).fDiscoveredCache;
+ }
+ }
+
+ protected ICLanguageSettingEntry[] getAllDiscoveredEntries(int kind) {
+ if(fDiscoveredCache != null){
+ int roFlag = canDisableDiscoveredEntries(kind) ? 0 : ICLanguageSettingEntry.READONLY;
+ return PathInfoToLangSettingsConverter.entriesForKind(kind,
+ roFlag
+ | ICLanguageSettingEntry.BUILTIN
+ | ICLanguageSettingEntry.RESOLVED,
+ fDiscoveredCache);
+ }
+ return null;
+ }
+
+ protected void setDiscoveredInfo(PathInfo info){
+ fDiscoveredCache = info;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java
new file mode 100644
index 00000000000..26c4b5800cf
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java
@@ -0,0 +1,1131 @@
+/*******************************************************************************
+ * 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.make.internal.core.scannerconfig;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+
+public class CDataDiscoveredInfoCalculator {
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ private static CDataDiscoveredInfoCalculator fInstance;
+
+ public interface IRcSettingInfo {
+ CResourceData getResourceData();
+
+ ILangSettingInfo[] getLangInfos();
+ }
+
+ public interface ILangSettingInfo {
+ CLanguageData getLanguageData();
+
+ PathInfo getFilePathInfo();
+ }
+
+ private static class RcSettingInfo implements IRcSettingInfo{
+ private ArrayList fLangInfoList;
+ private CResourceData fRcData;
+
+ RcSettingInfo(CResourceData rcData){
+ fRcData = rcData;
+ }
+
+ public ILangSettingInfo[] getLangInfos() {
+ if(fLangInfoList != null && fLangInfoList.size() != 0)
+ return (ILangSettingInfo[])fLangInfoList.toArray(new ILangSettingInfo[fLangInfoList.size()]);
+ return new ILangSettingInfo[0];
+ }
+
+ public CResourceData getResourceData() {
+ return fRcData;
+ }
+
+ void add(ILangSettingInfo info){
+ if(fLangInfoList == null)
+ fLangInfoList = new ArrayList();
+ fLangInfoList.add(info);
+ }
+ }
+
+ private static class LangSettingInfo implements ILangSettingInfo {
+ private CLanguageData fLangData;
+ private PathInfo fPathInfo;
+
+ LangSettingInfo(CLanguageData langData, PathInfo info){
+ fLangData = langData;
+ fPathInfo = info;
+ }
+
+ public PathInfo getFilePathInfo() {
+ return fPathInfo;
+ }
+
+ public CLanguageData getLanguageData() {
+ return fLangData;
+ }
+
+ }
+
+ private static class ListIndexStore {
+ private int fMaxIndex;
+ private List[] fStore;
+
+ public ListIndexStore(int size){
+ if(size < 0)
+ size = 0;
+
+ fStore = new List[size];
+ }
+
+ public void add(int index, Object value){
+ List list = checkResize(index) ? new ArrayList() : fStore[index];
+ if(list == null){
+ list = new ArrayList();
+ fStore[index] = list;
+ }
+
+ if(fMaxIndex < index)
+ fMaxIndex = index;
+
+ list.add(value);
+ }
+
+ private boolean checkResize(int index){
+ if(index >= fStore.length){
+ int newSize = ++index;
+ List resized[] = new List[newSize];
+ if(fStore != null && fStore.length != 0){
+ System.arraycopy(fStore, 0, resized, 0, fStore.length);
+ }
+ fStore = resized;
+ return true;
+ }
+ return false;
+ }
+
+ public List[] getLists(){
+ int size = fMaxIndex + 1;
+ List list = new ArrayList(size);
+ List l;
+ for(int i = 0; i < size; i++){
+ l = fStore[i];
+ if(l != null)
+ list.add(l);
+ }
+
+ return (List[])list.toArray(new List[list.size()]);
+ }
+ }
+
+ private static class PathFilePathInfo {
+ IPath fPath;
+ PathInfo fInfo;
+
+ PathFilePathInfo(IPath path, PathInfo info){
+ fPath = path;
+ fInfo = info;
+ }
+ }
+
+ private static class ExtsSetSettings {
+// String[] fExts;
+// HashSet fExtsSet;
+ private ExtsSet fExtsSet;
+ Map fPathFilePathInfoMap;
+ CLanguageData fBaseLangData;
+ boolean fIsDerived;
+ private PathInfo fMaxMatchInfo;
+ private List fMaxMatchInfoList;
+ private int fHash;
+
+ public ExtsSetSettings(CLanguageData baseLangData, ExtsSet extsSet, boolean isDerived) {
+ fExtsSet = extsSet;
+ fBaseLangData = baseLangData;
+ fIsDerived = isDerived;
+ }
+
+ void add(ExtsSetSettings setting){
+ if(setting.fPathFilePathInfoMap != null){
+ List list;
+ int size;
+ for(Iterator iter = setting.fPathFilePathInfoMap.values().iterator(); iter.hasNext();){
+ list = (List)iter.next();
+ size = list.size();
+ for(int i = 0; i < size; i++){
+ add((PathFilePathInfo)list.get(i));
+ }
+ }
+ }
+ }
+
+ void updateLangData(CLanguageData lData, boolean isDerived){
+ fBaseLangData = lData;
+ fIsDerived = lData != null ? isDerived : false;
+ }
+
+ public void add(PathFilePathInfo pInfo){
+ if(fPathFilePathInfoMap == null)
+ fPathFilePathInfoMap = new HashMap(3);
+
+ PathInfo fileInfo = pInfo.fInfo;
+ List list = fileInfo == fMaxMatchInfo ? fMaxMatchInfoList : (List)fPathFilePathInfoMap.get(fileInfo);
+ if(list == null){
+ list = new ArrayList();
+ fPathFilePathInfoMap.put(fileInfo, list);
+ if(fMaxMatchInfo == null){
+ fMaxMatchInfo = fileInfo;
+ fMaxMatchInfoList = list;
+ }
+// else {
+// fIsMultiple = true;
+// }
+ } else if(fMaxMatchInfoList != list){
+// fIsMultiple = true;
+
+ if(fMaxMatchInfoList.size() == list.size()){
+ fMaxMatchInfoList = list;
+ fMaxMatchInfo = fileInfo;
+ }
+ }
+ list.add(pInfo);
+ }
+
+ public boolean isMultiple(){
+ return fPathFilePathInfoMap != null && fPathFilePathInfoMap.size() > 1;
+ }
+
+ public PathInfo getMaxMatchPathInfo(){
+ return fMaxMatchInfo;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(isMultiple())
+ return false;
+
+ if(!(obj instanceof ExtsSetSettings))
+ return false;
+
+ ExtsSetSettings other = (ExtsSetSettings)obj;
+ if(other.isMultiple())
+ return false;
+
+ if(!fExtsSet.equals(other.fExtsSet))
+ return false;
+
+ if(!CDataUtil.objectsEqual(fMaxMatchInfo, other.fMaxMatchInfo))
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int hash = fHash;
+ if(hash == 0){
+ if(isMultiple())
+ hash = super.hashCode();
+ else {
+ hash = fExtsSet.hashCode();
+
+ if(fMaxMatchInfo != null)
+ hash += fMaxMatchInfo.hashCode();
+ }
+
+ fHash = hash;
+ }
+ return hash;
+ }
+
+ }
+
+ private static class ExtsSet {
+ private String[] fExts;
+ private HashSet fExtsSet;
+ private int fHash;
+
+ public ExtsSet(String[] exts){
+ fExts = exts == null || exts.length == 0 ? EMPTY_STRING_ARRAY : (String[])exts.clone();
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+
+ if(!(obj instanceof ExtsSet))
+ return false;
+
+ ExtsSet other = (ExtsSet)obj;
+ if(fExts.length != other.fExts.length)
+ return false;
+
+ if(fExts.length != 0){
+ HashSet set = (HashSet)calcExtsSet().clone();
+ set.removeAll(other.calcExtsSet());
+ if(set.size() != 0)
+ return false;
+ }
+ return true;
+ }
+
+ public String[] getExtensions(){
+ return (String[])fExts.clone();
+ }
+
+ public int hashCode() {
+ int hash = fHash;
+ if(hash == 0){
+ hash = 47;
+ for(int i = 0; i < fExts.length; i++){
+ hash += fExts[i].hashCode();
+ }
+ fHash = hash;
+ }
+ return hash;
+ }
+
+ private HashSet calcExtsSet(){
+ if(fExtsSet == null)
+ fExtsSet = new HashSet(Arrays.asList(fExts));
+ return fExtsSet;
+ }
+
+ public String toString() {
+ if(fExts.length == 0)
+ return "<empty>"; //$NON-NLS-1$
+
+ StringBuffer buf = new StringBuffer();
+
+ for(int i = 0; i < fExts.length; i++){
+ if(i != 0)
+ buf.append(","); //$NON-NLS-1$
+ buf.append(fExts[i]);
+ }
+ return buf.toString();
+ }
+ }
+
+ private static class RcSetSettings {
+ private CResourceData fRcData;
+ private HashMap fExtToExtsSetMap;
+ private HashMap fExtsSetToExtsSetSettingsMap;
+ private PathSettingsContainer fContainer;
+ private boolean fIsDerived;
+
+ RcSetSettings(PathSettingsContainer cr, CResourceData rcData, boolean isDerived){
+ this.fContainer = cr;
+ this.fRcData = rcData;
+ this.fIsDerived = isDerived;
+ cr.setValue(this);
+ }
+
+ public RcSetSettings getChild(IPath path, boolean exactPath){
+ PathSettingsContainer cr = fContainer.getChildContainer(path, false, exactPath);
+ if(cr != null)
+ return (RcSetSettings)cr.getValue();
+ return null;
+ }
+
+ public RcSetSettings getChild(IPath path){
+ PathSettingsContainer cr = fContainer.getChildContainer(path, false, true);
+ if(cr != null)
+ return (RcSetSettings)cr.getValue();
+ return null;
+ }
+
+ public CResourceData getResourceData() {
+ return fRcData;
+ }
+
+ public RcSetSettings createChild(IPath path, CResourceData data, boolean isDerived){
+ PathSettingsContainer cr = fContainer.getChildContainer(path, true, true);
+ RcSetSettings child = (RcSetSettings)cr.getValue();
+ if(child == null){
+ child = new RcSetSettings(cr, data, isDerived);
+// cr.setValue(child);
+ }
+ return child;
+ }
+
+ void updateRcData(CResourceData data, boolean isDerived){
+ fRcData = data;
+ fIsDerived = data != null ? isDerived : false;
+ updateLangDatas();
+ }
+
+ private void updateLangDatas(){
+ ExtsSetSettings extSetting;
+
+ if(fRcData.getType() == ICSettingBase.SETTING_FILE){
+ CLanguageData lData = ((CFileData)fRcData).getLanguageData();
+ extSetting = (ExtsSetSettings)fExtToExtsSetMap.get(getFileExt(fRcData.getPath()));
+ if(extSetting != null){
+ extSetting.fBaseLangData = lData;
+ extSetting.fIsDerived = lData != null ? fIsDerived : false;
+ }
+
+ if(extSetting != null ?
+ fExtsSetToExtsSetSettingsMap.size() > 1
+ : fExtsSetToExtsSetSettingsMap.size() > 0){
+ ExtsSetSettings s;
+ for(Iterator iter = fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){
+ s = (ExtsSetSettings)iter.next();
+ if(s != extSetting){
+ s.fBaseLangData = null;
+ s.fIsDerived = false;
+ }
+ }
+ }
+ } else {
+ CLanguageData[] lDatas = ((CFolderData)fRcData).getLanguageDatas();
+ Map map = (HashMap)fExtsSetToExtsSetSettingsMap.clone();
+
+ CLanguageData lData;
+ for(int i = 0; i < lDatas.length; i++){
+ lData = lDatas[i];
+ extSetting = (ExtsSetSettings)map.remove(new ExtsSet(lData.getSourceExtensions()));
+ if(extSetting != null){
+ extSetting.fBaseLangData = lData;
+ extSetting.fIsDerived = this.fIsDerived;
+ }
+ }
+
+ if(map.size() != 0){
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ extSetting = (ExtsSetSettings)iter.next();
+ extSetting.fBaseLangData = null;
+ extSetting.fIsDerived = false;
+ }
+ }
+ }
+ }
+
+ public IPath getPath(){
+ return fContainer.getPath();
+ }
+
+ public RcSetSettings getParent(){
+ PathSettingsContainer cr = fContainer.getParentContainer();
+ if(cr != null)
+ return (RcSetSettings)cr.getValue();
+ return null;
+ }
+
+ void internalSetSettingsMap(HashMap map){
+ fExtsSetToExtsSetSettingsMap = map;
+ fExtToExtsSetMap = calcExtToExtSetSettingsMap(map);
+ }
+
+ void internalAdd(ExtsSetSettings setting){
+ if(fExtsSetToExtsSetSettingsMap == null){
+ fExtsSetToExtsSetSettingsMap = new HashMap();
+ }
+
+ ExtsSetSettings cur = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(setting.fExtsSet);
+ if(cur != null){
+ cur.add(setting);
+ } else {
+ fExtsSetToExtsSetSettingsMap.put(setting.fExtsSet, setting);
+ fExtToExtsSetMap = addExtsInfoToMap(setting, fExtToExtsSetMap);
+ }
+ }
+
+ void internalAddSettingsMap(HashMap map){
+ ExtsSetSettings setting;//, thisSetting;
+// ExtsSet extsSet;
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ setting = (ExtsSetSettings)iter.next();
+ internalAdd(setting);
+// extsSet = setting.fExtsSet;
+// thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet);
+// if(thisSetting != null){
+// thisSetting.add(setting);
+// } else {
+// fExtsSetToExtsSetSettingsMap.put(extsSet, setting);
+// fExtToExtsSetMap = addExtsInfoToMap(setting, fExtToExtsSetMap);
+// }
+ }
+ }
+
+ public boolean settingsEqual(RcSetSettings other){
+ return fExtsSetToExtsSetSettingsMap.equals(other.fExtsSetToExtsSetSettingsMap);
+ }
+
+ public RcSetSettings[] getChildren(final boolean includeCurrent){
+ final List list = new ArrayList();
+ fContainer.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ if(includeCurrent || container != fContainer){
+ list.add(container.getValue());
+ }
+ return true;
+ }
+
+ });
+
+ return (RcSetSettings[])list.toArray(new RcSetSettings[list.size()]);
+ }
+
+ public boolean containsEqualMaxMatches(RcSetSettings other, boolean ignoreGenerated){
+ if(!ignoreGenerated && fExtsSetToExtsSetSettingsMap.size() < other.fExtsSetToExtsSetSettingsMap.size())
+ return false;
+
+ ExtsSetSettings otherSetting, thisSetting;
+ Map.Entry entry;
+
+ for(Iterator iter = other.fExtsSetToExtsSetSettingsMap.entrySet().iterator(); iter.hasNext();){
+ entry = (Map.Entry)iter.next();
+ otherSetting = (ExtsSetSettings)entry.getValue();
+ if(ignoreGenerated && otherSetting.fBaseLangData == null)
+ continue;
+
+ thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(entry.getKey());
+ if(thisSetting == null)
+ return false;
+
+ if(otherSetting.fMaxMatchInfo != null && !otherSetting.fMaxMatchInfo.equals(thisSetting.fMaxMatchInfo))
+ return false;
+ }
+
+ return true;
+ }
+
+ void removeChild(RcSetSettings setting){
+ IPath path = setting.fContainer.getPath();
+ IPath thisPath = fContainer.getPath();
+ if(!thisPath.isPrefixOf(path))
+ throw new IllegalArgumentException();
+
+ path = path.removeFirstSegments(thisPath.segmentCount());
+ fContainer.removeChildContainer(path);
+ }
+ }
+
+ private static HashMap calcExtToExtSetSettingsMap(Map extsSetMap){
+ HashMap result = null;
+ ExtsSetSettings setting;
+ for(Iterator iter = extsSetMap.values().iterator(); iter.hasNext();){
+ setting = (ExtsSetSettings)iter.next();
+ result = addExtsInfoToMap(setting, result);
+ }
+ return result;
+ }
+
+ private static HashMap addExtsInfoToMap(ExtsSetSettings setting, HashMap map){
+ boolean forceAdd = false;
+ String[] exts = setting.fExtsSet.fExts;
+ String ext;
+ if(map == null){
+ map = new HashMap();
+ forceAdd = true;
+ }
+
+ for(int i = 0; i < exts.length; i++){
+ ext = exts[i];
+ if(forceAdd || !map.containsKey(ext)){
+ map.put(ext, setting);
+ }
+ }
+ return map;
+ }
+
+ private RcSetSettings createRcSetInfo (CConfigurationData data){
+ CFolderData rootData = data.getRootFolderData();
+ PathSettingsContainer container = PathSettingsContainer.createRootContainer();
+ RcSetSettings rcSet = new RcSetSettings(container, rootData, false);
+ rcSet.internalSetSettingsMap(createExtsSetSettingsMap(rootData));
+// rcSet.fExtToExtsSetMap = new HashMap();
+// rcSet.fExtsSetToExtsSetSettingsMap = new HashMap();
+
+ CResourceData[] rcDatas = data.getResourceDatas();
+ CResourceData rcData;
+ RcSetSettings curRcSet;
+ HashMap fileMap;
+ ExtsSetSettings fileSetting;
+ IPath path;
+
+ for(int i = 0; i < rcDatas.length; i++){
+ rcData = rcDatas[i];
+ if(rcData == rootData)
+ continue;
+
+ if(!includeRcDataInCalculation(data, rcData))
+ continue;
+
+ path = rcData.getPath();
+ curRcSet = rcSet.createChild(path, rcData, false);
+ if(rcData.getType() == ICSettingBase.SETTING_FILE){
+ fileMap = new HashMap(1);
+ fileSetting = createExtsSetSettings(path, (CFileData)rcData);
+ fileMap.put(fileSetting.fExtsSet, fileSetting);
+ curRcSet.internalSetSettingsMap(fileMap);
+ } else {
+ curRcSet.internalSetSettingsMap(createExtsSetSettingsMap((CFolderData)rcData));
+ }
+ }
+
+ return rcSet;
+ }
+
+ protected boolean includeRcDataInCalculation(CConfigurationData cfgData, CResourceData rcData){
+ return true;
+ }
+
+ protected CFileData createFileData(CConfigurationData cfgData, IPath path, CFileData base) throws CoreException{
+ return cfgData.createFileData(path, base);
+ }
+
+ protected CFileData createFileData(CConfigurationData cfgData, IPath path, CFolderData base, CLanguageData langBase) throws CoreException{
+ return cfgData.createFileData(path, base, langBase);
+ }
+
+ protected CFolderData createFolderData(CConfigurationData cfgData, IPath path, CFolderData base) throws CoreException{
+ return cfgData.createFolderData(path, base);
+ }
+
+ private RcSetSettings createRcSetSettings(CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo){
+ RcSetSettings rcSet = createRcSetInfo(data);
+ Map map = discoveredInfo.getPathInfoMap();
+ PathFilePathInfo pInfos[] = createOrderedInfo(map);
+ mapDiscoveredInfo(rcSet, pInfos);
+ checkRemoveDups(rcSet);
+ return rcSet;
+ }
+
+ /*
+ * utility method for creating empty IRcSettingInfo
+ */
+ public static IRcSettingInfo createEmptyRcSettingInfo(CFolderData data){
+ return createRcSettingInfo(data, PathInfo.EMPTY_INFO);
+ }
+
+ public static IRcSettingInfo createRcSettingInfo(CFolderData data, PathInfo info){
+ RcSettingInfo rcInfo = new RcSettingInfo(data);
+ CLanguageData[] lDatas = data.getLanguageDatas();
+ addLanguageInfos(rcInfo, lDatas, info);
+ return rcInfo;
+ }
+
+ /*
+ * utility method for creating empty IRcSettingInfo
+ */
+ public static IRcSettingInfo createEmptyRcSettingInfo(CFileData data){
+ return createRcSettingInfo(data, PathInfo.EMPTY_INFO);
+ }
+
+ public static IRcSettingInfo createRcSettingInfo(CFileData data, PathInfo info){
+ RcSettingInfo rcInfo = new RcSettingInfo(data);
+ CLanguageData lData = data.getLanguageData();
+ if(lData != null)
+ addLanguageInfos(rcInfo, new CLanguageData[]{lData}, info);
+ return rcInfo;
+ }
+
+ private static void addLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas, PathInfo info){
+ ArrayList list = rcInfo.fLangInfoList;
+ if(list == null){
+ list = new ArrayList(lDatas.length);
+ rcInfo.fLangInfoList = list;
+ } else {
+ list.ensureCapacity(lDatas.length);
+ }
+
+ for(int i = 0; i < lDatas.length; i++){
+ list.add(new LangSettingInfo(lDatas[i], info));
+ }
+ }
+
+ private IRcSettingInfo[] mapFileDiscoveredInfo(IProject project, CConfigurationData data, RcSetSettings rcSet, PathFilePathInfo[] pfpis){
+// IResource rc;
+ PathInfo pInfo;
+ IPath projRelPath;
+ CResourceData rcData;
+// RcSetSettings dataSetting;
+ List list = new ArrayList(pfpis.length);
+ RcSettingInfo rcInfo;
+ LangSettingInfo lInfo;
+ CLanguageData lData;
+ ArrayList tmpList;
+ PathFilePathInfo pfpi;
+
+ for(int i = 0; i < pfpis.length; i++){
+ pfpi = pfpis[i];
+ projRelPath = pfpi.fPath;
+ pInfo = pfpi.fInfo;
+ if(pInfo.isEmpty())
+ continue;
+
+ if(projRelPath.segmentCount() == 0){
+ CFolderData rootData = (CFolderData)rcSet.fRcData;
+ CLanguageData lDatas[] = rootData.getLanguageDatas();
+ IPath[] incPaths = pInfo.getIncludePaths();
+ IPath[] quotedIncPaths = pInfo.getQuoteIncludePaths();
+ IPath[] incFiles = pInfo.getIncludeFiles();
+ IPath[] macroFiles = pInfo.getMacroFiles();
+ Map symbolMap = pInfo.getSymbols();
+ int kinds = 0;
+
+ if(incPaths.length != 0 || quotedIncPaths.length != 0)
+ kinds |= ICLanguageSettingEntry.INCLUDE_PATH;
+ if(incFiles.length != 0)
+ kinds |= ICLanguageSettingEntry.INCLUDE_FILE;
+ if(macroFiles.length != 0)
+ kinds |= ICLanguageSettingEntry.MACRO_FILE;
+ if(symbolMap.size() != 0)
+ kinds |= ICLanguageSettingEntry.MACRO;
+
+ rcInfo = null;
+ for(int k = 0; k < lDatas.length; k++){
+ lData = lDatas[k];
+ if((lData.getSupportedEntryKinds() & kinds) == 0)
+ continue;
+
+ if(rcInfo == null){
+ rcInfo = new RcSettingInfo(rootData);
+ tmpList = new ArrayList(lDatas.length - k);
+ rcInfo.fLangInfoList = tmpList;
+ }
+
+ lInfo = new LangSettingInfo(lData, pInfo);
+ rcInfo.add(lInfo);
+ }
+
+ if(rcInfo != null)
+ list.add(rcInfo);
+
+ continue;
+ }
+// switch(rc.getType()){
+// case IResource.FILE:
+// projRelPath = rc.getProjectRelativePath();
+// dataSetting = rcSet.getChild(projRelPath, false);
+// rcData = dataSetting.fRcData;
+ rcData = rcSet.getChild(projRelPath, false).fRcData;
+ if(!rcData.getPath().equals(projRelPath)){
+ if(rcData.getType() == ICSettingBase.SETTING_FOLDER){
+ CFolderData foData = (CFolderData)rcData;
+ lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData)rcData);
+ try {
+ rcData = createFileData(data, projRelPath, foData, lData);
+ } catch (CoreException e) {
+ rcData = null;
+ MakeCorePlugin.log(e);
+ }
+ } else {
+ try {
+ rcData = createFileData(data, projRelPath, (CFileData)rcData);
+ } catch (CoreException e) {
+ rcData = null;
+ MakeCorePlugin.log(e);
+ }
+ }
+// if(rcData != null)
+// dataSetting = rcSet.createChild(projRelPath, rcData, false);
+// else
+// dataSetting = null;
+ }
+
+ if(rcData != null){
+ if(rcData.getType() == ICSettingBase.SETTING_FILE){
+ lData = ((CFileData)rcData).getLanguageData();
+ } else {
+ lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData)rcData);
+
+ }
+
+ if(lData != null){
+ rcInfo = new RcSettingInfo(rcData);
+ lInfo = new LangSettingInfo(lData, pInfo);
+ tmpList = new ArrayList(1);
+ tmpList.add(lInfo);
+ rcInfo.fLangInfoList = tmpList;
+ list.add(rcInfo);
+ }
+
+ }
+
+// break;
+// }
+ }
+ return (RcSettingInfo[])list.toArray(new RcSettingInfo[list.size()]);
+ }
+
+ public IRcSettingInfo[] getSettingInfos(IProject project, CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo, boolean fileDataMode){
+ if(fileDataMode){
+ RcSetSettings rcSettings = createRcSetInfo(data);
+ PathFilePathInfo pInfos[] = createOrderedInfo(discoveredInfo.getPathInfoMap());
+ return mapFileDiscoveredInfo(project, data, rcSettings, pInfos);
+ }
+ RcSetSettings settings = createRcSetSettings(data, discoveredInfo);
+ return createInfos(data, settings);
+ }
+
+ private IRcSettingInfo[] createInfos(CConfigurationData data, RcSetSettings rootSetting){
+ RcSetSettings settings[] = rootSetting.getChildren(true);
+ RcSetSettings setting;
+ CResourceData rcData;
+ ExtsSetSettings extSetting;
+ List resultList = new ArrayList();
+ LangSettingInfo langInfo;
+ RcSettingInfo rcInfo;
+ PathInfo pathInfo;
+ for(int i = 0; i < settings.length; i++){
+ setting = settings[i];
+ rcData = setting.fRcData;
+ if(rcData == null)
+ continue;
+ if(setting.fIsDerived){
+// rcData = null;
+ try {
+ rcData = createFolderData(data, rcData, setting);
+ } catch (CoreException e) {
+ rcData = null;
+ MakeCorePlugin.log(e);
+ }
+ if(rcData != null){
+ setting.updateRcData(rcData, false);
+ } else {
+ //TODO:
+ continue;
+ }
+ }
+
+ if(rcData.getType() == ICSettingBase.SETTING_FILE){
+ extSetting = (ExtsSetSettings)setting.fExtToExtsSetMap.get(getFileExt(rcData.getPath()));
+ if(extSetting != null){
+ pathInfo = extSetting.fMaxMatchInfo;
+ if(pathInfo != null){
+ langInfo = new LangSettingInfo(extSetting.fBaseLangData, pathInfo);
+ rcInfo = new RcSettingInfo(rcData);
+ rcInfo.fLangInfoList = new ArrayList(1);
+ rcInfo.fLangInfoList.add(langInfo);
+ resultList.add(rcInfo);
+ }
+ }
+ } else {
+ if(setting.fExtsSetToExtsSetSettingsMap.size() != 0 ){
+ rcInfo = new RcSettingInfo(rcData);
+ rcInfo.fLangInfoList = new ArrayList(setting.fExtsSetToExtsSetSettingsMap.size());
+ resultList.add(rcInfo);
+
+ for(Iterator iter = setting.fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){
+ extSetting = (ExtsSetSettings)iter.next();
+ if(extSetting.fMaxMatchInfo == null)
+ continue;
+
+ if(extSetting.fBaseLangData == null)
+ continue;
+
+ if(extSetting.fIsDerived){
+ throw new IllegalStateException();
+ }
+
+
+ rcInfo.add(new LangSettingInfo(extSetting.fBaseLangData, extSetting.fMaxMatchInfo));
+
+ if(extSetting.isMultiple()){
+ Map.Entry entry;
+ List piList;
+ int sz;
+ PathFilePathInfo pi;
+ CFileData fiData;
+ RcSettingInfo fiInfo;
+ CLanguageData fiLangData;
+
+ for(Iterator pathInfoIter = extSetting.fPathFilePathInfoMap.entrySet().iterator(); pathInfoIter.hasNext();){
+ entry = (Map.Entry)pathInfoIter.next();
+ if(entry.getKey().equals(extSetting.fMaxMatchInfo))
+ continue;
+ piList = (List)entry.getValue();
+ sz = piList.size();
+
+ for(int k = 0; k < sz; k++){
+ pi = (PathFilePathInfo)piList.get(k);
+ try {
+ fiData = createFileData(data, pi.fPath, (CFolderData)rcData, extSetting.fBaseLangData);
+ fiLangData = fiData.getLanguageData();
+ if(fiLangData != null){
+ fiInfo = new RcSettingInfo(fiData);
+ fiInfo.add(new LangSettingInfo(fiLangData, pi.fInfo));
+ resultList.add(fiInfo);
+ }
+ } catch (CoreException e) {
+ MakeCorePlugin.log(e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+// }
+
+ return (RcSettingInfo[])resultList.toArray(new RcSettingInfo[resultList.size()]);
+ }
+
+ private CFolderData createFolderData(CConfigurationData cfg, CResourceData base, RcSetSettings setting) throws CoreException{
+ if(base.getType() == ICSettingBase.SETTING_FOLDER)
+ return createFolderData(cfg, setting.getPath(), (CFolderData)base);
+
+ //should not be here
+ throw new IllegalStateException();
+ }
+
+ private static void checkRemoveDups(RcSetSettings rcSet){
+ RcSetSettings settings[] = rcSet.getChildren(true);
+ RcSetSettings setting, parent;
+ for(int i = 0; i < settings.length; i++){
+ setting = settings[i];
+ if(!setting.fIsDerived)
+ continue;
+
+ parent = setting.getParent();
+ if(parent == null)
+ continue;
+
+ if(parent.containsEqualMaxMatches(setting, true))
+ removeChildAddingChildSettings(parent, setting);
+ }
+ }
+
+ private static void removeChildAddingChildSettings(RcSetSettings parent, RcSetSettings child){
+ parent.internalAddSettingsMap(child.fExtsSetToExtsSetSettingsMap);
+ parent.removeChild(child);
+ }
+
+ private static void mapDiscoveredInfo(RcSetSettings rcSet, PathFilePathInfo[] pInfos){
+ PathFilePathInfo pInfo;
+ RcSetSettings child, parent;
+ String ext;
+ ExtsSetSettings extsSet;
+// boolean isDerived;
+ IPath dirPath;
+ for(int i = 0; i < pInfos.length; i++){
+ pInfo = pInfos[i];
+ child = rcSet.getChild(pInfo.fPath);
+ if(child == null) {
+ dirPath = pInfo.fPath.removeLastSegments(1);
+ child = rcSet.getChild(dirPath);
+ if(child == null){
+ child = rcSet.createChild(dirPath, null, true);
+ if(child.fExtToExtsSetMap == null){
+ parent = child.getParent();
+ child.fRcData = parent.fRcData;
+ child.internalSetSettingsMap(createEmptyExtSetMapCopy(parent.fExtsSetToExtsSetSettingsMap));
+ }
+ }
+ }
+
+// isDerived = child.fIsDerived;
+
+ if(pInfo.fPath.segmentCount() == 0){
+ processProjectPaths(child, pInfo);
+ } else {
+ ext = getFileExt(pInfo.fPath);
+ extsSet = (ExtsSetSettings)child.fExtToExtsSetMap.get(ext);
+ if(extsSet == null){
+ extsSet = new ExtsSetSettings(null, new ExtsSet(new String[]{ext}), false);
+ child.internalAdd(extsSet);
+// child.fExtToExtsSetMap.put(ext, extsSet);
+ }
+ extsSet.add(pInfo);
+ }
+ }
+ }
+
+ private static void processProjectPaths(RcSetSettings rcSet, PathFilePathInfo pfpi){
+ ExtsSetSettings setting;
+ for(Iterator iter = rcSet.fExtsSetToExtsSetSettingsMap.values().iterator(); iter.hasNext();){
+ setting = (ExtsSetSettings)iter.next();
+ setting.add(pfpi);
+ }
+ }
+
+ private static String getFileExt(IPath path){
+ String ext = path.getFileExtension();
+ if(ext != null)
+ return ext;
+ return ""; //$NON-NLS-1$
+ }
+
+ private static HashMap createEmptyExtSetMapCopy(HashMap base){
+ HashMap map = (HashMap)base.clone();
+ ExtsSetSettings extsSet;
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ extsSet = (ExtsSetSettings)entry.getValue();
+ extsSet = new ExtsSetSettings(extsSet.fBaseLangData, extsSet.fExtsSet, true);
+ entry.setValue(extsSet);
+ }
+ return map;
+ }
+
+ private static ExtsSetSettings createExtsSetSettings(IPath path, CFileData data){
+ CLanguageData lData = data.getLanguageData();
+ if(lData != null){
+ String ext = getFileExt(path);
+ return createExtsSetSettings(lData, new String[]{ext});
+ }
+ return new ExtsSetSettings(null, new ExtsSet(EMPTY_STRING_ARRAY), false);
+ }
+
+ private static ExtsSetSettings createExtsSetSettings(CLanguageData lData, String exts[]){
+ return new ExtsSetSettings(lData, new ExtsSet(exts), false);
+ }
+
+ private static HashMap createExtsSetSettingsMap(CFolderData data){
+ CLanguageData[] lDatas = data.getLanguageDatas();
+ HashMap map = new HashMap(lDatas.length);
+ ExtsSetSettings settings;
+
+ if(lDatas.length != 0) {
+ CLanguageData lData;
+ for( int i = 0; i < lDatas.length; i++){
+ lData = lDatas[i];
+ settings = createExtsSetSettings(lData, lData.getSourceExtensions());
+ map.put(settings.fExtsSet, settings);
+ }
+ }
+
+ return map;
+ }
+
+ private static PathFilePathInfo[] createOrderedInfo(Map map){
+ Map.Entry entry;
+ IResource rc;
+ IPath path;
+ PathInfo info, storedInfo;
+ ListIndexStore store = new ListIndexStore(10);
+ HashMap infoMap = new HashMap();
+// LinkedHashMap result;
+
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ entry = (Map.Entry)iter.next();
+ rc = (IResource)entry.getKey();
+ path = rc.getProjectRelativePath();
+ int segCount = path.segmentCount();
+// if(segCount < 1)
+// continue;
+
+// path = path.removeFirstSegments(1);
+// segCount--;
+
+ info = (PathInfo)entry.getValue();
+ storedInfo = (PathInfo)infoMap.get(info);
+ if(storedInfo == null){
+ storedInfo = info;
+ infoMap.put(storedInfo, storedInfo);
+ }
+
+ store.add(segCount, new PathFilePathInfo(path, storedInfo));
+ }
+
+ List lists[] = store.getLists();
+// result = new LinkedHashMap(map.size());
+// List l;
+// int lSize;
+// PathFilePathInfo pfpi;
+// for(int i = 0; i < lists.length; i++){
+// l = lists[i];
+// lSize = l.size();
+// if(lSize != 0){
+// for(int k = 0; k < lSize; k++){
+// pfpi = (PathFilePathInfo)l.get(k);
+// result.put(pfpi.fPath, pfpi.fInfo);
+// }
+// }
+// }
+ int size = 0;
+ PathFilePathInfo infos[];
+ for(int i = 0; i < lists.length; i++){
+ size += lists[i].size();
+ }
+
+ infos = new PathFilePathInfo[size];
+ int num = 0;
+ int listSize;
+ List list;
+ for(int i = 0; i < lists.length; i++){
+ list = lists[i];
+ listSize = list.size();
+ for(int k = 0; k < listSize; k++){
+ infos[num++] = (PathFilePathInfo)list.get(k);
+ }
+ }
+
+ return infos;
+ }
+
+ public static CDataDiscoveredInfoCalculator getDefault(){
+ if(fInstance == null)
+ fInstance = new CDataDiscoveredInfoCalculator();
+ return fInstance;
+ }
+
+ public IRcSettingInfo[] getSettingInfos(IProject project,
+ CConfigurationData cfgData){
+ InfoContext context = createContext(project, cfgData);
+ try {
+ IDiscoveredPathManager.IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
+ if(info instanceof IDiscoveredPathManager.IPerFileDiscoveredPathInfo2){
+ IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 perFileInfo = (IDiscoveredPathManager.IPerFileDiscoveredPathInfo2)info;
+ return getSettingInfos(project, cfgData, perFileInfo, true);
+ }
+ IPath[] includes = info.getIncludePaths();
+ Map symbols = info.getSymbols();
+
+ PathInfo pathInfo = new PathInfo(includes, null, symbols, null, null);
+ CFolderData rootData = cfgData.getRootFolderData();
+ IRcSettingInfo rcInfo = createRcSettingInfo(rootData, pathInfo);
+ return new IRcSettingInfo[]{rcInfo};
+ } catch (CoreException e) {
+ MakeCorePlugin.log(e);
+ }
+ return new IRcSettingInfo[0];
+ }
+
+ protected InfoContext createContext(IProject project, CConfigurationData data){
+ return new InfoContext(project, idForData(data));
+ }
+
+ protected String idForData(CDataObject data){
+ return data.getId();
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java
new file mode 100644
index 00000000000..3c7cb20854d
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * 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.make.internal.core.scannerconfig;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
+import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.ILangSettingInfo;
+import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.IRcSettingInfo;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public abstract class CDataDiscoveredInfoProcessor {
+
+ public void applyDiscoveredInfo(CConfigurationData cfgData, IRcSettingInfo[] infos){
+ Map map = CDataUtil.createPathRcDataMap(cfgData);
+ IRcSettingInfo info;
+
+ PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
+
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ applyInfo(cfgData, info, cr);
+ map.remove(info.getResourceData().getPath());
+ }
+
+ if(map.size() != 0){
+ CResourceData rcData = (CResourceData)map.get(Path.EMPTY);
+ if(rcData != null){
+ info = CDataDiscoveredInfoCalculator.createEmptyRcSettingInfo((CFolderData)rcData);
+ applyInfo(cfgData, info, cr);
+ map.remove(Path.EMPTY);
+ }
+
+ if(map.size() != 0){
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ IPath path = (IPath)entry.getKey();
+ PathSettingsContainer curCr = cr.getChildContainer(path, false, false);
+ rcData = (CResourceData)entry.getValue();
+ info = (IRcSettingInfo)curCr.getValue();
+ applyInfo(cfgData, rcData, info);
+ }
+ }
+ }
+ }
+
+ protected void applyInfo(CConfigurationData cfgData, CResourceData rcData, IRcSettingInfo info){
+ CLanguageData[] lDatas = getLangDatas(rcData);
+ ILangSettingInfo lInfo;
+ ILangSettingInfo lInfos[] = info.getLangInfos();
+ CLanguageData lData;
+ for(int k = 0; k < lDatas.length; k++){
+ lData = lDatas[k];
+ lInfo = getMatch(lData, lInfos);
+ if(lInfo != null){
+ setInfoForData(cfgData,
+ rcData,
+ lData,
+ lInfo.getFilePathInfo(),
+ info.getResourceData(),
+ lInfo.getLanguageData());
+ } else {
+ setInfoForData(cfgData, rcData, lData, null, null, null);
+ }
+ }
+ }
+
+ protected CLanguageData[] getLangDatas(CResourceData rcData){
+ if(rcData.getType() == ICSettingBase.SETTING_FILE){
+ CLanguageData lData = ((CFileData)rcData).getLanguageData();
+ if(lData != null)
+ return new CLanguageData[]{lData};
+ return new CLanguageData[0];
+ }
+ return ((CFolderData)rcData).getLanguageDatas();
+ }
+
+ protected ILangSettingInfo getMatch(CLanguageData lData, ILangSettingInfo lInfos[]){
+ ILangSettingInfo lInfo;
+ for(int i = 0; i < lInfos.length; i++){
+ lInfo = lInfos[i];
+ if(langDatasMatch(lData, lInfo.getLanguageData()))
+ return lInfo;
+ }
+ return null;
+ }
+
+ protected CLanguageData getMatch(CLanguageData lData, CLanguageData[] datas){
+ for(int i = 0; i < datas.length; i++){
+ if(langDatasMatch(lData, datas[i]))
+ return datas[i];
+ }
+ return null;
+ }
+
+ protected boolean langDatasMatch(CLanguageData lData1, CLanguageData lData2){
+ if(!CDataUtil.objectsEqual(lData1.getLanguageId(), lData2.getLanguageId()))
+ return false;
+
+ String[] tmp = lData1.getSourceContentTypeIds();
+ if(tmp != null && tmp.length != 0){
+ if(!Arrays.equals(tmp, lData2.getSourceContentTypeIds()))
+ return false;
+ } else {
+ if(!Arrays.equals(lData1.getSourceExtensions(), lData2.getSourceExtensions()))
+ return false;
+ }
+ return true;
+ }
+
+ protected void applyInfo(CConfigurationData cfgData, IRcSettingInfo info, PathSettingsContainer cr){
+ CResourceData rcData;
+ CLanguageData lData;
+ ILangSettingInfo lInfo;
+ rcData = info.getResourceData();
+ IPath path = rcData.getPath();
+ PathSettingsContainer curCr = cr.getChildContainer(path, true, true);
+ curCr.setValue(info);
+ ILangSettingInfo lInfos[] = info.getLangInfos();
+ for(int k = 0; k < lInfos.length; k++){
+ lInfo = lInfos[k];
+ lData = lInfo.getLanguageData();
+ setInfoForData(cfgData, rcData, lData, lInfo.getFilePathInfo(), null, null);
+ }
+ }
+
+ protected abstract void setInfoForData(CConfigurationData cfgData,
+ CResourceData rcData,
+ CLanguageData lData,
+ PathInfo pi,
+ CResourceData baseRcData,
+ CLanguageData baseLangData);
+
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
index ba27dcbf68a..bf00acdedd3 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
@@ -164,6 +164,9 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
+ if(buildInfo == null)
+ buildInfo = container.getInfo(new InfoContext(project));
+
if(buildInfo != null){
String profileId = buildInfo.getSelectedProfileId();
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
index ab5ec31a819..e7bcf000ad6 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
@@ -164,11 +164,13 @@ public class ScannerInfoConsoleParserFactory {
if (collector == null) {
collector = profileInstance.getScannerInfoCollector();
}
- clParser.startup(currentProject, workingDirectory, collector,
- scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
- // create an output stream sniffer
- return new ConsoleOutputSniffer(outputStream, errorStream, new
- IScannerInfoConsoleParser[] {clParser});
+ if(clParser != null){
+ clParser.startup(currentProject, workingDirectory, collector,
+ scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
+ // create an output stream sniffer
+ return new ConsoleOutputSniffer(outputStream, errorStream, new
+ IScannerInfoConsoleParser[] {clParser});
+ }
}
}
// }
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
index c590146cdae..78034966378 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
@@ -63,7 +63,7 @@ public class SCJobsUtil {
public static boolean getProviderScannerInfo(final IProject project,
final IScannerConfigBuilderInfo2 buildInfo,
final IProgressMonitor monitor) {
- return getProviderScannerInfo(project, new InfoContext(project), buildInfo, monitor);
+ return getProviderScannerInfo(project, buildInfo.getContext(), buildInfo, monitor);
}
public static boolean getProviderScannerInfo(final IProject project,
@@ -114,7 +114,7 @@ public class SCJobsUtil {
public static boolean updateScannerConfiguration(IProject project,
IScannerConfigBuilderInfo2 buildInfo,
final IProgressMonitor monitor) {
- return updateScannerConfiguration(project, new InfoContext(project), buildInfo, monitor);
+ return updateScannerConfiguration(project, buildInfo.getContext(), buildInfo, monitor);
}
/**
@@ -163,7 +163,7 @@ public class SCJobsUtil {
public static boolean readBuildOutputFile(final IProject project,
final IScannerConfigBuilderInfo2 buildInfo,
final IProgressMonitor monitor) {
- return readBuildOutputFile(project, new InfoContext(project), buildInfo, monitor);
+ return readBuildOutputFile(project, buildInfo.getContext(), buildInfo, monitor);
}
/**
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java
new file mode 100644
index 00000000000..3043fe76bad
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.make.internal.core.scannerconfig.util;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICMacroEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
+import org.eclipse.core.runtime.IPath;
+
+public class PathInfoToLangSettingsConverter {
+ public static int getSupportedEntryKinds(IDiscoveredPathInfo info){
+ if(info instanceof IPerFileDiscoveredPathInfo){
+ return getSupportedEntryKinds((IPerFileDiscoveredPathInfo)info);
+ }
+ return ICLanguageSettingEntry.INCLUDE_PATH
+ | ICLanguageSettingEntry.MACRO;
+ }
+
+ public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info){
+ return ICLanguageSettingEntry.INCLUDE_FILE
+ | ICLanguageSettingEntry.INCLUDE_PATH
+ | ICLanguageSettingEntry.MACRO
+ | ICLanguageSettingEntry.MACRO_FILE;
+ }
+
+ public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info){
+ switch (kind) {
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ ICLanguageSettingEntry[] incPaths = calculateEntries(kind, flags, info.getIncludePaths());
+ IPath[] quotedPaths = info.getQuoteIncludePaths();
+ if(quotedPaths.length != 0){
+ if(incPaths.length != 0){
+ ICLanguageSettingEntry quotedEntries[] = calculateEntries(kind, flags, quotedPaths);
+ ICLanguageSettingEntry[] tmp = new ICLanguageSettingEntry[incPaths.length + quotedEntries.length];
+ System.arraycopy(incPaths, 0, tmp, 0, incPaths.length);
+ System.arraycopy(quotedEntries, 0, tmp, incPaths.length, quotedEntries.length);
+ incPaths = tmp;
+ } else {
+ incPaths = calculateEntries(kind, flags, quotedPaths);
+ }
+ }
+ return incPaths;
+ case ICLanguageSettingEntry.MACRO:
+ return calculateEntries(flags, info.getSymbols());
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return calculateEntries(kind, flags, info.getMacroFiles());
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return calculateEntries(kind, flags, info.getIncludeFiles());
+ }
+ return new ICLanguageSettingEntry[0];
+ }
+
+ private static ICLanguageSettingEntry[] calculateEntries(int kind, int flags, IPath[] values){
+ ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[values.length];
+ for(int i = 0; i < values.length; i++){
+ entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, values[i].toString(), null, null, flags);
+ }
+ return entries;
+ }
+
+ private static ICMacroEntry[] calculateEntries(int flags, Map map){
+ ICMacroEntry entries[] = new ICMacroEntry[map.size()];
+ int num = 0;
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String name = (String)entry.getKey();
+ String value = (String)entry.getValue();
+ entries[num++] = new CMacroEntry(name, value, flags);
+ }
+ return entries;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
index 9463306ca4a..ac2ff6f1754 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
@@ -61,6 +61,8 @@ public class ScannerConfigProfileManager {
try {
IScannerConfigBuilderInfo2Set container = createScannerConfigBuildInfo2Set(project);
IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
+ if(buildInfo == null)
+ buildInfo = container.getInfo(new InfoContext(project));
profileId = buildInfo.getSelectedProfileId();
} catch (CoreException e) {
MakeCorePlugin.log(e);
diff --git a/build/org.eclipse.cdt.make.ui/icons/obj16/define_obj.gif b/build/org.eclipse.cdt.make.ui/icons/obj16/define_obj.gif
new file mode 100644
index 00000000000..87d583e1dd3
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/icons/obj16/define_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.make.ui/icons/obj16/hfolder_obj.gif b/build/org.eclipse.cdt.make.ui/icons/obj16/hfolder_obj.gif
new file mode 100644
index 00000000000..b98b8172795
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/icons/obj16/hfolder_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties
index bce759ac41e..ff219ff7ddf 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.properties
+++ b/build/org.eclipse.cdt.make.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2005 QNX Software Systems and others.
+# Copyright (c) 2003, 2007 QNX Software Systems 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
@@ -70,3 +70,9 @@ DiscoveredScannerInfoContainer.name=Discovered scanner configuration container
GCCPerProjectProfile.name=GCC per project scanner info profile
GCCPerFileProfile.name=GCC per file scanner info profile
+
+## New CDT project model - property pages names
+CDTPathSymbolsProperty.name=C/C++ Project paths and symbols
+
+Includes=Includes
+Symbols=Symbols
diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml
index c17320d51f8..91048c5d044 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.xml
+++ b/build/org.eclipse.cdt.make.ui/plugin.xml
@@ -447,4 +447,59 @@
<contentExtension pattern="org.eclipse.cdt.make.ui.wizards.*"/>
</includes>
</viewerContentBinding>
- </extension></plugin>
+ </extension>
+
+ <extension
+ point="org.eclipse.cdt.ui.cPropertyTab">
+
+<!-- exported from CORE -->
+ <tab
+ class="org.eclipse.cdt.ui.newui.IncludeTab"
+ name="%Includes"
+ icon="icons/obj16/hfolder_obj.gif"
+ weight="001"
+ parentId="org.eclipse.cdt.make.internal.ui.properties.PathAndSymbolPage"
+ tooltip="&quot;Includes list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.SymbolTab"
+ name="%Symbols"
+ icon="icons/obj16/define_obj.gif"
+ weight="002"
+ parentId="org.eclipse.cdt.make.internal.ui.properties.PathAndSymbolPage"
+ tooltip="&quot;Macros list&quot;"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.propertyPages">
+
+ <page
+ class="org.eclipse.cdt.make.internal.ui.properties.PathAndSymbolPage"
+ id="org.eclipse.cdt.make.ui.propertypages.project.ref12"
+ name="%CDTPathSymbolsProperty.name"
+ >
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.make.core.cfgSupportNature">
+ </filter>
+ <enabledWhen>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+
+ <instanceof value="org.eclipse.core.resources.IFolder"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
+
+ <and>
+ ` <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+ <and>
+ <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+
+ </or>
+ </enabledWhen>
+ </page>
+ </extension>
+</plugin>
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/properties/PathAndSymbolPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/properties/PathAndSymbolPage.java
new file mode 100644
index 00000000000..8c631fe3e27
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/properties/PathAndSymbolPage.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.make.internal.ui.properties;
+
+import org.eclipse.cdt.ui.newui.AbstractPage;
+
+public class PathAndSymbolPage extends AbstractPage {
+
+ protected boolean isSingle() {
+ return false;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java
index fcb0ed530b8..3a6fae63be7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java
@@ -16,9 +16,6 @@ import java.util.Map;
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICDescriptorOperation;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.make.core.MakeCorePlugin;
@@ -39,8 +36,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.InputType;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java
index 8197091d1d1..deb2d8b64a3 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java
@@ -13,6 +13,14 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.core.runtime.IPath;
public class CDataFacroty {
+ private static CDataFacroty fInstance;
+
+ public static CDataFacroty getDefault(){
+ if(fInstance == null)
+ fInstance = new CDataFacroty();
+ return fInstance;
+ }
+
public CConfigurationData createConfigurationdata(String id,
String name,
CConfigurationData base,
@@ -25,22 +33,26 @@ public class CDataFacroty {
return new CDefaultConfigurationData(id, name, base, this, clone);
}
-
+
public CFolderData createFolderData(CConfigurationData cfg,
- CFolderData base,
+ CFolderData base,
+ String id,
boolean clone,
IPath path){
- String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
return new CDefaultFolderData(id, path, base, cfg, this, clone);
}
public CFileData createFileData(CConfigurationData cfg,
CResourceData base,
CLanguageData lBase,
+ String id,
boolean clone,
IPath path){
- String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
- if(base.getType() == ICSettingBase.SETTING_FILE)
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ if(base != null && base.getType() == ICSettingBase.SETTING_FILE)
return new CDefaultFileData(id, path, (CFileData)base, cfg, this, clone);
return new CDefaultFileData(id, path, (CFolderData)base, lBase, cfg, this);
}
@@ -48,28 +60,43 @@ public class CDataFacroty {
public CLanguageData createLanguageData(CConfigurationData cfg,
CResourceData rcBase,
CLanguageData base,
+ String id,
boolean clone){
- String id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
return new CDefaultLanguageData(id, base);
}
public CLanguageData createLanguageData(CConfigurationData cfg,
CResourceData rcBase,
+ String id,
+ String name,
String languageId,
+ int supportedEntryKinds,
String[] rcTypes,
boolean isContentTypes){
- String id = CDataUtil.genId(rcBase.getId());
- return new CDefaultLanguageData(id, languageId, rcTypes, isContentTypes);
+ if(id == null)
+ id = CDataUtil.genId(rcBase.getId());
+ CDefaultLanguageData lData = new CDefaultLanguageData(id, languageId, rcTypes, isContentTypes);
+ lData.fName = name;
+ lData.fSupportedKinds = supportedEntryKinds;
+ return lData;
}
- public CBuildData createBuildData(CConfigurationData cfg, CBuildData base, boolean clone){
- String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
- return new CDefaultBuildData(id, base);
+ public CBuildData createBuildData(CConfigurationData cfg, CBuildData base, String id, String name, boolean clone){
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ CDefaultBuildData data = new CDefaultBuildData(id, base);
+ data.fName = name;
+ return data;
}
- public CTargetPlatformData createTargetPlatformData(CConfigurationData cfg, CTargetPlatformData base, boolean clone){
- String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
- return new CDefaultTargetPlatformData(id, base);
+ public CTargetPlatformData createTargetPlatformData(CConfigurationData cfg, CTargetPlatformData base, String id, String name, boolean clone){
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ CDefaultTargetPlatformData tpData = new CDefaultTargetPlatformData(id, base);
+ tpData.fName = name;
+ return tpData;
}
public boolean isModified(CDataObject data){
@@ -112,5 +139,29 @@ public class CDataFacroty {
break;
}
}
-
+
+ public void link(CDataObject parent, CDataObject child){
+ switch(parent.getType()){
+ case ICSettingBase.SETTING_CONFIGURATION:
+ switch(child.getType()){
+ case ICSettingBase.SETTING_FILE:
+ case ICSettingBase.SETTING_FOLDER:
+ ((CDefaultConfigurationData)parent).addRcData((CResourceData)child);
+ break;
+ case ICSettingBase.SETTING_TARGET_PLATFORM:
+ ((CDefaultConfigurationData)parent).fTargetPlatformData = (CTargetPlatformData)child;
+ break;
+ case ICSettingBase.SETTING_BUILD:
+ ((CDefaultConfigurationData)parent).fBuildData = (CBuildData)child;
+ break;
+ }
+ break;
+ case ICSettingBase.SETTING_FOLDER:
+ ((CDefaultFolderData)parent).fLanguageDatas.add(child);
+ break;
+ case ICSettingBase.SETTING_FILE:
+ ((CDefaultFileData)parent).fLanguageData = (CLanguageData)child;
+ break;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java
index 3d26bc2bd28..85143261f42 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java
@@ -125,25 +125,25 @@ public class CDefaultConfigurationData extends CConfigurationData {
}
protected CFolderData copyFolderData(IPath path, CFolderData base, boolean clone){
- return fFactory.createFolderData(this, base, clone, path);
+ return fFactory.createFolderData(this, base, null, clone, path);
}
protected CFileData copyFileData(IPath path, CFileData base, boolean clone){
- return fFactory.createFileData(this, base, null, clone, path);
+ return fFactory.createFileData(this, base, null, null, clone, path);
}
protected CFileData copyFileData(IPath path, CFolderData base, CLanguageData langData){
- return fFactory.createFileData(this, base, langData, false, path);
+ return fFactory.createFileData(this, base, langData, null, false, path);
}
protected CTargetPlatformData copyTargetPlatformData(CTargetPlatformData base, boolean clone){
- return fFactory.createTargetPlatformData(this, base, clone);
+ return fFactory.createTargetPlatformData(this, base, null, base.getName(), clone);
}
protected CBuildData copyBuildData(CBuildData data, boolean clone){
- return fFactory.createBuildData(this, data, clone);
+ return fFactory.createBuildData(this, data, null, data.getName(), clone);
}
public CFolderData createFolderData(IPath path, CFolderData base) throws CoreException{
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationDataProvider.java
new file mode 100644
index 00000000000..215b6e08d98
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationDataProvider.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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.extension.impl;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.cdt.core.settings.model.util.CDataSerializer;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class CDefaultConfigurationDataProvider extends
+ CConfigurationDataProvider {
+ private static final String DEFAULT_STORAGE_ID = "defaultConfigurationDataProvider"; //$NON-NLS-1$
+
+ public CConfigurationData applyConfiguration(
+ ICConfigurationDescription des,
+ ICConfigurationDescription baseDescription,
+ CConfigurationData base,
+ IProgressMonitor monitor)
+ throws CoreException {
+ ICStorageElement el = getStorageElement(des, true);
+ CDataSerializer serializer = getDataSerializer();
+ serializer.store(base, el);
+ return base;
+ }
+
+ public CConfigurationData createConfiguration(
+ ICConfigurationDescription des,
+ ICConfigurationDescription baseDescription,
+ CConfigurationData base,
+ boolean clone,
+ IProgressMonitor monitor) throws CoreException {
+ CDataFacroty factory = getDataFactory();
+ return factory.createConfigurationdata(des.getId(), des.getName(), base, clone);
+ }
+
+ public CConfigurationData loadConfiguration(ICConfigurationDescription des,
+ IProgressMonitor monitor)
+ throws CoreException {
+ ICStorageElement el = getStorageElement(des, false);
+ if(el != null){
+ CDataSerializer serializer = getDataSerializer();
+ CDataFacroty factory = getDataFactory();
+ try {
+ return serializer.loadConfigurationData(factory, el);
+ } catch (CoreException e){
+ if(des.isPreferenceConfiguration())
+ return createPreferenceConfig(factory);
+ throw e;
+ }
+ } else if (des.isPreferenceConfiguration()){
+ return createPreferenceConfig(getDataFactory());
+ }
+ return null;
+ }
+
+ public void removeConfiguration(ICConfigurationDescription des,
+ CConfigurationData data,
+ IProgressMonitor monitor) {
+ //do nothing
+ }
+
+ protected CDataFacroty getDataFactory(){
+ return CDataFacroty.getDefault();
+ }
+
+ protected CDataSerializer getDataSerializer(){
+ return CDataSerializer.getDefault();
+ }
+
+ protected String getStorageId(){
+ return DEFAULT_STORAGE_ID;
+ }
+
+ protected ICStorageElement getStorageElement(ICConfigurationDescription des, boolean create) throws CoreException{
+ return des.getStorage(getStorageId(), create);
+ }
+
+ protected CConfigurationData createPreferenceConfig(CDataFacroty factory){
+ return CDataUtil.createEmptyData(null, "preference", factory, true);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java
index 13633eb4fc1..54fde78f7b9 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java
@@ -61,13 +61,13 @@ public class CDefaultFileData extends CFileData {
}
protected void copyDataFrom(CFolderData base, CLanguageData baseLanguageData){
- fIsExcluded = base.isExcluded();
+ fIsExcluded = base != null ? base.isExcluded() : false;
if(baseLanguageData != null)
fLanguageData = copyLanguageData(baseLanguageData, false);
}
protected CLanguageData copyLanguageData(CLanguageData data, boolean clone){
- return fFactory.createLanguageData(fCfg, this, data, clone);
+ return fFactory.createLanguageData(fCfg, this, data, null, clone);
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java
index e2122ffb446..c0c624e6d11 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java
@@ -61,7 +61,7 @@ public class CDefaultFolderData extends CFolderData {
}
protected CLanguageData copyLanguageData(CLanguageData base, boolean clone){
- return fFactory.createLanguageData(fCfg, this, base, clone);
+ return fFactory.createLanguageData(fCfg, this, base, null, clone);
}
public CLanguageData[] getLanguageDatas() {
@@ -104,34 +104,36 @@ public class CDefaultFolderData extends CFolderData {
return getId() != null;
}
- protected CLanguageData doCreateLanguageDataForContentTypes(String languageId,
- String[] typesIds) {
- return fFactory.createLanguageData(fCfg, this, languageId, typesIds, true);
- }
-
- protected CLanguageData doCreateLanguageDataForExtensions(String languageId,
- String[] extensions) {
- return fFactory.createLanguageData(fCfg, this, languageId, extensions, false);
- }
+// protected CLanguageData doCreateLanguageDataForContentTypes(String languageId,
+// String[] typesIds) {
+// return fFactory.createLanguageData(fCfg, this, null, null, languageId, typesIds, true);
+// }
+//
+// protected CLanguageData doCreateLanguageDataForExtensions(String languageId,
+// String[] extensions) {
+// return fFactory.createLanguageData(fCfg, this, null, null, languageId, extensions, false);
+// }
public CLanguageData createLanguageDataForContentTypes(String languageId,
String[] typesIds) {
- CLanguageData data = doCreateLanguageDataForContentTypes(languageId, typesIds);
- if(data != null){
- fLanguageDatas.add(data);
- setModified(true);
- }
- return data;
+ throw new UnsupportedOperationException();
+// CLanguageData data = doCreateLanguageDataForContentTypes(languageId, typesIds);
+// if(data != null){
+// fLanguageDatas.add(data);
+// setModified(true);
+// }
+// return data;
}
public CLanguageData createLanguageDataForExtensions(String languageId,
String[] extensions) {
- CLanguageData data = doCreateLanguageDataForExtensions(languageId, extensions);
- if(data != null){
- fLanguageDatas.add(data);
- setModified(true);
- }
- return data;
+ throw new UnsupportedOperationException();
+// CLanguageData data = doCreateLanguageDataForExtensions(languageId, extensions);
+// if(data != null){
+// fLanguageDatas.add(data);
+// setModified(true);
+// }
+// return data;
}
public boolean isModified(){
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java
index 8b10456fbca..cf37bb8b0ba 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java
@@ -86,13 +86,17 @@ public class CDefaultLanguageData extends CLanguageData {
EntryStore store = createStore();
int kinds[] = KindBasedStore.getLanguageEntryKinds();
for(int i = 0; i < kinds.length; i++){
- ICLanguageSettingEntry entries[] = data.getEntries(kinds[i]);
+ ICLanguageSettingEntry entries[] = getEntriesToCopy(kinds[i], data);
entries = processStoredEntries(entries, OP_COPY);
store.storeEntries(kinds[i], entries);
}
return store;
}
+ protected ICLanguageSettingEntry[] getEntriesToCopy(int kind, CLanguageData lData){
+ return lData.getEntries(kind);
+ }
+
protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op){
return entries;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/AbstractEntryStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/AbstractEntryStorage.java
new file mode 100644
index 00000000000..4ea01645d6a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/AbstractEntryStorage.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.SettingsSet.SettingLevel;
+
+public abstract class AbstractEntryStorage {
+ private int fKind;
+
+ private static final String EMPTY_STRING = new String();
+
+ public AbstractEntryStorage(int kind){
+ fKind = kind;
+ }
+
+ public int getKind(){
+ return fKind;
+ }
+
+ public List getEntries(List list){
+ SettingsSet settings = initCache();
+ if(list == null)
+ list = new ArrayList();
+
+ ICLanguageSettingEntry entries[] = settings.getEntries();
+ list.addAll(Arrays.asList(entries));
+ return list;
+ }
+
+ protected void resetDefaults(){
+ SettingsSet settings = createEmptySettings();
+ SettingLevel[] levels = settings.getLevels();
+ for(int i = 0; i < levels.length; i++){
+ obtainEntriesFromLevel(i, null);
+ }
+ }
+
+ public void setEntries(ICLanguageSettingEntry entries[]){
+ if(entries == null){
+ resetDefaults();
+ return;
+ }
+ SettingsSet settings = initCache();
+
+ settings.applyEntries(entries);
+
+ SettingLevel levels[] = settings.getLevels();
+
+ for(int i = 0; i < levels.length; i++){
+ obtainEntriesFromLevel(i, levels[i]);
+ }
+ }
+
+ protected SettingsSet initCache(){
+ SettingsSet settings = createEmptySettings();
+ SettingLevel levels[] = settings.getLevels();
+ for(int i = 0; i < levels.length; i++){
+ putEntriesToLevel(i, levels[i]);
+ }
+
+ settings.adjustOverrideState();
+
+ return settings;
+ }
+
+ protected abstract void putEntriesToLevel(int levelNum, SettingLevel level);
+
+ protected abstract void obtainEntriesFromLevel(int levelNum, SettingLevel level);
+
+ protected abstract SettingsSet createEmptySettings();
+
+ public static String[] macroNameValueFromValue(String value){
+ String nv[] = new String[2];
+ int index = value.indexOf('=');
+ if(index > 0){
+ nv[0] = value.substring(0, index);
+ nv[1] = value.substring(index + 1);
+ } else {
+ nv[0] = value;
+ nv[1] = EMPTY_STRING;
+ }
+ return nv;
+ }
+}
+
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataSerializer.java
new file mode 100644
index 00000000000..60215330884
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataSerializer.java
@@ -0,0 +1,479 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+
+public class CDataSerializer {
+ protected static final String NAME = "name";
+ protected static final String ID = "id";
+ protected static final String DESCRIPTION = "description";
+ protected static final String SOURCE_PATHS = "sourcePaths";
+ protected static final String PATH = "path";
+ protected static final String LANGUAGE_ID = "languageId";
+ protected static final String CONTENT_TYPE_IDS = "contentTypeIds";
+ protected static final String EXTENSIONS = "extensions";
+ protected static final String DELIMITER = ";";
+ protected static final String FOLDER_DATA = "folderData";
+ protected static final String FILE_DATA = "fileData";
+ protected static final String BUILD_DATA = "buildData";
+ protected static final String TARGET_PLATFORM_DATA = "targetPlatformData";
+ protected static final String LANGUAGE_DATA = "languageData";
+ protected static final String EXCLUDED = "excluded";
+ protected static final String OUTPUT_ENTRIES = "outputEntries";
+ protected static final String ERROR_PARSERS = "errorParsers";
+ protected static final String BINARY_PARSERS = "binaryParsers";
+ protected static final String CWD = "cwd";
+ protected static final String SETTING_ENTRIES = "settingEntries";
+ protected static final String SUPPORTED_ENTRY_KINDS = "supportedEntryKinds";
+
+ private static CDataSerializer fInstance;
+
+ public static CDataSerializer getDefault(){
+ if(fInstance == null)
+ fInstance = new CDataSerializer();
+ return fInstance;
+ }
+
+ public CConfigurationData loadConfigurationData(CDataFacroty factory, ICStorageElement el) throws CoreException {
+ String id = el.getAttribute(ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no id attribute for configuration"));
+
+ String name = el.getAttribute(NAME);
+ CConfigurationData data = factory.createConfigurationdata(id, name, null, false);
+ if(data == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create configuration"));
+
+ String tmp = el.getAttribute(DESCRIPTION);
+ if(tmp != null)
+ data.setDescription(tmp);
+
+ tmp = el.getAttribute(SOURCE_PATHS);
+ if(tmp != null){
+ String[] strPaths = CDataUtil.stringToArray(tmp, DELIMITER);
+ IPath[] paths = new IPath[strPaths.length];
+ for(int i = 0; i < paths.length; i++){
+ paths[i] = new Path(strPaths[i]);
+ }
+ data.setSourcePaths(paths);
+ }
+
+ ICStorageElement[] children = el.getChildren();
+ ICStorageElement child;
+ String childName;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ childName = child.getName();
+ if(FOLDER_DATA.equals(childName)){
+ CFolderData foData = loadFolderData(data, factory, child);
+ if(foData != null)
+ factory.link(data, foData);
+ } else if (FILE_DATA.equals(childName)){
+ CFileData fiData = loadFileData(data, factory, child);
+ if(fiData != null)
+ factory.link(data, fiData);
+ } else if (BUILD_DATA.equals(childName)){
+ CBuildData bData = loadBuildData(data, factory, child);
+ if(bData != null)
+ factory.link(data, bData);
+ } else if (TARGET_PLATFORM_DATA.equals(childName)){
+ CTargetPlatformData tpData = loadTargetPlatformData(data, factory, child);
+ if(tpData != null)
+ factory.link(data, tpData);
+ }
+ }
+ return data;
+ }
+
+ public CFolderData loadFolderData(CConfigurationData data, CDataFacroty factory, ICStorageElement el) throws CoreException {
+ String id = el.getAttribute(ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no id attribute for folder data"));
+
+ String tmp = el.getAttribute(PATH);
+ IPath path = null;
+ if(tmp != null){
+ path = new Path(tmp);
+ }
+ if(path == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no path attribute for folder data"));
+
+ CFolderData foData = factory.createFolderData(data, null, id, false, path);
+ if(foData == null){
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create folder data"));
+ }
+
+ tmp = el.getAttribute(EXCLUDED);
+ if(tmp != null){
+ boolean b = Boolean.valueOf(tmp).booleanValue();
+ foData.setExcluded(b);
+ }
+
+ ICStorageElement[] children = el.getChildren();
+ ICStorageElement child;
+ String childName;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ childName = child.getName();
+ if(LANGUAGE_DATA.equals(childName)){
+ CLanguageData lData = loadLanguageData(data, foData, factory, child);
+ if(lData != null)
+ factory.link(foData, lData);
+ }
+ }
+ return foData;
+ }
+
+ public CFileData loadFileData(CConfigurationData data, CDataFacroty factory, ICStorageElement el) throws CoreException {
+ String id = el.getAttribute(ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no id attribute for file data"));
+
+ String tmp = el.getAttribute(PATH);
+ IPath path = null;
+ if(tmp != null){
+ path = new Path(tmp);
+ }
+ if(path == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no path attribute for file data"));
+
+ CFileData fiData = factory.createFileData(data, null, null, id, false, path);
+ if(fiData == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create file data"));
+
+ tmp = el.getAttribute(EXCLUDED);
+ if(tmp != null){
+ boolean b = Boolean.valueOf(tmp).booleanValue();
+ fiData.setExcluded(b);
+ }
+
+ ICStorageElement[] children = el.getChildren();
+ ICStorageElement child;
+ String childName;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ childName = child.getName();
+ if(LANGUAGE_DATA.equals(childName)){
+ CLanguageData lData = loadLanguageData(data, fiData, factory, child);
+ if(lData != null)
+ factory.link(fiData, lData);
+
+ }
+ }
+ return fiData;
+ }
+
+ public CBuildData loadBuildData(CConfigurationData data, CDataFacroty factory, ICStorageElement el) throws CoreException {
+ String id = el.getAttribute(ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no id attribute for build data"));
+
+ String name = el.getAttribute(NAME);
+
+ CBuildData bData = factory.createBuildData(data, null, id, name, false);
+ if(bData == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create build data"));
+
+ String tmp = el.getAttribute(ERROR_PARSERS);
+ if(tmp != null){
+ String ids[] = CDataUtil.stringToArray(tmp, DELIMITER);
+ bData.setErrorParserIDs(ids);
+ }
+
+ tmp = el.getAttribute(CWD);
+ if(tmp != null){
+ IPath cwd = new Path(tmp);
+ bData.setBuilderCWD(cwd);
+ }
+
+ ICStorageElement[] children = el.getChildren();
+ ICStorageElement child;
+ String childName;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ childName = child.getName();
+ if(OUTPUT_ENTRIES.equals(childName)){
+ List list = LanguageSettingEntriesSerializer.loadEntriesList(child);
+ for(int k = 0; k < list.size(); k++){
+ ICSettingEntry e = (ICSettingEntry)list.get(i);
+ if(e.getKind() != ICSettingEntry.OUTPUT_PATH)
+ list.remove(i);
+ }
+ bData.setOutputDirectories((ICOutputEntry[])list.toArray(new ICOutputEntry[list.size()]));
+ }
+ }
+ return bData;
+ }
+
+ public CTargetPlatformData loadTargetPlatformData(CConfigurationData data, CDataFacroty factory, ICStorageElement el) throws CoreException {
+ String id = el.getAttribute(ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no id attribute for target platform data"));
+
+ String name = el.getAttribute(NAME);
+
+ CTargetPlatformData tpData = factory.createTargetPlatformData(data, null, id, name, false);
+ if(tpData == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create target platform data"));
+
+ String tmp = el.getAttribute(BINARY_PARSERS);
+ if(tmp != null){
+ String ids[] = CDataUtil.stringToArray(tmp, DELIMITER);
+ tpData.setBinaryParserIds(ids);
+ }
+
+ return tpData;
+ }
+
+ public CLanguageData loadLanguageData(CConfigurationData data, CResourceData rcData, CDataFacroty factory, ICStorageElement el) throws CoreException {
+ String id = el.getAttribute(ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "no id attribute for language data"));
+
+ String name = el.getAttribute(NAME);
+ String langId = el.getAttribute(LANGUAGE_ID);
+ boolean cTypes = true;
+ String ids[];
+ String typesStr = el.getAttribute(CONTENT_TYPE_IDS);
+ if(typesStr == null){
+ cTypes = false;
+ typesStr = el.getAttribute(EXTENSIONS);
+ }
+
+ if(typesStr != null){
+ ids = CDataUtil.stringToArray(typesStr, DELIMITER);
+ } else {
+ ids = CDefaultLanguageData.EMPTY_STRING_ARRAY;
+ }
+
+ String tmp = el.getAttribute(SUPPORTED_ENTRY_KINDS);
+ int supportedKinds = 0;
+ if(tmp != null){
+ String[] strKinds = CDataUtil.stringToArray(tmp, DELIMITER);
+ for(int i = 0; i < strKinds.length; i++){
+ supportedKinds |= LanguageSettingEntriesSerializer.stringToKind(strKinds[i]);
+ }
+ }
+ CLanguageData lData = factory.createLanguageData(data, rcData, id, name, langId, supportedKinds, ids, cTypes);
+ if(lData == null)
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create language data"));
+
+ ICStorageElement[] children = el.getChildren();
+ String childName;
+ ICStorageElement child;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ childName = child.getName();
+ if(SETTING_ENTRIES.equals(childName)){
+ loadEntries(lData, child);
+ }
+ }
+ return lData;
+ }
+
+ public void loadEntries(CLanguageData lData, ICStorageElement el){
+ List entries = LanguageSettingEntriesSerializer.loadEntriesList(el);
+ EntryStore store = new EntryStore();
+ store.addEntries((ICLanguageSettingEntry[])entries.toArray(new ICLanguageSettingEntry[entries.size()]));
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ ICLanguageSettingEntry[] sortedEntries;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ if(store.containsEntriesList(kind)){
+ sortedEntries = store.getEntries(kind);
+ lData.setEntries(kind, sortedEntries);
+ }
+ }
+ }
+
+ private void setAttribute(ICStorageElement el, String name, String value){
+ if(value != null)
+ el.setAttribute(name, value);
+ }
+
+ public void store(CConfigurationData data, ICStorageElement el) throws CoreException {
+ setAttribute(el, ID, data.getId());
+ setAttribute(el, NAME, data.getName());
+ setAttribute(el, DESCRIPTION, data.getDescription());
+
+ IPath[] paths = data.getSourcePaths();
+ if(paths != null && paths.length != 0){
+ setAttribute(el, SOURCE_PATHS, CDataUtil.arrayToString(paths, DELIMITER));
+ }
+
+ CResourceData[] rcDatas = data.getResourceDatas();
+ CResourceData rcData;
+ ICStorageElement child;
+ for(int i = 0; i < rcDatas.length; i++){
+ rcData = rcDatas[i];
+ if(rcData.getType() == ICSettingBase.SETTING_FILE){
+ child = el.createChild(FILE_DATA);
+ store((CFileData)rcData, child);
+ } else {
+ child = el.createChild(FOLDER_DATA);
+ store((CFolderData)rcData, child);
+ }
+ }
+
+ CBuildData bData = data.getBuildData();
+ if(bData != null){
+ child = el.createChild(BUILD_DATA);
+ store(bData, child);
+ }
+
+ CTargetPlatformData tpData = data.getTargetPlatformData();
+ if(tpData != null){
+ child = el.createChild(TARGET_PLATFORM_DATA);
+ store(tpData, child);
+ }
+ }
+
+ public void store(CFolderData data, ICStorageElement el){
+ setAttribute(el, ID, data.getId());
+ setAttribute(el, NAME, data.getName());
+
+ IPath path = data.getPath();
+ if(path != null){
+ setAttribute(el, PATH, path.toString());
+ }
+
+ setAttribute(el, EXCLUDED, Boolean.valueOf(data.isExcluded()).toString());
+
+ CLanguageData lDatas[] = data.getLanguageDatas();
+ ICStorageElement child;
+ for(int i = 0; i < lDatas.length; i++){
+ child = el.createChild(LANGUAGE_DATA);
+ store(lDatas[i], child);
+ }
+ }
+
+ public void store(CFileData data, ICStorageElement el){
+ setAttribute(el, ID, data.getId());
+ setAttribute(el, NAME, data.getName());
+
+ IPath path = data.getPath();
+ if(path != null){
+ setAttribute(el, PATH, path.toString());
+ }
+
+ setAttribute(el, EXCLUDED, Boolean.valueOf(data.isExcluded()).toString());
+
+ CLanguageData lData = data.getLanguageData();
+ if(lData != null){
+ ICStorageElement child = el.createChild(LANGUAGE_DATA);
+ store(lData, child);
+ }
+ }
+
+ public void store(CBuildData data, ICStorageElement el){
+ setAttribute(el, ID, data.getId());
+ setAttribute(el, NAME, data.getName());
+
+ String[] errParserIds = data.getErrorParserIDs();
+ if(errParserIds != null && errParserIds.length != 0){
+ setAttribute(el, ERROR_PARSERS, CDataUtil.arrayToString(errParserIds, DELIMITER));
+ }
+
+ IPath cwd = data.getBuilderCWD();
+ if(cwd != null){
+ setAttribute(el, CWD, cwd.toString());
+ }
+
+ ICOutputEntry[] outEntries = data.getOutputDirectories();
+ if(outEntries != null && outEntries.length != 0){
+ ICStorageElement child = el.createChild(OUTPUT_ENTRIES);
+ LanguageSettingEntriesSerializer.serializeEntries(outEntries, child);
+ }
+ }
+
+ public void store(CTargetPlatformData data, ICStorageElement el){
+ setAttribute(el, ID, data.getId());
+ setAttribute(el, NAME, data.getName());
+
+ String[] binParserIds = data.getBinaryParserIds();
+ if(binParserIds != null && binParserIds.length != 0){
+ setAttribute(el, BINARY_PARSERS, CDataUtil.arrayToString(binParserIds, DELIMITER));
+ }
+ }
+
+ public void store(CLanguageData data, ICStorageElement el){
+ setAttribute(el, ID, data.getId());
+ setAttribute(el, NAME, data.getName());
+ setAttribute(el, LANGUAGE_ID, data.getLanguageId());
+
+ String[] tmp = data.getSourceContentTypeIds();
+ if(tmp != null && tmp.length != 0){
+ setAttribute(el, CONTENT_TYPE_IDS, CDataUtil.arrayToString(tmp, DELIMITER));
+ }
+
+ tmp = data.getSourceExtensions();
+ if(tmp != null && tmp.length != 0){
+ setAttribute(el, EXTENSIONS, CDataUtil.arrayToString(tmp, DELIMITER));
+ }
+
+ int kinds = data.getSupportedEntryKinds();
+ int[] allKinds = KindBasedStore.getLanguageEntryKinds();
+ StringBuffer buf = new StringBuffer();
+ boolean found = false;
+ for(int i = 0; i < allKinds.length; i++){
+ if((allKinds[i] & kinds) != 0){
+ if(found)
+ buf.append(DELIMITER);
+ found = true;
+ buf.append(LanguageSettingEntriesSerializer.kindToString(allKinds[i]));
+
+ }
+ }
+
+ if(found){
+ el.setAttribute(SUPPORTED_ENTRY_KINDS, buf.toString());
+ }
+
+ ICStorageElement child = el.createChild(SETTING_ENTRIES);
+ storeEntries(data, child);
+ }
+
+ public void storeEntries(CLanguageData lData, ICStorageElement el){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ ICLanguageSettingEntry[] sortedEntries;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ sortedEntries = lData.getEntries(kind);
+ if(sortedEntries != null && sortedEntries.length != 0){
+ LanguageSettingEntriesSerializer.serializeEntries(sortedEntries, el);
+ }
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
index 6224a568d4b..66e5afcd343 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
@@ -12,13 +12,19 @@ package org.eclipse.cdt.core.settings.model.util;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Random;
+import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.model.ILanguageDescriptor;
+import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
@@ -29,16 +35,20 @@ import org.eclipse.cdt.core.settings.model.COutputEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
-import org.eclipse.cdt.core.settings.model.extension.CFileData;
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
@@ -74,14 +84,18 @@ public class CDataUtil {
return o2 == null;
return o1.equals(o2);
}
-
+
public static String arrayToString(String[] array, String separator){
+ return arrayToString((Object[])array, separator);
+ }
+
+ public static String arrayToString(Object[] array, String separator){
if(array == null)
return null;
if(array.length == 0)
return ""; //$NON-NLS-1$
if(array.length == 1)
- return array[0];
+ return array[0].toString();
StringBuffer buf = new StringBuffer();
buf.append(array[0]);
for(int i = 1; i < array.length; i++){
@@ -322,7 +336,18 @@ public class CDataUtil {
}
return null;
}
-
+
+ public static Map createPathRcDataMap(CConfigurationData data){
+ Map map = new HashMap();
+ CResourceData[] rcDatas = data.getResourceDatas();
+ CResourceData rcData;
+ for(int i = 0; i < rcDatas.length; i++){
+ rcData = rcDatas[i];
+ map.put(rcData.getPath(), rcData);
+ }
+ return map;
+ }
+
public static PathSettingsContainer createRcDataHolder(CConfigurationData data){
PathSettingsContainer h = PathSettingsContainer.createRootContainer();
@@ -337,4 +362,130 @@ public class CDataUtil {
}
return h;
}
+
+ public static CConfigurationData createEmptyData(String id, String name, CDataFacroty factory, boolean performLangAdjustment){
+ if(id == null)
+ id = genId(null);
+
+ CConfigurationData data = factory.createConfigurationdata(id, name, null, false);
+ if(data.getRootFolderData() == null){
+ CFolderData foData = factory.createFolderData(data, null, genId(data.getId()), false, Path.EMPTY);
+ factory.link(data, foData);
+ }
+
+ if(data.getBuildData() == null){
+ CBuildData bData = factory.createBuildData(data, null, genId(data.getId()), null, false);
+ factory.link(data, bData);
+ }
+
+ if(data.getTargetPlatformData() == null){
+ CTargetPlatformData tpData = factory.createTargetPlatformData(data, null, genId(data.getId()), null, false);
+ factory.link(data, tpData);
+ }
+
+ if(performLangAdjustment)
+ adjustConfig(data, factory);
+
+ return data;
+ }
+
+ public static CConfigurationData adjustConfig(CConfigurationData cfg, CDataFacroty factory){
+ LanguageManager mngr = LanguageManager.getInstance();
+ ILanguageDescriptor dess[] = mngr.getLanguageDescriptors();
+ Map map = mngr.getContentTypeIdToLanguageDescriptionsMap();
+
+ CResourceData[] rcDatas = cfg.getResourceDatas();
+ for(int i = 0; i < rcDatas.length; i++){
+ if(rcDatas[i].getType() == ICSettingBase.SETTING_FOLDER){
+ adjustFolderData(cfg, (CFolderData)rcDatas[i], factory, dess, new HashMap(map));
+ }
+ }
+
+ return cfg;
+ }
+
+
+ private static void adjustFolderData(CConfigurationData cfgData, CFolderData data, CDataFacroty factory, ILanguageDescriptor dess[], HashMap map){
+ Map langMap = new HashMap();
+ for(int i = 0; i < dess.length; i++){
+ langMap.put(dess[i].getId(), dess[i]);
+ }
+ CLanguageData lDatas[] = data.getLanguageDatas();
+ for(int i = 0; i < lDatas.length; i++){
+ CLanguageData lData = (CLanguageData)lDatas[i];
+ String langId = lData.getLanguageId();
+ if(langId != null){
+ ILanguageDescriptor des = (ILanguageDescriptor)langMap.remove(langId);
+ adjustLanguageData(data, lData, des);
+ continue;
+ } else {
+ String[] cTypeIds = lData.getSourceContentTypeIds();
+ for(int c = 0; c < cTypeIds.length; c++){
+ String cTypeId = cTypeIds[c];
+ ILanguageDescriptor[] langs = (ILanguageDescriptor[])map.remove(cTypeId);
+ if(langs != null && langs.length != 0){
+ for(int q = 0; q < langs.length; q++){
+ langMap.remove(langs[q].getId());
+ }
+
+ adjustLanguageData(data, lData, langs[0]);
+ }
+ }
+ }
+ }
+
+ if(!langMap.isEmpty()){
+ addLangs(cfgData, data, factory, langMap, map);
+ }
+
+ }
+
+ private static CLanguageData adjustLanguageData(CFolderData data, CLanguageData lData, ILanguageDescriptor des){
+ String [] cTypeIds = des.getContentTypeIds();
+ String srcIds[] = lData.getSourceContentTypeIds();
+
+ Set landTypes = new HashSet(Arrays.asList(cTypeIds));
+ landTypes.removeAll(Arrays.asList(srcIds));
+
+ if(landTypes.size() != 0){
+ List srcList = new ArrayList();
+ srcList.addAll(landTypes);
+ lData.setSourceContentTypeIds((String[])srcList.toArray(new String[srcList.size()]));
+ }
+
+ if(!des.getId().equals(lData.getLanguageId())){
+ lData.setLanguageId(des.getId());
+ }
+ return lData;
+ }
+
+ private static void addLangs(CConfigurationData cfgData, CFolderData data, CDataFacroty factory, Map langMap, Map cTypeToLangMap){
+ List list = new ArrayList(langMap.values());
+ ILanguageDescriptor des;
+ while(list.size() != 0){
+ des = (ILanguageDescriptor)list.remove(list.size() - 1);
+ String[] ctypeIds = des.getContentTypeIds();
+ boolean addLang = false;
+ for(int i = 0; i < ctypeIds.length; i++){
+ ILanguageDescriptor[] langs = (ILanguageDescriptor[])cTypeToLangMap.remove(ctypeIds[i]);
+ if(langs != null && langs.length != 0){
+ addLang = true;
+ for(int q = 0; q < langs.length; q++){
+ list.remove(langs[q]);
+ }
+ }
+ }
+
+ if(addLang){
+ CLanguageData lData = factory.createLanguageData(cfgData, data, genId(data.getId()), des.getName(), des.getId(),
+ ICLanguageSettingEntry.INCLUDE_FILE
+ | ICLanguageSettingEntry.INCLUDE_PATH
+ | ICLanguageSettingEntry.MACRO
+ | ICLanguageSettingEntry.MACRO_FILE,
+ ctypeIds, true);
+ factory.link(data, lData);
+ }
+ }
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryInfo.java
new file mode 100644
index 00000000000..63a58dfae80
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryInfo.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.util;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class EntryInfo {
+ private ICLanguageSettingEntry fEntry;
+ private EntryNameKey fNameKey;
+ private boolean fIsOverRidden;
+
+ EntryInfo(ICLanguageSettingEntry entry){
+ fEntry = entry;
+ }
+
+ public EntryNameKey getNameKey(){
+ if(fNameKey == null){
+ fNameKey = new EntryNameKey(fEntry);
+ }
+ return fNameKey;
+ }
+
+ public void makeOverridden(boolean overrridden){
+ fIsOverRidden = overrridden;
+ }
+
+ public ICLanguageSettingEntry getEntry(){
+ return fEntry;
+ }
+
+ public boolean isOverridden(){
+ return fIsOverRidden;
+ }
+
+}
+
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStorageBasedLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStorageBasedLanguageData.java
new file mode 100644
index 00000000000..56c54debaa9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStorageBasedLanguageData.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+
+public abstract class EntryStorageBasedLanguageData extends CDefaultLanguageData {
+
+ public EntryStorageBasedLanguageData() {
+ super();
+ }
+
+ public EntryStorageBasedLanguageData(String id, CLanguageData base) {
+ super(id, base);
+ }
+
+ public EntryStorageBasedLanguageData(String id, String languageId,
+ String[] ids, boolean isContentTypes) {
+ super(id, languageId, ids, isContentTypes);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int kind) {
+ AbstractEntryStorage storage = getStorage(kind);
+ if(storage != null){
+ List list = storage.getEntries(null);
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ }
+ return new ICLanguageSettingEntry[0];
+ }
+
+ public void setEntries(int kind, ICLanguageSettingEntry[] entries) {
+ AbstractEntryStorage storage = getStorage(kind);
+ if(storage != null){
+ storage.setEntries(entries);
+ }
+ }
+
+ protected void setEntriesToStore(int kind, ICLanguageSettingEntry[] entries){
+ fStore.storeEntries(kind, entries);
+ }
+
+ protected ICLanguageSettingEntry[] getEntriesFromStore(int kind){
+ return fStore.getEntries(kind);
+ }
+
+ protected EntryStore createStore(){
+ return new EntryStore(false);
+ }
+
+ protected abstract AbstractEntryStorage getStorage(int kind);
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java
index 65bdc4018d8..f07e8a7c5c7 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java
@@ -124,9 +124,19 @@ public class EntryStore {
list.add(pos ,entry);
}
+ public void addEntries(ICLanguageSettingEntry[] entries){
+ for(int i = 0; i < entries.length; i++){
+ addEntry(entries[i]);
+ }
+ }
+
public void storeEntries(int kind, ICLanguageSettingEntry[] entries){
- List newList = new ArrayList(entries.length);
- newList.addAll(Arrays.asList(entries));
+ storeEntries(kind, entries != null ? Arrays.asList(entries) : new ArrayList());
+ }
+
+ public void storeEntries(int kind, List list){
+ List newList = new ArrayList(list);
+// newList.addAll(Arrays.asList(entries));
if(fPreserveReadOnly){
List oldList = getEntriesList(kind, false);
if(oldList != null){
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 abbd6cfde67..8d30547b18f 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
@@ -164,7 +164,7 @@ public class LanguageSettingEntriesSerializer {
}
}
- static String kindToString(int kind){
+ public static String kindToString(int kind){
switch(kind){
case ICLanguageSettingEntry.INCLUDE_PATH:
return INCLUDE_PATH;
@@ -183,10 +183,10 @@ public class LanguageSettingEntriesSerializer {
case ICLanguageSettingEntry.OUTPUT_PATH:
return OUTPUT_PATH;
}
- throw new UnsupportedOperationException();
+ throw new IllegalArgumentException();
}
- static int stringToKind(String kind){
+ public static int stringToKind(String kind){
if(INCLUDE_PATH.equals(kind))
return ICLanguageSettingEntry.INCLUDE_PATH;
if(INCLUDE_FILE.equals(kind))
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java
new file mode 100644
index 00000000000..d710adf4850
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java
@@ -0,0 +1,314 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class SettingsSet {
+ public static final int READ_ONLY = 1;
+ public static final int WRITABLE = 1 << 1;
+
+ private SettingLevel[] fLevels;
+ public class SettingLevel {
+ private int fFlagsToSet;
+ private int fFlagsToClear;
+ private boolean fIsReadOnly;
+ private boolean fIsOverrideSupported;
+ private LinkedHashMap fEntries;
+ HashSet fOverrideSet;
+
+ private SettingLevel(){
+ fEntries = new LinkedHashMap();
+ }
+
+ public boolean isReadOnly(){
+ return fIsReadOnly;
+ }
+
+ public void setReadOnly(boolean readOnly){
+ fIsReadOnly = readOnly;
+ }
+
+ public boolean isOverrideSupported(){
+ return fIsOverrideSupported;
+ }
+
+ public void setOverrideSupported(boolean supported){
+ fIsOverrideSupported = supported;
+ }
+
+ public void setFlagsToSet(int flags){
+ fFlagsToSet = flags;
+ }
+
+ public boolean containsOverrideInfo(){
+ return fOverrideSet != null;
+ }
+
+ public void setFlagsToClear(int flags){
+ fFlagsToClear = flags;
+ }
+
+ public int getFlagsToSet(){
+ return fFlagsToSet;
+ }
+
+ public int getFlagsToClear(){
+ return fFlagsToClear;
+ }
+
+ public Set getOverrideSet(){
+ if(fOverrideSet != null)
+ return (HashSet)fOverrideSet.clone();
+ return new HashSet();
+ }
+
+ public void addEntries(ICLanguageSettingEntry entries[]){
+ if(entries != null){
+ for(int i = 0; i < entries.length; i++){
+ addEntry(entries[i]);
+ }
+ }
+ }
+
+ public void addEntries(List list){
+ int size = list.size();
+ for(int i = 0; i < size; i++){
+ addEntry((ICLanguageSettingEntry)list.get(i));
+ }
+ }
+
+ public void addEntry(ICLanguageSettingEntry entry){
+ entry = CDataUtil.createEntry(entry, fFlagsToSet, fFlagsToClear);
+ EntryInfo info = new EntryInfo(entry);
+ fEntries.put(info.getNameKey(), info);
+ }
+
+ public void addOverrideName(String name){
+ if(fOverrideSet == null)
+ fOverrideSet = new HashSet();
+
+ fOverrideSet.add(name);
+ }
+
+ public void removeOverrideName(String name){
+ if(fOverrideSet == null)
+ return;
+
+ fOverrideSet.remove(name);
+
+ if(fOverrideSet.size() == 0)
+ fOverrideSet = null;
+ }
+
+ public void clear(){
+ fEntries.clear();
+ fOverrideSet = null;
+ }
+
+ EntryInfo[] getInfos(){
+ return (EntryInfo[])fEntries.values().toArray(new EntryInfo[fEntries.size()]);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(){
+ List list = getEntriesList(false);
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(boolean includeOverridden){
+ List list = getEntriesList(includeOverridden);
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ }
+
+ public List getEntriesList(boolean includeOverridden){
+ List list = new ArrayList();
+ EntryInfo infos[] = getInfos();
+ for(int i = 0; i < infos.length; i++){
+ if(includeOverridden || !infos[i].isOverridden())
+ list.add(infos[i].getEntry());
+ }
+
+ return list;
+ }
+
+ }
+
+ public SettingsSet(int num){
+ fLevels = new SettingLevel[num];
+ for(int i = 0; i < num; i++){
+ fLevels[i] = new SettingLevel();
+ }
+ }
+
+ public SettingLevel[] getLevels(){
+ return (SettingLevel[])fLevels.clone();
+ }
+
+ public void adjustOverrideState(){
+ Set set = new HashSet();
+ SettingLevel level;
+ for(int i = 0; i < fLevels.length; i++){
+ level = fLevels[i];
+ if(level.isOverrideSupported() && level.fOverrideSet != null)
+ set.addAll(level.fOverrideSet);
+ adjustOverrideState(fLevels[i], set);
+ }
+ }
+
+ private void adjustOverrideState(SettingLevel level, Set overridenSet){
+ EntryInfo[] infos = level.getInfos();
+ EntryInfo info;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ if(overridenSet.add(info.getEntry().getName())){
+ info.makeOverridden(false);
+ } else {
+ info.makeOverridden(true);
+ }
+ }
+ }
+
+ public ICLanguageSettingEntry[] getEntries(){
+ return getEntries(READ_ONLY | WRITABLE);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int types){
+ adjustOverrideState();
+ List entries = new ArrayList();
+ for(int i = 0; i < fLevels.length; i++){
+ if(isCompatible(fLevels[i], types))
+ getEntries(fLevels[i], entries);
+ }
+
+ return (ICLanguageSettingEntry[])entries.toArray(new ICLanguageSettingEntry[entries.size()]);
+ }
+
+ private void getEntries(SettingLevel level, List list){
+ EntryInfo[] infos = level.getInfos();
+ EntryInfo info;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ if(!info.isOverridden())
+ list.add(info.getEntry());
+ }
+ }
+
+ private boolean isCompatible(SettingLevel level, int types){
+ if((types & READ_ONLY) == 0 && level.isReadOnly())
+ return false;
+ if((types & WRITABLE) == 0 && !level.isReadOnly())
+ return false;
+
+ return true;
+ }
+
+ private int getWritableLevelNum(){
+ for(int i = 0; i <fLevels.length; i++){
+ if(!fLevels[i].isReadOnly())
+ return i;
+ }
+
+ return -1;
+ }
+
+ private int getOverrideLevelNum(){
+ for(int i = 0; i <fLevels.length; i++){
+ if(fLevels[i].isOverrideSupported())
+ return i;
+ }
+
+ return -1;
+ }
+
+ public void applyEntries(ICLanguageSettingEntry[] entries){
+ HashMap map = getEntryLevelMap(WRITABLE | READ_ONLY);
+ Map mapCopy = (HashMap)map.clone();
+
+ for(int i = 0; i < fLevels.length; i++){
+ if(!fLevels[i].isReadOnly()){
+ fLevels[i].clear();
+ }
+ }
+
+ Integer levelInteger;
+ int levelNum;
+ EntryNameKey key;
+ ICLanguageSettingEntry entry;
+ int writableLevel = getWritableLevelNum();
+ SettingLevel level;
+
+ for(int i = 0; i < entries.length; i++){
+ entry = entries[i];
+ key = new EntryNameKey(entry);
+ Object[] o = (Object[])map.get(key);
+
+ if(o != null){
+ mapCopy.remove(key);
+ levelInteger = (Integer)o[0];
+ } else {
+ levelInteger = null;
+ }
+
+ levelNum = levelInteger != null ? levelInteger.intValue() : writableLevel;
+ if(levelNum >= 0){
+ level = fLevels[levelNum];
+ if(!level.isReadOnly())
+ level.addEntry(entry);
+ }
+ }
+
+ int overrideLevel = getOverrideLevelNum();
+ if(overrideLevel > 0){
+ level = fLevels[overrideLevel];
+ if(level.isOverrideSupported() && !mapCopy.isEmpty()){
+ String str;
+ for(Iterator iter = mapCopy.keySet().iterator(); iter.hasNext();){
+ str = ((EntryNameKey)iter.next()).getEntry().getName();
+ if(str != null)
+ level.addOverrideName(str);
+ }
+ }
+ }
+ adjustOverrideState();
+ }
+
+ public HashMap getEntryLevelMap(int types){
+ HashMap map = new HashMap();
+ for(int i = 0; i < fLevels.length; i++){
+ if(isCompatible(fLevels[i], types))
+ addLevelInfoToMap(fLevels[i], i, map);
+ }
+
+ return map;
+
+ }
+
+ private void addLevelInfoToMap(SettingLevel level, int l, Map map){
+ EntryInfo infos[] = level.getInfos();
+ EntryInfo info;
+ EntryNameKey key;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ key = info.getNameKey();
+ if(!map.containsKey(key))
+ map.put(key, new Object[]{new Integer(l), info.getEntry()});
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryDataSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryDataSerializer.java
new file mode 100644
index 00000000000..046549bb72a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryDataSerializer.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+
+public class UserAndDiscoveredEntryDataSerializer extends CDataSerializer {
+ protected static final String DISABLED_DISCOVERED_ENTRIES = "disabledDiscoveredEntries";
+ protected static final String KIND = "kind";
+ protected static final String VALUE = "value";
+
+ private static UserAndDiscoveredEntryDataSerializer fInstance;
+
+ public static CDataSerializer getDefault(){
+ if(fInstance == null)
+ fInstance = new UserAndDiscoveredEntryDataSerializer();
+ return fInstance;
+ }
+
+ public void loadEntries(CLanguageData data, ICStorageElement el) {
+ UserAndDiscoveredEntryLanguageData lData = (UserAndDiscoveredEntryLanguageData)data;
+
+ List entries = LanguageSettingEntriesSerializer.loadEntriesList(el);
+ EntryStore store = new EntryStore();
+ store.addEntries((ICLanguageSettingEntry[])entries.toArray(new ICLanguageSettingEntry[entries.size()]));
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ ICLanguageSettingEntry[] sortedEntries;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ if(store.containsEntriesList(kind)){
+ sortedEntries = store.getEntries(kind);
+ lData.setEntriesToStore(kind, sortedEntries);
+ }
+ }
+
+ ICStorageElement[] children = el.getChildren();
+ ICStorageElement child;
+ String name;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ name = child.getName();
+ if(DISABLED_DISCOVERED_ENTRIES.equals(name)){
+ loadDisabledEntriesInfo(lData, child);
+ }
+ }
+ }
+
+ protected void loadDisabledEntriesInfo(UserAndDiscoveredEntryLanguageData lData, ICStorageElement el){
+ ICStorageElement[] children = el.getChildren();
+ ICStorageElement child;
+ String name;
+ String tmp;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ name = child.getName();
+ if(NAME.equals(name)){
+ tmp = child.getAttribute(KIND);
+ int kind = LanguageSettingEntriesSerializer.stringToKind(tmp);
+ if(kind != 0){
+ tmp = child.getAttribute(VALUE);
+ if(tmp != null){
+ Set set = lData.getDisabledSet(kind);
+ if(set == null)
+ set = new HashSet();
+ set.add(tmp);
+ lData.setDisabledSet(kind, set);
+ }
+ }
+ }
+ }
+ }
+
+ public void storeEntries(CLanguageData data, ICStorageElement el) {
+ UserAndDiscoveredEntryLanguageData lData = (UserAndDiscoveredEntryLanguageData)data;
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ ICLanguageSettingEntry[] sortedEntries;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ sortedEntries = lData.getEntriesFromStore(kind);
+ if(sortedEntries != null && sortedEntries.length != 0){
+ LanguageSettingEntriesSerializer.serializeEntries(sortedEntries, el);
+ }
+ }
+
+ ICStorageElement disabledNamesEl = el.createChild(DISABLED_DISCOVERED_ENTRIES);
+
+ storeDisabledEntriesInfo(lData, disabledNamesEl);
+ }
+
+ protected void storeDisabledEntriesInfo(UserAndDiscoveredEntryLanguageData lData, ICStorageElement el){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ Set set;
+ int kind;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ set = lData.getDisabledSet(kind);
+ if(set != null && set.size() != 0){
+ for(Iterator iter = set.iterator();iter.hasNext();){
+ ICStorageElement child = el.createChild(NAME);
+ child.setAttribute(KIND, LanguageSettingEntriesSerializer.kindToString(kind));
+ child.setAttribute(VALUE, (String)iter.next());
+ }
+ }
+ }
+ }
+
+
+
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryLanguageData.java
new file mode 100644
index 00000000000..4eb628f1fb6
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryLanguageData.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+
+public abstract class UserAndDiscoveredEntryLanguageData extends
+ EntryStorageBasedLanguageData {
+ private KindBasedStore fDisabledNameSetStore;
+
+ public UserAndDiscoveredEntryLanguageData() {
+ super();
+ }
+
+ public UserAndDiscoveredEntryLanguageData(String id, CLanguageData base) {
+ super(id, base);
+ }
+
+ protected void copySettingsFrom(CLanguageData data) {
+ super.copySettingsFrom(data);
+
+ if(data instanceof UserAndDiscoveredEntryLanguageData){
+ UserAndDiscoveredEntryLanguageData lData = (UserAndDiscoveredEntryLanguageData)data;
+ if(lData.fDisabledNameSetStore != null){
+ fDisabledNameSetStore = (KindBasedStore)lData.fDisabledNameSetStore.clone();
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ Set set;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ set = (Set)fDisabledNameSetStore.get(kind);
+ if(set != null){
+ set = new HashSet(set);
+ fDisabledNameSetStore.put(kind, set);
+ }
+ }
+ }
+ }
+ }
+
+ public UserAndDiscoveredEntryLanguageData(String id, String languageId,
+ String[] ids, boolean isContentTypes) {
+ super(id, languageId, ids, isContentTypes);
+ }
+
+ public static class UserAndDiscoveredEntryLanguageDataEntryStorage extends UserAndDiscoveredEntryStorage {
+ private UserAndDiscoveredEntryLanguageData fLangData;
+ public UserAndDiscoveredEntryLanguageDataEntryStorage(int kind, UserAndDiscoveredEntryLanguageData lData) {
+ super(kind);
+ fLangData = lData;
+ }
+
+ protected ICLanguageSettingEntry[] getDiscoveredEntries(
+ Set disabledNameSet) {
+ return fLangData.getDiscoveredEntries(getKind(), disabledNameSet);
+ }
+
+ protected ICLanguageSettingEntry[] getUserEntries() {
+ return fLangData.getUserEntries(getKind());
+ }
+
+ protected void setDisabledDiscoveredNames(Set disabledNameSet) {
+ fLangData.setDisabledDiscoveredNames(getKind(), disabledNameSet);
+ }
+
+ protected void setUserEntries(ICLanguageSettingEntry[] entries) {
+ fLangData.setUserEntries(getKind(), entries);
+ }
+
+ protected boolean canDisableDiscoveredEntries() {
+ return fLangData.canDisableDiscoveredEntries(getKind());
+ }
+ }
+
+ protected AbstractEntryStorage getStorage(int kind) {
+ return new UserAndDiscoveredEntryLanguageDataEntryStorage(kind, this);
+ }
+
+ protected ICLanguageSettingEntry[] getDiscoveredEntries(int kind,
+ Set disabledNameSet){
+ ICLanguageSettingEntry[] entries = getAllDiscoveredEntries(kind);
+ Set set = getDisabledSet(kind);
+ if(set != null && set.size() != 0){
+ disabledNameSet.addAll(set);
+ }
+ return entries;
+ }
+
+ protected void removeInexistent(ICLanguageSettingEntry[] entries, Set set){
+ Set copy = new HashSet(set);
+ for(int i = 0; i < entries.length; i++){
+ copy.remove(entries[i].getName());
+ }
+
+ if(copy.size() != 0){
+ set.removeAll(copy);
+ }
+ }
+
+ protected ICLanguageSettingEntry[] getUserEntries(int kind) {
+ return getEntriesFromStore(kind);
+ }
+
+ protected void setDisabledDiscoveredNames(int kind, Set disabledNameSet){
+ setDisabledSet(kind, disabledNameSet != null ? new HashSet(disabledNameSet) : null);
+ }
+
+ protected Set getDisabledSet(int kind){
+ if(fDisabledNameSetStore != null){
+ return (Set)fDisabledNameSetStore.get(kind);
+ }
+ return null;
+ }
+
+ protected void setDisabledSet(int kind, Set set){
+ if(set == null || set.size() == 0){
+ if(fDisabledNameSetStore != null){
+ fDisabledNameSetStore.put(kind, null);
+ }
+ } else {
+ if(fDisabledNameSetStore == null)
+ fDisabledNameSetStore = new KindBasedStore();
+ fDisabledNameSetStore.put(kind, set);
+ }
+ }
+
+ protected abstract ICLanguageSettingEntry[] getAllDiscoveredEntries(int kind);
+
+ protected void setUserEntries(int kind, ICLanguageSettingEntry[] entries) {
+ setEntriesToStore(kind, entries);
+ }
+
+ protected boolean canDisableDiscoveredEntries(int kind) {
+ return true;
+ }
+
+ protected ICLanguageSettingEntry[] getEntriesToCopy(int kind,
+ CLanguageData data) {
+ return ((UserAndDiscoveredEntryLanguageData)data).getEntriesFromStore(kind);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryStorage.java
new file mode 100644
index 00000000000..cfbab88d046
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UserAndDiscoveredEntryStorage.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.SettingsSet.SettingLevel;
+
+public abstract class UserAndDiscoveredEntryStorage extends AbstractEntryStorage {
+ public UserAndDiscoveredEntryStorage(int kind) {
+ super(kind);
+ }
+
+ protected SettingsSet createEmptySettings(){
+ SettingsSet settings = new SettingsSet(2);
+ SettingLevel levels[] = settings.getLevels();
+
+ boolean override = canDisableDiscoveredEntries();
+ int readOnlyFlag = override ? 0 : ICSettingEntry.READONLY;
+ levels[0].setFlagsToClear(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
+ levels[0].setFlagsToSet(0);
+ levels[0].setReadOnly(false);
+ levels[0].setOverrideSupported(false);
+
+ levels[1].setFlagsToClear(0);
+ levels[1].setFlagsToSet(readOnlyFlag | ICSettingEntry.BUILTIN | ICSettingEntry.RESOLVED);
+ levels[1].setReadOnly(true);
+ levels[1].setOverrideSupported(override);
+
+ return settings;
+ }
+
+ protected void obtainEntriesFromLevel(int levelNum, SettingLevel level) {
+ switch(levelNum){
+ case 0:
+ setUserEntries(level != null ? level.getEntries() : null);
+ break;
+ case 1:
+ if(level != null){
+ Set set = level.getOverrideSet();
+ setDisabledDiscoveredNames(set);
+ } else {
+ setDisabledDiscoveredNames(null);
+ }
+ }
+ }
+
+ protected void putEntriesToLevel(int levelNum, SettingLevel level) {
+ switch(levelNum){
+ case 0:
+ level.addEntries(getUserEntries());
+ break;
+ case 1:
+ HashSet set = new HashSet();
+ ICLanguageSettingEntry[] entries = getDiscoveredEntries(set);
+ level.addEntries(entries);
+ if(set.size() != 0)
+ level.fOverrideSet = set;
+ break;
+ }
+ }
+
+ protected boolean canDisableDiscoveredEntries(){
+ return false;
+ }
+
+ protected abstract void setUserEntries(ICLanguageSettingEntry[] entries);
+
+ protected abstract ICLanguageSettingEntry[] getUserEntries();
+
+ protected abstract void setDisabledDiscoveredNames(Set disabledNameSet);
+
+ protected abstract ICLanguageSettingEntry[] getDiscoveredEntries(Set disabledNameSet);
+}
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 0aab0ef608d..c700aca5191 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
@@ -45,8 +45,6 @@ import org.eclipse.cdt.core.model.CModelException;
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.model.ILanguageDescriptor;
-import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICFileDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
@@ -68,7 +66,6 @@ import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
-import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
@@ -1491,7 +1488,6 @@ public class CProjectDescriptionManager {
}
}
}
-
CConfigurationData loadData(ICConfigurationDescription des, IProgressMonitor monitor) throws CoreException{
if(monitor == null)
@@ -2973,107 +2969,16 @@ public class CProjectDescriptionManager {
if(factory == null)
factory = new CDataFacroty();
- CDefaultConfigurationData data = (CDefaultConfigurationData)factory.createConfigurationdata(id, name, null, false);
- data.initEmptyData();
- adjustDefaultConfig(data);
-
- data.setModified(false);
- return data;
- }
-
- public CConfigurationData adjustDefaultConfig(CConfigurationData cfg){
- LanguageManager mngr = LanguageManager.getInstance();
- ILanguageDescriptor dess[] = mngr.getLanguageDescriptors();
- Map map = mngr.getContentTypeIdToLanguageDescriptionsMap();
-
- CResourceData[] rcDatas = cfg.getResourceDatas();
- for(int i = 0; i < rcDatas.length; i++){
- if(rcDatas[i].getType() == ICSettingBase.SETTING_FOLDER){
- adjustFolderData((CFolderData)rcDatas[i], dess, new HashMap(map));
- }
- }
-
- return cfg;
- }
+ CConfigurationData data = CDataUtil.createEmptyData(id, name, factory, true);
+// CDataUtil.
+//// data.initEmptyData();
+//
+// CDataUtil.adjustConfig(data, factory);
-
- private static void adjustFolderData(CFolderData data, ILanguageDescriptor dess[], HashMap map){
- Map langMap = new HashMap();
- for(int i = 0; i < dess.length; i++){
- langMap.put(dess[i].getId(), dess[i]);
- }
- CLanguageData lDatas[] = data.getLanguageDatas();
- for(int i = 0; i < lDatas.length; i++){
- CLanguageData lData = (CLanguageData)lDatas[i];
- String langId = lData.getLanguageId();
- if(langId != null){
- ILanguageDescriptor des = (ILanguageDescriptor)langMap.remove(langId);
- adjustLanguageData(data, lData, des);
- continue;
- } else {
- String[] cTypeIds = lData.getSourceContentTypeIds();
- for(int c = 0; c < cTypeIds.length; c++){
- String cTypeId = cTypeIds[c];
- ILanguageDescriptor[] langs = (ILanguageDescriptor[])map.remove(cTypeId);
- if(langs != null && langs.length != 0){
- for(int q = 0; q < langs.length; q++){
- langMap.remove(langs[q].getId());
- }
-
- adjustLanguageData(data, lData, langs[0]);
- }
- }
- }
- }
-
- if(!langMap.isEmpty()){
- addLangs(data, langMap, map);
- }
-
- }
-
- private static CLanguageData adjustLanguageData(CFolderData data, CLanguageData lData, ILanguageDescriptor des){
- String [] cTypeIds = des.getContentTypeIds();
- String srcIds[] = lData.getSourceContentTypeIds();
-
- Set landTypes = new HashSet(Arrays.asList(cTypeIds));
- landTypes.removeAll(Arrays.asList(srcIds));
-
- if(landTypes.size() != 0){
- List srcList = new ArrayList();
- srcList.addAll(landTypes);
- lData.setSourceContentTypeIds((String[])srcList.toArray(new String[srcList.size()]));
- }
-
- if(!des.getId().equals(lData.getLanguageId())){
- lData.setLanguageId(des.getId());
- }
- return lData;
+ factory.setModified(data, false);
+ return data;
}
- private static void addLangs(CFolderData data, Map langMap, Map cTypeToLangMap){
- List list = new ArrayList(langMap.values());
- ILanguageDescriptor des;
- while(list.size() != 0){
- des = (ILanguageDescriptor)list.remove(list.size() - 1);
- String[] ctypeIds = des.getContentTypeIds();
- boolean addLang = false;
- for(int i = 0; i < ctypeIds.length; i++){
- ILanguageDescriptor[] langs = (ILanguageDescriptor[])cTypeToLangMap.remove(ctypeIds[i]);
- if(langs != null && langs.length != 0){
- addLang = true;
- for(int q = 0; q < langs.length; q++){
- list.remove(langs[q]);
- }
- }
- }
-
- if(addLang){
- data.createLanguageDataForContentTypes(des.getId(), ctypeIds);
- }
- }
- }
-
public boolean isNewStyleIndexCfg(IProject project){
ICProjectDescription des = getProjectDescription(project, false);
if(des != null)
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java
deleted file mode 100644
index 4d926751c4c..00000000000
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * 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.internal.core.settings.model;
-
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
-import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
-import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class DefaultConfigurationDataProvider extends
- CConfigurationDataProvider {
-
- public CConfigurationData applyConfiguration(
- ICConfigurationDescription des,
- ICConfigurationDescription baseDescription,
- CConfigurationData base,
- IProgressMonitor monitor)
- throws CoreException {
- //TODO: implement load/store
- return base;
- }
-
- public CConfigurationData createConfiguration(
- ICConfigurationDescription des,
- ICConfigurationDescription baseDescription,
- CConfigurationData base,
- boolean clone,
- IProgressMonitor monitor) throws CoreException {
- //TODO: implement load/store
- CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), base, null, clone);
- return data;
- }
-
- public CConfigurationData loadConfiguration(ICConfigurationDescription des,
- IProgressMonitor monitor)
- throws CoreException {
- //TODO: implement load/store
- CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), null);
- data.initEmptyData();
- return data;
- }
-
- public void removeConfiguration(ICConfigurationDescription des,
- CConfigurationData data,
- IProgressMonitor monitor) {
- //TODO: implement load/store
-
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java
index 4ba52225dc4..2852e4fe125 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java
@@ -127,10 +127,12 @@ public class PathEntryConfigurationDataProvider extends
copySettingsFrom(base);
}
- public PathEntryLanguageData(String id, String languageId,
+ public PathEntryLanguageData(String id, String name, String languageId, int kinds,
String[] ids, boolean isContentTypes, EntryStore store) {
super(id, languageId, ids, isContentTypes);
fStore = store;
+ fName = name;
+ fSupportedKinds = kinds;
}
protected EntryStore createStore() {
@@ -157,9 +159,11 @@ public class PathEntryConfigurationDataProvider extends
}
public CFileData createFileData(CConfigurationData cfg,
- CResourceData base, CLanguageData base2, boolean clone,
+ CResourceData base, CLanguageData base2,
+ String id, boolean clone,
IPath path) {
- String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
if(base.getType() == ICSettingBase.SETTING_FILE)
return new PathEntryFileData(id, path, (PathEntryFileData)base, cfg, this, clone);
return new PathEntryFileData(id, path, (PathEntryFolderData)base,
@@ -167,14 +171,16 @@ public class PathEntryConfigurationDataProvider extends
}
public CFolderData createFolderData(CConfigurationData cfg,
- CFolderData base, boolean clone, IPath path) {
- String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ CFolderData base, String id, boolean clone, IPath path) {
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
return new PathEntryFolderData(id, path, (PathEntryFolderData)base, cfg, this, clone);
}
public CLanguageData createLanguageData(CConfigurationData cfg,
- CResourceData rcBase, CLanguageData base, boolean clone) {
- String id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
+ CResourceData rcBase, CLanguageData base, String id, boolean clone) {
+ if(id == null)
+ id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
EntryStore store;
if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
store = ((PathEntryFolderData)rcBase).fStore;
@@ -184,14 +190,16 @@ public class PathEntryConfigurationDataProvider extends
}
public CLanguageData createLanguageData(CConfigurationData cfg,
- CResourceData rcBase, String languageId, String[] rcTypes,
+ CResourceData rcBase, String id, String name, String languageId, int supportedEntryKinds, String[] rcTypes,
boolean isContentTypes) {
+ if(id == null)
+ id = CDataUtil.genId(rcBase.getId());
EntryStore store;
if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
store = ((PathEntryFolderData)rcBase).fStore;
else
store = ((PathEntryFileData)rcBase).fStore;
- return new PathEntryLanguageData(CDataUtil.genId(rcBase.getId()), languageId, rcTypes, isContentTypes, store);
+ return new PathEntryLanguageData(id, name, languageId, supportedEntryKinds, rcTypes, isContentTypes, store);
}
}
@@ -271,7 +279,8 @@ public class PathEntryConfigurationDataProvider extends
CfgData data = new CfgData(des.getId(), des.getName());
data.initEmptyData();
- CProjectDescriptionManager.getInstance().adjustDefaultConfig(data);
+ CDataUtil.adjustConfig(data, getDataFactory());
+ //CProjectDescriptionManager.getInstance().adjustDefaultConfig(data);
// data.setResolveInfo(rInfo);
PathEntryTranslator tr = new PathEntryTranslator(project, data);
diff --git a/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd b/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd
index 15a87ea94c5..a55d4af0974 100644
--- a/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd
+++ b/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd
@@ -12,6 +12,9 @@
<element name="extension">
<complexType>
+ <sequence>
+ <element ref="provider"/>
+ </sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
@@ -39,6 +42,41 @@
</complexType>
</element>
+ <element name="provider">
+ <complexType>
+ <attribute name="natures" type="string">
+ <annotation>
+ <documentation>
+ project nature ids associated with this provider. IDs are separated by the semicolon.
+Each time the Build Active configuration gets changed, the project natures set gets adjusted by removing natures associated with the previously active configuration and adding natures associated with the new actove configuration.
+This allows to adjust, e.g. the builders to be used with the project, etc.
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ class implementing the org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="conflictingNatures" type="string">
+ <annotation>
+ <documentation>
+ project nature ids to be unset for this provider. IDs are separated by the semicolon.
+Each time the Build Active configuration gets changed, the project natures set gets adjusted by removing natures associated with the previously active configuration and natures conflicting for the new active configuration and adding natures associated with the new active configuration.
+
+This allows to adjust, e.g. the builders to be used with the project, etc.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appInfo>
<meta.section type="since"/>

Back to the top