Add workspace folders to task API

This commit is contained in:
Dirk Baeumer
2017-09-14 11:31:05 +02:00
parent 48a286f962
commit 9c6880cb32
6 changed files with 207 additions and 133 deletions

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import URI from 'vs/base/common/uri';
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import * as Objects from 'vs/base/common/objects';
@@ -326,10 +327,11 @@ namespace Tasks {
return undefined;
}
command.presentation = PresentationOptions.from(task.presentationOptions);
let source = {
let source: TaskSystem.ExtensionTaskSource = {
kind: TaskSystem.TaskSourceKind.Extension,
label: typeof task.source === 'string' ? task.source : extension.name,
extension: extension.id
extension: extension.id,
workspaceFolder: task.workspaceFolder ? { uri: task.workspaceFolder.uri as URI } : undefined
};
let label = nls.localize('task.label', '{0}: {1}', source.label, task.name);
let key = (task as types.Task).definitionKey;

View File

@@ -1218,6 +1218,7 @@ export class Task implements vscode.Task {
private _definition: vscode.TaskDefinition;
private _definitionKey: string;
private _workspaceFolder: vscode.WorkspaceFolder;
private _name: string;
private _execution: ProcessExecution | ShellExecution;
private _problemMatchers: string[];
@@ -1227,11 +1228,23 @@ export class Task implements vscode.Task {
private _group: TaskGroup;
private _presentationOptions: vscode.TaskPresentationOptions;
constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]) {
constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, workspaceFolder: vscode.WorkspaceFolder, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, arg2: string | vscode.WorkspaceFolder, arg3: any, arg4?: any, arg5?: any, arg6?: any) {
this.definition = definition;
this.name = name;
this.source = source;
this.execution = execution;
let problemMatchers: string | string[];
if (typeof arg2 === 'string') {
this.name = arg2;
this.source = arg3;
this.execution = arg4;
problemMatchers = arg5;
} else {
this.workspaceFolder = arg2;
this.name = arg3;
this.source = arg4;
this.execution = arg5;
problemMatchers = arg6;
}
if (typeof problemMatchers === 'string') {
this._problemMatchers = [problemMatchers];
this._hasDefinedMatchers = true;
@@ -1266,6 +1279,14 @@ export class Task implements vscode.Task {
return this._definitionKey;
}
get workspaceFolder(): vscode.WorkspaceFolder {
return this._workspaceFolder;
}
set workspaceFolder(value: vscode.WorkspaceFolder) {
this._workspaceFolder = value;
}
get name(): string {
return this._name;
}