mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +02:00
fixed backdoor access to list of providers inside configuration
This commit is contained in:
parent
57afab135d
commit
c410b4b521
2 changed files with 35 additions and 9 deletions
|
@ -184,6 +184,32 @@ public class LanguageSettingsPersistenceProjectTests extends TestCase {
|
||||||
// test passes if no exception was thrown
|
// test passes if no exception was thrown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void testProjectDescription_PreventBackDoorAccess() throws Exception {
|
||||||
|
// create a project
|
||||||
|
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
|
||||||
|
|
||||||
|
// get project descriptions
|
||||||
|
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project);
|
||||||
|
assertNotNull(writableProjDescription);
|
||||||
|
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations();
|
||||||
|
assertEquals(1, cfgDescriptions.length);
|
||||||
|
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
|
||||||
|
List<ILanguageSettingsProvider> originalProviders = cfgDescription.getLanguageSettingProviders();
|
||||||
|
int originalSize = originalProviders.size();
|
||||||
|
|
||||||
|
// create new provider list
|
||||||
|
LanguageSettingsSerializable mockProvider = new MockEditableProvider(PROVIDER_0, PROVIDER_NAME_0);
|
||||||
|
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(originalProviders);
|
||||||
|
providers.add(mockProvider);
|
||||||
|
assertTrue(originalSize != providers.size());
|
||||||
|
|
||||||
|
// changing providers shouldn't affect the original list
|
||||||
|
cfgDescription.setLanguageSettingProviders(providers);
|
||||||
|
assertEquals(originalSize, originalProviders.size());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public void testProjectDescription_ReadWriteProviders() throws Exception {
|
public void testProjectDescription_ReadWriteProviders() throws Exception {
|
||||||
|
|
|
@ -989,7 +989,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
||||||
* @param providers - list of providers to keep in the specs.
|
* @param providers - list of providers to keep in the specs.
|
||||||
*/
|
*/
|
||||||
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
|
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
|
||||||
fLanguageSettingsProviders.clear();
|
fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0);
|
||||||
Set<String> ids = new HashSet<String>();
|
Set<String> ids = new HashSet<String>();
|
||||||
for (ILanguageSettingsProvider provider : providers) {
|
for (ILanguageSettingsProvider provider : providers) {
|
||||||
String id = provider.getId();
|
String id = provider.getId();
|
||||||
|
|
Loading…
Add table
Reference in a new issue