mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
1.Fix for [Bug 189125] [New project model] Stroage modules don't get copied
2. small bug-fixes
This commit is contained in:
parent
d94ffa1869
commit
d118d88beb
4 changed files with 81 additions and 16 deletions
|
@ -57,6 +57,7 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
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.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||||
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.util.XmlStorageElement;
|
import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
|
||||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
|
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
|
||||||
|
@ -2619,19 +2620,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
public static void setLoaddedBuildInfo(IProject project, IManagedBuildInfo info) throws CoreException{
|
public static void setLoaddedBuildInfo(IProject project, IManagedBuildInfo info) throws CoreException{
|
||||||
// Associate the build info with the project for the duration of the session
|
// Associate the build info with the project for the duration of the session
|
||||||
//project.setSessionProperty(buildInfoProperty, info);
|
//project.setSessionProperty(buildInfoProperty, info);
|
||||||
IResourceRuleFactory rcRf = ResourcesPlugin.getWorkspace().getRuleFactory();
|
// IResourceRuleFactory rcRf = ResourcesPlugin.getWorkspace().getRuleFactory();
|
||||||
ISchedulingRule rule = rcRf.modifyRule(project);
|
// ISchedulingRule rule = rcRf.modifyRule(project);
|
||||||
IJobManager mngr = Job.getJobManager();
|
// IJobManager mngr = Job.getJobManager();
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
mngr.beginRule(rule, null);
|
// mngr.beginRule(rule, null);
|
||||||
doSetLoaddedInfo(project, info);
|
doSetLoaddedInfo(project, info);
|
||||||
} catch (IllegalArgumentException e) {
|
// } catch (IllegalArgumentException e) {
|
||||||
// TODO: set anyway for now
|
// // TODO: set anyway for now
|
||||||
doSetLoaddedInfo(project, info);
|
// doSetLoaddedInfo(project, info);
|
||||||
}finally {
|
// }finally {
|
||||||
mngr.endRule(rule);
|
// mngr.endRule(rule);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized static void doSetLoaddedInfo(IProject project, IManagedBuildInfo info){
|
private synchronized static void doSetLoaddedInfo(IProject project, IManagedBuildInfo info){
|
||||||
|
@ -2733,10 +2734,12 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buildInfo == null && forceLoad){
|
if(buildInfo == null /*&& forceLoad*/){
|
||||||
|
int flags = forceLoad ? 0 : ICProjectDescriptionManager.GET_IF_LOADDED;
|
||||||
|
|
||||||
if(BuildDbgUtil.DEBUG)
|
if(BuildDbgUtil.DEBUG)
|
||||||
BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: build info is NOT loadded and force_load");
|
BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: build info is NOT loadded" + (forceLoad ? " forceload" : ""));
|
||||||
ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(proj, false);
|
ICProjectDescription projDes = CoreModel.getDefault().getProjectDescriptionManager().getProjectDescription(proj, flags);
|
||||||
if(projDes != null){
|
if(projDes != null){
|
||||||
if(BuildDbgUtil.DEBUG)
|
if(BuildDbgUtil.DEBUG)
|
||||||
BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: project description is obtained, qwerying the loaded build info");
|
BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: project description is obtained, qwerying the loaded build info");
|
||||||
|
|
|
@ -13,7 +13,9 @@ package org.eclipse.cdt.core.settings.model;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
|
@ -27,7 +29,7 @@ import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
public class CProjectDescriptionBasicTests extends BaseTestCase{
|
public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||||
private static final String PROJ_NAME_PREFIX = "CProjectDescriptionBasicTests_";
|
private static final String PROJ_NAME_PREFIX = "CProjectDescriptionBasicTests_";
|
||||||
IProject p1, p2;
|
IProject p1, p2, p3;
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(CProjectDescriptionBasicTests.class, "_");
|
return suite(CProjectDescriptionBasicTests.class, "_");
|
||||||
|
@ -59,6 +61,49 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testModulesCopiedOnCreateNewConfig() throws Exception {
|
||||||
|
ICProject p = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
p3 = p.getProject();
|
||||||
|
|
||||||
|
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||||
|
|
||||||
|
ICProjectDescription des = mngr.getProjectDescription(p3);
|
||||||
|
ICConfigurationDescription baseCfg = des.getConfigurations()[0];
|
||||||
|
final String baseCfgId = baseCfg.getId();
|
||||||
|
final String STORAGE_ID = "test.storage_id";
|
||||||
|
final String ATTR = "testAttr";
|
||||||
|
final String ATTR_VALUE = "testAttrValue";
|
||||||
|
final String EL_NAME = "testElName";
|
||||||
|
final String ATTR2 = "testAttr2";
|
||||||
|
final String ATTR2_VALUE = "testAttr2Value";
|
||||||
|
|
||||||
|
ICStorageElement el = baseCfg.getStorage(STORAGE_ID, false);
|
||||||
|
assertNull(el);
|
||||||
|
el = baseCfg.getStorage(STORAGE_ID, true);
|
||||||
|
assertNotNull(el);
|
||||||
|
assertNull(el.getAttribute(ATTR));
|
||||||
|
el.setAttribute(ATTR, ATTR_VALUE);
|
||||||
|
assertEquals(0, el.getChildren().length);
|
||||||
|
ICStorageElement child = el.createChild(EL_NAME);
|
||||||
|
child.setAttribute(ATTR2, ATTR2_VALUE);
|
||||||
|
|
||||||
|
final String newCfgId1 = CDataUtil.genId(null);
|
||||||
|
final String newCfgId2 = CDataUtil.genId(null);
|
||||||
|
|
||||||
|
ICConfigurationDescription cfg1 = des.createConfiguration(newCfgId1, newCfgId1 + ".name", baseCfg);
|
||||||
|
assertEquals(newCfgId1, cfg1.getId());
|
||||||
|
el = cfg1.getStorage(STORAGE_ID, false);
|
||||||
|
assertNotNull(el);
|
||||||
|
assertEquals(ATTR_VALUE, el.getAttribute(ATTR));
|
||||||
|
assertEquals(1, el.getChildren().length);
|
||||||
|
child = el.getChildren()[0];
|
||||||
|
assertEquals(EL_NAME, child.getName());
|
||||||
|
assertEquals(ATTR2_VALUE, child.getAttribute(ATTR2));
|
||||||
|
|
||||||
|
mngr.setProjectDescription(p3, des);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void remove_prefix_testSetInvalidCreatingDescription() throws Exception {
|
public void remove_prefix_testSetInvalidCreatingDescription() throws Exception {
|
||||||
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||||
IWorkspaceRoot root = wsp.getRoot();
|
IWorkspaceRoot root = wsp.getRoot();
|
||||||
|
@ -106,6 +151,11 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||||
p2.getProject().delete(true, null);
|
p2.getProject().delete(true, null);
|
||||||
} catch (CoreException e){
|
} catch (CoreException e){
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if(p3 != null)
|
||||||
|
p3.getProject().delete(true, null);
|
||||||
|
} catch (CoreException e){
|
||||||
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,15 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
||||||
super(null, projectDes, null);
|
super(null, projectDes, null);
|
||||||
|
|
||||||
setConfiguration(this);
|
setConfiguration(this);
|
||||||
fCfgSpecSettings = new CConfigurationSpecSettings(this, ((CConfigurationDescription)base).getSpecSettings());
|
internalSetId(id);
|
||||||
|
|
||||||
|
CConfigurationSpecSettings baseSettings = ((CConfigurationDescription)base).getSpecSettings();
|
||||||
|
InternalXmlStorageElement baseRootEl = (InternalXmlStorageElement)baseSettings.getRootStorageElement();
|
||||||
|
InternalXmlStorageElement newRootEl = CProjectDescriptionManager.getInstance().copyElement(baseRootEl, false);
|
||||||
|
ICStorageElement parentEl = baseRootEl.getParent();
|
||||||
|
parentEl.importChild(newRootEl);
|
||||||
|
|
||||||
|
fCfgSpecSettings = new CConfigurationSpecSettings(this, baseSettings, newRootEl);
|
||||||
fCfgSpecSettings.setId(id);
|
fCfgSpecSettings.setId(id);
|
||||||
fCfgSpecSettings.setName(name);
|
fCfgSpecSettings.setName(name);
|
||||||
CConfigurationData baseData = ((IInternalCCfgInfo)base).getConfigurationData(false);
|
CConfigurationData baseData = ((IInternalCCfgInfo)base).getConfigurationData(false);
|
||||||
|
|
|
@ -106,6 +106,10 @@ public abstract class CDataProxy implements ICSettingObject {
|
||||||
fData = data;
|
fData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void internalSetId(String id){
|
||||||
|
fId = id;
|
||||||
|
}
|
||||||
|
|
||||||
void doClearData(){
|
void doClearData(){
|
||||||
fData = null;
|
fData = null;
|
||||||
setRescan(true);
|
setRescan(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue