mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
1. Fix for [Bug 189277] Workbench Build Behaviour isn't persisted accross workbench restarts
2. Mark the cproject description as modified in case the session properties are changed 3. Basics for allowing the empty (with no configurations) project description in case the icCdtProjectCreating state is true
This commit is contained in:
parent
957775408c
commit
43e78cee49
7 changed files with 83 additions and 15 deletions
|
@ -787,7 +787,7 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
|
|||
if(incrementalBuildTarget != null)
|
||||
element.setAttribute(ATTRIBUTE_TARGET_INCREMENTAL, incrementalBuildTarget);
|
||||
if(incrementalBuildEnabled != null)
|
||||
element.setAttribute(ATTRIBUTE_AUTO_ENABLED, incrementalBuildEnabled.toString());
|
||||
element.setAttribute(ATTRIBUTE_INCREMENTAL_ENABLED, incrementalBuildEnabled.toString());
|
||||
if(cleanBuildTarget != null)
|
||||
element.setAttribute(ATTRIBUTE_TARGET_CLEAN, cleanBuildTarget);
|
||||
if(cleanBuildEnabled != null)
|
||||
|
|
|
@ -14,17 +14,20 @@ import junit.framework.TestSuite;
|
|||
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
|
||||
public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||
private static final String PROJ_NAME_PREFIX = "CProjectDescriptionBasicTests_";
|
||||
IProject p1;
|
||||
IProject p1, p2;
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(CProjectDescriptionBasicTests.class, "_");
|
||||
|
@ -55,10 +58,52 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
|||
|
||||
assertTrue(failed);
|
||||
}
|
||||
|
||||
public void remove_prefix_testSetInvalidCreatingDescription() throws Exception {
|
||||
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||
IWorkspaceRoot root = wsp.getRoot();
|
||||
|
||||
p2 = root.getProject(PROJ_NAME_PREFIX + "2");
|
||||
p2.create(null);
|
||||
p2.open(null);
|
||||
|
||||
CProjectHelper.addNatureToProject(p2, CProjectNature.C_NATURE_ID, null);
|
||||
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
|
||||
ICProjectDescription des = mngr.createProjectDescription(p2, false, true);
|
||||
des.setSessionProperty(new QualifiedName(CTestPlugin.PLUGIN_ID, "tmp"), "tmp");
|
||||
|
||||
assertFalse(des.isValid());
|
||||
|
||||
boolean failed = false;
|
||||
try {
|
||||
mngr.setProjectDescription(p2, des);
|
||||
} catch (CoreException e){
|
||||
failed = true;
|
||||
}
|
||||
|
||||
assertFalse(failed);
|
||||
|
||||
assertNotNull(mngr.getProjectDescription(p2, false));
|
||||
assertNotNull(mngr.getProjectDescription(p2, true));
|
||||
|
||||
des = mngr.getProjectDescription(p2, true);
|
||||
ICConfigurationDescription cfg = mngr.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID, true);
|
||||
cfg = des.createConfiguration(CDataUtil.genId(null), CDataUtil.genId(null), cfg);
|
||||
mngr.setProjectDescription(p2, des);
|
||||
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
p1.getProject().delete(true, null);
|
||||
if(p1 != null)
|
||||
p1.getProject().delete(true, null);
|
||||
} catch (CoreException e){
|
||||
}
|
||||
try {
|
||||
if(p2 != null)
|
||||
p2.getProject().delete(true, null);
|
||||
} catch (CoreException e){
|
||||
}
|
||||
super.tearDown();
|
||||
|
|
|
@ -167,4 +167,10 @@ public interface ICProjectDescriptionManager {
|
|||
* @see ICConfigurationDescription#updateExternalSettingsProviders(String[])
|
||||
*/
|
||||
void updateExternalSettingsProviders(String[] ids, IProgressMonitor monitor);
|
||||
|
||||
ICConfigurationDescription getPreferenceConfiguration(String buildSystemId) throws CoreException;
|
||||
|
||||
ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws CoreException;
|
||||
|
||||
void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException;
|
||||
}
|
||||
|
|
|
@ -525,7 +525,12 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
|||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName name, Object value) {
|
||||
fPropertiesMap.put(name, value);
|
||||
if(value != null)
|
||||
fPropertiesMap.put(name, value);
|
||||
else
|
||||
fPropertiesMap.remove(name);
|
||||
|
||||
fIsModified = true;
|
||||
}
|
||||
|
||||
public void removeStorage(String id) throws CoreException {
|
||||
|
|
|
@ -259,6 +259,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
private Map fDescriptionMap = new HashMap(); //calls to this map are "manually" synchronized with the CProjectDescriptionManager object lock;
|
||||
private ResourceChangeHandler fRcChangeHandler;
|
||||
private CProjectDescriptionWorkspacePreferences fPreferences;
|
||||
private boolean fAllowEmptyCreatingDescription = false; // not allowed by default
|
||||
|
||||
// private CStorage fPrefCfgStorage;
|
||||
private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){
|
||||
|
@ -1160,7 +1161,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
if(!des.isValid())
|
||||
if(!des.isValid() && (!fAllowEmptyCreatingDescription || !des.isCdtProjectCreating()))
|
||||
throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName()); //$NON-NLS-1$
|
||||
|
||||
if(!checkFlags(flags, SET_FORCE) && !des.isModified())
|
||||
|
@ -3442,4 +3443,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
public void updateExternalSettingsProviders(String[] ids, IProgressMonitor monitor){
|
||||
ExtensionContainerFactory.updateReferencedProviderIds(ids, monitor);
|
||||
}
|
||||
|
||||
boolean isEmptyCreatingDescriptionAllowed(){
|
||||
return fAllowEmptyCreatingDescription;
|
||||
}
|
||||
|
||||
void setEmptyCreatingDescriptionAllowed(boolean allow){
|
||||
fAllowEmptyCreatingDescription = allow;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,9 +42,6 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
|
|||
ICProject cProject = (ICProject)getElementToProcess();
|
||||
final IProject project = cProject.getProject();
|
||||
|
||||
if(!fSetDescription.isValid())
|
||||
throw new CModelException(ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName())); //$NON-NLS-1$
|
||||
|
||||
CProjectDescription fOldDescriptionCache = (CProjectDescription)mngr.getProjectDescription(project, false);
|
||||
|
||||
CProjectDescriptionEvent event = mngr.createAboutToApplyEvent(fSetDescription, fOldDescriptionCache);
|
||||
|
@ -59,7 +56,10 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
|
|||
boolean creating = fOldDescriptionCache != null ? fOldDescriptionCache.isCdtProjectCreating() : true;
|
||||
if(creating)
|
||||
creating = fSetDescription.isCdtProjectCreating();
|
||||
|
||||
|
||||
if(!fSetDescription.isValid() && (!mngr.isEmptyCreatingDescriptionAllowed() || !creating))
|
||||
throw new CModelException(ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName())); //$NON-NLS-1$
|
||||
|
||||
CProjectDescription fNewDescriptionCache = new CProjectDescription(fSetDescription, true, el, creating);
|
||||
try {
|
||||
mngr.setDescriptionApplying(project, fNewDescriptionCache);
|
||||
|
|
|
@ -442,13 +442,15 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
|||
ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration();
|
||||
ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration();
|
||||
int flags = 0;
|
||||
if(newCfg.getId().equals(oldCfg.getId())){
|
||||
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
|
||||
if(cfgDelta != null){
|
||||
flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER);
|
||||
if(oldCfg != null && newCfg != null){
|
||||
if(newCfg.getId().equals(oldCfg.getId())){
|
||||
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
|
||||
if(cfgDelta != null){
|
||||
flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER);
|
||||
}
|
||||
} else {
|
||||
flags = CProjectDescriptionManager.getInstance().calculateDescriptorFlags(newCfg, oldCfg);
|
||||
}
|
||||
} else {
|
||||
flags = CProjectDescriptionManager.getInstance().calculateDescriptorFlags(newCfg, oldCfg);
|
||||
}
|
||||
|
||||
int drEventFlags = descriptionFlagsToDescriptorFlags(flags);
|
||||
|
|
Loading…
Add table
Reference in a new issue