diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index c8517858e66..d2622ab91ea 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -418,6 +418,7 @@ "./vs/workbench/api/electron-browser/mainThreadWorkspace.ts", "./vs/workbench/api/node/extHost.protocol.ts", "./vs/workbench/api/node/extHostClipboard.ts", + "vs/workbench/api/node/extHostConfiguration.ts", "./vs/workbench/api/node/extHostDecorations.ts", "./vs/workbench/api/node/extHostDialogs.ts", "./vs/workbench/api/node/extHostDocumentData.ts", diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 476a17010df..7aba5deca47 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -409,7 +409,7 @@ export class SimpleConfigurationService implements IConfigurationService { getValue(arg1?: any, arg2?: any): any { const section = typeof arg1 === 'string' ? arg1 : undefined; const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {}; - return this.configuration().getValue(section, overrides, null); + return this.configuration().getValue(section, overrides, undefined); } public updateValue(key: string, value: any, arg3?: any, arg4?: any): Promise { @@ -424,11 +424,11 @@ export class SimpleConfigurationService implements IConfigurationService { workspaceFolder?: C value: C, } { - return this.configuration().inspect(key, options, null); + return this.configuration().inspect(key, options, undefined); } public keys() { - return this.configuration().keys(null); + return this.configuration().keys(undefined); } public reloadConfiguration(): Promise { diff --git a/src/vs/platform/configuration/common/configurationModels.ts b/src/vs/platform/configuration/common/configurationModels.ts index 2a3e33868f0..a3e0810edd8 100644 --- a/src/vs/platform/configuration/common/configurationModels.ts +++ b/src/vs/platform/configuration/common/configurationModels.ts @@ -291,7 +291,7 @@ export class Configuration { private _freeze: boolean = true) { } - getValue(section: string | undefined, overrides: IConfigurationOverrides, workspace: Workspace | null): any { + getValue(section: string | undefined, overrides: IConfigurationOverrides, workspace: Workspace | undefined): any { const consolidateConfigurationModel = this.getConsolidateConfigurationModel(overrides, workspace); return consolidateConfigurationModel.getValue(section); } @@ -319,7 +319,7 @@ export class Configuration { } } - inspect(key: string, overrides: IConfigurationOverrides, workspace: Workspace | null): { + inspect(key: string, overrides: IConfigurationOverrides, workspace: Workspace | undefined): { default: C, user: C, workspace?: C, @@ -340,7 +340,7 @@ export class Configuration { }; } - keys(workspace: Workspace | null): { + keys(workspace: Workspace | undefined): { default: string[]; user: string[]; workspace: string[]; @@ -399,12 +399,12 @@ export class Configuration { return this._folderConfigurations; } - private getConsolidateConfigurationModel(overrides: IConfigurationOverrides, workspace: Workspace | null): ConfigurationModel { + private getConsolidateConfigurationModel(overrides: IConfigurationOverrides, workspace: Workspace | undefined): ConfigurationModel { let configurationModel = this.getConsolidatedConfigurationModelForResource(overrides, workspace); return overrides.overrideIdentifier ? configurationModel.override(overrides.overrideIdentifier) : configurationModel; } - private getConsolidatedConfigurationModelForResource({ resource }: IConfigurationOverrides, workspace: Workspace | null): ConfigurationModel { + private getConsolidatedConfigurationModelForResource({ resource }: IConfigurationOverrides, workspace: Workspace | undefined): ConfigurationModel { let consolidateConfiguration = this.getWorkspaceConsolidatedConfiguration(); if (workspace && resource) { @@ -449,7 +449,7 @@ export class Configuration { return folderConsolidatedConfiguration; } - private getFolderConfigurationModelForResource(resource: URI | null | undefined, workspace: Workspace | null): ConfigurationModel | null { + private getFolderConfigurationModelForResource(resource: URI | null | undefined, workspace: Workspace | undefined): ConfigurationModel | null { if (workspace && resource) { const root = workspace.getFolder(resource); if (root) { diff --git a/src/vs/platform/configuration/node/configurationService.ts b/src/vs/platform/configuration/node/configurationService.ts index 398b3dafec2..c3d82139cb5 100644 --- a/src/vs/platform/configuration/node/configurationService.ts +++ b/src/vs/platform/configuration/node/configurationService.ts @@ -55,7 +55,7 @@ export class ConfigurationService extends Disposable implements IConfigurationSe getValue(arg1?: any, arg2?: any): any { const section = typeof arg1 === 'string' ? arg1 : undefined; const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {}; - return this.configuration.getValue(section, overrides, null); + return this.configuration.getValue(section, overrides, undefined); } updateValue(key: string, value: any): Promise; @@ -73,7 +73,7 @@ export class ConfigurationService extends Disposable implements IConfigurationSe workspaceFolder?: T value: T } { - return this.configuration.inspect(key, {}, null); + return this.configuration.inspect(key, {}, undefined); } keys(): { @@ -82,7 +82,7 @@ export class ConfigurationService extends Disposable implements IConfigurationSe workspace: string[]; workspaceFolder: string[]; } { - return this.configuration.keys(null); + return this.configuration.keys(undefined); } reloadConfiguration(folder?: IWorkspaceFolder): Promise { diff --git a/src/vs/workbench/api/electron-browser/mainThreadConfiguration.ts b/src/vs/workbench/api/electron-browser/mainThreadConfiguration.ts index a219ce3dca3..495b36864ad 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadConfiguration.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadConfiguration.ts @@ -46,12 +46,12 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape { this._configurationListener.dispose(); } - $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, resourceUriComponenets: UriComponents | null): Promise { + $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, resourceUriComponenets: UriComponents | undefined): Promise { const resource = resourceUriComponenets ? URI.revive(resourceUriComponenets) : null; return this.writeConfiguration(target, key, value, resource); } - $removeConfigurationOption(target: ConfigurationTarget | null, key: string, resourceUriComponenets: UriComponents | null): Promise { + $removeConfigurationOption(target: ConfigurationTarget | null, key: string, resourceUriComponenets: UriComponents | undefined): Promise { const resource = resourceUriComponenets ? URI.revive(resourceUriComponenets) : null; return this.writeConfiguration(target, key, undefined, resource); } diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index f2efe2c5adc..2dac214ec89 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -127,8 +127,8 @@ export interface MainThreadCommentsShape extends IDisposable { } export interface MainThreadConfigurationShape extends IDisposable { - $updateConfigurationOption(target: ConfigurationTarget, key: string, value: any, resource: UriComponents): Promise; - $removeConfigurationOption(target: ConfigurationTarget, key: string, resource: UriComponents): Promise; + $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, resource: UriComponents | undefined): Promise; + $removeConfigurationOption(target: ConfigurationTarget | null, key: string, resource: UriComponents | undefined): Promise; } export interface MainThreadDiagnosticsShape extends IDisposable { diff --git a/src/vs/workbench/api/node/extHostConfiguration.ts b/src/vs/workbench/api/node/extHostConfiguration.ts index 88604967795..be43259afaf 100644 --- a/src/vs/workbench/api/node/extHostConfiguration.ts +++ b/src/vs/workbench/api/node/extHostConfiguration.ts @@ -64,7 +64,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape { } $acceptConfigurationChanged(data: IConfigurationInitData, eventData: IWorkspaceConfigurationChangeEventData): void { - this._actual.$acceptConfigurationChanged(data, eventData); + this.getConfigProvider().then(provider => provider.$acceptConfigurationChanged(data, eventData)); } } @@ -129,7 +129,7 @@ export class ExtHostConfigProvider { } else { let clonedConfig = undefined; const cloneOnWriteProxy = (target: any, accessor: string): any => { - let clonedTarget = undefined; + let clonedTarget: any | undefined = undefined; const cloneTarget = () => { clonedConfig = clonedConfig ? clonedConfig : deepClone(config); clonedTarget = clonedTarget ? clonedTarget : lookUp(clonedConfig, accessor); @@ -153,17 +153,23 @@ export class ExtHostConfigProvider { }, set: (_target: any, property: string, value: any) => { cloneTarget(); - clonedTarget[property] = value; + if (clonedTarget) { + clonedTarget[property] = value; + } return true; }, deleteProperty: (_target: any, property: string) => { cloneTarget(); - delete clonedTarget[property]; + if (clonedTarget) { + delete clonedTarget[property]; + } return true; }, defineProperty: (_target: any, property: string, descriptor: any) => { cloneTarget(); - Object.defineProperty(clonedTarget, property, descriptor); + if (clonedTarget) { + Object.defineProperty(clonedTarget, property, descriptor); + } return true; } }) : target; @@ -181,7 +187,7 @@ export class ExtHostConfigProvider { return this._proxy.$removeConfigurationOption(target, key, resource); } }, - inspect: (key: string): ConfigurationInspect => { + inspect: (key: string): ConfigurationInspect | undefined => { key = section ? `${section}.${key}` : key; const config = deepClone(this._configuration.inspect(key, { resource }, this._extHostWorkspace.workspace)); if (config) { @@ -220,7 +226,7 @@ export class ExtHostConfigProvider { return readonlyProxy(result); } - private _validateConfigurationAccess(key: string, resource: URI | undefined, extensionId: ExtensionIdentifier): void { + private _validateConfigurationAccess(key: string, resource: URI | undefined, extensionId?: ExtensionIdentifier): void { const scope = OVERRIDE_PROPERTY_PATTERN.test(key) ? ConfigurationScope.RESOURCE : this._configurationScopes[key]; const extensionIdText = extensionId ? `[${extensionId.value}] ` : ''; if (ConfigurationScope.RESOURCE === scope) { diff --git a/src/vs/workbench/services/configuration/common/configurationModels.ts b/src/vs/workbench/services/configuration/common/configurationModels.ts index a943fab87fe..92a3834f1d9 100644 --- a/src/vs/workbench/services/configuration/common/configurationModels.ts +++ b/src/vs/workbench/services/configuration/common/configurationModels.ts @@ -256,7 +256,7 @@ export class AllKeysConfigurationChangeEvent extends AbstractConfigurationChange export class WorkspaceConfigurationChangeEvent implements IConfigurationChangeEvent { - constructor(private configurationChangeEvent: IConfigurationChangeEvent, private workspace: Workspace) { } + constructor(private configurationChangeEvent: IConfigurationChangeEvent, private workspace: Workspace | undefined) { } get changedConfiguration(): IConfigurationModel { return this.configurationChangeEvent.changedConfiguration;