#68658 Strict null check - ExtHostConfiguration

This commit is contained in:
Sandeep Somavarapu
2019-02-19 11:41:23 +01:00
parent 5531df2d31
commit 36e3c88fa4
8 changed files with 31 additions and 24 deletions

View File

@@ -127,8 +127,8 @@ export interface MainThreadCommentsShape extends IDisposable {
}
export interface MainThreadConfigurationShape extends IDisposable {
$updateConfigurationOption(target: ConfigurationTarget, key: string, value: any, resource: UriComponents): Promise<void>;
$removeConfigurationOption(target: ConfigurationTarget, key: string, resource: UriComponents): Promise<void>;
$updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, resource: UriComponents | undefined): Promise<void>;
$removeConfigurationOption(target: ConfigurationTarget | null, key: string, resource: UriComponents | undefined): Promise<void>;
}
export interface MainThreadDiagnosticsShape extends IDisposable {

View File

@@ -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: <T>(key: string): ConfigurationInspect<T> => {
inspect: <T>(key: string): ConfigurationInspect<T> | undefined => {
key = section ? `${section}.${key}` : key;
const config = deepClone(this._configuration.inspect<T>(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) {