Use log service in exthosttask and exthosttreeviews

Part of #84283
This commit is contained in:
Alex Ross 2019-11-12 10:33:11 +01:00
parent 4312a6feb6
commit 1aa537bf59
3 changed files with 24 additions and 11 deletions

View file

@ -24,6 +24,7 @@ import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitData
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import * as Platform from 'vs/base/common/platform'; import * as Platform from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
export interface IExtHostTask extends ExtHostTaskShape { export interface IExtHostTask extends ExtHostTaskShape {
@ -374,6 +375,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
protected readonly _editorService: IExtHostDocumentsAndEditors; protected readonly _editorService: IExtHostDocumentsAndEditors;
protected readonly _configurationService: IExtHostConfiguration; protected readonly _configurationService: IExtHostConfiguration;
protected readonly _terminalService: IExtHostTerminalService; protected readonly _terminalService: IExtHostTerminalService;
protected readonly _logService: ILogService;
protected _handleCounter: number; protected _handleCounter: number;
protected _handlers: Map<number, HandlerData>; protected _handlers: Map<number, HandlerData>;
protected _taskExecutions: Map<string, TaskExecutionImpl>; protected _taskExecutions: Map<string, TaskExecutionImpl>;
@ -393,7 +395,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
@IExtHostWorkspace workspaceService: IExtHostWorkspace, @IExtHostWorkspace workspaceService: IExtHostWorkspace,
@IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors, @IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors,
@IExtHostConfiguration configurationService: IExtHostConfiguration, @IExtHostConfiguration configurationService: IExtHostConfiguration,
@IExtHostTerminalService extHostTerminalService: IExtHostTerminalService @IExtHostTerminalService extHostTerminalService: IExtHostTerminalService,
@ILogService logService: ILogService
) { ) {
this._proxy = extHostRpc.getProxy(MainContext.MainThreadTask); this._proxy = extHostRpc.getProxy(MainContext.MainThreadTask);
this._workspaceProvider = workspaceService; this._workspaceProvider = workspaceService;
@ -406,6 +409,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
this._providedCustomExecutions2 = new Map<string, types.CustomExecution>(); this._providedCustomExecutions2 = new Map<string, types.CustomExecution>();
this._notProvidedCustomExecutions = new Set<string>(); this._notProvidedCustomExecutions = new Set<string>();
this._activeCustomExecutions2 = new Map<string, types.CustomExecution>(); this._activeCustomExecutions2 = new Map<string, types.CustomExecution>();
this._logService = logService;
} }
public registerTaskProvider(extension: IExtensionDescription, type: string, provider: vscode.TaskProvider): vscode.Disposable { public registerTaskProvider(extension: IExtensionDescription, type: string, provider: vscode.TaskProvider): vscode.Disposable {
@ -661,9 +665,10 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
@IExtHostWorkspace workspaceService: IExtHostWorkspace, @IExtHostWorkspace workspaceService: IExtHostWorkspace,
@IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors, @IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors,
@IExtHostConfiguration configurationService: IExtHostConfiguration, @IExtHostConfiguration configurationService: IExtHostConfiguration,
@IExtHostTerminalService extHostTerminalService: IExtHostTerminalService @IExtHostTerminalService extHostTerminalService: IExtHostTerminalService,
@ILogService logService: ILogService
) { ) {
super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService); super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService);
if (initData.remote.isRemote && initData.remote.authority) { if (initData.remote.isRemote && initData.remote.authority) {
this.registerTaskSystem(Schemas.vscodeRemote, { this.registerTaskSystem(Schemas.vscodeRemote, {
scheme: Schemas.vscodeRemote, scheme: Schemas.vscodeRemote,
@ -696,7 +701,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
if (value) { if (value) {
for (let task of value) { for (let task of value) {
if (!task.definition || !validTypes[task.definition.type]) { if (!task.definition || !validTypes[task.definition.type]) {
console.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`); this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`);
} }
const taskDTO: tasks.TaskDTO | undefined = TaskDTO.from(task, handler.extension); const taskDTO: tasks.TaskDTO | undefined = TaskDTO.from(task, handler.extension);
@ -707,7 +712,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
// is invoked, we have to be able to map it back to our data. // is invoked, we have to be able to map it back to our data.
taskIdPromises.push(this.addCustomExecution(taskDTO, task, true)); taskIdPromises.push(this.addCustomExecution(taskDTO, task, true));
} else { } else {
console.warn('Only custom execution tasks supported.'); this._logService.warn('Only custom execution tasks supported.');
} }
} }
} }
@ -721,7 +726,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
if (CustomExecutionDTO.is(resolvedTaskDTO.execution)) { if (CustomExecutionDTO.is(resolvedTaskDTO.execution)) {
return resolvedTaskDTO; return resolvedTaskDTO;
} else { } else {
console.warn('Only custom execution tasks supported.'); this._logService.warn('Only custom execution tasks supported.');
} }
return undefined; return undefined;
} }

View file

@ -198,7 +198,13 @@ class ExtHostTreeView<T> extends Disposable {
private refreshPromise: Promise<void> = Promise.resolve(); private refreshPromise: Promise<void> = Promise.resolve();
private refreshQueue: Promise<void> = Promise.resolve(); private refreshQueue: Promise<void> = Promise.resolve();
constructor(private viewId: string, options: vscode.TreeViewOptions<T>, private proxy: MainThreadTreeViewsShape, private commands: CommandsConverter, private logService: ILogService, private extension: IExtensionDescription) { constructor(
private viewId: string, options: vscode.TreeViewOptions<T>,
private proxy: MainThreadTreeViewsShape,
private commands: CommandsConverter,
private logService: ILogService,
private extension: IExtensionDescription
) {
super(); super();
if (extension.contributes && extension.contributes.views) { if (extension.contributes && extension.contributes.views) {
for (const location in extension.contributes.views) { for (const location in extension.contributes.views) {
@ -250,7 +256,7 @@ class ExtHostTreeView<T> extends Disposable {
getChildren(parentHandle: TreeItemHandle | Root): Promise<ITreeItem[]> { getChildren(parentHandle: TreeItemHandle | Root): Promise<ITreeItem[]> {
const parentElement = parentHandle ? this.getExtensionElement(parentHandle) : undefined; const parentElement = parentHandle ? this.getExtensionElement(parentHandle) : undefined;
if (parentHandle && !parentElement) { if (parentHandle && !parentElement) {
console.error(`No tree item with id \'${parentHandle}\' found.`); this.logService.error(`No tree item with id \'${parentHandle}\' found.`);
return Promise.resolve([]); return Promise.resolve([]);
} }

View file

@ -22,6 +22,7 @@ import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService'; import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { ExtHostTaskBase, TaskHandleDTO, TaskDTO, CustomExecutionDTO, HandlerData } from 'vs/workbench/api/common/extHostTask'; import { ExtHostTaskBase, TaskHandleDTO, TaskDTO, CustomExecutionDTO, HandlerData } from 'vs/workbench/api/common/extHostTask';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import { ILogService } from 'vs/platform/log/common/log';
export class ExtHostTask extends ExtHostTaskBase { export class ExtHostTask extends ExtHostTaskBase {
private _variableResolver: ExtHostVariableResolverService | undefined; private _variableResolver: ExtHostVariableResolverService | undefined;
@ -32,9 +33,10 @@ export class ExtHostTask extends ExtHostTaskBase {
@IExtHostWorkspace workspaceService: IExtHostWorkspace, @IExtHostWorkspace workspaceService: IExtHostWorkspace,
@IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors, @IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors,
@IExtHostConfiguration configurationService: IExtHostConfiguration, @IExtHostConfiguration configurationService: IExtHostConfiguration,
@IExtHostTerminalService extHostTerminalService: IExtHostTerminalService @IExtHostTerminalService extHostTerminalService: IExtHostTerminalService,
@ILogService logService: ILogService
) { ) {
super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService); super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService);
if (initData.remote.isRemote && initData.remote.authority) { if (initData.remote.isRemote && initData.remote.authority) {
this.registerTaskSystem(Schemas.vscodeRemote, { this.registerTaskSystem(Schemas.vscodeRemote, {
scheme: Schemas.vscodeRemote, scheme: Schemas.vscodeRemote,
@ -71,7 +73,7 @@ export class ExtHostTask extends ExtHostTaskBase {
if (value) { if (value) {
for (let task of value) { for (let task of value) {
if (!task.definition || !validTypes[task.definition.type]) { if (!task.definition || !validTypes[task.definition.type]) {
console.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`); this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`);
} }
const taskDTO: tasks.TaskDTO | undefined = TaskDTO.from(task, handler.extension); const taskDTO: tasks.TaskDTO | undefined = TaskDTO.from(task, handler.extension);