1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Add a new event kind to CProjectDescriptionEvent for adding

Language Settings Providers to a configuration
This commit is contained in:
Andrew Gvozdev 2011-09-23 17:53:39 -04:00
parent c410b4b521
commit 6a09056f15
4 changed files with 60 additions and 1 deletions

View file

@ -19,6 +19,8 @@ import java.util.Map;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializable;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
@ -994,5 +996,52 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
ICProjectDescription newSetting = (ICProjectDescription)delta.getNewSetting();
assertEquals(cfgDescription1.getName(), newSetting.getDefaultSettingConfiguration().getName());
}
public void testDelta_LANGUAGE_SETTINGS_PROVIDERS() throws Exception {
String projName = getName();
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
initListener(projName);
IProject project = ResourceHelper.createCDTProjectWithConfig(projName);
// Get writable project description and its configuration
ICProjectDescription prjDescription = mngr.getProjectDescription(project, true);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0];
assertNotNull(cfgDescription);
List<ILanguageSettingsProvider> originalProviders = cfgDescription.getLanguageSettingProviders();
// Modification LANGUAGE_SETTINGS_PROVIDERS
ILanguageSettingsProvider provider = new LanguageSettingsSerializable("id", "name");
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
cfgDescription.setLanguageSettingProviders(providers);
// Write project description
listener.clearNotified();
mngr.setProjectDescription(project, prjDescription);
assertEquals(true, listener.isNotified());
// Analyze delta
ICDescriptionDelta rootDelta = listener.getDelta();
assertNotNull(rootDelta);
List<ICDescriptionDelta> deltas = findDeltas(rootDelta, ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS);
assertEquals(1, deltas.size());
ICDescriptionDelta delta = deltas.get(0);
assertNotNull(delta);
assertEquals(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS, delta.getChangeFlags());
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
List<ILanguageSettingsProvider> oldProviders = oldSetting.getLanguageSettingProviders();
assertEquals(originalProviders, oldProviders);
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
List<ILanguageSettingsProvider> newProviders = newSetting.getLanguageSettingProviders();
assertEquals(providers, newProviders);
}
}

View file

@ -49,7 +49,10 @@ public interface ICDescriptionDelta {
// int PATH = 1 << 3;
int LANGUAGE_ID = 1 << 4;
int SOURCE_CONTENT_TYPE = 1 << 5;
int SOURCE_ENTENSIONS = 1 << 6;
int SOURCE_EXTENSIONS = 1 << 6;
/** @deprecated Use ICDescriptionDelta.SOURCE_EXTENSIONS */
@Deprecated
int SOURCE_ENTENSIONS = SOURCE_EXTENSIONS;
// int HEADER_CONTENT_TYPE = 1 << 7;
// int HEADER_ENTENSIONS = 1 << 8;
int SETTING_ENTRIES = 1 << 9;
@ -66,6 +69,7 @@ public interface ICDescriptionDelta {
int OWNER = 1 << 20;
int INDEX_CFG = 1 << 21;
int SETTING_CFG = INDEX_CFG;
int LANGUAGE_SETTINGS_PROVIDERS = 1 << 22;
/**
* specifies that the project "isCdtProjectCreating" state was set to false

View file

@ -171,6 +171,7 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta {
if ((flags&EXT_REF)!=0) str.append("EXT_REF|");
if ((flags&OWNER)!=0) str.append("OWNER|");
if ((flags&INDEX_CFG)!=0) str.append("INDEX_CFG|");
if ((flags&LANGUAGE_SETTINGS_PROVIDERS)!=0) str.append("LANGUAGE_SETTINGS_PROVIDERS|");
if (str.charAt(str.length()-1)=='|') str.deleteCharAt(str.length()-1);
return str.toString();

View file

@ -50,6 +50,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
@ -1556,6 +1557,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
CCorePlugin.log(e);
}
List<ILanguageSettingsProvider> newLSProviders = newCfg.getLanguageSettingProviders();
List<ILanguageSettingsProvider> oldLSProviders = oldCfg.getLanguageSettingProviders();
if(!newLSProviders.equals(oldLSProviders))
delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS);
calculateCfgExtSettingsDelta(delta);