@theia/task 1.53.0-next.4 → 1.53.0-next.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +193 -193
  2. package/lib/browser/task-schema-updater.js +1 -1
  3. package/package.json +13 -13
  4. package/src/browser/index.ts +22 -22
  5. package/src/browser/process/process-task-contribution.ts +31 -31
  6. package/src/browser/process/process-task-frontend-module.ts +27 -27
  7. package/src/browser/process/process-task-resolver.ts +89 -89
  8. package/src/browser/provided-task-configurations.spec.ts +46 -46
  9. package/src/browser/provided-task-configurations.ts +213 -213
  10. package/src/browser/quick-open-task.ts +831 -831
  11. package/src/browser/style/index.css +19 -19
  12. package/src/browser/task-configuration-manager.ts +256 -256
  13. package/src/browser/task-configuration-model.ts +101 -101
  14. package/src/browser/task-configurations.ts +508 -508
  15. package/src/browser/task-contribution.ts +266 -266
  16. package/src/browser/task-definition-registry.spec.ts +203 -203
  17. package/src/browser/task-definition-registry.ts +131 -131
  18. package/src/browser/task-frontend-contribution.ts +402 -402
  19. package/src/browser/task-frontend-module.ts +86 -86
  20. package/src/browser/task-name-resolver.ts +55 -55
  21. package/src/browser/task-node.ts +37 -37
  22. package/src/browser/task-preferences.ts +40 -40
  23. package/src/browser/task-problem-matcher-registry.ts +308 -308
  24. package/src/browser/task-problem-pattern-registry.ts +196 -196
  25. package/src/browser/task-schema-updater.ts +701 -701
  26. package/src/browser/task-service.ts +1164 -1164
  27. package/src/browser/task-source-resolver.ts +36 -36
  28. package/src/browser/task-templates.ts +168 -168
  29. package/src/browser/task-terminal-widget-manager.ts +224 -224
  30. package/src/browser/tasks-monaco-contribution.ts +27 -27
  31. package/src/common/index.ts +20 -20
  32. package/src/common/problem-matcher-protocol.ts +234 -234
  33. package/src/common/process/task-protocol.ts +97 -97
  34. package/src/common/task-common-module.ts +34 -34
  35. package/src/common/task-protocol.ts +317 -317
  36. package/src/common/task-util.ts +43 -43
  37. package/src/common/task-watcher.ts +78 -78
  38. package/src/node/custom/custom-task-runner-backend-module.ts +37 -37
  39. package/src/node/custom/custom-task-runner-contribution.ts +30 -30
  40. package/src/node/custom/custom-task-runner.ts +60 -60
  41. package/src/node/custom/custom-task.ts +73 -73
  42. package/src/node/index.ts +19 -19
  43. package/src/node/process/process-task-runner-backend-module.ts +37 -37
  44. package/src/node/process/process-task-runner-contribution.ts +31 -31
  45. package/src/node/process/process-task-runner.ts +371 -371
  46. package/src/node/process/process-task.spec.ts +30 -30
  47. package/src/node/process/process-task.ts +144 -144
  48. package/src/node/task-abstract-line-matcher.ts +312 -312
  49. package/src/node/task-backend-application-contribution.ts +36 -36
  50. package/src/node/task-backend-module.ts +57 -57
  51. package/src/node/task-line-matchers.ts +127 -127
  52. package/src/node/task-manager.ts +129 -129
  53. package/src/node/task-problem-collector.spec.ts +338 -338
  54. package/src/node/task-problem-collector.ts +62 -62
  55. package/src/node/task-runner-protocol.ts +33 -33
  56. package/src/node/task-runner.ts +96 -96
  57. package/src/node/task-server.slow-spec.ts +444 -444
  58. package/src/node/task-server.ts +263 -263
  59. package/src/node/task.ts +103 -103
  60. package/src/node/test/task-test-container.ts +63 -63
