First cut of #45664: Add API to query and execute tasks

This commit is contained in:
Dirk Baeumer
2018-03-15 17:42:56 +01:00
parent 055ac07ca7
commit a4cf2abe7e
4 changed files with 82 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
import { IWorkspaceSymbolProvider } from 'vs/workbench/parts/search/common/search';
import { Position as EditorPosition, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { CustomCodeAction } from 'vs/workbench/api/node/extHostLanguageFeatures';
import * as TaskSystem from 'vs/workbench/parts/tasks/common/tasks';
export class ExtHostApiCommands {
@@ -169,6 +170,11 @@ export class ExtHostApiCommands {
],
returns: 'A promise that resolves to an array of DocumentLink-instances.'
});
this._register('vscode.executeTaskProvider', this._executeTaskProvider, {
description: 'Execute task provider',
args: [],
returns: 'An array of task handles'
});
this._register('vscode.previewHtml', (uri: URI, position?: vscode.ViewColumn, label?: string, options?: any) => {
return this._commands.executeCommand('_workbench.previewHtml',
@@ -465,6 +471,22 @@ export class ExtHostApiCommands {
return this._commands.executeCommand<modes.ILink[]>('_executeLinkProvider', resource)
.then(tryMapWith(typeConverters.DocumentLink.to));
}
private _executeTaskProvider(): Thenable<vscode.TaskHandle[]> {
return this._commands.executeCommand<TaskSystem.TaskHandleTransfer[]>('_executeTaskProvider').then<vscode.TaskHandle[]>((values) => {
return values.map(handle => {
return {
id: handle.id,
label: handle.label,
workspaceFolder: {
name: handle.workspaceFolder.name,
index: handle.workspaceFolder.index,
uri: URI.revive(handle.workspaceFolder.uri)
}
};
});
});
}
}
function tryMapWith<T, R>(f: (x: T) => R) {