mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 06:17:18 +00:00
Implements #27399: Separate the task provider name from the task name in the task API
This commit is contained in:
parent
7c3f873bed
commit
e58c2abb97
|
@ -139,8 +139,8 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
|
|||
if (matches && matches.length === 2) {
|
||||
let taskName = matches[1];
|
||||
let task = taskName.indexOf(' ') === -1
|
||||
? new vscode.ShellTask(`grunt: ${taskName}`, `${command} ${taskName}`)
|
||||
: new vscode.ShellTask(`grunt: ${taskName}`, `${command} "${taskName}"`);
|
||||
? new vscode.ShellTask(taskName, `${command} ${taskName}`)
|
||||
: new vscode.ShellTask(taskName, `${command} "${taskName}"`);
|
||||
task.identifier = `grunt.${taskName}`;
|
||||
result.push(task);
|
||||
let lowerCaseTaskName = taskName.toLowerCase();
|
||||
|
|
|
@ -114,7 +114,7 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
|
|||
if (line.length === 0) {
|
||||
continue;
|
||||
}
|
||||
let task = new vscode.ShellTask(`gulp: ${line}`, `${gulpCommand} ${line}`);
|
||||
let task = new vscode.ShellTask(line, `${gulpCommand} ${line}`);
|
||||
task.identifier = `gulp.${line}`;
|
||||
result.push(task);
|
||||
let lowerCaseLine = line.toLowerCase();
|
||||
|
|
|
@ -118,7 +118,7 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
|
|||
let matches = regExp.exec(line);
|
||||
if (matches && matches.length === 2) {
|
||||
let taskName = matches[1];
|
||||
let task = new vscode.ShellTask(`jake: ${taskName}`, `${jakeCommand} ${taskName}`);
|
||||
let task = new vscode.ShellTask(taskName, `${jakeCommand} ${taskName}`);
|
||||
task.identifier = `jake.${taskName}`;
|
||||
result.push(task);
|
||||
let lowerCaseLine = line.toLowerCase();
|
||||
|
|
|
@ -81,7 +81,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
|||
|
||||
const result: vscode.Task[] = [];
|
||||
Object.keys(json.scripts).forEach(each => {
|
||||
const task = new vscode.ShellTask(`npm: run ${each}`, `npm run ${each}`);
|
||||
const task = new vscode.ShellTask(`run ${each}`, `npm run ${each}`);
|
||||
const lowerCaseTaskName = each.toLowerCase();
|
||||
if (lowerCaseTaskName === 'build') {
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
|
@ -91,7 +91,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
|||
result.push(task);
|
||||
});
|
||||
// add some 'well known' npm tasks
|
||||
result.push(new vscode.ShellTask(`npm: install`, `npm install`));
|
||||
result.push(new vscode.ShellTask(`install`, `npm install`));
|
||||
return Promise.resolve(result);
|
||||
} catch (e) {
|
||||
return Promise.resolve(emptyTasks);
|
||||
|
|
|
@ -48,7 +48,8 @@ class TscTaskProvider implements vscode.TaskProvider {
|
|||
|
||||
return projects.map(configFile => {
|
||||
const configFileName = path.relative(rootPath, configFile);
|
||||
const buildTask = new vscode.ShellTask(`tsc: build ${configFileName}`, `${command} -p "${configFile}"`, '$tsc');
|
||||
const buildTask = new vscode.ShellTask(`build ${configFileName}`, `${command} -p "${configFile}"`, '$tsc');
|
||||
buildTask.source = 'tsc';
|
||||
buildTask.group = vscode.TaskGroup.Build;
|
||||
return buildTask;
|
||||
});
|
||||
|
|
33
src/vs/vscode.d.ts
vendored
33
src/vs/vscode.d.ts
vendored
|
@ -3580,11 +3580,6 @@ declare module 'vscode' {
|
|||
export const Test: 'test';
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported task groups.
|
||||
*/
|
||||
export type TaskGroup = 'clean' | 'build' | 'rebuildAll' | 'test';
|
||||
|
||||
/**
|
||||
* The ProblemMatchers type definition.
|
||||
*/
|
||||
|
@ -3652,10 +3647,18 @@ declare module 'vscode' {
|
|||
args: string[];
|
||||
|
||||
/**
|
||||
* The task group this tasks belongs to. Defaults to undefined meaning
|
||||
* that the task doesn't belong to any special group.
|
||||
* A human-readable string describing the source of this
|
||||
* shell task, e.g. 'gulp' or 'npm'.
|
||||
*/
|
||||
group?: TaskGroup;
|
||||
source: string | undefined;
|
||||
|
||||
/**
|
||||
* The task group this tasks belongs to. See TaskGroup
|
||||
* for a predefined set of available groups.
|
||||
* Defaults to undefined meaning that the task doesn't
|
||||
* belong to any special group.
|
||||
*/
|
||||
group: string | undefined;
|
||||
|
||||
/**
|
||||
* The process options used when the process is executed.
|
||||
|
@ -3772,10 +3775,18 @@ declare module 'vscode' {
|
|||
readonly commandLine: string;
|
||||
|
||||
/**
|
||||
* The task group this tasks belongs to. Defaults to undefined meaning
|
||||
* that the task doesn't belong to any special group.
|
||||
* A human-readable string describing the source of this
|
||||
* shell task, e.g. 'gulp' or 'npm'.
|
||||
*/
|
||||
group?: TaskGroup;
|
||||
source: string | undefined;
|
||||
|
||||
/**
|
||||
* The task group this tasks belongs to. See TaskGroup
|
||||
* for a predefined set of available groups.
|
||||
* Defaults to undefined meaning that the task doesn't
|
||||
* belong to any special group.
|
||||
*/
|
||||
group: string | undefined;
|
||||
|
||||
/**
|
||||
* The shell options used when the shell is executed. Defaults to an
|
||||
|
|
|
@ -310,7 +310,11 @@ namespace Tasks {
|
|||
}
|
||||
let result: TaskSystem.Task = {
|
||||
_id: uuidMap.getUUID(task.identifier),
|
||||
_source: { kind: TaskSystem.TaskSourceKind.Extension, detail: extension.id },
|
||||
_source: {
|
||||
kind: TaskSystem.TaskSourceKind.Extension,
|
||||
label: typeof task.source === 'string' ? task.source : extension.name,
|
||||
detail: extension.id
|
||||
},
|
||||
name: task.name,
|
||||
identifier: task.identifier,
|
||||
group: types.TaskGroup.is(task.group) ? task.group : undefined,
|
||||
|
|
|
@ -1021,6 +1021,8 @@ export class BaseTask {
|
|||
private _problemMatchers: string[];
|
||||
private _identifier: string;
|
||||
private _isBackground: boolean;
|
||||
private _source: string;
|
||||
private _group: string;
|
||||
private _terminal: vscode.TerminalBehaviour;
|
||||
|
||||
constructor(name: string, problemMatchers: string[]) {
|
||||
|
@ -1063,6 +1065,36 @@ export class BaseTask {
|
|||
this._isBackground = value;
|
||||
}
|
||||
|
||||
get source(): string {
|
||||
return this._source;
|
||||
}
|
||||
|
||||
set source(value: string) {
|
||||
if (value === void 0 || value === null) {
|
||||
this._source = undefined;
|
||||
return;
|
||||
}
|
||||
if (typeof value !== 'string' || value.length === 0) {
|
||||
throw illegalArgument('source must be a string of length > 0');
|
||||
}
|
||||
this._source = value;
|
||||
}
|
||||
|
||||
get group(): string {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
set group(value: string) {
|
||||
if (value === void 0 || value === null) {
|
||||
this._group = undefined;
|
||||
return;
|
||||
}
|
||||
if (typeof value !== 'string' || value.length === 0) {
|
||||
throw illegalArgument('group must be a string of length > 0');
|
||||
}
|
||||
this._group = value;
|
||||
}
|
||||
|
||||
get terminal(): vscode.TerminalBehaviour {
|
||||
return this._terminal;
|
||||
}
|
||||
|
@ -1122,7 +1154,7 @@ export namespace TaskGroup {
|
|||
*/
|
||||
export const Test: 'test' = 'test';
|
||||
|
||||
export function is(value: string): value is vscode.TaskGroup {
|
||||
export function is(value: string): value is string {
|
||||
return value === Clean || value === Build || value === RebuildAll || value === Test;
|
||||
}
|
||||
}
|
||||
|
@ -1131,7 +1163,6 @@ export class ProcessTask extends BaseTask {
|
|||
|
||||
private _process: string;
|
||||
private _args: string[];
|
||||
private _group: vscode.TaskGroup;
|
||||
private _options: vscode.ProcessOptions;
|
||||
|
||||
constructor(name: string, process: string, args?: string[], problemMatchers?: vscode.ProblemMatchers);
|
||||
|
@ -1183,17 +1214,6 @@ export class ProcessTask extends BaseTask {
|
|||
this._args = value;
|
||||
}
|
||||
|
||||
get group(): vscode.TaskGroup {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
set group(value: vscode.TaskGroup) {
|
||||
if (!TaskGroup.is(value)) {
|
||||
throw illegalArgument('group');
|
||||
}
|
||||
this._group = value;
|
||||
}
|
||||
|
||||
get options(): vscode.ProcessOptions {
|
||||
return this._options;
|
||||
}
|
||||
|
@ -1209,7 +1229,6 @@ export class ProcessTask extends BaseTask {
|
|||
export class ShellTask extends BaseTask implements vscode.ShellTask {
|
||||
|
||||
private _commandLine: string;
|
||||
private _group: vscode.TaskGroup;
|
||||
private _options: vscode.ShellOptions;
|
||||
|
||||
constructor(name: string, commandLine: string, problemMatchers?: vscode.ProblemMatchers);
|
||||
|
@ -1240,17 +1259,6 @@ export class ShellTask extends BaseTask implements vscode.ShellTask {
|
|||
return this._commandLine;
|
||||
}
|
||||
|
||||
get group(): vscode.TaskGroup {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
set group(value: vscode.TaskGroup) {
|
||||
if (!TaskGroup.is(value)) {
|
||||
throw illegalArgument('group');
|
||||
}
|
||||
this._group = value;
|
||||
}
|
||||
|
||||
get options(): vscode.ShellOptions {
|
||||
return this._options;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,19 @@ import { ActionBarContributor, ContributableActionProvider } from 'vs/workbench/
|
|||
|
||||
export class TaskEntry extends Model.QuickOpenEntry {
|
||||
|
||||
private _label: string;
|
||||
|
||||
constructor(protected taskService: ITaskService, protected _task: Task, highlights: Model.IHighlight[] = []) {
|
||||
super(highlights);
|
||||
this._task = _task;
|
||||
if (_task._source.kind === TaskSourceKind.Extension) {
|
||||
this._label = nls.localize('taskEntry.label', '{0}: {1}', _task._source.label, _task.name);
|
||||
} else {
|
||||
this._label = _task.name;
|
||||
}
|
||||
}
|
||||
|
||||
public getLabel(): string {
|
||||
return this._task.name;
|
||||
return this._label;
|
||||
}
|
||||
|
||||
public getAriaLabel(): string {
|
||||
|
@ -76,6 +82,12 @@ export abstract class QuickOpenHandler extends Quickopen.QuickOpenHandler {
|
|||
let aKind = a._source.kind;
|
||||
let bKind = b._source.kind;
|
||||
if (aKind === bKind) {
|
||||
if (aKind === TaskSourceKind.Extension) {
|
||||
let compare = a._source.label.localeCompare(b._source.label);
|
||||
if (compare !== 0) {
|
||||
return compare;
|
||||
}
|
||||
}
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
if (aKind === TaskSourceKind.Workspace) {
|
||||
|
|
|
@ -764,6 +764,7 @@ namespace TaskDescription {
|
|||
|
||||
export let source: Tasks.TaskSource = {
|
||||
kind: Tasks.TaskSourceKind.Workspace,
|
||||
label: 'Workspace',
|
||||
detail: '.settins\tasks.json'
|
||||
};
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ export namespace TaskGroup {
|
|||
|
||||
export const Test: 'test' = 'test';
|
||||
|
||||
export function is(value: string): value is TaskGroup {
|
||||
export function is(value: string): value is string {
|
||||
return value === Clean || value === Build || value === RebuildAll || value === Test;
|
||||
}
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ export enum TaskSourceKind {
|
|||
|
||||
export interface TaskSource {
|
||||
kind: TaskSourceKind;
|
||||
label: string;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
|
@ -199,7 +200,7 @@ export interface Task {
|
|||
/**
|
||||
* the task's group;
|
||||
*/
|
||||
group?: TaskGroup;
|
||||
group?: string;
|
||||
|
||||
/**
|
||||
* The command configuration
|
||||
|
|
|
@ -780,7 +780,7 @@ class TaskService extends EventEmitter implements ITaskService {
|
|||
let id: string = UUID.generateUuid();
|
||||
let task: Task = {
|
||||
_id: id,
|
||||
_source: { kind: TaskSourceKind.Generic },
|
||||
_source: { kind: TaskSourceKind.Generic, label: 'generic' },
|
||||
name: id,
|
||||
identifier: id,
|
||||
dependsOn: extensionTasks.map(task => task._id),
|
||||
|
|
|
@ -144,7 +144,7 @@ class TaskBuilder {
|
|||
this.commandBuilder = new CommandConfigurationBuilder(this, command);
|
||||
this.result = {
|
||||
_id: name,
|
||||
_source: { kind: Tasks.TaskSourceKind.Workspace },
|
||||
_source: { kind: Tasks.TaskSourceKind.Workspace, label: 'workspace' },
|
||||
identifier: name,
|
||||
name: name,
|
||||
command: this.commandBuilder.result,
|
||||
|
|
Loading…
Reference in a new issue