@@ -1,831 +1,831 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable, optional } from '@theia/core/shared/inversify';
18
- import { TaskService } from './task-service';
19
- import { TaskInfo, TaskConfiguration, TaskCustomization, TaskScope, TaskConfigurationScope, TaskDefinition } from '../common/task-protocol';
20
- import { TaskDefinitionRegistry } from './task-definition-registry';
21
- import URI from '@theia/core/lib/common/uri';
22
- import { LabelProvider, QuickAccessProvider, QuickAccessRegistry, QuickInputService, QuickPick, PreferenceService } from '@theia/core/lib/browser';
23
- import { WorkspaceService } from '@theia/workspace/lib/browser';
24
- import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
25
- import { ALL_TASK_TYPES } from './provided-task-configurations';
26
- import { TaskNameResolver } from './task-name-resolver';
27
- import { TaskSourceResolver } from './task-source-resolver';
28
- import { TaskConfigurationManager } from './task-configuration-manager';
29
- import { filterItems, QuickInputButton, QuickPickItem, QuickPickItemOrSeparator, QuickPicks, QuickPickInput, QuickPickValue } from
30
- '@theia/core/lib/browser/quick-input/quick-input-service';
31
- import { CancellationToken } from '@theia/core/lib/common';
32
- import { nls } from '@theia/core/lib/common/nls';
33
- import { TriggerAction } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/pickerQuickAccess';
34
-
35
- export namespace ConfigureTaskAction {
36
- export const ID = 'workbench.action.tasks.configureTaskRunner';
37
- export const TEXT = 'Configure Task';
38
- }
39
-
40
- export type TaskEntry = QuickPickItemOrSeparator | QuickPickValue<string>;
41
- export namespace TaskEntry {
42
- export function isQuickPickValue(item: QuickPickItemOrSeparator | QuickPickValue<String>): item is QuickPickValue<string> {
43
- return 'value' in item && typeof item.value === 'string';
44
- }
45
- }
46
-
47
- export const CHOOSE_TASK = nls.localizeByDefault('Select the task to run');
48
- export const CONFIGURE_A_TASK = nls.localizeByDefault('Configure a Task');
49
- export const NO_TASK_TO_RUN = nls.localize('theia/task/noTaskToRun', 'No task to run found. Configure Tasks...');
50
- export const SHOW_ALL = nls.localizeByDefault('Show All Tasks...');
51
-
52
- @injectable()
53
- export class QuickOpenTask implements QuickAccessProvider {
54
- static readonly PREFIX = 'task ';
55
- readonly description: string = 'Run Task';
56
- protected items: Array<TaskEntry> = [];
57
-
58
- @inject(TaskService)
59
- protected readonly taskService: TaskService;
60
-
61
- @inject(QuickInputService) @optional()
62
- protected readonly quickInputService: QuickInputService;
63
-
64
- @inject(QuickAccessRegistry)
65
- protected readonly quickAccessRegistry: QuickAccessRegistry;
66
-
67
- @inject(WorkspaceService)
68
- protected readonly workspaceService: WorkspaceService;
69
-
70
- @inject(TaskDefinitionRegistry)
71
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
72
-
73
- @inject(TaskNameResolver)
74
- protected readonly taskNameResolver: TaskNameResolver;
75
-
76
- @inject(TaskSourceResolver)
77
- protected readonly taskSourceResolver: TaskSourceResolver;
78
-
79
- @inject(TaskConfigurationManager)
80
- protected readonly taskConfigurationManager: TaskConfigurationManager;
81
-
82
- @inject(PreferenceService)
83
- protected readonly preferences: PreferenceService;
84
-
85
- @inject(LabelProvider)
86
- protected readonly labelProvider: LabelProvider;
87
-
88
- init(): Promise<void> {
89
- return this.doInit(this.taskService.startUserAction());
90
- }
91
-
92
- protected async doInit(token: number): Promise<void> {
93
- const recentTasks = this.taskService.recentTasks;
94
- const configuredTasks = await this.taskService.getConfiguredTasks(token);
95
- const providedTypes = this.taskDefinitionRegistry.getAll();
96
-
97
- const { filteredRecentTasks, filteredConfiguredTasks } = this.getFilteredTasks(recentTasks, configuredTasks, []);
98
- const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
99
- this.items = [];
100
-
101
- const filteredRecentTasksItems = this.getItems(filteredRecentTasks, 'recently used tasks', token, isMulti);
102
- const filteredConfiguredTasksItems = this.getItems(filteredConfiguredTasks, 'configured tasks', token, isMulti, {
103
- label: `$(plus) ${CONFIGURE_A_TASK}`,
104
- execute: () => this.configure()
105
- });
106
- const providedTypeItems = this.createProvidedTypeItems(providedTypes);
107
-
108
- this.items.push(
109
- ...filteredRecentTasksItems,
110
- ...filteredConfiguredTasksItems,
111
- ...providedTypeItems
112
- );
113
-
114
- if (!this.items.length) {
115
- this.items.push(({
116
- label: NO_TASK_TO_RUN,
117
- execute: () => this.configure()
118
- }));
119
- }
120
- }
121
-
122
- protected createProvidedTypeItems(providedTypes: TaskDefinition[]): TaskEntry[] {
123
- const result: TaskEntry[] = [];
124
- result.push({ type: 'separator', label: nls.localizeByDefault('contributed') });
125
-
126
- providedTypes.sort((t1, t2) =>
127
- t1.taskType.localeCompare(t2.taskType)
128
- );
129
-
130
- for (const definition of providedTypes) {
131
- const type = definition.taskType;
132
- result.push(this.toProvidedTaskTypeEntry(type, `$(folder) ${type}`));
133
- }
134
-
135
- result.push(this.toProvidedTaskTypeEntry(SHOW_ALL, SHOW_ALL));
136
- return result;
137
- }
138
-
139
- protected toProvidedTaskTypeEntry(type: string, label: string): TaskEntry {
140
- return {
141
- label,
142
- value: type,
143
- /**
144
- * This function is used in the context of a QuickAccessProvider (triggered from the command palette: '?task').
145
- * It triggers a call to QuickOpenTask#getPicks,
146
- * the 'execute' function below is called when the user selects an entry for a task type which triggers the display of
147
- * the second level quick pick.
148
- *
149
- * Due to the asynchronous resolution of second-level tasks, there may be a delay in showing the quick input widget.
150
- *
151
- * NOTE: The widget is not delayed in other contexts e.g. by commands (Run Tasks), see the implementation at QuickOpenTask#open
152
- *
153
- * To improve the performance, we may consider using a `PickerQuickAccessProvider` instead of a `QuickAccessProvider`,
154
- * and support providing 'FastAndSlowPicks'.
155
- *
156
- * TODO: Consider the introduction and exposure of monaco `PickerQuickAccessProvider` and the corresponding refactoring for this and other
157
- * users of QuickAccessProvider.
158
- */
159
- execute: () => {
160
- this.doSecondLevel(type);
161
- }
162
- };
163
- }
164
-
165
- protected onDidTriggerGearIcon(item: QuickPickItem): void {
166
- if (item instanceof TaskRunQuickOpenItem) {
167
- this.taskService.configure(item.token, item.task);
168
- this.quickInputService.hide();
169
- }
170
- }
171
-
172
- async open(): Promise<void> {
173
- this.showMultiLevelQuickPick();
174
- }
175
-
176
- async showMultiLevelQuickPick(skipInit?: boolean): Promise<void> {
177
- if (!skipInit) {
178
- await this.init();
179
- }
180
- const picker: QuickPick<TaskEntry> = this.quickInputService.createQuickPick();
181
- picker.placeholder = CHOOSE_TASK;
182
- picker.matchOnDescription = true;
183
- picker.ignoreFocusOut = false;
184
- picker.items = this.items;
185
- picker.onDidTriggerItemButton(({ item }) => this.onDidTriggerGearIcon(item));
186
-
187
- const firstLevelTask = await this.doPickerFirstLevel(picker);
188
-
189
- if (!!firstLevelTask && TaskEntry.isQuickPickValue(firstLevelTask)) {
190
- // A taskType was selected
191
- picker.busy = true;
192
- await this.doSecondLevel(firstLevelTask.value);
193
- } else if (!!firstLevelTask && 'execute' in firstLevelTask && typeof firstLevelTask.execute === 'function') {
194
- firstLevelTask.execute();
195
- }
196
- picker.dispose();
197
- }
198
-
199
- protected async doPickerFirstLevel(picker: QuickPick<TaskEntry>): Promise<TaskEntry | undefined> {
200
- picker.show();
201
- const firstLevelPickerResult = await new Promise<TaskEntry | undefined | null>(resolve => {
202
- picker.onDidAccept(async () => {
203
- resolve(picker.selectedItems ? picker.selectedItems[0] : undefined);
204
- });
205
- });
206
- return firstLevelPickerResult ?? undefined;
207
- }
208
-
209
- protected async doSecondLevel(taskType: string): Promise<void> {
210
- // Resolve Second level tasks based on selected TaskType
211
- const isMulti = this.workspaceService.isMultiRootWorkspaceOpened;
212
- const token = this.taskService.startUserAction();
213
-
214
- const providedTasks = taskType === SHOW_ALL ?
215
- await this.taskService.getProvidedTasks(token, ALL_TASK_TYPES) :
216
- await this.taskService.getProvidedTasks(token, taskType);
217
-
218
- const providedTasksItems = this.getItems(providedTasks, taskType + ' tasks', token, isMulti);
219
-
220
- const label = providedTasksItems.length ?
221
- nls.localizeByDefault('Go back ↩') :
222
- nls.localizeByDefault('No {0} tasks found. Go back ↩', taskType);
223
-
224
- providedTasksItems.push(({
225
- label,
226
- execute: () => this.showMultiLevelQuickPick(true)
227
- }));
228
-
229
- this.quickInputService?.showQuickPick(providedTasksItems, {
230
- placeholder: CHOOSE_TASK,
231
- onDidTriggerItemButton: ({ item }) => this.onDidTriggerGearIcon(item)
232
- });
233
- }
234
-
235
- attach(): void {
236
- this.items = [];
237
- const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
238
- this.taskService.getRunningTasks().then(tasks => {
239
- if (!tasks.length) {
240
- this.items.push({
241
- label: 'No tasks found',
242
- });
243
- } else {
244
- tasks.forEach((task: TaskInfo) => {
245
- // can only attach to terminal processes, so only list those
246
- if (task.terminalId) {
247
- this.items.push(new RunningTaskQuickOpenItem(
248
- task,
249
- this.taskService,
250
- this.taskNameResolver,
251
- this.taskSourceResolver,
252
- this.taskDefinitionRegistry,
253
- this.labelProvider,
254
- isMulti,
255
- () => this.taskService.attach(task.terminalId!, task)
256
- ));
257
- }
258
- });
259
- }
260
- if (this.items.length === 0) {
261
- this.items.push(({
262
- label: 'No tasks found'
263
- }));
264
- }
265
- this.quickInputService?.showQuickPick(this.items, { placeholder: CHOOSE_TASK });
266
- });
267
- }
268
-
269
- async configure(): Promise<void> {
270
- this.quickInputService?.pick(this.resolveItemsToConfigure(), { placeHolder: nls.localizeByDefault('Select a task to configure') }).
271
- then(async item => {
272
- if (item && 'execute' in item && typeof item.execute === 'function') {
273
- item.execute();
274
- }
275
- });
276
- }
277
-
278
- protected async resolveItemsToConfigure(): Promise<QuickPickInput<QuickPickItemOrSeparator>[]> {
279
- const items: Array<QuickPickInput<QuickPickItemOrSeparator>> = [];
280
- const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
281
- const token: number = this.taskService.startUserAction();
282
-
283
- const configuredTasks = await this.taskService.getConfiguredTasks(token);
284
- const providedTasks = await this.taskService.getProvidedTasks(token, ALL_TASK_TYPES);
285
-
286
- // check if tasks.json exists. If not, display "Create tasks.json file from template"
287
- // If tasks.json exists and empty, display 'Open tasks.json file'
288
- const { filteredConfiguredTasks, filteredProvidedTasks } = this.getFilteredTasks([], configuredTasks, providedTasks);
289
- const groupedTasks = this.getGroupedTasksByWorkspaceFolder([...filteredConfiguredTasks, ...filteredProvidedTasks]);
290
- if (groupedTasks.has(TaskScope.Global.toString())) {
291
- const configs = groupedTasks.get(TaskScope.Global.toString())!;
292
- this.addConfigurationItems(items, configs, token, isMulti);
293
- }
294
- if (groupedTasks.has(TaskScope.Workspace.toString())) {
295
- const configs = groupedTasks.get(TaskScope.Workspace.toString())!;
296
- this.addConfigurationItems(items, configs, token, isMulti);
297
- }
298
-
299
- const rootUris = (await this.workspaceService.roots).map(rootStat => rootStat.resource.toString());
300
- for (const rootFolder of rootUris) {
301
- const folderName = new URI(rootFolder).displayName;
302
- if (groupedTasks.has(rootFolder)) {
303
- const configs = groupedTasks.get(rootFolder.toString())!;
304
- this.addConfigurationItems(items, configs, token, isMulti);
305
- } else {
306
- const { configUri } = this.preferences.resolve('tasks', [], rootFolder);
307
- const existTaskConfigFile = !!configUri;
308
- items.push(({
309
- label: existTaskConfigFile ? 'Open tasks.json file' : 'Create tasks.json file from template',
310
- execute: () => {
311
- setTimeout(() => this.taskConfigurationManager.openConfiguration(rootFolder));
312
- }
313
- }));
314
- }
315
- if (items.length > 0) {
316
- items.unshift({
317
- type: 'separator',
318
- label: isMulti ? folderName : ''
319
- });
320
- }
321
- }
322
-
323
- if (items.length === 0) {
324
- items.push(({
325
- label: 'No tasks found'
326
- }));
327
- }
328
-
329
- return items;
330
- }
331
-
332
- private addConfigurationItems(items: QuickPickInput<QuickPickItemOrSeparator>[], configs: TaskConfiguration[], token: number, isMulti: boolean): void {
333
- items.push(
334
- ...configs.map(taskConfig => {
335
- const item = new TaskConfigureQuickOpenItem(
336
- token,
337
- taskConfig,
338
- this.taskService,
339
- this.taskNameResolver,
340
- this.workspaceService,
341
- isMulti
342
- );
343
- item['taskDefinitionRegistry'] = this.taskDefinitionRegistry;
344
- return item;
345
- }).sort((t1, t2) =>
346
- t1.label.localeCompare(t2.label)
347
- )
348
- );
349
- }
350
-
351
- protected getTaskItems(): QuickPickItem[] {
352
- return this.items.filter((item): item is QuickPickItem => item.type !== 'separator' && (item as TaskRunQuickOpenItem).task !== undefined);
353
- }
354
-
355
- async runBuildOrTestTask(buildOrTestType: 'build' | 'test'): Promise<void> {
356
- const shouldRunBuildTask = buildOrTestType === 'build';
357
- const token: number = this.taskService.startUserAction();
358
-
359
- await this.doInit(token);
360
-
361
- const taskItems = this.getTaskItems();
362
-
363
- if (taskItems.length > 0) { // the item in `this.items` is not 'No tasks found'
364
- const buildOrTestTasks = taskItems.filter((t: TaskRunQuickOpenItem) =>
365
- shouldRunBuildTask ? TaskCustomization.isBuildTask(t.task) : TaskCustomization.isTestTask(t.task)
366
- );
367
- if (buildOrTestTasks.length > 0) { // build / test tasks are defined in the workspace
368
- const defaultBuildOrTestTasks = buildOrTestTasks.filter((t: TaskRunQuickOpenItem) =>
369
- shouldRunBuildTask ? TaskCustomization.isDefaultBuildTask(t.task) : TaskCustomization.isDefaultTestTask(t.task)
370
- );
371
- if (defaultBuildOrTestTasks.length === 1) { // run the default build / test task
372
- const defaultBuildOrTestTask = defaultBuildOrTestTasks[0];
373
- const taskToRun = (defaultBuildOrTestTask as TaskRunQuickOpenItem).task;
374
- const scope = taskToRun._scope;
375
-
376
- if (this.taskDefinitionRegistry && !!this.taskDefinitionRegistry.getDefinition(taskToRun)) {
377
- this.taskService.run(token, taskToRun.source, taskToRun.label, scope);
378
- } else {
379
- this.taskService.run(token, taskToRun._source, taskToRun.label, scope);
380
- }
381
- return;
382
- }
383
- // if default build / test task is not found, or there are more than one default,
384
- // display the list of build /test tasks to let the user decide which to run
385
- this.items = buildOrTestTasks;
386
- } else { // no build / test tasks, display an action item to configure the build / test task
387
- this.items = [({
388
- label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType.charAt(0).toUpperCase() + buildOrTestType.slice(1)} Task...`,
389
- execute: () => {
390
- this.doInit(token).then(() => {
391
- // update the `tasks.json` file, instead of running the task itself
392
- this.items = this.getTaskItems().map((item: TaskRunQuickOpenItem) => new ConfigureBuildOrTestTaskQuickOpenItem(
393
- token,
394
- item.task,
395
- this.taskService,
396
- this.workspaceService.isMultiRootWorkspaceOpened,
397
- this.taskNameResolver,
398
- shouldRunBuildTask,
399
- this.taskConfigurationManager,
400
- this.taskDefinitionRegistry,
401
- this.taskSourceResolver
402
- ));
403
- this.quickInputService?.showQuickPick(this.items, { placeholder: `Select the task to be used as the default ${buildOrTestType} task` });
404
- });
405
- }
406
- })];
407
- }
408
- } else { // no tasks are currently present, prompt users if they'd like to configure a task.
409
- this.items = [{
410
- label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType.charAt(0).toUpperCase() + buildOrTestType.slice(1)} Task...`,
411
- execute: () => this.configure()
412
- }];
413
- }
414
-
415
- this.quickInputService?.showQuickPick(this.items, {
416
- placeholder: `Select the ${buildOrTestType} task to run`,
417
- onDidTriggerItemButton: ({ item }) => this.onDidTriggerGearIcon(item)
418
- });
419
- }
420
-
421
- async getPicks(filter: string, token: CancellationToken): Promise<QuickPicks> {
422
- await this.init();
423
- return filterItems(this.items, filter);
424
- }
425
-
426
- registerQuickAccessProvider(): void {
427
- this.quickAccessRegistry.registerQuickAccessProvider({
428
- getInstance: () => this,
429
- prefix: QuickOpenTask.PREFIX,
430
- placeholder: 'Select the task to run',
431
- helpEntries: [{ description: 'Run Task', needsEditor: false }]
432
- });
433
- }
434
-
435
- protected getRunningTaskLabel(task: TaskInfo): string {
436
- return `Task id: ${task.taskId}, label: ${task.config.label}`;
437
- }
438
-
439
- private getItems(tasks: TaskConfiguration[], groupLabel: string, token: number, isMulti: boolean, defaultTask?: TaskEntry):
440
- TaskEntry[] {
441
- const items: TaskEntry[] = tasks.map(task =>
442
- new TaskRunQuickOpenItem(token, task, this.taskService, isMulti, this.taskDefinitionRegistry, this.taskNameResolver,
443
- this.taskSourceResolver, this.taskConfigurationManager, [{
444
- iconClass: 'codicon-gear',
445
- tooltip: 'Configure Task',
446
- }])
447
- ).sort((t1, t2) => {
448
- let result = (t1.description ?? '').localeCompare(t2.description ?? '');
449
- if (result === 0) {
450
- result = t1.label.localeCompare(t2.label);
451
- }
452
- return result;
453
- });
454
-
455
- if (items.length === 0 && defaultTask) {
456
- items.push(defaultTask);
457
- }
458
-
459
- if (items.length > 0) {
460
- items.unshift({ type: 'separator', label: groupLabel });
461
- }
462
- return items;
463
- }
464
-
465
- private getFilteredTasks(recentTasks: TaskConfiguration[], configuredTasks: TaskConfiguration[], providedTasks: TaskConfiguration[]): {
466
- filteredRecentTasks: TaskConfiguration[], filteredConfiguredTasks: TaskConfiguration[], filteredProvidedTasks: TaskConfiguration[]
467
- } {
468
-
469
- const filteredRecentTasks: TaskConfiguration[] = [];
470
- recentTasks.forEach(recent => {
471
- const originalTaskConfig = [...configuredTasks, ...providedTasks].find(t => this.taskDefinitionRegistry.compareTasks(recent, t));
472
- if (originalTaskConfig) {
473
- filteredRecentTasks.push(originalTaskConfig);
474
- }
475
- });
476
-
477
- const filteredProvidedTasks: TaskConfiguration[] = [];
478
- providedTasks.forEach(provided => {
479
- const exist = [...filteredRecentTasks, ...configuredTasks].some(t => this.taskDefinitionRegistry.compareTasks(provided, t));
480
- if (!exist) {
481
- filteredProvidedTasks.push(provided);
482
- }
483
- });
484
-
485
- const filteredConfiguredTasks: TaskConfiguration[] = [];
486
- configuredTasks.forEach(configured => {
487
- const exist = filteredRecentTasks.some(t => this.taskDefinitionRegistry.compareTasks(configured, t));
488
- if (!exist) {
489
- filteredConfiguredTasks.push(configured);
490
- }
491
- });
492
-
493
- return {
494
- filteredRecentTasks, filteredConfiguredTasks, filteredProvidedTasks
495
- };
496
- }
497
-
498
- private getGroupedTasksByWorkspaceFolder(tasks: TaskConfiguration[]): Map<string, TaskConfiguration[]> {
499
- const grouped = new Map<string, TaskConfiguration[]>();
500
- for (const task of tasks) {
501
- const scope = task._scope;
502
- if (grouped.has(scope.toString())) {
503
- grouped.get(scope.toString())!.push(task);
504
- } else {
505
- grouped.set(scope.toString(), [task]);
506
- }
507
- }
508
- for (const taskConfigs of grouped.values()) {
509
- taskConfigs.sort((t1, t2) => t1.label.localeCompare(t2.label));
510
- }
511
- return grouped;
512
- }
513
- }
514
-
515
- export class TaskRunQuickOpenItem implements QuickPickItem {
516
- constructor(
517
- readonly token: number,
518
- readonly task: TaskConfiguration,
519
- protected taskService: TaskService,
520
- protected isMulti: boolean,
521
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry,
522
- protected readonly taskNameResolver: TaskNameResolver,
523
- protected readonly taskSourceResolver: TaskSourceResolver,
524
- protected taskConfigurationManager: TaskConfigurationManager,
525
- readonly buttons?: Array<QuickInputButton>
526
- ) { }
527
-
528
- get label(): string {
529
- return this.taskNameResolver.resolve(this.task);
530
- }
531
-
532
- get description(): string {
533
- return renderScope(this.task._scope, this.isMulti);
534
- }
535
-
536
- get detail(): string | undefined {
537
- return this.task.detail;
538
- }
539
-
540
- execute(): void {
541
- const scope = this.task._scope;
542
- if (this.taskDefinitionRegistry && !!this.taskDefinitionRegistry.getDefinition(this.task)) {
543
- this.taskService.run(this.token, this.task.source || this.task._source, this.task.label, scope);
544
- } else {
545
- this.taskService.run(this.token, this.task._source, this.task.label, scope);
546
- }
547
- }
548
-
549
- trigger(): TriggerAction {
550
- this.taskService.configure(this.token, this.task);
551
- return TriggerAction.CLOSE_PICKER;
552
- }
553
- }
554
-
555
- export class ConfigureBuildOrTestTaskQuickOpenItem extends TaskRunQuickOpenItem {
556
- constructor(
557
- token: number,
558
- task: TaskConfiguration,
559
- taskService: TaskService,
560
- isMulti: boolean,
561
- taskNameResolver: TaskNameResolver,
562
- protected readonly isBuildTask: boolean,
563
- taskConfigurationManager: TaskConfigurationManager,
564
- taskDefinitionRegistry: TaskDefinitionRegistry,
565
- taskSourceResolver: TaskSourceResolver
566
- ) {
567
- super(token, task, taskService, isMulti, taskDefinitionRegistry, taskNameResolver, taskSourceResolver, taskConfigurationManager);
568
- }
569
-
570
- override execute(): void {
571
- this.taskService.updateTaskConfiguration(this.token, this.task, { group: { kind: this.isBuildTask ? 'build' : 'test', isDefault: true } })
572
- .then(() => {
573
- if (this.task._scope) {
574
- this.taskConfigurationManager.openConfiguration(this.task._scope);
575
- }
576
- });
577
- }
578
- }
579
-
580
- function renderScope(scope: TaskConfigurationScope, isMulti: boolean): string {
581
- if (typeof scope === 'string') {
582
- if (isMulti) {
583
- return new URI(scope).displayName;
584
- } else {
585
- return '';
586
- }
587
- } else {
588
- return TaskScope[scope];
589
- }
590
- }
591
-
592
- export class TaskConfigureQuickOpenItem implements QuickPickItem {
593
-
594
- protected taskDefinitionRegistry: TaskDefinitionRegistry;
595
-
596
- constructor(
597
- protected readonly token: number,
598
- protected readonly task: TaskConfiguration,
599
- protected readonly taskService: TaskService,
600
- protected readonly taskNameResolver: TaskNameResolver,
601
- protected readonly workspaceService: WorkspaceService,
602
- protected readonly isMulti: boolean
603
- ) {
604
- const stat = this.workspaceService.workspace;
605
- this.isMulti = stat ? !stat.isDirectory : false;
606
- }
607
-
608
- get label(): string {
609
- return this.taskNameResolver.resolve(this.task);
610
- }
611
-
612
- get description(): string {
613
- return renderScope(this.task._scope, this.isMulti);
614
- }
615
-
616
- accept(): void {
617
- this.execute();
618
- }
619
-
620
- execute(): void {
621
- this.taskService.configure(this.token, this.task);
622
- }
623
- }
624
-
625
- @injectable()
626
- export class TaskTerminateQuickOpen {
627
-
628
- @inject(LabelProvider)
629
- protected readonly labelProvider: LabelProvider;
630
-
631
- @inject(QuickInputService) @optional()
632
- protected readonly quickInputService: QuickInputService;
633
-
634
- @inject(TaskDefinitionRegistry)
635
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
636
-
637
- @inject(TaskNameResolver)
638
- protected readonly taskNameResolver: TaskNameResolver;
639
-
640
- @inject(TaskSourceResolver)
641
- protected readonly taskSourceResolver: TaskSourceResolver;
642
-
643
- @inject(TaskService)
644
- protected readonly taskService: TaskService;
645
-
646
- @inject(WorkspaceService)
647
- protected readonly workspaceService: WorkspaceService;
648
-
649
- async getItems(): Promise<Array<QuickPickItem>> {
650
- const items: Array<QuickPickItem> = [];
651
- const runningTasks: TaskInfo[] = await this.taskService.getRunningTasks();
652
- const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
653
- if (runningTasks.length <= 0) {
654
- items.push(({
655
- label: 'No task is currently running',
656
- }));
657
- } else {
658
- runningTasks.forEach((task: TaskInfo) => {
659
- items.push(new RunningTaskQuickOpenItem(
660
- task,
661
- this.taskService,
662
- this.taskNameResolver,
663
- this.taskSourceResolver,
664
- this.taskDefinitionRegistry,
665
- this.labelProvider,
666
- isMulti,
667
- () => this.taskService.kill(task.taskId)
668
- ));
669
- });
670
- if (runningTasks.length > 1) {
671
- items.push(({
672
- label: 'All running tasks',
673
- execute: () => {
674
- runningTasks.forEach((t: TaskInfo) => {
675
- this.taskService.kill(t.taskId);
676
- });
677
- }
678
- }));
679
- }
680
- }
681
- return items;
682
- }
683
-
684
- async open(): Promise<void> {
685
- const items = await this.getItems();
686
- this.quickInputService?.showQuickPick(items, { placeholder: 'Select task to terminate' });
687
- }
688
- }
689
-
690
- @injectable()
691
- export class TaskRunningQuickOpen {
692
- @inject(LabelProvider)
693
- protected readonly labelProvider: LabelProvider;
694
-
695
- @inject(QuickInputService) @optional()
696
- protected readonly quickInputService: QuickInputService;
697
-
698
- @inject(TaskDefinitionRegistry)
699
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
700
-
701
- @inject(TaskNameResolver)
702
- protected readonly taskNameResolver: TaskNameResolver;
703
-
704
- @inject(TaskSourceResolver)
705
- protected readonly taskSourceResolver: TaskSourceResolver;
706
-
707
- @inject(TaskService)
708
- protected readonly taskService: TaskService;
709
-
710
- @inject(WorkspaceService)
711
- protected readonly workspaceService: WorkspaceService;
712
-
713
- @inject(TerminalService)
714
- protected readonly terminalService: TerminalService;
715
-
716
- async getItems(): Promise<Array<QuickPickItem>> {
717
- const items: Array<QuickPickItem> = [];
718
- const runningTasks: TaskInfo[] = await this.taskService.getRunningTasks();
719
- const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
720
- if (runningTasks.length <= 0) {
721
- items.push(({
722
- label: 'No task is currently running',
723
- }));
724
- } else {
725
- runningTasks.forEach((task: TaskInfo) => {
726
- items.push(new RunningTaskQuickOpenItem(
727
- task,
728
- this.taskService,
729
- this.taskNameResolver,
730
- this.taskSourceResolver,
731
- this.taskDefinitionRegistry,
732
- this.labelProvider,
733
- isMulti,
734
- () => {
735
- if (task.terminalId) {
736
- const terminal = this.terminalService.getByTerminalId(task.terminalId);
737
- if (terminal) {
738
- this.terminalService.open(terminal);
739
- }
740
- }
741
- }
742
- ));
743
- });
744
- }
745
- return items;
746
- }
747
-
748
- async open(): Promise<void> {
749
- const items = await this.getItems();
750
- this.quickInputService?.showQuickPick(items, { placeholder: 'Select the task to show its output' });
751
- }
752
- }
753
-
754
- export class RunningTaskQuickOpenItem implements QuickPickItem {
755
- constructor(
756
- protected readonly taskInfo: TaskInfo,
757
- protected readonly taskService: TaskService,
758
- protected readonly taskNameResolver: TaskNameResolver,
759
- protected readonly taskSourceResolver: TaskSourceResolver,
760
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry,
761
- protected readonly labelProvider: LabelProvider,
762
- protected readonly isMulti: boolean,
763
- public readonly execute: () => void,
764
- ) { }
765
-
766
- get label(): string {
767
- return this.taskNameResolver.resolve(this.taskInfo.config);
768
- }
769
-
770
- get description(): string {
771
- return renderScope(this.taskInfo.config._scope, this.isMulti);
772
- }
773
-
774
- get detail(): string | undefined {
775
- return this.taskInfo.config.detail;
776
- }
777
- }
778
-
779
- @injectable()
780
- export class TaskRestartRunningQuickOpen {
781
- @inject(LabelProvider)
782
- protected readonly labelProvider: LabelProvider;
783
-
784
- @inject(QuickInputService) @optional()
785
- protected readonly quickInputService: QuickInputService;
786
-
787
- @inject(TaskDefinitionRegistry)
788
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
789
-
790
- @inject(TaskNameResolver)
791
- protected readonly taskNameResolver: TaskNameResolver;
792
-
793
- @inject(TaskSourceResolver)
794
- protected readonly taskSourceResolver: TaskSourceResolver;
795
-
796
- @inject(TaskService)
797
- protected readonly taskService: TaskService;
798
-
799
- @inject(WorkspaceService)
800
- protected readonly workspaceService: WorkspaceService;
801
-
802
- async getItems(): Promise<Array<QuickPickItem>> {
803
- const items: Array<QuickPickItem> = [];
804
- const runningTasks: TaskInfo[] = await this.taskService.getRunningTasks();
805
- const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
806
- if (runningTasks.length <= 0) {
807
- items.push({
808
- label: 'No task to restart'
809
- });
810
- } else {
811
- runningTasks.forEach((task: TaskInfo) => {
812
- items.push(new RunningTaskQuickOpenItem(
813
- task,
814
- this.taskService,
815
- this.taskNameResolver,
816
- this.taskSourceResolver,
817
- this.taskDefinitionRegistry,
818
- this.labelProvider,
819
- isMulti,
820
- () => this.taskService.restartTask(task)
821
- ));
822
- });
823
- }
824
- return items;
825
- }
826
-
827
- async open(): Promise<void> {
828
- const items = await this.getItems();
829
- this.quickInputService?.showQuickPick(items, { placeholder: 'Select task to restart' });
830
- }
831
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, optional } from '@theia/core/shared/inversify';
18
+ import { TaskService } from './task-service';
19
+ import { TaskInfo, TaskConfiguration, TaskCustomization, TaskScope, TaskConfigurationScope, TaskDefinition } from '../common/task-protocol';
20
+ import { TaskDefinitionRegistry } from './task-definition-registry';
21
+ import URI from '@theia/core/lib/common/uri';
22
+ import { LabelProvider, QuickAccessProvider, QuickAccessRegistry, QuickInputService, QuickPick, PreferenceService } from '@theia/core/lib/browser';
23
+ import { WorkspaceService } from '@theia/workspace/lib/browser';
24
+ import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
25
+ import { ALL_TASK_TYPES } from './provided-task-configurations';
26
+ import { TaskNameResolver } from './task-name-resolver';
27
+ import { TaskSourceResolver } from './task-source-resolver';
28
+ import { TaskConfigurationManager } from './task-configuration-manager';
29
+ import { filterItems, QuickInputButton, QuickPickItem, QuickPickItemOrSeparator, QuickPicks, QuickPickInput, QuickPickValue } from
30
+ '@theia/core/lib/browser/quick-input/quick-input-service';
31
+ import { CancellationToken } from '@theia/core/lib/common';
32
+ import { nls } from '@theia/core/lib/common/nls';
33
+ import { TriggerAction } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/pickerQuickAccess';
34
+
35
+ export namespace ConfigureTaskAction {
36
+ export const ID = 'workbench.action.tasks.configureTaskRunner';
37
+ export const TEXT = 'Configure Task';
38
+ }
39
+
40
+ export type TaskEntry = QuickPickItemOrSeparator | QuickPickValue<string>;
41
+ export namespace TaskEntry {
42
+ export function isQuickPickValue(item: QuickPickItemOrSeparator | QuickPickValue<String>): item is QuickPickValue<string> {
43
+ return 'value' in item && typeof item.value === 'string';
44
+ }
45
+ }
46
+
47
+ export const CHOOSE_TASK = nls.localizeByDefault('Select the task to run');
48
+ export const CONFIGURE_A_TASK = nls.localizeByDefault('Configure a Task');
49
+ export const NO_TASK_TO_RUN = nls.localize('theia/task/noTaskToRun', 'No task to run found. Configure Tasks...');
50
+ export const SHOW_ALL = nls.localizeByDefault('Show All Tasks...');
51
+
52
+ @injectable()
53
+ export class QuickOpenTask implements QuickAccessProvider {
54
+ static readonly PREFIX = 'task ';
55
+ readonly description: string = 'Run Task';
56
+ protected items: Array<TaskEntry> = [];
57
+
58
+ @inject(TaskService)
59
+ protected readonly taskService: TaskService;
60
+
61
+ @inject(QuickInputService) @optional()
62
+ protected readonly quickInputService: QuickInputService;
63
+
64
+ @inject(QuickAccessRegistry)
65
+ protected readonly quickAccessRegistry: QuickAccessRegistry;
66
+
67
+ @inject(WorkspaceService)
68
+ protected readonly workspaceService: WorkspaceService;
69
+
70
+ @inject(TaskDefinitionRegistry)
71
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
72
+
73
+ @inject(TaskNameResolver)
74
+ protected readonly taskNameResolver: TaskNameResolver;
75
+
76
+ @inject(TaskSourceResolver)
77
+ protected readonly taskSourceResolver: TaskSourceResolver;
78
+
79
+ @inject(TaskConfigurationManager)
80
+ protected readonly taskConfigurationManager: TaskConfigurationManager;
81
+
82
+ @inject(PreferenceService)
83
+ protected readonly preferences: PreferenceService;
84
+
85
+ @inject(LabelProvider)
86
+ protected readonly labelProvider: LabelProvider;
87
+
88
+ init(): Promise<void> {
89
+ return this.doInit(this.taskService.startUserAction());
90
+ }
91
+
92
+ protected async doInit(token: number): Promise<void> {
93
+ const recentTasks = this.taskService.recentTasks;
94
+ const configuredTasks = await this.taskService.getConfiguredTasks(token);
95
+ const providedTypes = this.taskDefinitionRegistry.getAll();
96
+
97
+ const { filteredRecentTasks, filteredConfiguredTasks } = this.getFilteredTasks(recentTasks, configuredTasks, []);
98
+ const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
99
+ this.items = [];
100
+
101
+ const filteredRecentTasksItems = this.getItems(filteredRecentTasks, 'recently used tasks', token, isMulti);
102
+ const filteredConfiguredTasksItems = this.getItems(filteredConfiguredTasks, 'configured tasks', token, isMulti, {
103
+ label: `$(plus) ${CONFIGURE_A_TASK}`,
104
+ execute: () => this.configure()
105
+ });
106
+ const providedTypeItems = this.createProvidedTypeItems(providedTypes);
107
+
108
+ this.items.push(
109
+ ...filteredRecentTasksItems,
110
+ ...filteredConfiguredTasksItems,
111
+ ...providedTypeItems
112
+ );
113
+
114
+ if (!this.items.length) {
115
+ this.items.push(({
116
+ label: NO_TASK_TO_RUN,
117
+ execute: () => this.configure()
118
+ }));
119
+ }
120
+ }
121
+
122
+ protected createProvidedTypeItems(providedTypes: TaskDefinition[]): TaskEntry[] {
123
+ const result: TaskEntry[] = [];
124
+ result.push({ type: 'separator', label: nls.localizeByDefault('contributed') });
125
+
126
+ providedTypes.sort((t1, t2) =>
127
+ t1.taskType.localeCompare(t2.taskType)
128
+ );
129
+
130
+ for (const definition of providedTypes) {
131
+ const type = definition.taskType;
132
+ result.push(this.toProvidedTaskTypeEntry(type, `$(folder) ${type}`));
133
+ }
134
+
135
+ result.push(this.toProvidedTaskTypeEntry(SHOW_ALL, SHOW_ALL));
136
+ return result;
137
+ }
138
+
139
+ protected toProvidedTaskTypeEntry(type: string, label: string): TaskEntry {
140
+ return {
141
+ label,
142
+ value: type,
143
+ /**
144
+ * This function is used in the context of a QuickAccessProvider (triggered from the command palette: '?task').
145
+ * It triggers a call to QuickOpenTask#getPicks,
146
+ * the 'execute' function below is called when the user selects an entry for a task type which triggers the display of
147
+ * the second level quick pick.
148
+ *
149
+ * Due to the asynchronous resolution of second-level tasks, there may be a delay in showing the quick input widget.
150
+ *
151
+ * NOTE: The widget is not delayed in other contexts e.g. by commands (Run Tasks), see the implementation at QuickOpenTask#open
152
+ *
153
+ * To improve the performance, we may consider using a `PickerQuickAccessProvider` instead of a `QuickAccessProvider`,
154
+ * and support providing 'FastAndSlowPicks'.
155
+ *
156
+ * TODO: Consider the introduction and exposure of monaco `PickerQuickAccessProvider` and the corresponding refactoring for this and other
157
+ * users of QuickAccessProvider.
158
+ */
159
+ execute: () => {
160
+ this.doSecondLevel(type);
161
+ }
162
+ };
163
+ }
164
+
165
+ protected onDidTriggerGearIcon(item: QuickPickItem): void {
166
+ if (item instanceof TaskRunQuickOpenItem) {
167
+ this.taskService.configure(item.token, item.task);
168
+ this.quickInputService.hide();
169
+ }
170
+ }
171
+
172
+ async open(): Promise<void> {
173
+ this.showMultiLevelQuickPick();
174
+ }
175
+
176
+ async showMultiLevelQuickPick(skipInit?: boolean): Promise<void> {
177
+ if (!skipInit) {
178
+ await this.init();
179
+ }
180
+ const picker: QuickPick<TaskEntry> = this.quickInputService.createQuickPick();
181
+ picker.placeholder = CHOOSE_TASK;
182
+ picker.matchOnDescription = true;
183
+ picker.ignoreFocusOut = false;
184
+ picker.items = this.items;
185
+ picker.onDidTriggerItemButton(({ item }) => this.onDidTriggerGearIcon(item));
186
+
187
+ const firstLevelTask = await this.doPickerFirstLevel(picker);
188
+
189
+ if (!!firstLevelTask && TaskEntry.isQuickPickValue(firstLevelTask)) {
190
+ // A taskType was selected
191
+ picker.busy = true;
192
+ await this.doSecondLevel(firstLevelTask.value);
193
+ } else if (!!firstLevelTask && 'execute' in firstLevelTask && typeof firstLevelTask.execute === 'function') {
194
+ firstLevelTask.execute();
195
+ }
196
+ picker.dispose();
197
+ }
198
+
199
+ protected async doPickerFirstLevel(picker: QuickPick<TaskEntry>): Promise<TaskEntry | undefined> {
200
+ picker.show();
201
+ const firstLevelPickerResult = await new Promise<TaskEntry | undefined | null>(resolve => {
202
+ picker.onDidAccept(async () => {
203
+ resolve(picker.selectedItems ? picker.selectedItems[0] : undefined);
204
+ });
205
+ });
206
+ return firstLevelPickerResult ?? undefined;
207
+ }
208
+
209
+ protected async doSecondLevel(taskType: string): Promise<void> {
210
+ // Resolve Second level tasks based on selected TaskType
211
+ const isMulti = this.workspaceService.isMultiRootWorkspaceOpened;
212
+ const token = this.taskService.startUserAction();
213
+
214
+ const providedTasks = taskType === SHOW_ALL ?
215
+ await this.taskService.getProvidedTasks(token, ALL_TASK_TYPES) :
216
+ await this.taskService.getProvidedTasks(token, taskType);
217
+
218
+ const providedTasksItems = this.getItems(providedTasks, taskType + ' tasks', token, isMulti);
219
+
220
+ const label = providedTasksItems.length ?
221
+ nls.localizeByDefault('Go back ↩') :
222
+ nls.localizeByDefault('No {0} tasks found. Go back ↩', taskType);
223
+
224
+ providedTasksItems.push(({
225
+ label,
226
+ execute: () => this.showMultiLevelQuickPick(true)
227
+ }));
228
+
229
+ this.quickInputService?.showQuickPick(providedTasksItems, {
230
+ placeholder: CHOOSE_TASK,
231
+ onDidTriggerItemButton: ({ item }) => this.onDidTriggerGearIcon(item)
232
+ });
233
+ }
234
+
235
+ attach(): void {
236
+ this.items = [];
237
+ const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
238
+ this.taskService.getRunningTasks().then(tasks => {
239
+ if (!tasks.length) {
240
+ this.items.push({
241
+ label: 'No tasks found',
242
+ });
243
+ } else {
244
+ tasks.forEach((task: TaskInfo) => {
245
+ // can only attach to terminal processes, so only list those
246
+ if (task.terminalId) {
247
+ this.items.push(new RunningTaskQuickOpenItem(
248
+ task,
249
+ this.taskService,
250
+ this.taskNameResolver,
251
+ this.taskSourceResolver,
252
+ this.taskDefinitionRegistry,
253
+ this.labelProvider,
254
+ isMulti,
255
+ () => this.taskService.attach(task.terminalId!, task)
256
+ ));
257
+ }
258
+ });
259
+ }
260
+ if (this.items.length === 0) {
261
+ this.items.push(({
262
+ label: 'No tasks found'
263
+ }));
264
+ }
265
+ this.quickInputService?.showQuickPick(this.items, { placeholder: CHOOSE_TASK });
266
+ });
267
+ }
268
+
269
+ async configure(): Promise<void> {
270
+ this.quickInputService?.pick(this.resolveItemsToConfigure(), { placeHolder: nls.localizeByDefault('Select a task to configure') }).
271
+ then(async item => {
272
+ if (item && 'execute' in item && typeof item.execute === 'function') {
273
+ item.execute();
274
+ }
275
+ });
276
+ }
277
+
278
+ protected async resolveItemsToConfigure(): Promise<QuickPickInput<QuickPickItemOrSeparator>[]> {
279
+ const items: Array<QuickPickInput<QuickPickItemOrSeparator>> = [];
280
+ const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
281
+ const token: number = this.taskService.startUserAction();
282
+
283
+ const configuredTasks = await this.taskService.getConfiguredTasks(token);
284
+ const providedTasks = await this.taskService.getProvidedTasks(token, ALL_TASK_TYPES);
285
+
286
+ // check if tasks.json exists. If not, display "Create tasks.json file from template"
287
+ // If tasks.json exists and empty, display 'Open tasks.json file'
288
+ const { filteredConfiguredTasks, filteredProvidedTasks } = this.getFilteredTasks([], configuredTasks, providedTasks);
289
+ const groupedTasks = this.getGroupedTasksByWorkspaceFolder([...filteredConfiguredTasks, ...filteredProvidedTasks]);
290
+ if (groupedTasks.has(TaskScope.Global.toString())) {
291
+ const configs = groupedTasks.get(TaskScope.Global.toString())!;
292
+ this.addConfigurationItems(items, configs, token, isMulti);
293
+ }
294
+ if (groupedTasks.has(TaskScope.Workspace.toString())) {
295
+ const configs = groupedTasks.get(TaskScope.Workspace.toString())!;
296
+ this.addConfigurationItems(items, configs, token, isMulti);
297
+ }
298
+
299
+ const rootUris = (await this.workspaceService.roots).map(rootStat => rootStat.resource.toString());
300
+ for (const rootFolder of rootUris) {
301
+ const folderName = new URI(rootFolder).displayName;
302
+ if (groupedTasks.has(rootFolder)) {
303
+ const configs = groupedTasks.get(rootFolder.toString())!;
304
+ this.addConfigurationItems(items, configs, token, isMulti);
305
+ } else {
306
+ const { configUri } = this.preferences.resolve('tasks', [], rootFolder);
307
+ const existTaskConfigFile = !!configUri;
308
+ items.push(({
309
+ label: existTaskConfigFile ? 'Open tasks.json file' : 'Create tasks.json file from template',
310
+ execute: () => {
311
+ setTimeout(() => this.taskConfigurationManager.openConfiguration(rootFolder));
312
+ }
313
+ }));
314
+ }
315
+ if (items.length > 0) {
316
+ items.unshift({
317
+ type: 'separator',
318
+ label: isMulti ? folderName : ''
319
+ });
320
+ }
321
+ }
322
+
323
+ if (items.length === 0) {
324
+ items.push(({
325
+ label: 'No tasks found'
326
+ }));
327
+ }
328
+
329
+ return items;
330
+ }
331
+
332
+ private addConfigurationItems(items: QuickPickInput<QuickPickItemOrSeparator>[], configs: TaskConfiguration[], token: number, isMulti: boolean): void {
333
+ items.push(
334
+ ...configs.map(taskConfig => {
335
+ const item = new TaskConfigureQuickOpenItem(
336
+ token,
337
+ taskConfig,
338
+ this.taskService,
339
+ this.taskNameResolver,
340
+ this.workspaceService,
341
+ isMulti
342
+ );
343
+ item['taskDefinitionRegistry'] = this.taskDefinitionRegistry;
344
+ return item;
345
+ }).sort((t1, t2) =>
346
+ t1.label.localeCompare(t2.label)
347
+ )
348
+ );
349
+ }
350
+
351
+ protected getTaskItems(): QuickPickItem[] {
352
+ return this.items.filter((item): item is QuickPickItem => item.type !== 'separator' && (item as TaskRunQuickOpenItem).task !== undefined);
353
+ }
354
+
355
+ async runBuildOrTestTask(buildOrTestType: 'build' | 'test'): Promise<void> {
356
+ const shouldRunBuildTask = buildOrTestType === 'build';
357
+ const token: number = this.taskService.startUserAction();
358
+
359
+ await this.doInit(token);
360
+
361
+ const taskItems = this.getTaskItems();
362
+
363
+ if (taskItems.length > 0) { // the item in `this.items` is not 'No tasks found'
364
+ const buildOrTestTasks = taskItems.filter((t: TaskRunQuickOpenItem) =>
365
+ shouldRunBuildTask ? TaskCustomization.isBuildTask(t.task) : TaskCustomization.isTestTask(t.task)
366
+ );
367
+ if (buildOrTestTasks.length > 0) { // build / test tasks are defined in the workspace
368
+ const defaultBuildOrTestTasks = buildOrTestTasks.filter((t: TaskRunQuickOpenItem) =>
369
+ shouldRunBuildTask ? TaskCustomization.isDefaultBuildTask(t.task) : TaskCustomization.isDefaultTestTask(t.task)
370
+ );
371
+ if (defaultBuildOrTestTasks.length === 1) { // run the default build / test task
372
+ const defaultBuildOrTestTask = defaultBuildOrTestTasks[0];
373
+ const taskToRun = (defaultBuildOrTestTask as TaskRunQuickOpenItem).task;
374
+ const scope = taskToRun._scope;
375
+
376
+ if (this.taskDefinitionRegistry && !!this.taskDefinitionRegistry.getDefinition(taskToRun)) {
377
+ this.taskService.run(token, taskToRun.source, taskToRun.label, scope);
378
+ } else {
379
+ this.taskService.run(token, taskToRun._source, taskToRun.label, scope);
380
+ }
381
+ return;
382
+ }
383
+ // if default build / test task is not found, or there are more than one default,
384
+ // display the list of build /test tasks to let the user decide which to run
385
+ this.items = buildOrTestTasks;
386
+ } else { // no build / test tasks, display an action item to configure the build / test task
387
+ this.items = [({
388
+ label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType.charAt(0).toUpperCase() + buildOrTestType.slice(1)} Task...`,
389
+ execute: () => {
390
+ this.doInit(token).then(() => {
391
+ // update the `tasks.json` file, instead of running the task itself
392
+ this.items = this.getTaskItems().map((item: TaskRunQuickOpenItem) => new ConfigureBuildOrTestTaskQuickOpenItem(
393
+ token,
394
+ item.task,
395
+ this.taskService,
396
+ this.workspaceService.isMultiRootWorkspaceOpened,
397
+ this.taskNameResolver,
398
+ shouldRunBuildTask,
399
+ this.taskConfigurationManager,
400
+ this.taskDefinitionRegistry,
401
+ this.taskSourceResolver
402
+ ));
403
+ this.quickInputService?.showQuickPick(this.items, { placeholder: `Select the task to be used as the default ${buildOrTestType} task` });
404
+ });
405
+ }
406
+ })];
407
+ }
408
+ } else { // no tasks are currently present, prompt users if they'd like to configure a task.
409
+ this.items = [{
410
+ label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType.charAt(0).toUpperCase() + buildOrTestType.slice(1)} Task...`,
411
+ execute: () => this.configure()
412
+ }];
413
+ }
414
+
415
+ this.quickInputService?.showQuickPick(this.items, {
416
+ placeholder: `Select the ${buildOrTestType} task to run`,
417
+ onDidTriggerItemButton: ({ item }) => this.onDidTriggerGearIcon(item)
418
+ });
419
+ }
420
+
421
+ async getPicks(filter: string, token: CancellationToken): Promise<QuickPicks> {
422
+ await this.init();
423
+ return filterItems(this.items, filter);
424
+ }
425
+
426
+ registerQuickAccessProvider(): void {
427
+ this.quickAccessRegistry.registerQuickAccessProvider({
428
+ getInstance: () => this,
429
+ prefix: QuickOpenTask.PREFIX,
430
+ placeholder: 'Select the task to run',
431
+ helpEntries: [{ description: 'Run Task', needsEditor: false }]
432
+ });
433
+ }
434
+
435
+ protected getRunningTaskLabel(task: TaskInfo): string {
436
+ return `Task id: ${task.taskId}, label: ${task.config.label}`;
437
+ }
438
+
439
+ private getItems(tasks: TaskConfiguration[], groupLabel: string, token: number, isMulti: boolean, defaultTask?: TaskEntry):
440
+ TaskEntry[] {
441
+ const items: TaskEntry[] = tasks.map(task =>
442
+ new TaskRunQuickOpenItem(token, task, this.taskService, isMulti, this.taskDefinitionRegistry, this.taskNameResolver,
443
+ this.taskSourceResolver, this.taskConfigurationManager, [{
444
+ iconClass: 'codicon-gear',
445
+ tooltip: 'Configure Task',
446
+ }])
447
+ ).sort((t1, t2) => {
448
+ let result = (t1.description ?? '').localeCompare(t2.description ?? '');
449
+ if (result === 0) {
450
+ result = t1.label.localeCompare(t2.label);
451
+ }
452
+ return result;
453
+ });
454
+
455
+ if (items.length === 0 && defaultTask) {
456
+ items.push(defaultTask);
457
+ }
458
+
459
+ if (items.length > 0) {
460
+ items.unshift({ type: 'separator', label: groupLabel });
461
+ }
462
+ return items;
463
+ }
464
+
465
+ private getFilteredTasks(recentTasks: TaskConfiguration[], configuredTasks: TaskConfiguration[], providedTasks: TaskConfiguration[]): {
466
+ filteredRecentTasks: TaskConfiguration[], filteredConfiguredTasks: TaskConfiguration[], filteredProvidedTasks: TaskConfiguration[]
467
+ } {
468
+
469
+ const filteredRecentTasks: TaskConfiguration[] = [];
470
+ recentTasks.forEach(recent => {
471
+ const originalTaskConfig = [...configuredTasks, ...providedTasks].find(t => this.taskDefinitionRegistry.compareTasks(recent, t));
472
+ if (originalTaskConfig) {
473
+ filteredRecentTasks.push(originalTaskConfig);
474
+ }
475
+ });
476
+
477
+ const filteredProvidedTasks: TaskConfiguration[] = [];
478
+ providedTasks.forEach(provided => {
479
+ const exist = [...filteredRecentTasks, ...configuredTasks].some(t => this.taskDefinitionRegistry.compareTasks(provided, t));
480
+ if (!exist) {
481
+ filteredProvidedTasks.push(provided);
482
+ }
483
+ });
484
+
485
+ const filteredConfiguredTasks: TaskConfiguration[] = [];
486
+ configuredTasks.forEach(configured => {
487
+ const exist = filteredRecentTasks.some(t => this.taskDefinitionRegistry.compareTasks(configured, t));
488
+ if (!exist) {
489
+ filteredConfiguredTasks.push(configured);
490
+ }
491
+ });
492
+
493
+ return {
494
+ filteredRecentTasks, filteredConfiguredTasks, filteredProvidedTasks
495
+ };
496
+ }
497
+
498
+ private getGroupedTasksByWorkspaceFolder(tasks: TaskConfiguration[]): Map<string, TaskConfiguration[]> {
499
+ const grouped = new Map<string, TaskConfiguration[]>();
500
+ for (const task of tasks) {
501
+ const scope = task._scope;
502
+ if (grouped.has(scope.toString())) {
503
+ grouped.get(scope.toString())!.push(task);
504
+ } else {
505
+ grouped.set(scope.toString(), [task]);
506
+ }
507
+ }
508
+ for (const taskConfigs of grouped.values()) {
509
+ taskConfigs.sort((t1, t2) => t1.label.localeCompare(t2.label));
510
+ }
511
+ return grouped;
512
+ }
513
+ }
514
+
515
+ export class TaskRunQuickOpenItem implements QuickPickItem {
516
+ constructor(
517
+ readonly token: number,
518
+ readonly task: TaskConfiguration,
519
+ protected taskService: TaskService,
520
+ protected isMulti: boolean,
521
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry,
522
+ protected readonly taskNameResolver: TaskNameResolver,
523
+ protected readonly taskSourceResolver: TaskSourceResolver,
524
+ protected taskConfigurationManager: TaskConfigurationManager,
525
+ readonly buttons?: Array<QuickInputButton>
526
+ ) { }
527
+
528
+ get label(): string {
529
+ return this.taskNameResolver.resolve(this.task);
530
+ }
531
+
532
+ get description(): string {
533
+ return renderScope(this.task._scope, this.isMulti);
534
+ }
535
+
536
+ get detail(): string | undefined {
537
+ return this.task.detail;
538
+ }
539
+
540
+ execute(): void {
541
+ const scope = this.task._scope;
542
+ if (this.taskDefinitionRegistry && !!this.taskDefinitionRegistry.getDefinition(this.task)) {
543
+ this.taskService.run(this.token, this.task.source || this.task._source, this.task.label, scope);
544
+ } else {
545
+ this.taskService.run(this.token, this.task._source, this.task.label, scope);
546
+ }
547
+ }
548
+
549
+ trigger(): TriggerAction {
550
+ this.taskService.configure(this.token, this.task);
551
+ return TriggerAction.CLOSE_PICKER;
552
+ }
553
+ }
554
+
555
+ export class ConfigureBuildOrTestTaskQuickOpenItem extends TaskRunQuickOpenItem {
556
+ constructor(
557
+ token: number,
558
+ task: TaskConfiguration,
559
+ taskService: TaskService,
560
+ isMulti: boolean,
561
+ taskNameResolver: TaskNameResolver,
562
+ protected readonly isBuildTask: boolean,
563
+ taskConfigurationManager: TaskConfigurationManager,
564
+ taskDefinitionRegistry: TaskDefinitionRegistry,
565
+ taskSourceResolver: TaskSourceResolver
566
+ ) {
567
+ super(token, task, taskService, isMulti, taskDefinitionRegistry, taskNameResolver, taskSourceResolver, taskConfigurationManager);
568
+ }
569
+
570
+ override execute(): void {
571
+ this.taskService.updateTaskConfiguration(this.token, this.task, { group: { kind: this.isBuildTask ? 'build' : 'test', isDefault: true } })
572
+ .then(() => {
573
+ if (this.task._scope) {
574
+ this.taskConfigurationManager.openConfiguration(this.task._scope);
575
+ }
576
+ });
577
+ }
578
+ }
579
+
580
+ function renderScope(scope: TaskConfigurationScope, isMulti: boolean): string {
581
+ if (typeof scope === 'string') {
582
+ if (isMulti) {
583
+ return new URI(scope).displayName;
584
+ } else {
585
+ return '';
586
+ }
587
+ } else {
588
+ return TaskScope[scope];
589
+ }
590
+ }
591
+
592
+ export class TaskConfigureQuickOpenItem implements QuickPickItem {
593
+
594
+ protected taskDefinitionRegistry: TaskDefinitionRegistry;
595
+
596
+ constructor(
597
+ protected readonly token: number,
598
+ protected readonly task: TaskConfiguration,
599
+ protected readonly taskService: TaskService,
600
+ protected readonly taskNameResolver: TaskNameResolver,
601
+ protected readonly workspaceService: WorkspaceService,
602
+ protected readonly isMulti: boolean
603
+ ) {
604
+ const stat = this.workspaceService.workspace;
605
+ this.isMulti = stat ? !stat.isDirectory : false;
606
+ }
607
+
608
+ get label(): string {
609
+ return this.taskNameResolver.resolve(this.task);
610
+ }
611
+
612
+ get description(): string {
613
+ return renderScope(this.task._scope, this.isMulti);
614
+ }
615
+
616
+ accept(): void {
617
+ this.execute();
618
+ }
619
+
620
+ execute(): void {
621
+ this.taskService.configure(this.token, this.task);
622
+ }
623
+ }
624
+
625
+ @injectable()
626
+ export class TaskTerminateQuickOpen {
627
+
628
+ @inject(LabelProvider)
629
+ protected readonly labelProvider: LabelProvider;
630
+
631
+ @inject(QuickInputService) @optional()
632
+ protected readonly quickInputService: QuickInputService;
633
+
634
+ @inject(TaskDefinitionRegistry)
635
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
636
+
637
+ @inject(TaskNameResolver)
638
+ protected readonly taskNameResolver: TaskNameResolver;
639
+
640
+ @inject(TaskSourceResolver)
641
+ protected readonly taskSourceResolver: TaskSourceResolver;
642
+
643
+ @inject(TaskService)
644
+ protected readonly taskService: TaskService;
645
+
646
+ @inject(WorkspaceService)
647
+ protected readonly workspaceService: WorkspaceService;
648
+
649
+ async getItems(): Promise<Array<QuickPickItem>> {
650
+ const items: Array<QuickPickItem> = [];
651
+ const runningTasks: TaskInfo[] = await this.taskService.getRunningTasks();
652
+ const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
653
+ if (runningTasks.length <= 0) {
654
+ items.push(({
655
+ label: 'No task is currently running',
656
+ }));
657
+ } else {
658
+ runningTasks.forEach((task: TaskInfo) => {
659
+ items.push(new RunningTaskQuickOpenItem(
660
+ task,
661
+ this.taskService,
662
+ this.taskNameResolver,
663
+ this.taskSourceResolver,
664
+ this.taskDefinitionRegistry,
665
+ this.labelProvider,
666
+ isMulti,
667
+ () => this.taskService.kill(task.taskId)
668
+ ));
669
+ });
670
+ if (runningTasks.length > 1) {
671
+ items.push(({
672
+ label: 'All running tasks',
673
+ execute: () => {
674
+ runningTasks.forEach((t: TaskInfo) => {
675
+ this.taskService.kill(t.taskId);
676
+ });
677
+ }
678
+ }));
679
+ }
680
+ }
681
+ return items;
682
+ }
683
+
684
+ async open(): Promise<void> {
685
+ const items = await this.getItems();
686
+ this.quickInputService?.showQuickPick(items, { placeholder: 'Select task to terminate' });
687
+ }
688
+ }
689
+
690
+ @injectable()
691
+ export class TaskRunningQuickOpen {
692
+ @inject(LabelProvider)
693
+ protected readonly labelProvider: LabelProvider;
694
+
695
+ @inject(QuickInputService) @optional()
696
+ protected readonly quickInputService: QuickInputService;
697
+
698
+ @inject(TaskDefinitionRegistry)
699
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
700
+
701
+ @inject(TaskNameResolver)
702
+ protected readonly taskNameResolver: TaskNameResolver;
703
+
704
+ @inject(TaskSourceResolver)
705
+ protected readonly taskSourceResolver: TaskSourceResolver;
706
+
707
+ @inject(TaskService)
708
+ protected readonly taskService: TaskService;
709
+
710
+ @inject(WorkspaceService)
711
+ protected readonly workspaceService: WorkspaceService;
712
+
713
+ @inject(TerminalService)
714
+ protected readonly terminalService: TerminalService;
715
+
716
+ async getItems(): Promise<Array<QuickPickItem>> {
717
+ const items: Array<QuickPickItem> = [];
718
+ const runningTasks: TaskInfo[] = await this.taskService.getRunningTasks();
719
+ const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
720
+ if (runningTasks.length <= 0) {
721
+ items.push(({
722
+ label: 'No task is currently running',
723
+ }));
724
+ } else {
725
+ runningTasks.forEach((task: TaskInfo) => {
726
+ items.push(new RunningTaskQuickOpenItem(
727
+ task,
728
+ this.taskService,
729
+ this.taskNameResolver,
730
+ this.taskSourceResolver,
731
+ this.taskDefinitionRegistry,
732
+ this.labelProvider,
733
+ isMulti,
734
+ () => {
735
+ if (task.terminalId) {
736
+ const terminal = this.terminalService.getByTerminalId(task.terminalId);
737
+ if (terminal) {
738
+ this.terminalService.open(terminal);
739
+ }
740
+ }
741
+ }
742
+ ));
743
+ });
744
+ }
745
+ return items;
746
+ }
747
+
748
+ async open(): Promise<void> {
749
+ const items = await this.getItems();
750
+ this.quickInputService?.showQuickPick(items, { placeholder: 'Select the task to show its output' });
751
+ }
752
+ }
753
+
754
+ export class RunningTaskQuickOpenItem implements QuickPickItem {
755
+ constructor(
756
+ protected readonly taskInfo: TaskInfo,
757
+ protected readonly taskService: TaskService,
758
+ protected readonly taskNameResolver: TaskNameResolver,
759
+ protected readonly taskSourceResolver: TaskSourceResolver,
760
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry,
761
+ protected readonly labelProvider: LabelProvider,
762
+ protected readonly isMulti: boolean,
763
+ public readonly execute: () => void,
764
+ ) { }
765
+
766
+ get label(): string {
767
+ return this.taskNameResolver.resolve(this.taskInfo.config);
768
+ }
769
+
770
+ get description(): string {
771
+ return renderScope(this.taskInfo.config._scope, this.isMulti);
772
+ }
773
+
774
+ get detail(): string | undefined {
775
+ return this.taskInfo.config.detail;
776
+ }
777
+ }
778
+
779
+ @injectable()
780
+ export class TaskRestartRunningQuickOpen {
781
+ @inject(LabelProvider)
782
+ protected readonly labelProvider: LabelProvider;
783
+
784
+ @inject(QuickInputService) @optional()
785
+ protected readonly quickInputService: QuickInputService;
786
+
787
+ @inject(TaskDefinitionRegistry)
788
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
789
+
790
+ @inject(TaskNameResolver)
791
+ protected readonly taskNameResolver: TaskNameResolver;
792
+
793
+ @inject(TaskSourceResolver)
794
+ protected readonly taskSourceResolver: TaskSourceResolver;
795
+
796
+ @inject(TaskService)
797
+ protected readonly taskService: TaskService;
798
+
799
+ @inject(WorkspaceService)
800
+ protected readonly workspaceService: WorkspaceService;
801
+
802
+ async getItems(): Promise<Array<QuickPickItem>> {
803
+ const items: Array<QuickPickItem> = [];
804
+ const runningTasks: TaskInfo[] = await this.taskService.getRunningTasks();
805
+ const isMulti: boolean = this.workspaceService.isMultiRootWorkspaceOpened;
806
+ if (runningTasks.length <= 0) {
807
+ items.push({
808
+ label: 'No task to restart'
809
+ });
810
+ } else {
811
+ runningTasks.forEach((task: TaskInfo) => {
812
+ items.push(new RunningTaskQuickOpenItem(
813
+ task,
814
+ this.taskService,
815
+ this.taskNameResolver,
816
+ this.taskSourceResolver,
817
+ this.taskDefinitionRegistry,
818
+ this.labelProvider,
819
+ isMulti,
820
+ () => this.taskService.restartTask(task)
821
+ ));
822
+ });
823
+ }
824
+ return items;
825
+ }
826
+
827
+ async open(): Promise<void> {
828
+ const items = await this.getItems();
829
+ this.quickInputService?.showQuickPick(items, { placeholder: 'Select task to restart' });
830
+ }
831
+ }