Skip to content

Commit

Permalink
#26707 do not use overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Dec 16, 2019
1 parent 1a1cbf4 commit 93c91eb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
5 changes: 1 addition & 4 deletions src/vs/platform/configuration/common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,11 @@ export function compare(from: IConfigurationModel | undefined, to: IConfiguratio

export function toOverrides(raw: any, conflictReporter: (message: string) => void): IOverrides[] {
const overrides: IOverrides[] = [];
const configurationProperties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
for (const key of Object.keys(raw)) {
if (OVERRIDE_PROPERTY_PATTERN.test(key)) {
const overrideRaw: any = {};
for (const keyInOverrideRaw in raw[key]) {
if (configurationProperties[keyInOverrideRaw] && configurationProperties[keyInOverrideRaw].overridable) {
overrideRaw[keyInOverrideRaw] = raw[key][keyInOverrideRaw];
}
overrideRaw[keyInOverrideRaw] = raw[key][keyInOverrideRaw];
}
overrides.push({
identifiers: [overrideIdentifierFromKey(key).trim()],
Expand Down
10 changes: 2 additions & 8 deletions src/vs/platform/configuration/common/configurationRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,8 @@ class ConfigurationRegistry implements IConfigurationRegistry {
this.updateOverridePropertyPatternKey();
}

private validateAndRegisterProperties(configuration: IConfigurationNode, validate: boolean = true, scope: ConfigurationScope = ConfigurationScope.WINDOW, overridable: boolean = false): string[] {
private validateAndRegisterProperties(configuration: IConfigurationNode, validate: boolean = true, scope: ConfigurationScope = ConfigurationScope.WINDOW): string[] {
scope = types.isUndefinedOrNull(configuration.scope) ? scope : configuration.scope;
overridable = configuration.overridable || overridable;
let propertyKeys: string[] = [];
let properties = configuration.properties;
if (properties) {
Expand All @@ -315,11 +314,6 @@ class ConfigurationRegistry implements IConfigurationRegistry {
if (types.isUndefined(defaultValue)) {
property.default = getDefaultValue(property.type);
}
// Inherit overridable property from parent
if (overridable) {
property.overridable = true;
}

if (OVERRIDE_PROPERTY_PATTERN.test(key)) {
property.scope = undefined; // No scope for overridable properties `[${identifier}]`
} else {
Expand All @@ -342,7 +336,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
let subNodes = configuration.allOf;
if (subNodes) {
for (let node of subNodes) {
propertyKeys.push(...this.validateAndRegisterProperties(node, validate, scope, overridable));
propertyKeys.push(...this.validateAndRegisterProperties(node, validate, scope));
}
}
return propertyKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,6 @@ suite('ConfigurationModel', () => {

suite('CustomConfigurationModel', () => {

suiteSetup(() => {
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
'id': 'a',
'order': 1,
'title': 'a',
'type': 'object',
'properties': {
'a': {
'description': 'a',
'type': 'boolean',
'default': true,
'overridable': true
}
}
});
});

test('simple merge using models', () => {
let base = new ConfigurationModelParser('base');
base.parseContent(JSON.stringify({ 'a': 1, 'b': 2 }));
Expand Down Expand Up @@ -346,6 +329,19 @@ suite('CustomConfigurationModel', () => {
});

test('Test registering the same property again', () => {
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
'id': 'a',
'order': 1,
'title': 'a',
'type': 'object',
'properties': {
'a': {
'description': 'a',
'type': 'boolean',
'default': true,
}
}
});
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
'id': 'a',
'order': 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ suite('FolderSettingsModelParser', () => {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.RESOURCE,
overridable: true
},
'FolderSettingsModelParser.resourceLanguage': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.RESOURCE_LANGUAGE,
},
'FolderSettingsModelParser.application': {
'type': 'string',
Expand Down Expand Up @@ -59,12 +63,12 @@ suite('FolderSettingsModelParser', () => {
assert.deepEqual(testObject.configurationModel.contents, { 'FolderSettingsModelParser': { 'resource': 'resource' } });
});

test('parse overridable resource settings', () => {
const testObject = new ConfigurationModelParser('settings', [ConfigurationScope.RESOURCE]);
test('parse resource and resource language settings', () => {
const testObject = new ConfigurationModelParser('settings', [ConfigurationScope.RESOURCE, ConfigurationScope.RESOURCE_LANGUAGE]);

testObject.parseContent(JSON.stringify({ '[json]': { 'FolderSettingsModelParser.window': 'window', 'FolderSettingsModelParser.resource': 'resource', 'FolderSettingsModelParser.application': 'application', 'FolderSettingsModelParser.machine': 'executable' } }));
testObject.parseContent(JSON.stringify({ '[json]': { 'FolderSettingsModelParser.window': 'window', 'FolderSettingsModelParser.resource': 'resource', 'FolderSettingsModelParser.resourceLanguage': 'resourceLanguage', 'FolderSettingsModelParser.application': 'application', 'FolderSettingsModelParser.machine': 'executable' } }));

assert.deepEqual(testObject.configurationModel.overrides, [{ 'contents': { 'FolderSettingsModelParser': { 'resource': 'resource' } }, 'identifiers': ['json'], 'keys': ['FolderSettingsModelParser.resource'] }]);
assert.deepEqual(testObject.configurationModel.overrides, [{ 'contents': { 'FolderSettingsModelParser': { 'resource': 'resource', 'resourceLanguage': 'resourceLanguage' } }, 'identifiers': ['json'], 'keys': ['FolderSettingsModelParser.resource', 'FolderSettingsModelParser.resourceLanguage'] }]);
});

test('reprocess folder settings excludes application and machine setting', () => {
Expand Down

0 comments on commit 93c91eb

Please sign in to comment.