提交 8977893b 编写于 作者: S Sandeep Somavarapu

Clean up

上级 dfc46d75
......@@ -267,7 +267,7 @@ export class ModelServiceImpl implements IModelService {
public getCreationOptions(language: string): editorCommon.ITextModelCreationOptions {
let creationOptions = this._modelCreationOptionsByLanguage[language];
if (!creationOptions) {
creationOptions = ModelServiceImpl._readModelOptions(this._configurationService.getConfiguration(null, { language }));
creationOptions = ModelServiceImpl._readModelOptions(this._configurationService.getConfiguration(null, { overrideIdentifier: language }));
this._modelCreationOptionsByLanguage[language] = creationOptions;
}
return creationOptions;
......
......@@ -34,7 +34,7 @@ export class TextResourceConfigurationService extends Disposable implements ITex
const position: IPosition = Position.isIPosition(arg2) ? arg2 : null;
const section: string = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0);
const language = resource ? this.getLanguage(resource, position) : void 0;
return this.configurationService.getConfiguration<T>(section, { resource, language });
return this.configurationService.getConfiguration<T>(section, { resource, overrideIdentifier: language });
}
private getLanguage(resource: URI, position: IPosition): string {
......
......@@ -16,7 +16,7 @@ import Event from 'vs/base/common/event';
export const IConfigurationService = createDecorator<IConfigurationService>('configurationService');
export interface IConfigurationOverrides {
language?: string;
overrideIdentifier?: string;
resource?: URI;
}
......@@ -37,7 +37,7 @@ export interface IConfigurationService {
* Resolves a configuration key to its values in the different scopes
* the setting is defined.
*/
lookup<T>(key: string, overrideIdentifier?: string): IConfigurationValue<T>;
lookup<T>(key: string, overrides?: IConfigurationOverrides): IConfigurationValue<T>;
/**
* Returns the defined keys of configurations in the different scopes
......@@ -246,13 +246,14 @@ export class Configuration<T> {
return section ? configModel.getContentsFor<C>(section) : configModel.contents;
}
lookup<C>(key: string, overrideIdentifier?: string): IConfigurationValue<C> {
lookup<C>(key: string, overrides: IConfigurationOverrides = {}): IConfigurationValue<C> {
// make sure to clone the configuration so that the receiver does not tamper with the values
const workspaceConfiguration = this.getConfigurationModel(overrides);
return {
default: objects.clone(getConfigurationValue<C>(overrideIdentifier ? this._defaults.override(overrideIdentifier).contents : this._defaults.contents, key)),
user: objects.clone(getConfigurationValue<C>(overrideIdentifier ? this._user.override(overrideIdentifier).contents : this._user.contents, key)),
workspace: objects.clone(this._workspace ? getConfigurationValue<C>(overrideIdentifier ? this.folders.get(this.workspaceUri).override(overrideIdentifier).contents : this.folders.get(this.workspaceUri).contents, key) : void 0),
value: objects.clone(getConfigurationValue<C>(overrideIdentifier ? this._workspaceConfiguration.override(overrideIdentifier).contents : this._workspaceConfiguration.contents, key))
default: objects.clone(getConfigurationValue<C>(overrides.overrideIdentifier ? this._defaults.override(overrides.overrideIdentifier).contents : this._defaults.contents, key)),
user: objects.clone(getConfigurationValue<C>(overrides.overrideIdentifier ? this._user.override(overrides.overrideIdentifier).contents : this._user.contents, key)),
workspace: objects.clone(this._workspace ? getConfigurationValue<C>(overrides.overrideIdentifier ? this.folders.get(this.workspaceUri).override(overrides.overrideIdentifier).contents : this.folders.get(this.workspaceUri).contents, key) : void 0),
value: objects.clone(getConfigurationValue<C>(workspaceConfiguration.contents, key))
};
}
......@@ -302,7 +303,7 @@ export class Configuration<T> {
private getConfigurationModel<C>(overrides: IConfigurationOverrides): ConfigurationModel<any> {
let configurationModel = this.getConfigurationForResource(overrides);
return overrides.language ? configurationModel.override<T>(overrides.language) : configurationModel;
return overrides.overrideIdentifier ? configurationModel.override<T>(overrides.overrideIdentifier) : configurationModel;
}
private getConfigurationForResource({ resource }: IConfigurationOverrides): ConfigurationModel<any> {
......
......@@ -71,8 +71,8 @@ export class ConfigurationService<T> extends Disposable implements IConfiguratio
return this.configuration().getValue<C>(section, options);
}
public lookup<C>(key: string, overrideIdentifier?: string): IConfigurationValue<C> {
return this.configuration().lookup<C>(key, overrideIdentifier);
public lookup<C>(key: string, options?: IConfigurationOverrides): IConfigurationValue<C> {
return this.configuration().lookup<C>(key, options);
}
public keys(): IConfigurationKeys {
......
......@@ -419,7 +419,7 @@ export class WalkThroughPart extends BaseEditor {
}
private getEditorOptions(language: string): IEditorOptions {
const config = this.configurationService.getConfiguration<IEditorOptions>('editor', { language });
const config = this.configurationService.getConfiguration<IEditorOptions>('editor', { overrideIdentifier: language });
return {
...isObject(config) ? config : Object.create(null),
scrollBeyondLastLine: false,
......
......@@ -270,8 +270,8 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
return this._configuration.getValue<C>(section, overrides);
}
public lookup<C>(key: string, overrideIdentifier?: string): IConfigurationValue<C> {
return this._configuration.lookup<C>(key, overrideIdentifier);
public lookup<C>(key: string, overrides?: IConfigurationOverrides): IConfigurationValue<C> {
return this._configuration.lookup<C>(key, overrides);
}
public keys(): IConfigurationKeys {
......
......@@ -215,7 +215,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private resolveModelReference(): TPromise<IReference<ITextEditorModel>> {
return this.fileService.existsFile(this.resource)
.then(exists => {
const EOL = this.configurationService.getConfiguration('files', { language: 'json' })['eol'];
const EOL = this.configurationService.getConfiguration('files', { overrideIdentifier: 'json' })['eol'];
const result = exists ? TPromise.as(null) : this.fileService.updateContent(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });
return result.then(() => this.textModelResolverService.createModelReference(this.resource));
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册