more 💄

This commit is contained in:
Johannes Rieken
2017-06-21 16:09:38 +02:00
parent 92b2d10871
commit f3ae32fc37
3 changed files with 36 additions and 41 deletions

View File

@@ -25,41 +25,32 @@ function lookUp(tree: any, key: string) {
export class ExtHostConfiguration extends ExtHostConfigurationShape {
private _onDidChangeConfiguration = new Emitter<void>();
private _proxy: MainThreadConfigurationShape;
private _data: IConfigurationData<any>;
private _extHostWorkspace: ExtHostWorkspace;
private readonly _onDidChangeConfiguration = new Emitter<void>();
private readonly _proxy: MainThreadConfigurationShape;
private readonly _extHostWorkspace: ExtHostWorkspace;
private _configuration: Configuration<any>;
constructor(proxy: MainThreadConfigurationShape, data: IConfigurationData<any>, extWorkspace: ExtHostWorkspace) {
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationData<any>) {
super();
this._proxy = proxy;
this._data = data;
this._extHostWorkspace = extWorkspace;
this._extHostWorkspace = extHostWorkspace;
this._configuration = Configuration.parse(data, extHostWorkspace.workspace);
}
get onDidChangeConfiguration(): Event<void> {
return this._onDidChangeConfiguration && this._onDidChangeConfiguration.event;
}
public $acceptConfigurationChanged(data: IConfigurationData<any>) {
this._configuration = null;
this._data = data;
$acceptConfigurationChanged(data: IConfigurationData<any>) {
this._configuration = Configuration.parse(data, this._extHostWorkspace.workspace);
this._onDidChangeConfiguration.fire(undefined);
}
private get configuration(): Configuration<any> {
if (!this._configuration) {
this._configuration = Configuration.parse(this._data, this._extHostWorkspace.workspace);
}
return this._configuration;
}
public getConfiguration(section?: string): WorkspaceConfiguration {
getConfiguration(section?: string): WorkspaceConfiguration {
const config = section
? lookUp(this.configuration.getValue(), section)
: this.configuration.getValue();
? lookUp(this._configuration.getValue(), section)
: this._configuration.getValue();
const result: WorkspaceConfiguration = {
has(key: string): boolean {
@@ -83,7 +74,7 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
},
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T } => {
key = section ? `${section}.${key}` : key;
const config = this.configuration.values()[key];
const config = this._configuration.values()[key];
if (config) {
return {
key,