Skip to content

Commit 1a644f6

Browse files
committed
microsoft#84283 Use log service
1 parent 599864a commit 1a644f6

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/vs/workbench/api/common/extHostConfiguration.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
2020
import { Barrier } from 'vs/base/common/async';
2121
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
2222
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
23+
import { ILogService } from 'vs/platform/log/common/log';
2324

2425
function lookUp(tree: any, key: string) {
2526
if (key) {
@@ -45,16 +46,19 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
4546
readonly _serviceBrand: undefined;
4647

4748
private readonly _proxy: MainThreadConfigurationShape;
49+
private readonly _logService: ILogService;
4850
private readonly _extHostWorkspace: ExtHostWorkspace;
4951
private readonly _barrier: Barrier;
5052
private _actual: ExtHostConfigProvider | null;
5153

5254
constructor(
5355
@IExtHostRpcService extHostRpc: IExtHostRpcService,
54-
@IExtHostWorkspace extHostWorkspace: IExtHostWorkspace
56+
@IExtHostWorkspace extHostWorkspace: IExtHostWorkspace,
57+
@ILogService logService: ILogService,
5558
) {
5659
this._proxy = extHostRpc.getProxy(MainContext.MainThreadConfiguration);
5760
this._extHostWorkspace = extHostWorkspace;
61+
this._logService = logService;
5862
this._barrier = new Barrier();
5963
this._actual = null;
6064
}
@@ -64,7 +68,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
6468
}
6569

6670
$initializeConfiguration(data: IConfigurationInitData): void {
67-
this._actual = new ExtHostConfigProvider(this._proxy, this._extHostWorkspace, data);
71+
this._actual = new ExtHostConfigProvider(this._proxy, this._extHostWorkspace, data, this._logService);
6872
this._barrier.open();
6973
}
7074

@@ -80,9 +84,11 @@ export class ExtHostConfigProvider {
8084
private readonly _extHostWorkspace: ExtHostWorkspace;
8185
private _configurationScopes: Map<string, ConfigurationScope | undefined>;
8286
private _configuration: Configuration;
87+
private _logService: ILogService;
8388

84-
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationInitData) {
89+
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationInitData, logService: ILogService) {
8590
this._proxy = proxy;
91+
this._logService = logService;
8692
this._extHostWorkspace = extHostWorkspace;
8793
this._configuration = ExtHostConfigProvider.parse(data);
8894
this._configurationScopes = this._toMap(data.configurationScopes);
@@ -236,13 +242,13 @@ export class ExtHostConfigProvider {
236242
const extensionIdText = extensionId ? `[${extensionId.value}] ` : '';
237243
if (ConfigurationScope.RESOURCE === scope) {
238244
if (resource === undefined) {
239-
console.warn(`${extensionIdText}Accessing a resource scoped configuration without providing a resource is not expected. To get the effective value for '${key}', provide the URI of a resource or 'null' for any resource.`);
245+
this._logService.warn(`${extensionIdText}Accessing a resource scoped configuration without providing a resource is not expected. To get the effective value for '${key}', provide the URI of a resource or 'null' for any resource.`);
240246
}
241247
return;
242248
}
243249
if (ConfigurationScope.WINDOW === scope) {
244250
if (resource) {
245-
console.warn(`${extensionIdText}Accessing a window scoped configuration for a resource is not expected. To associate '${key}' to a resource, define its scope to 'resource' in configuration contributions in 'package.json'.`);
251+
this._logService.warn(`${extensionIdText}Accessing a window scoped configuration for a resource is not expected. To associate '${key}' to a resource, define its scope to 'resource' in configuration contributions in 'package.json'.`);
246252
}
247253
return;
248254
}

src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ suite('ExtHostConfiguration', function () {
3535
if (!shape) {
3636
shape = new class extends mock<MainThreadConfigurationShape>() { };
3737
}
38-
return new ExtHostConfigProvider(shape, createExtHostWorkspace(), createConfigurationData(contents));
38+
return new ExtHostConfigProvider(shape, createExtHostWorkspace(), createConfigurationData(contents), new NullLogService());
3939
}
4040

4141
function createConfigurationData(contents: any): IConfigurationInitData {
@@ -283,7 +283,8 @@ suite('ExtHostConfiguration', function () {
283283
workspace: new ConfigurationModel({}, []),
284284
folders: [],
285285
configurationScopes: []
286-
}
286+
},
287+
new NullLogService()
287288
);
288289

289290
let actual = testObject.getConfiguration().inspect('editor.wordWrap')!;
@@ -331,7 +332,8 @@ suite('ExtHostConfiguration', function () {
331332
workspace,
332333
folders,
333334
configurationScopes: []
334-
}
335+
},
336+
new NullLogService()
335337
);
336338

337339
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
@@ -407,7 +409,8 @@ suite('ExtHostConfiguration', function () {
407409
workspace,
408410
folders,
409411
configurationScopes: []
410-
}
412+
},
413+
new NullLogService()
411414
);
412415

413416
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
@@ -607,7 +610,8 @@ suite('ExtHostConfiguration', function () {
607610
'config': false,
608611
'updatedconfig': false
609612
}
610-
})
613+
}),
614+
new NullLogService()
611615
);
612616

613617
const newConfigData = createConfigurationData({

0 commit comments

Comments
 (0)