mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Fix for [Bug 179662] Implement configuration-based scanner discovery in the make.core
This commit is contained in:
parent
19a895a652
commit
cae9417adf
45 changed files with 3761 additions and 246 deletions
|
@ -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];
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# 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
|
extensionGCCPerFileProfile.name=GNU C/C++ Scanner Info per file profile
|
||||||
|
|
||||||
makefile=Makefile
|
makefile=Makefile
|
||||||
|
|
||||||
|
CfgDataProvider.name=Make Data Provider
|
||||||
|
natureCfg.name=Configuration Support Nature
|
||||||
|
|
|
@ -160,4 +160,28 @@
|
||||||
file-extensions="mk"/>
|
file-extensions="mk"/>
|
||||||
</extension>
|
</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>
|
</plugin>
|
||||||
|
|
|
@ -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_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 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 MakeTargetManager fTargetManager;
|
||||||
private DiscoveredPathManager fDiscoveryPathManager;
|
private DiscoveredPathManager fDiscoveryPathManager;
|
||||||
//The shared instance.
|
//The shared instance.
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,7 +12,11 @@ package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.resources.ACBuilder;
|
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.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.SCJobsUtil;
|
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 {
|
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||||
// If auto discovery is disabled, do nothing
|
// If auto discovery is disabled, do nothing
|
||||||
// boolean autodiscoveryEnabled;
|
// boolean autodiscoveryEnabled;
|
||||||
|
if(buildNewStyle(getProject(), monitor))
|
||||||
|
return getProject().getReferencedProjects();
|
||||||
boolean autodiscoveryEnabled2;
|
boolean autodiscoveryEnabled2;
|
||||||
IScannerConfigBuilderInfo2 buildInfo2 = null;
|
IScannerConfigBuilderInfo2 buildInfo2 = null;
|
||||||
try {
|
try {
|
||||||
|
@ -76,8 +82,57 @@ public class ScannerConfigBuilder extends ACBuilder {
|
||||||
autodiscoveryEnabled2 = false;
|
autodiscoveryEnabled2 = false;
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getProject().getReferencedProjects();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -164,6 +164,9 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
|
|
||||||
IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
|
IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
|
||||||
IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
|
IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
|
||||||
|
if(buildInfo == null)
|
||||||
|
buildInfo = container.getInfo(new InfoContext(project));
|
||||||
|
|
||||||
if(buildInfo != null){
|
if(buildInfo != null){
|
||||||
String profileId = buildInfo.getSelectedProfileId();
|
String profileId = buildInfo.getSelectedProfileId();
|
||||||
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
|
|
|
@ -164,11 +164,13 @@ public class ScannerInfoConsoleParserFactory {
|
||||||
if (collector == null) {
|
if (collector == null) {
|
||||||
collector = profileInstance.getScannerInfoCollector();
|
collector = profileInstance.getScannerInfoCollector();
|
||||||
}
|
}
|
||||||
clParser.startup(currentProject, workingDirectory, collector,
|
if(clParser != null){
|
||||||
scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
|
clParser.startup(currentProject, workingDirectory, collector,
|
||||||
// create an output stream sniffer
|
scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
|
||||||
return new ConsoleOutputSniffer(outputStream, errorStream, new
|
// create an output stream sniffer
|
||||||
IScannerInfoConsoleParser[] {clParser});
|
return new ConsoleOutputSniffer(outputStream, errorStream, new
|
||||||
|
IScannerInfoConsoleParser[] {clParser});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SCJobsUtil {
|
||||||
public static boolean getProviderScannerInfo(final IProject project,
|
public static boolean getProviderScannerInfo(final IProject project,
|
||||||
final IScannerConfigBuilderInfo2 buildInfo,
|
final IScannerConfigBuilderInfo2 buildInfo,
|
||||||
final IProgressMonitor monitor) {
|
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,
|
public static boolean getProviderScannerInfo(final IProject project,
|
||||||
|
@ -114,7 +114,7 @@ public class SCJobsUtil {
|
||||||
public static boolean updateScannerConfiguration(IProject project,
|
public static boolean updateScannerConfiguration(IProject project,
|
||||||
IScannerConfigBuilderInfo2 buildInfo,
|
IScannerConfigBuilderInfo2 buildInfo,
|
||||||
final IProgressMonitor monitor) {
|
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,
|
public static boolean readBuildOutputFile(final IProject project,
|
||||||
final IScannerConfigBuilderInfo2 buildInfo,
|
final IScannerConfigBuilderInfo2 buildInfo,
|
||||||
final IProgressMonitor monitor) {
|
final IProgressMonitor monitor) {
|
||||||
return readBuildOutputFile(project, new InfoContext(project), buildInfo, monitor);
|
return readBuildOutputFile(project, buildInfo.getContext(), buildInfo, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,6 +61,8 @@ public class ScannerConfigProfileManager {
|
||||||
try {
|
try {
|
||||||
IScannerConfigBuilderInfo2Set container = createScannerConfigBuildInfo2Set(project);
|
IScannerConfigBuilderInfo2Set container = createScannerConfigBuildInfo2Set(project);
|
||||||
IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
|
IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
|
||||||
|
if(buildInfo == null)
|
||||||
|
buildInfo = container.getInfo(new InfoContext(project));
|
||||||
profileId = buildInfo.getSelectedProfileId();
|
profileId = buildInfo.getSelectedProfileId();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
|
|
BIN
build/org.eclipse.cdt.make.ui/icons/obj16/define_obj.gif
Normal file
BIN
build/org.eclipse.cdt.make.ui/icons/obj16/define_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 B |
BIN
build/org.eclipse.cdt.make.ui/icons/obj16/hfolder_obj.gif
Normal file
BIN
build/org.eclipse.cdt.make.ui/icons/obj16/hfolder_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 579 B |
|
@ -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
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# 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
|
GCCPerProjectProfile.name=GCC per project scanner info profile
|
||||||
GCCPerFileProfile.name=GCC per file 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
|
||||||
|
|
|
@ -447,4 +447,59 @@
|
||||||
<contentExtension pattern="org.eclipse.cdt.make.ui.wizards.*"/>
|
<contentExtension pattern="org.eclipse.cdt.make.ui.wizards.*"/>
|
||||||
</includes>
|
</includes>
|
||||||
</viewerContentBinding>
|
</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=""Includes list""/>
|
||||||
|
<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=""Macros list""/>
|
||||||
|
</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>
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,9 +16,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
|
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
|
||||||
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
|
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.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
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.core.Tool;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
|
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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.Preferences;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,14 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class CDataFacroty {
|
public class CDataFacroty {
|
||||||
|
private static CDataFacroty fInstance;
|
||||||
|
|
||||||
|
public static CDataFacroty getDefault(){
|
||||||
|
if(fInstance == null)
|
||||||
|
fInstance = new CDataFacroty();
|
||||||
|
return fInstance;
|
||||||
|
}
|
||||||
|
|
||||||
public CConfigurationData createConfigurationdata(String id,
|
public CConfigurationData createConfigurationdata(String id,
|
||||||
String name,
|
String name,
|
||||||
CConfigurationData base,
|
CConfigurationData base,
|
||||||
|
@ -25,22 +33,26 @@ public class CDataFacroty {
|
||||||
|
|
||||||
return new CDefaultConfigurationData(id, name, base, this, clone);
|
return new CDefaultConfigurationData(id, name, base, this, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFolderData createFolderData(CConfigurationData cfg,
|
public CFolderData createFolderData(CConfigurationData cfg,
|
||||||
CFolderData base,
|
CFolderData base,
|
||||||
|
String id,
|
||||||
boolean clone,
|
boolean clone,
|
||||||
IPath path){
|
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);
|
return new CDefaultFolderData(id, path, base, cfg, this, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFileData createFileData(CConfigurationData cfg,
|
public CFileData createFileData(CConfigurationData cfg,
|
||||||
CResourceData base,
|
CResourceData base,
|
||||||
CLanguageData lBase,
|
CLanguageData lBase,
|
||||||
|
String id,
|
||||||
boolean clone,
|
boolean clone,
|
||||||
IPath path){
|
IPath path){
|
||||||
String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
|
if(id == null)
|
||||||
if(base.getType() == ICSettingBase.SETTING_FILE)
|
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, (CFileData)base, cfg, this, clone);
|
||||||
return new CDefaultFileData(id, path, (CFolderData)base, lBase, cfg, this);
|
return new CDefaultFileData(id, path, (CFolderData)base, lBase, cfg, this);
|
||||||
}
|
}
|
||||||
|
@ -48,28 +60,43 @@ public class CDataFacroty {
|
||||||
public CLanguageData createLanguageData(CConfigurationData cfg,
|
public CLanguageData createLanguageData(CConfigurationData cfg,
|
||||||
CResourceData rcBase,
|
CResourceData rcBase,
|
||||||
CLanguageData base,
|
CLanguageData base,
|
||||||
|
String id,
|
||||||
boolean clone){
|
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);
|
return new CDefaultLanguageData(id, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CLanguageData createLanguageData(CConfigurationData cfg,
|
public CLanguageData createLanguageData(CConfigurationData cfg,
|
||||||
CResourceData rcBase,
|
CResourceData rcBase,
|
||||||
|
String id,
|
||||||
|
String name,
|
||||||
String languageId,
|
String languageId,
|
||||||
|
int supportedEntryKinds,
|
||||||
String[] rcTypes,
|
String[] rcTypes,
|
||||||
boolean isContentTypes){
|
boolean isContentTypes){
|
||||||
String id = CDataUtil.genId(rcBase.getId());
|
if(id == null)
|
||||||
return new CDefaultLanguageData(id, languageId, rcTypes, isContentTypes);
|
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){
|
public CBuildData createBuildData(CConfigurationData cfg, CBuildData base, String id, String name, boolean clone){
|
||||||
String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
|
if(id == null)
|
||||||
return new CDefaultBuildData(id, base);
|
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){
|
public CTargetPlatformData createTargetPlatformData(CConfigurationData cfg, CTargetPlatformData base, String id, String name, boolean clone){
|
||||||
String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
|
if(id == null)
|
||||||
return new CDefaultTargetPlatformData(id, base);
|
id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
|
||||||
|
CDefaultTargetPlatformData tpData = new CDefaultTargetPlatformData(id, base);
|
||||||
|
tpData.fName = name;
|
||||||
|
return tpData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModified(CDataObject data){
|
public boolean isModified(CDataObject data){
|
||||||
|
@ -112,5 +139,29 @@ public class CDataFacroty {
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,25 +125,25 @@ public class CDefaultConfigurationData extends CConfigurationData {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CFolderData copyFolderData(IPath path, CFolderData base, boolean clone){
|
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){
|
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){
|
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){
|
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){
|
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{
|
public CFolderData createFolderData(IPath path, CFolderData base) throws CoreException{
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,13 +61,13 @@ public class CDefaultFileData extends CFileData {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyDataFrom(CFolderData base, CLanguageData baseLanguageData){
|
protected void copyDataFrom(CFolderData base, CLanguageData baseLanguageData){
|
||||||
fIsExcluded = base.isExcluded();
|
fIsExcluded = base != null ? base.isExcluded() : false;
|
||||||
if(baseLanguageData != null)
|
if(baseLanguageData != null)
|
||||||
fLanguageData = copyLanguageData(baseLanguageData, false);
|
fLanguageData = copyLanguageData(baseLanguageData, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLanguageData copyLanguageData(CLanguageData data, boolean clone){
|
protected CLanguageData copyLanguageData(CLanguageData data, boolean clone){
|
||||||
return fFactory.createLanguageData(fCfg, this, data, clone);
|
return fFactory.createLanguageData(fCfg, this, data, null, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class CDefaultFolderData extends CFolderData {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLanguageData copyLanguageData(CLanguageData base, boolean clone){
|
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() {
|
public CLanguageData[] getLanguageDatas() {
|
||||||
|
@ -104,34 +104,36 @@ public class CDefaultFolderData extends CFolderData {
|
||||||
return getId() != null;
|
return getId() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLanguageData doCreateLanguageDataForContentTypes(String languageId,
|
// protected CLanguageData doCreateLanguageDataForContentTypes(String languageId,
|
||||||
String[] typesIds) {
|
// String[] typesIds) {
|
||||||
return fFactory.createLanguageData(fCfg, this, languageId, typesIds, true);
|
// return fFactory.createLanguageData(fCfg, this, null, null, languageId, typesIds, true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
protected CLanguageData doCreateLanguageDataForExtensions(String languageId,
|
// protected CLanguageData doCreateLanguageDataForExtensions(String languageId,
|
||||||
String[] extensions) {
|
// String[] extensions) {
|
||||||
return fFactory.createLanguageData(fCfg, this, languageId, extensions, false);
|
// return fFactory.createLanguageData(fCfg, this, null, null, languageId, extensions, false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public CLanguageData createLanguageDataForContentTypes(String languageId,
|
public CLanguageData createLanguageDataForContentTypes(String languageId,
|
||||||
String[] typesIds) {
|
String[] typesIds) {
|
||||||
CLanguageData data = doCreateLanguageDataForContentTypes(languageId, typesIds);
|
throw new UnsupportedOperationException();
|
||||||
if(data != null){
|
// CLanguageData data = doCreateLanguageDataForContentTypes(languageId, typesIds);
|
||||||
fLanguageDatas.add(data);
|
// if(data != null){
|
||||||
setModified(true);
|
// fLanguageDatas.add(data);
|
||||||
}
|
// setModified(true);
|
||||||
return data;
|
// }
|
||||||
|
// return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CLanguageData createLanguageDataForExtensions(String languageId,
|
public CLanguageData createLanguageDataForExtensions(String languageId,
|
||||||
String[] extensions) {
|
String[] extensions) {
|
||||||
CLanguageData data = doCreateLanguageDataForExtensions(languageId, extensions);
|
throw new UnsupportedOperationException();
|
||||||
if(data != null){
|
// CLanguageData data = doCreateLanguageDataForExtensions(languageId, extensions);
|
||||||
fLanguageDatas.add(data);
|
// if(data != null){
|
||||||
setModified(true);
|
// fLanguageDatas.add(data);
|
||||||
}
|
// setModified(true);
|
||||||
return data;
|
// }
|
||||||
|
// return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModified(){
|
public boolean isModified(){
|
||||||
|
|
|
@ -86,13 +86,17 @@ public class CDefaultLanguageData extends CLanguageData {
|
||||||
EntryStore store = createStore();
|
EntryStore store = createStore();
|
||||||
int kinds[] = KindBasedStore.getLanguageEntryKinds();
|
int kinds[] = KindBasedStore.getLanguageEntryKinds();
|
||||||
for(int i = 0; i < kinds.length; i++){
|
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);
|
entries = processStoredEntries(entries, OP_COPY);
|
||||||
store.storeEntries(kinds[i], entries);
|
store.storeEntries(kinds[i], entries);
|
||||||
}
|
}
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ICLanguageSettingEntry[] getEntriesToCopy(int kind, CLanguageData lData){
|
||||||
|
return lData.getEntries(kind);
|
||||||
|
}
|
||||||
|
|
||||||
protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op){
|
protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op){
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,13 +12,19 @@ package org.eclipse.cdt.core.settings.model.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
|
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
|
||||||
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
|
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.CIncludeFileEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
|
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
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.CSourceEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
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.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.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.CFolderData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
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.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.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
|
@ -74,14 +84,18 @@ public class CDataUtil {
|
||||||
return o2 == null;
|
return o2 == null;
|
||||||
return o1.equals(o2);
|
return o1.equals(o2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String arrayToString(String[] array, String separator){
|
public static String arrayToString(String[] array, String separator){
|
||||||
|
return arrayToString((Object[])array, separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String arrayToString(Object[] array, String separator){
|
||||||
if(array == null)
|
if(array == null)
|
||||||
return null;
|
return null;
|
||||||
if(array.length == 0)
|
if(array.length == 0)
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
if(array.length == 1)
|
if(array.length == 1)
|
||||||
return array[0];
|
return array[0].toString();
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
buf.append(array[0]);
|
buf.append(array[0]);
|
||||||
for(int i = 1; i < array.length; i++){
|
for(int i = 1; i < array.length; i++){
|
||||||
|
@ -322,7 +336,18 @@ public class CDataUtil {
|
||||||
}
|
}
|
||||||
return null;
|
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){
|
public static PathSettingsContainer createRcDataHolder(CConfigurationData data){
|
||||||
PathSettingsContainer h = PathSettingsContainer.createRootContainer();
|
PathSettingsContainer h = PathSettingsContainer.createRootContainer();
|
||||||
|
|
||||||
|
@ -337,4 +362,130 @@ public class CDataUtil {
|
||||||
}
|
}
|
||||||
return h;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -124,9 +124,19 @@ public class EntryStore {
|
||||||
list.add(pos ,entry);
|
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){
|
public void storeEntries(int kind, ICLanguageSettingEntry[] entries){
|
||||||
List newList = new ArrayList(entries.length);
|
storeEntries(kind, entries != null ? Arrays.asList(entries) : new ArrayList());
|
||||||
newList.addAll(Arrays.asList(entries));
|
}
|
||||||
|
|
||||||
|
public void storeEntries(int kind, List list){
|
||||||
|
List newList = new ArrayList(list);
|
||||||
|
// newList.addAll(Arrays.asList(entries));
|
||||||
if(fPreserveReadOnly){
|
if(fPreserveReadOnly){
|
||||||
List oldList = getEntriesList(kind, false);
|
List oldList = getEntriesList(kind, false);
|
||||||
if(oldList != null){
|
if(oldList != null){
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class LanguageSettingEntriesSerializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String kindToString(int kind){
|
public static String kindToString(int kind){
|
||||||
switch(kind){
|
switch(kind){
|
||||||
case ICLanguageSettingEntry.INCLUDE_PATH:
|
case ICLanguageSettingEntry.INCLUDE_PATH:
|
||||||
return INCLUDE_PATH;
|
return INCLUDE_PATH;
|
||||||
|
@ -183,10 +183,10 @@ public class LanguageSettingEntriesSerializer {
|
||||||
case ICLanguageSettingEntry.OUTPUT_PATH:
|
case ICLanguageSettingEntry.OUTPUT_PATH:
|
||||||
return 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))
|
if(INCLUDE_PATH.equals(kind))
|
||||||
return ICLanguageSettingEntry.INCLUDE_PATH;
|
return ICLanguageSettingEntry.INCLUDE_PATH;
|
||||||
if(INCLUDE_FILE.equals(kind))
|
if(INCLUDE_FILE.equals(kind))
|
||||||
|
|
|
@ -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()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
|
@ -45,8 +45,6 @@ import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
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.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
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.CResourceData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
|
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.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.CDataUtil;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
|
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
|
||||||
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
||||||
|
@ -1491,7 +1488,6 @@ public class CProjectDescriptionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CConfigurationData loadData(ICConfigurationDescription des, IProgressMonitor monitor) throws CoreException{
|
CConfigurationData loadData(ICConfigurationDescription des, IProgressMonitor monitor) throws CoreException{
|
||||||
if(monitor == null)
|
if(monitor == null)
|
||||||
|
@ -2973,107 +2969,16 @@ public class CProjectDescriptionManager {
|
||||||
if(factory == null)
|
if(factory == null)
|
||||||
factory = new CDataFacroty();
|
factory = new CDataFacroty();
|
||||||
|
|
||||||
CDefaultConfigurationData data = (CDefaultConfigurationData)factory.createConfigurationdata(id, name, null, false);
|
CConfigurationData data = CDataUtil.createEmptyData(id, name, factory, true);
|
||||||
data.initEmptyData();
|
// CDataUtil.
|
||||||
adjustDefaultConfig(data);
|
//// data.initEmptyData();
|
||||||
|
//
|
||||||
data.setModified(false);
|
// CDataUtil.adjustConfig(data, factory);
|
||||||
|
|
||||||
|
factory.setModified(data, false);
|
||||||
return data;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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){
|
public boolean isNewStyleIndexCfg(IProject project){
|
||||||
ICProjectDescription des = getProjectDescription(project, false);
|
ICProjectDescription des = getProjectDescription(project, false);
|
||||||
if(des != null)
|
if(des != 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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -127,10 +127,12 @@ public class PathEntryConfigurationDataProvider extends
|
||||||
copySettingsFrom(base);
|
copySettingsFrom(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathEntryLanguageData(String id, String languageId,
|
public PathEntryLanguageData(String id, String name, String languageId, int kinds,
|
||||||
String[] ids, boolean isContentTypes, EntryStore store) {
|
String[] ids, boolean isContentTypes, EntryStore store) {
|
||||||
super(id, languageId, ids, isContentTypes);
|
super(id, languageId, ids, isContentTypes);
|
||||||
fStore = store;
|
fStore = store;
|
||||||
|
fName = name;
|
||||||
|
fSupportedKinds = kinds;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntryStore createStore() {
|
protected EntryStore createStore() {
|
||||||
|
@ -157,9 +159,11 @@ public class PathEntryConfigurationDataProvider extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFileData createFileData(CConfigurationData cfg,
|
public CFileData createFileData(CConfigurationData cfg,
|
||||||
CResourceData base, CLanguageData base2, boolean clone,
|
CResourceData base, CLanguageData base2,
|
||||||
|
String id, boolean clone,
|
||||||
IPath path) {
|
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)
|
if(base.getType() == ICSettingBase.SETTING_FILE)
|
||||||
return new PathEntryFileData(id, path, (PathEntryFileData)base, cfg, this, clone);
|
return new PathEntryFileData(id, path, (PathEntryFileData)base, cfg, this, clone);
|
||||||
return new PathEntryFileData(id, path, (PathEntryFolderData)base,
|
return new PathEntryFileData(id, path, (PathEntryFolderData)base,
|
||||||
|
@ -167,14 +171,16 @@ public class PathEntryConfigurationDataProvider extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFolderData createFolderData(CConfigurationData cfg,
|
public CFolderData createFolderData(CConfigurationData cfg,
|
||||||
CFolderData base, boolean clone, IPath path) {
|
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 PathEntryFolderData(id, path, (PathEntryFolderData)base, cfg, this, clone);
|
return new PathEntryFolderData(id, path, (PathEntryFolderData)base, cfg, this, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CLanguageData createLanguageData(CConfigurationData cfg,
|
public CLanguageData createLanguageData(CConfigurationData cfg,
|
||||||
CResourceData rcBase, CLanguageData base, boolean clone) {
|
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());
|
||||||
EntryStore store;
|
EntryStore store;
|
||||||
if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
|
if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
|
||||||
store = ((PathEntryFolderData)rcBase).fStore;
|
store = ((PathEntryFolderData)rcBase).fStore;
|
||||||
|
@ -184,14 +190,16 @@ public class PathEntryConfigurationDataProvider extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public CLanguageData createLanguageData(CConfigurationData cfg,
|
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) {
|
boolean isContentTypes) {
|
||||||
|
if(id == null)
|
||||||
|
id = CDataUtil.genId(rcBase.getId());
|
||||||
EntryStore store;
|
EntryStore store;
|
||||||
if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
|
if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
|
||||||
store = ((PathEntryFolderData)rcBase).fStore;
|
store = ((PathEntryFolderData)rcBase).fStore;
|
||||||
else
|
else
|
||||||
store = ((PathEntryFileData)rcBase).fStore;
|
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());
|
CfgData data = new CfgData(des.getId(), des.getName());
|
||||||
data.initEmptyData();
|
data.initEmptyData();
|
||||||
CProjectDescriptionManager.getInstance().adjustDefaultConfig(data);
|
CDataUtil.adjustConfig(data, getDataFactory());
|
||||||
|
//CProjectDescriptionManager.getInstance().adjustDefaultConfig(data);
|
||||||
|
|
||||||
// data.setResolveInfo(rInfo);
|
// data.setResolveInfo(rInfo);
|
||||||
PathEntryTranslator tr = new PathEntryTranslator(project, data);
|
PathEntryTranslator tr = new PathEntryTranslator(project, data);
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
<element name="extension">
|
<element name="extension">
|
||||||
<complexType>
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element ref="provider"/>
|
||||||
|
</sequence>
|
||||||
<attribute name="point" type="string" use="required">
|
<attribute name="point" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
@ -39,6 +42,41 @@
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</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>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.section type="since"/>
|
<meta.section type="since"/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue