@theia/task 1.34.2 → 1.34.3

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 (169) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +193 -193
  3. package/lib/browser/index.d.ts +6 -6
  4. package/lib/browser/index.js +33 -33
  5. package/lib/browser/process/process-task-contribution.d.ts +6 -6
  6. package/lib/browser/process/process-task-contribution.js +43 -43
  7. package/lib/browser/process/process-task-frontend-module.d.ts +2 -2
  8. package/lib/browser/process/process-task-frontend-module.js +27 -27
  9. package/lib/browser/process/process-task-resolver.d.ts +17 -17
  10. package/lib/browser/process/process-task-resolver.js +93 -93
  11. package/lib/browser/provided-task-configurations.d.ts +32 -32
  12. package/lib/browser/provided-task-configurations.js +171 -171
  13. package/lib/browser/provided-task-configurations.spec.d.ts +1 -1
  14. package/lib/browser/provided-task-configurations.spec.js +43 -43
  15. package/lib/browser/quick-open-task.d.ts +129 -129
  16. package/lib/browser/quick-open-task.js +636 -636
  17. package/lib/browser/task-configuration-manager.d.ts +64 -64
  18. package/lib/browser/task-configuration-manager.js +261 -261
  19. package/lib/browser/task-configuration-model.d.ts +32 -32
  20. package/lib/browser/task-configuration-model.js +79 -79
  21. package/lib/browser/task-configurations.d.ts +127 -127
  22. package/lib/browser/task-configurations.js +479 -479
  23. package/lib/browser/task-contribution.d.ts +173 -173
  24. package/lib/browser/task-contribution.js +199 -199
  25. package/lib/browser/task-definition-registry.d.ts +38 -38
  26. package/lib/browser/task-definition-registry.js +131 -131
  27. package/lib/browser/task-definition-registry.spec.d.ts +1 -1
  28. package/lib/browser/task-definition-registry.spec.js +170 -170
  29. package/lib/browser/task-frontend-contribution.d.ts +56 -56
  30. package/lib/browser/task-frontend-contribution.js +353 -353
  31. package/lib/browser/task-frontend-module.d.ts +5 -5
  32. package/lib/browser/task-frontend-module.js +79 -79
  33. package/lib/browser/task-name-resolver.d.ts +13 -13
  34. package/lib/browser/task-name-resolver.js +65 -65
  35. package/lib/browser/task-node.d.ts +9 -9
  36. package/lib/browser/task-node.js +17 -17
  37. package/lib/browser/task-preferences.d.ts +4 -4
  38. package/lib/browser/task-preferences.js +40 -40
  39. package/lib/browser/task-problem-matcher-registry.d.ts +40 -40
  40. package/lib/browser/task-problem-matcher-registry.js +310 -310
  41. package/lib/browser/task-problem-pattern-registry.d.ts +23 -23
  42. package/lib/browser/task-problem-pattern-registry.js +208 -208
  43. package/lib/browser/task-schema-updater.d.ts +58 -58
  44. package/lib/browser/task-schema-updater.js +672 -672
  45. package/lib/browser/task-service.d.ts +276 -276
  46. package/lib/browser/task-service.js +1119 -1119
  47. package/lib/browser/task-source-resolver.d.ts +9 -9
  48. package/lib/browser/task-source-resolver.js +51 -51
  49. package/lib/browser/task-templates.d.ts +13 -13
  50. package/lib/browser/task-templates.js +161 -161
  51. package/lib/browser/task-terminal-widget-manager.d.ts +44 -44
  52. package/lib/browser/task-terminal-widget-manager.js +224 -224
  53. package/lib/browser/tasks-monaco-contribution.d.ts +1 -1
  54. package/lib/browser/tasks-monaco-contribution.js +27 -27
  55. package/lib/common/index.d.ts +3 -3
  56. package/lib/common/index.js +30 -30
  57. package/lib/common/problem-matcher-protocol.d.ts +124 -124
  58. package/lib/common/problem-matcher-protocol.js +132 -132
  59. package/lib/common/process/task-protocol.d.ts +68 -68
  60. package/lib/common/process/task-protocol.js +33 -33
  61. package/lib/common/task-common-module.d.ts +7 -7
  62. package/lib/common/task-common-module.js +33 -33
  63. package/lib/common/task-protocol.d.ts +190 -190
  64. package/lib/common/task-protocol.js +125 -125
  65. package/lib/common/task-watcher.d.ts +17 -17
  66. package/lib/common/task-watcher.js +86 -86
  67. package/lib/node/custom/custom-task-runner-backend-module.d.ts +2 -2
  68. package/lib/node/custom/custom-task-runner-backend-module.js +36 -36
  69. package/lib/node/custom/custom-task-runner-contribution.d.ts +6 -6
  70. package/lib/node/custom/custom-task-runner-contribution.js +42 -42
  71. package/lib/node/custom/custom-task-runner.d.ts +15 -15
  72. package/lib/node/custom/custom-task-runner.js +69 -69
  73. package/lib/node/custom/custom-task.d.ts +20 -20
  74. package/lib/node/custom/custom-task.js +78 -78
  75. package/lib/node/index.d.ts +3 -3
  76. package/lib/node/index.js +30 -30
  77. package/lib/node/process/process-task-runner-backend-module.d.ts +2 -2
  78. package/lib/node/process/process-task-runner-backend-module.js +36 -36
  79. package/lib/node/process/process-task-runner-contribution.d.ts +6 -6
  80. package/lib/node/process/process-task-runner-contribution.js +43 -43
  81. package/lib/node/process/process-task-runner.d.ts +60 -60
  82. package/lib/node/process/process-task-runner.js +352 -352
  83. package/lib/node/process/process-task.d.ts +26 -26
  84. package/lib/node/process/process-task.js +139 -139
  85. package/lib/node/process/process-task.spec.d.ts +1 -1
  86. package/lib/node/process/process-task.spec.js +29 -29
  87. package/lib/node/task-abstract-line-matcher.d.ts +49 -49
  88. package/lib/node/task-abstract-line-matcher.js +278 -278
  89. package/lib/node/task-backend-application-contribution.d.ts +8 -8
  90. package/lib/node/task-backend-application-contribution.js +48 -48
  91. package/lib/node/task-backend-module.d.ts +3 -3
  92. package/lib/node/task-backend-module.js +50 -50
  93. package/lib/node/task-line-matchers.d.ts +27 -27
  94. package/lib/node/task-line-matchers.js +121 -121
  95. package/lib/node/task-manager.d.ts +55 -55
  96. package/lib/node/task-manager.js +135 -135
  97. package/lib/node/task-problem-collector.d.ts +10 -10
  98. package/lib/node/task-problem-collector.js +57 -57
  99. package/lib/node/task-problem-collector.spec.d.ts +1 -1
  100. package/lib/node/task-problem-collector.spec.js +310 -310
  101. package/lib/node/task-runner-protocol.d.ts +16 -16
  102. package/lib/node/task-runner-protocol.js +19 -19
  103. package/lib/node/task-runner.d.ts +50 -50
  104. package/lib/node/task-runner.js +97 -97
  105. package/lib/node/task-server.d.ts +39 -39
  106. package/lib/node/task-server.js +237 -237
  107. package/lib/node/task-server.slow-spec.d.ts +1 -1
  108. package/lib/node/task-server.slow-spec.js +395 -395
  109. package/lib/node/task.d.ts +50 -50
  110. package/lib/node/task.js +77 -77
  111. package/lib/node/test/task-test-container.d.ts +2 -2
  112. package/lib/node/test/task-test-container.js +58 -58
  113. package/package.json +13 -13
  114. package/src/browser/index.ts +22 -22
  115. package/src/browser/process/process-task-contribution.ts +31 -31
  116. package/src/browser/process/process-task-frontend-module.ts +27 -27
  117. package/src/browser/process/process-task-resolver.ts +89 -89
  118. package/src/browser/provided-task-configurations.spec.ts +46 -46
  119. package/src/browser/provided-task-configurations.ts +170 -170
  120. package/src/browser/quick-open-task.ts +701 -701
  121. package/src/browser/style/index.css +19 -19
  122. package/src/browser/task-configuration-manager.ts +256 -256
  123. package/src/browser/task-configuration-model.ts +101 -101
  124. package/src/browser/task-configurations.ts +507 -507
  125. package/src/browser/task-contribution.ts +254 -254
  126. package/src/browser/task-definition-registry.spec.ts +203 -203
  127. package/src/browser/task-definition-registry.ts +128 -128
  128. package/src/browser/task-frontend-contribution.ts +396 -396
  129. package/src/browser/task-frontend-module.ts +86 -86
  130. package/src/browser/task-name-resolver.ts +55 -55
  131. package/src/browser/task-node.ts +37 -37
  132. package/src/browser/task-preferences.ts +40 -40
  133. package/src/browser/task-problem-matcher-registry.ts +308 -308
  134. package/src/browser/task-problem-pattern-registry.ts +195 -195
  135. package/src/browser/task-schema-updater.ts +703 -703
  136. package/src/browser/task-service.ts +1163 -1163
  137. package/src/browser/task-source-resolver.ts +36 -36
  138. package/src/browser/task-templates.ts +168 -168
  139. package/src/browser/task-terminal-widget-manager.ts +221 -221
  140. package/src/browser/tasks-monaco-contribution.ts +27 -27
  141. package/src/common/index.ts +19 -19
  142. package/src/common/problem-matcher-protocol.ts +235 -235
  143. package/src/common/process/task-protocol.ts +97 -97
  144. package/src/common/task-common-module.ts +34 -34
  145. package/src/common/task-protocol.ts +310 -310
  146. package/src/common/task-watcher.ts +78 -78
  147. package/src/node/custom/custom-task-runner-backend-module.ts +37 -37
  148. package/src/node/custom/custom-task-runner-contribution.ts +30 -30
  149. package/src/node/custom/custom-task-runner.ts +60 -60
  150. package/src/node/custom/custom-task.ts +73 -73
  151. package/src/node/index.ts +19 -19
  152. package/src/node/process/process-task-runner-backend-module.ts +37 -37
  153. package/src/node/process/process-task-runner-contribution.ts +31 -31
  154. package/src/node/process/process-task-runner.ts +371 -371
  155. package/src/node/process/process-task.spec.ts +30 -30
  156. package/src/node/process/process-task.ts +147 -147
  157. package/src/node/task-abstract-line-matcher.ts +317 -317
  158. package/src/node/task-backend-application-contribution.ts +36 -36
  159. package/src/node/task-backend-module.ts +57 -57
  160. package/src/node/task-line-matchers.ts +127 -127
  161. package/src/node/task-manager.ts +129 -129
  162. package/src/node/task-problem-collector.spec.ts +338 -338
  163. package/src/node/task-problem-collector.ts +62 -62
  164. package/src/node/task-runner-protocol.ts +33 -33
  165. package/src/node/task-runner.ts +96 -96
  166. package/src/node/task-server.slow-spec.ts +444 -444
  167. package/src/node/task-server.ts +263 -263
  168. package/src/node/task.ts +103 -103
  169. package/src/node/test/task-test-container.ts +63 -63
@@ -1,1120 +1,1120 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 Ericsson and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.TaskService = exports.TaskEndedTypes = void 0;
28
- const browser_1 = require("@theia/core/lib/browser");
29
- const opener_service_1 = require("@theia/core/lib/browser/opener-service");
30
- const common_1 = require("@theia/core/lib/common");
31
- const message_service_1 = require("@theia/core/lib/common/message-service");
32
- const promise_util_1 = require("@theia/core/lib/common/promise-util");
33
- const quick_pick_service_1 = require("@theia/core/lib/common/quick-pick-service");
34
- const label_provider_1 = require("@theia/core/lib/browser/label-provider");
35
- const uri_1 = require("@theia/core/lib/common/uri");
36
- const browser_2 = require("@theia/editor/lib/browser");
37
- const problem_manager_1 = require("@theia/markers/lib/browser/problem/problem-manager");
38
- const terminal_service_1 = require("@theia/terminal/lib/browser/base/terminal-service");
39
- const browser_3 = require("@theia/variable-resolver/lib/browser");
40
- const workspace_service_1 = require("@theia/workspace/lib/browser/workspace-service");
41
- const inversify_1 = require("@theia/core/shared/inversify");
42
- const vscode_languageserver_protocol_1 = require("@theia/core/shared/vscode-languageserver-protocol");
43
- const common_2 = require("../common");
44
- const task_watcher_1 = require("../common/task-watcher");
45
- const provided_task_configurations_1 = require("./provided-task-configurations");
46
- const task_configurations_1 = require("./task-configurations");
47
- const task_contribution_1 = require("./task-contribution");
48
- const task_definition_registry_1 = require("./task-definition-registry");
49
- const task_name_resolver_1 = require("./task-name-resolver");
50
- const task_source_resolver_1 = require("./task-source-resolver");
51
- const task_problem_matcher_registry_1 = require("./task-problem-matcher-registry");
52
- const task_schema_updater_1 = require("./task-schema-updater");
53
- const task_configuration_manager_1 = require("./task-configuration-manager");
54
- const problem_widget_1 = require("@theia/markers/lib/browser/problem/problem-widget");
55
- const task_node_1 = require("./task-node");
56
- const monaco_workspace_1 = require("@theia/monaco/lib/browser/monaco-workspace");
57
- const task_terminal_widget_manager_1 = require("./task-terminal-widget-manager");
58
- const shell_terminal_protocol_1 = require("@theia/terminal/lib/common/shell-terminal-protocol");
59
- const async_mutex_1 = require("async-mutex");
60
- var TaskEndedTypes;
61
- (function (TaskEndedTypes) {
62
- TaskEndedTypes[TaskEndedTypes["TaskExited"] = 0] = "TaskExited";
63
- TaskEndedTypes[TaskEndedTypes["BackgroundTaskEnded"] = 1] = "BackgroundTaskEnded";
64
- })(TaskEndedTypes = exports.TaskEndedTypes || (exports.TaskEndedTypes = {}));
65
- let TaskService = class TaskService {
66
- constructor() {
67
- /**
68
- * The last executed task.
69
- */
70
- this.lastTask = { resolvedTask: undefined, option: undefined };
71
- this.cachedRecentTasks = [];
72
- this.runningTasks = new Map();
73
- this.taskStartingLock = new async_mutex_1.Mutex();
74
- }
75
- init() {
76
- this.getRunningTasks().then(tasks => tasks.forEach(task => {
77
- if (!this.runningTasks.has(task.taskId)) {
78
- this.runningTasks.set(task.taskId, {
79
- exitCode: new promise_util_1.Deferred(), terminateSignal: new promise_util_1.Deferred(),
80
- isBackgroundTaskEnded: new promise_util_1.Deferred()
81
- });
82
- }
83
- }));
84
- // notify user that task has started
85
- this.taskWatcher.onTaskCreated((event) => {
86
- if (!this.isEventForThisClient(event.ctx)) {
87
- return;
88
- }
89
- this.runningTasks.set(event.taskId, {
90
- exitCode: new promise_util_1.Deferred(),
91
- terminateSignal: new promise_util_1.Deferred(),
92
- isBackgroundTaskEnded: new promise_util_1.Deferred()
93
- });
94
- });
95
- this.taskWatcher.onOutputProcessed(async (event) => {
96
- if (!this.isEventForThisClient(event.ctx)) {
97
- return;
98
- }
99
- if (event.problems) {
100
- const runningTasksInfo = await this.getRunningTasks();
101
- // check if the task is active
102
- const matchedRunningTaskInfo = runningTasksInfo.find(taskInfo => {
103
- const taskConfig = taskInfo.config;
104
- return this.taskDefinitionRegistry.compareTasks(taskConfig, event.config);
105
- });
106
- const isTaskActiveAndOutputSilent = matchedRunningTaskInfo &&
107
- matchedRunningTaskInfo.config.presentation && matchedRunningTaskInfo.config.presentation.reveal === common_2.RevealKind.Silent;
108
- event.problems.forEach(problem => {
109
- const existingMarkers = this.problemManager.findMarkers({ owner: problem.description.owner });
110
- const uris = new Set();
111
- existingMarkers.forEach(marker => uris.add(marker.uri));
112
- if (common_2.ProblemMatchData.is(problem) && problem.resource) {
113
- // When task.presentation.reveal === RevealKind.Silent, put focus on the terminal only if it is an error
114
- if (isTaskActiveAndOutputSilent && problem.marker.severity === vscode_languageserver_protocol_1.DiagnosticSeverity.Error) {
115
- const terminalId = matchedRunningTaskInfo.terminalId;
116
- if (terminalId) {
117
- const terminal = this.terminalService.getByTerminalId(terminalId);
118
- if (terminal) {
119
- const focus = !!matchedRunningTaskInfo.config.presentation.focus;
120
- if (focus) { // assign focus to the terminal if presentation.focus is true
121
- this.terminalService.open(terminal, { mode: 'activate' });
122
- }
123
- else { // show the terminal but not assign focus
124
- this.terminalService.open(terminal, { mode: 'reveal' });
125
- }
126
- }
127
- }
128
- }
129
- const uri = new uri_1.default(problem.resource.path).withScheme(problem.resource.scheme);
130
- const document = this.monacoWorkspace.getTextDocument(uri.toString());
131
- if (problem.description.applyTo === common_2.ApplyToKind.openDocuments && !!document ||
132
- problem.description.applyTo === common_2.ApplyToKind.closedDocuments && !document ||
133
- problem.description.applyTo === common_2.ApplyToKind.allDocuments) {
134
- if (uris.has(uri.toString())) {
135
- const newData = [
136
- ...existingMarkers
137
- .filter(marker => marker.uri === uri.toString())
138
- .map(markerData => markerData.data),
139
- problem.marker
140
- ];
141
- this.problemManager.setMarkers(uri, problem.description.owner, newData);
142
- }
143
- else {
144
- this.problemManager.setMarkers(uri, problem.description.owner, [problem.marker]);
145
- }
146
- }
147
- }
148
- else { // should have received an event for finding the "background task begins" pattern
149
- uris.forEach(uriString => this.problemManager.setMarkers(new uri_1.default(uriString), problem.description.owner, []));
150
- }
151
- });
152
- }
153
- });
154
- this.taskWatcher.onBackgroundTaskEnded((event) => {
155
- if (!this.isEventForThisClient(event.ctx)) {
156
- return;
157
- }
158
- if (!this.runningTasks.has(event.taskId)) {
159
- this.runningTasks.set(event.taskId, {
160
- exitCode: new promise_util_1.Deferred(),
161
- terminateSignal: new promise_util_1.Deferred(),
162
- isBackgroundTaskEnded: new promise_util_1.Deferred()
163
- });
164
- }
165
- this.runningTasks.get(event.taskId).isBackgroundTaskEnded.resolve(true);
166
- });
167
- // notify user that task has finished
168
- this.taskWatcher.onTaskExit((event) => {
169
- if (!this.isEventForThisClient(event.ctx)) {
170
- return;
171
- }
172
- if (!this.runningTasks.has(event.taskId)) {
173
- this.runningTasks.set(event.taskId, {
174
- exitCode: new promise_util_1.Deferred(),
175
- terminateSignal: new promise_util_1.Deferred(),
176
- isBackgroundTaskEnded: new promise_util_1.Deferred()
177
- });
178
- }
179
- this.runningTasks.get(event.taskId).exitCode.resolve(event.code);
180
- this.runningTasks.get(event.taskId).terminateSignal.resolve(event.signal);
181
- setTimeout(() => this.runningTasks.delete(event.taskId), 60 * 1000);
182
- const taskConfig = event.config;
183
- const taskIdentifier = taskConfig ? this.getTaskIdentifier(taskConfig) : event.taskId.toString();
184
- if (event.code !== undefined) {
185
- if (event.code !== 0) {
186
- const eventTaskConfig = event.config;
187
- if (eventTaskConfig && eventTaskConfig.presentation && eventTaskConfig.presentation.reveal === common_2.RevealKind.Silent && event.terminalId) {
188
- const terminal = this.terminalService.getByTerminalId(event.terminalId);
189
- const focus = !!eventTaskConfig.presentation.focus;
190
- if (terminal) {
191
- if (focus) { // assign focus to the terminal if presentation.focus is true
192
- this.terminalService.open(terminal, { mode: 'activate' });
193
- }
194
- else { // show the terminal but not assign focus
195
- this.terminalService.open(terminal, { mode: 'reveal' });
196
- }
197
- }
198
- }
199
- this.messageService.error(`Task '${taskIdentifier}' has exited with code ${event.code}.`);
200
- }
201
- }
202
- else if (event.signal !== undefined) {
203
- this.messageService.info(`Task '${taskIdentifier}' was terminated by signal ${event.signal}.`);
204
- }
205
- else {
206
- console.error('Invalid TaskExitedEvent received, neither code nor signal is set.');
207
- }
208
- });
209
- }
210
- getTaskIdentifier(taskConfig) {
211
- const taskName = this.taskNameResolver.resolve(taskConfig);
212
- const sourceStrUri = this.taskSourceResolver.resolve(taskConfig);
213
- return `${taskName} (${this.labelProvider.getName(new uri_1.default(sourceStrUri))})`;
214
- }
215
- /**
216
- * Client should call this method to indicate that a new user-level action related to tasks has been started,
217
- * like invoking "Run Task..."
218
- * This method returns a token that can be used with various methods in this service.
219
- * As long as a client uses the same token, task providers will only asked once to contribute
220
- * tasks and the set of tasks will be cached. Each time the a new token is used, the cache of
221
- * contributed tasks is cleared.
222
- * @returns a token to be used for task-related actions
223
- */
224
- startUserAction() {
225
- return this.providedTaskConfigurations.startUserAction();
226
- }
227
- /**
228
- * Returns an array of the task configurations configured in tasks.json and provided by the extensions.
229
- * @param token The cache token for the user interaction in progress
230
- */
231
- async getTasks(token) {
232
- const configuredTasks = await this.getConfiguredTasks(token);
233
- const providedTasks = await this.getProvidedTasks(token);
234
- const notCustomizedProvidedTasks = providedTasks.filter(provided => !configuredTasks.some(configured => this.taskDefinitionRegistry.compareTasks(configured, provided)));
235
- return [...configuredTasks, ...notCustomizedProvidedTasks];
236
- }
237
- /**
238
- * Returns an array of the valid task configurations which are configured in tasks.json files
239
- * @param token The cache token for the user interaction in progress
240
- *
241
- */
242
- async getConfiguredTasks(token) {
243
- const invalidTaskConfig = this.taskConfigurations.getInvalidTaskConfigurations()[0];
244
- if (invalidTaskConfig) {
245
- const widget = await this.widgetManager.getOrCreateWidget(problem_widget_1.PROBLEMS_WIDGET_ID);
246
- const isProblemsWidgetVisible = widget && widget.isVisible;
247
- const currentEditorUri = this.editorManager.currentEditor && this.editorManager.currentEditor.editor.getResourceUri();
248
- let isInvalidTaskConfigFileOpen = false;
249
- if (currentEditorUri) {
250
- const folderUri = this.workspaceService.getWorkspaceRootUri(currentEditorUri);
251
- if (folderUri && folderUri.toString() === invalidTaskConfig._scope) {
252
- isInvalidTaskConfigFileOpen = true;
253
- }
254
- }
255
- const warningMessage = 'Invalid task configurations are found. Open tasks.json and find details in the Problems view.';
256
- if (!isProblemsWidgetVisible || !isInvalidTaskConfigFileOpen) {
257
- this.messageService.warn(warningMessage, 'Open').then(actionOpen => {
258
- if (actionOpen) {
259
- if (invalidTaskConfig && invalidTaskConfig._scope) {
260
- this.taskConfigurationManager.openConfiguration(invalidTaskConfig._scope);
261
- }
262
- if (!isProblemsWidgetVisible) {
263
- this.commands.executeCommand('problemsView:toggle');
264
- }
265
- }
266
- });
267
- }
268
- else {
269
- this.messageService.warn(warningMessage);
270
- }
271
- }
272
- const validTaskConfigs = await this.taskConfigurations.getTasks(token);
273
- return validTaskConfigs;
274
- }
275
- /**
276
- * Returns an array of the task configurations which are provided by the extensions.
277
- * @param token The cache token for the user interaction in progress
278
- */
279
- getProvidedTasks(token) {
280
- return this.providedTaskConfigurations.getTasks(token);
281
- }
282
- addRecentTasks(tasks) {
283
- if (Array.isArray(tasks)) {
284
- tasks.forEach(task => this.addRecentTasks(task));
285
- }
286
- else {
287
- const ind = this.cachedRecentTasks.findIndex(recent => this.taskDefinitionRegistry.compareTasks(recent, tasks));
288
- if (ind >= 0) {
289
- this.cachedRecentTasks.splice(ind, 1);
290
- }
291
- this.cachedRecentTasks.unshift(tasks);
292
- }
293
- }
294
- get recentTasks() {
295
- return this.cachedRecentTasks;
296
- }
297
- set recentTasks(recent) {
298
- this.cachedRecentTasks = recent;
299
- }
300
- /**
301
- * Clears the list of recently used tasks.
302
- */
303
- clearRecentTasks() {
304
- this.cachedRecentTasks = [];
305
- }
306
- /**
307
- * Open user ser
308
- */
309
- openUserTasks() {
310
- return this.taskConfigurations.openUserTasks();
311
- }
312
- /**
313
- * Returns a task configuration provided by an extension by task source, scope and label.
314
- * If there are no task configuration, returns undefined.
315
- * @param token The cache token for the user interaction in progress
316
- * @param source The source for configured tasks
317
- * @param label The label of the task to find
318
- * @param scope The task scope to look in
319
- */
320
- async getProvidedTask(token, source, label, scope) {
321
- return this.providedTaskConfigurations.getTask(token, source, label, scope);
322
- }
323
- /** Returns an array of running tasks 'TaskInfo' objects */
324
- getRunningTasks() {
325
- return this.taskServer.getTasks(this.getContext());
326
- }
327
- async customExecutionComplete(id, exitCode) {
328
- return this.taskServer.customExecutionComplete(id, exitCode);
329
- }
330
- /** Returns an array of task types that are registered, including the default types */
331
- getRegisteredTaskTypes() {
332
- return this.taskSchemaUpdater.getRegisteredTaskTypes();
333
- }
334
- /**
335
- * Get the last executed task.
336
- *
337
- * @returns the last executed task or `undefined`.
338
- */
339
- getLastTask() {
340
- return this.lastTask;
341
- }
342
- /**
343
- * Runs a task, by task configuration label.
344
- * Note, it looks for a task configured in tasks.json only.
345
- * @param token The cache token for the user interaction in progress
346
- * @param scope The scope where to look for tasks
347
- * @param taskLabel the label to look for
348
- */
349
- async runConfiguredTask(token, scope, taskLabel) {
350
- const task = this.taskConfigurations.getTask(scope, taskLabel);
351
- if (!task) {
352
- this.logger.error(`Can't get task launch configuration for label: ${taskLabel}`);
353
- return;
354
- }
355
- this.run(token, task._source, taskLabel, scope);
356
- }
357
- /**
358
- * Run the last executed task.
359
- * @param token The cache token for the user interaction in progress
360
- */
361
- async runLastTask(token) {
362
- var _a, _b;
363
- if (!((_a = this.lastTask) === null || _a === void 0 ? void 0 : _a.resolvedTask)) {
364
- return;
365
- }
366
- if (!((_b = this.lastTask.resolvedTask.runOptions) === null || _b === void 0 ? void 0 : _b.reevaluateOnRerun)) {
367
- return this.runResolvedTask(this.lastTask.resolvedTask, this.lastTask.option);
368
- }
369
- const { _source, label, _scope } = this.lastTask.resolvedTask;
370
- return this.run(token, _source, label, _scope);
371
- }
372
- /**
373
- * Runs a task, by the source and label of the task configuration.
374
- * It looks for configured and detected tasks.
375
- * @param token The cache token for the user interaction in progress
376
- * @param source The source for configured tasks
377
- * @param taskLabel The label to look for
378
- * @param scope The scope where to look for tasks
379
- */
380
- async run(token, source, taskLabel, scope) {
381
- var _a, _b;
382
- let task;
383
- task = this.taskConfigurations.getTask(scope, taskLabel);
384
- if (!task) { // if a configured task cannot be found, search from detected tasks
385
- task = await this.getProvidedTask(token, source, taskLabel, scope);
386
- if (!task) { // find from the customized detected tasks
387
- task = await this.taskConfigurations.getCustomizedTask(token, scope, taskLabel);
388
- }
389
- if (!task) {
390
- this.logger.error(`Can't get task launch configuration for label: ${taskLabel}`);
391
- return;
392
- }
393
- }
394
- const customizationObject = await this.getTaskCustomization(task);
395
- if (!customizationObject.problemMatcher) {
396
- // ask the user what s/he wants to use to parse the task output
397
- const items = this.getCustomizeProblemMatcherItems();
398
- const selected = await this.quickPickService.show(items, {
399
- placeholder: 'Select for which kind of errors and warnings to scan the task output'
400
- });
401
- if (selected && ('value' in selected)) {
402
- if ((_a = selected.value) === null || _a === void 0 ? void 0 : _a.problemMatchers) {
403
- let matcherNames = [];
404
- if (selected.value.problemMatchers && selected.value.problemMatchers.length === 0) { // never parse output for this task
405
- matcherNames = [];
406
- }
407
- else if (selected.value.problemMatchers && selected.value.problemMatchers.length > 0) { // continue with user-selected parser
408
- matcherNames = selected.value.problemMatchers.map(matcher => matcher.name);
409
- }
410
- customizationObject.problemMatcher = matcherNames;
411
- // write the selected matcher (or the decision of "never parse") into the `tasks.json`
412
- this.updateTaskConfiguration(token, task, { problemMatcher: matcherNames });
413
- }
414
- else if ((_b = selected.value) === null || _b === void 0 ? void 0 : _b.learnMore) { // user wants to learn more about parsing task output
415
- (0, opener_service_1.open)(this.openerService, new uri_1.default('https://code.visualstudio.com/docs/editor/tasks#_processing-task-output-with-problem-matchers'));
416
- }
417
- // else, continue the task with no parser
418
- }
419
- else { // do not start the task in case that the user did not select any item from the list
420
- return;
421
- }
422
- }
423
- const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject);
424
- const runTaskOption = {
425
- customization: Object.assign(Object.assign({}, customizationObject), { problemMatcher: resolvedMatchers })
426
- };
427
- if (task.dependsOn) {
428
- return this.runCompoundTask(token, task, runTaskOption);
429
- }
430
- else {
431
- return this.runTask(task, runTaskOption).catch(error => {
432
- console.error('Error at launching task', error);
433
- return undefined;
434
- });
435
- }
436
- }
437
- /**
438
- * Runs a compound task
439
- * @param token The cache token for the user interaction in progress
440
- * @param task The task to be executed
441
- * @param option options for executing the task
442
- */
443
- async runCompoundTask(token, task, option) {
444
- const tasks = await this.getWorkspaceTasks(token, task._scope);
445
- try {
446
- const rootNode = new task_node_1.TaskNode(task, [], []);
447
- this.detectDirectedAcyclicGraph(task, rootNode, tasks);
448
- }
449
- catch (error) {
450
- console.error(`Error at launching task '${task.label}'`, error);
451
- this.messageService.error(error.message);
452
- return undefined;
453
- }
454
- return this.runTasksGraph(task, tasks, option).catch(error => {
455
- console.error(`Error at launching task '${task.label}'`, error);
456
- return undefined;
457
- });
458
- }
459
- /**
460
- * A recursive function that runs a task and all its sub tasks that it depends on.
461
- * A task can be executed only when all of its dependencies have been executed, or when it doesn’t have any dependencies at all.
462
- */
463
- async runTasksGraph(task, tasks, option) {
464
- if (task && task.dependsOn) {
465
- // In case it is an array of task dependencies
466
- if (Array.isArray(task.dependsOn) && task.dependsOn.length > 0) {
467
- const dependentTasks = [];
468
- for (let i = 0; i < task.dependsOn.length; i++) {
469
- // It may be a string (a task label) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
470
- const taskIdentifier = task.dependsOn[i];
471
- const dependentTask = this.getDependentTask(taskIdentifier, tasks);
472
- const taskCustomization = await this.getTaskCustomization(dependentTask);
473
- const resolvedMatchers = await this.resolveProblemMatchers(dependentTask, taskCustomization);
474
- dependentTasks.push({ 'task': dependentTask, 'taskCustomization': taskCustomization, 'resolvedMatchers': resolvedMatchers });
475
- // In case the 'dependsOrder' is 'sequence'
476
- if (task.dependsOrder && task.dependsOrder === common_2.DependsOrder.Sequence) {
477
- await this.runTasksGraph(dependentTask, tasks, {
478
- customization: Object.assign(Object.assign({}, taskCustomization), { problemMatcher: resolvedMatchers })
479
- });
480
- }
481
- }
482
- // In case the 'dependsOrder' is 'parallel'
483
- if (((!task.dependsOrder) || (task.dependsOrder && task.dependsOrder === common_2.DependsOrder.Parallel))) {
484
- const promises = dependentTasks.map(item => this.runTasksGraph(item.task, tasks, {
485
- customization: Object.assign(Object.assign({}, item.taskCustomization), { problemMatcher: item.resolvedMatchers })
486
- }));
487
- await Promise.all(promises);
488
- }
489
- }
490
- else if (!Array.isArray(task.dependsOn)) {
491
- // In case it is a string (a task label) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
492
- const taskIdentifier = task.dependsOn;
493
- const dependentTask = this.getDependentTask(taskIdentifier, tasks);
494
- const taskCustomization = await this.getTaskCustomization(dependentTask);
495
- const resolvedMatchers = await this.resolveProblemMatchers(dependentTask, taskCustomization);
496
- await this.runTasksGraph(dependentTask, tasks, {
497
- customization: Object.assign(Object.assign({}, taskCustomization), { problemMatcher: resolvedMatchers })
498
- });
499
- }
500
- }
501
- const taskInfo = await this.runTask(task, option);
502
- if (taskInfo) {
503
- const getExitCodePromise = this.getExitCode(taskInfo.taskId).then(result => ({ taskEndedType: TaskEndedTypes.TaskExited, value: result }));
504
- const isBackgroundTaskEndedPromise = this.isBackgroundTaskEnded(taskInfo.taskId).then(result => ({ taskEndedType: TaskEndedTypes.BackgroundTaskEnded, value: result }));
505
- // After start running the task, we wait for the task process to exit and if it is a background task, we also wait for a feedback
506
- // that a background task is active, as soon as one of the promises fulfills, we can continue and analyze the results.
507
- const taskEndedInfo = await Promise.race([getExitCodePromise, isBackgroundTaskEndedPromise]);
508
- if ((taskEndedInfo.taskEndedType === TaskEndedTypes.TaskExited && taskEndedInfo.value !== 0) ||
509
- (taskEndedInfo.taskEndedType === TaskEndedTypes.BackgroundTaskEnded && !taskEndedInfo.value)) {
510
- throw new Error('The task: ' + task.label + ' terminated with exit code ' + taskEndedInfo.value + '.');
511
- }
512
- }
513
- return taskInfo;
514
- }
515
- /**
516
- * Creates a graph of dependencies tasks from the root task and verify there is no DAG (Directed Acyclic Graph).
517
- * In case of detection of a circular dependency, an error is thrown with a message which describes the detected circular reference.
518
- */
519
- detectDirectedAcyclicGraph(task, taskNode, tasks) {
520
- if (task && task.dependsOn) {
521
- // In case the 'dependsOn' is an array
522
- if (Array.isArray(task.dependsOn) && task.dependsOn.length > 0) {
523
- for (let i = 0; i < task.dependsOn.length; i++) {
524
- const childNode = this.createChildTaskNode(task, taskNode, task.dependsOn[i], tasks);
525
- this.detectDirectedAcyclicGraph(childNode.taskConfiguration, childNode.node, tasks);
526
- }
527
- }
528
- else if (!Array.isArray(task.dependsOn)) {
529
- const childNode = this.createChildTaskNode(task, taskNode, task.dependsOn, tasks);
530
- this.detectDirectedAcyclicGraph(childNode.taskConfiguration, childNode.node, tasks);
531
- }
532
- }
533
- }
534
- // 'childTaskIdentifier' may be a string (a task label) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
535
- createChildTaskNode(task, taskNode, childTaskIdentifier, tasks) {
536
- const childTaskConfiguration = this.getDependentTask(childTaskIdentifier, tasks);
537
- // If current task and child task are identical or if
538
- // one of the child tasks is identical to one of the current task ancestors, then raise an error
539
- if (this.taskDefinitionRegistry.compareTasks(task, childTaskConfiguration) ||
540
- taskNode.parentsID.filter(t => this.taskDefinitionRegistry.compareTasks(childTaskConfiguration, t)).length > 0) {
541
- const fromNode = task.label;
542
- const toNode = childTaskConfiguration.label;
543
- throw new Error('Circular reference detected: ' + fromNode + ' --> ' + toNode);
544
- }
545
- const childNode = new task_node_1.TaskNode(childTaskConfiguration, [], Object.assign([], taskNode.parentsID));
546
- childNode.addParentDependency(taskNode.taskId);
547
- taskNode.addChildDependency(childNode);
548
- return { 'taskConfiguration': childTaskConfiguration, 'node': childNode };
549
- }
550
- /**
551
- * Gets task configuration by task label or by a JSON object which represents a task identifier
552
- *
553
- * @param taskIdentifier The task label (string) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
554
- * @param tasks an array of the task configurations
555
- * @returns the correct TaskConfiguration object which matches the taskIdentifier
556
- */
557
- getDependentTask(taskIdentifier, tasks) {
558
- const notEnoughDataError = 'The information provided in the "dependsOn" is not enough for matching the correct task !';
559
- let currentTaskChildConfiguration;
560
- if (typeof (taskIdentifier) !== 'string') {
561
- // TaskIdentifier object does not support tasks of type 'shell' (The same behavior as in VS Code).
562
- // So if we want the 'dependsOn' property to include tasks of type 'shell',
563
- // then we must mention their labels (in the 'dependsOn' property) and not to create a task identifier object for them.
564
- currentTaskChildConfiguration = this.getTaskByTaskIdentifier(taskIdentifier, tasks);
565
- if (!currentTaskChildConfiguration.type) {
566
- this.messageService.error(notEnoughDataError);
567
- throw new Error(notEnoughDataError);
568
- }
569
- return currentTaskChildConfiguration;
570
- }
571
- else {
572
- currentTaskChildConfiguration = tasks.filter(t => taskIdentifier === this.taskNameResolver.resolve(t))[0];
573
- return currentTaskChildConfiguration;
574
- }
575
- }
576
- /**
577
- * Gets the matched task from an array of task configurations by TaskIdentifier.
578
- * In case that more than one task configuration matches, we returns the first one.
579
- *
580
- * @param taskIdentifier The task label (string) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
581
- * @param tasks An array of task configurations.
582
- * @returns The correct TaskConfiguration object which matches the taskIdentifier.
583
- */
584
- getTaskByTaskIdentifier(taskIdentifier, tasks) {
585
- const requiredProperties = Object.keys(taskIdentifier);
586
- const taskWithAllProperties = tasks.find(task => requiredProperties.every(property => task.hasOwnProperty(property) && task[property] === taskIdentifier[property]));
587
- return taskWithAllProperties !== null && taskWithAllProperties !== void 0 ? taskWithAllProperties : { label: '', _scope: '', type: '' }; // Fall back to empty TaskConfiguration
588
- }
589
- async runTask(task, option) {
590
- console.debug('entering runTask');
591
- const releaseLock = await this.taskStartingLock.acquire();
592
- console.debug('got lock');
593
- try {
594
- // resolve problemMatchers
595
- if (!option && task.problemMatcher) {
596
- const customizationObject = { type: task.taskType, problemMatcher: task.problemMatcher, runOptions: task.runOptions };
597
- const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject);
598
- option = {
599
- customization: Object.assign(Object.assign({}, customizationObject), { problemMatcher: resolvedMatchers })
600
- };
601
- }
602
- const runningTasksInfo = await this.getRunningTasks();
603
- // check if the task is active
604
- const matchedRunningTaskInfo = runningTasksInfo.find(taskInfo => {
605
- const taskConfig = taskInfo.config;
606
- return this.taskDefinitionRegistry.compareTasks(taskConfig, task);
607
- });
608
- console.debug(`running task ${JSON.stringify(task)}, already running = ${!!matchedRunningTaskInfo}`);
609
- if (matchedRunningTaskInfo) { // the task is active
610
- releaseLock();
611
- console.debug('released lock');
612
- const taskName = this.taskNameResolver.resolve(task);
613
- const terminalId = matchedRunningTaskInfo.terminalId;
614
- if (terminalId) {
615
- const terminal = this.terminalService.getByTerminalId(terminalId);
616
- if (terminal) {
617
- if (common_2.TaskOutputPresentation.shouldSetFocusToTerminal(task)) { // assign focus to the terminal if presentation.focus is true
618
- this.terminalService.open(terminal, { mode: 'activate' });
619
- }
620
- else if (common_2.TaskOutputPresentation.shouldAlwaysRevealTerminal(task)) { // show the terminal but not assign focus
621
- this.terminalService.open(terminal, { mode: 'reveal' });
622
- }
623
- }
624
- }
625
- const selectedAction = await this.messageService.info(`The task '${taskName}' is already active`, 'Terminate Task', 'Restart Task');
626
- if (selectedAction === 'Terminate Task') {
627
- await this.terminateTask(matchedRunningTaskInfo);
628
- }
629
- else if (selectedAction === 'Restart Task') {
630
- return this.restartTask(matchedRunningTaskInfo, option);
631
- }
632
- }
633
- else { // run task as the task is not active
634
- console.debug('task about to start');
635
- const taskInfo = await this.doRunTask(task, option);
636
- releaseLock();
637
- console.debug('release lock 2');
638
- return taskInfo;
639
- }
640
- }
641
- catch (e) {
642
- releaseLock();
643
- throw e;
644
- }
645
- }
646
- /**
647
- * Terminates a task that is actively running.
648
- * @param activeTaskInfo the TaskInfo of the task that is actively running
649
- */
650
- async terminateTask(activeTaskInfo) {
651
- const taskId = activeTaskInfo.taskId;
652
- return this.kill(taskId);
653
- }
654
- /**
655
- * Terminates a task that is actively running, and restarts it.
656
- * @param activeTaskInfo the TaskInfo of the task that is actively running
657
- */
658
- async restartTask(activeTaskInfo, option) {
659
- await this.terminateTask(activeTaskInfo);
660
- return this.doRunTask(activeTaskInfo.config, option);
661
- }
662
- async doRunTask(task, option) {
663
- let overridePropertiesFunction = () => { };
664
- if (option && option.customization) {
665
- const taskDefinition = this.taskDefinitionRegistry.getDefinition(task);
666
- if (taskDefinition) { // use the customization object to override the task config
667
- overridePropertiesFunction = tsk => {
668
- Object.keys(option.customization).forEach(customizedProperty => {
669
- // properties used to define the task cannot be customized
670
- if (customizedProperty !== 'type' && !taskDefinition.properties.all.some(pDefinition => pDefinition === customizedProperty)) {
671
- tsk[customizedProperty] = option.customization[customizedProperty];
672
- }
673
- });
674
- };
675
- }
676
- }
677
- overridePropertiesFunction(task);
678
- this.addRecentTasks(task);
679
- try {
680
- const resolver = await this.taskResolverRegistry.getTaskResolver(task.type);
681
- const resolvedTask = resolver ? await resolver.resolveTask(task) : task;
682
- const executionResolver = this.taskResolverRegistry.getExecutionResolver(resolvedTask.taskType || resolvedTask.type);
683
- overridePropertiesFunction(resolvedTask);
684
- const taskToRun = executionResolver ? await executionResolver.resolveTask(resolvedTask) : resolvedTask;
685
- await this.removeProblemMarkers(option);
686
- return this.runResolvedTask(taskToRun, option);
687
- }
688
- catch (error) {
689
- const errMessage = `Error resolving task '${task.label}': ${error}`;
690
- this.logger.error(errMessage);
691
- }
692
- return undefined;
693
- }
694
- /**
695
- * Runs the first task with the given label.
696
- *
697
- * @param token The cache token for the user interaction in progress
698
- * @param taskLabel The label of the task to be executed
699
- */
700
- async runTaskByLabel(token, taskLabel) {
701
- const tasks = await this.getTasks(token);
702
- for (const task of tasks) {
703
- if (task.label === taskLabel) {
704
- return this.runTask(task);
705
- }
706
- }
707
- return;
708
- }
709
- /**
710
- * Runs a task identified by the given identifier, but only if found in the given workspace folder
711
- *
712
- * @param token The cache token for the user interaction in progress
713
- * @param workspaceFolderUri The folder to restrict the search to
714
- * @param taskIdentifier The identifier to look for
715
- */
716
- async runWorkspaceTask(token, workspaceFolderUri, taskIdentifier) {
717
- const tasks = await this.getWorkspaceTasks(token, workspaceFolderUri);
718
- const task = this.getDependentTask(taskIdentifier, tasks);
719
- if (!task) {
720
- return undefined;
721
- }
722
- const taskCustomization = await this.getTaskCustomization(task);
723
- const resolvedMatchers = await this.resolveProblemMatchers(task, taskCustomization);
724
- try {
725
- const rootNode = new task_node_1.TaskNode(task, [], []);
726
- this.detectDirectedAcyclicGraph(task, rootNode, tasks);
727
- }
728
- catch (error) {
729
- this.logger.error(error.message);
730
- this.messageService.error(error.message);
731
- return undefined;
732
- }
733
- return this.runTasksGraph(task, tasks, {
734
- customization: Object.assign(Object.assign({}, taskCustomization), { problemMatcher: resolvedMatchers })
735
- }).catch(error => {
736
- console.log(error.message);
737
- return undefined;
738
- });
739
- }
740
- /**
741
- * Updates the task configuration in the `tasks.json`.
742
- * The task config, together with updates, will be written into the `tasks.json` if it is not found in the file.
743
- *
744
- * @param token The cache token for the user interaction in progress
745
- * @param task task that the updates will be applied to
746
- * @param update the updates to be applied
747
- */
748
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
749
- async updateTaskConfiguration(token, task, update) {
750
- if (update.problemMatcher) {
751
- if (Array.isArray(update.problemMatcher)) {
752
- update.problemMatcher.forEach((name, index) => {
753
- if (!name.startsWith('$')) {
754
- update.problemMatcher[index] = `$${update.problemMatcher[index]}`;
755
- }
756
- });
757
- }
758
- else if (!update.problemMatcher.startsWith('$')) {
759
- update.problemMatcher = `$${update.problemMatcher}`;
760
- }
761
- }
762
- this.taskConfigurations.updateTaskConfig(token, task, update);
763
- }
764
- async getWorkspaceTasks(token, restrictToFolder) {
765
- const tasks = await this.getTasks(token);
766
- // if we pass undefined, return everything, otherwise only tasks with the same uri or workspace/global scope tasks
767
- return tasks.filter(t => typeof t._scope !== 'string' || t._scope === restrictToFolder);
768
- }
769
- async resolveProblemMatchers(task, customizationObject) {
770
- const notResolvedMatchers = customizationObject.problemMatcher ?
771
- (Array.isArray(customizationObject.problemMatcher) ? customizationObject.problemMatcher : [customizationObject.problemMatcher]) : undefined;
772
- let resolvedMatchers = [];
773
- if (notResolvedMatchers) {
774
- // resolve matchers before passing them to the server
775
- for (const matcher of notResolvedMatchers) {
776
- let resolvedMatcher;
777
- await this.problemMatcherRegistry.onReady();
778
- if (typeof matcher === 'string') {
779
- resolvedMatcher = this.problemMatcherRegistry.get(matcher);
780
- }
781
- else {
782
- resolvedMatcher = await this.problemMatcherRegistry.getProblemMatcherFromContribution(matcher);
783
- }
784
- if (resolvedMatcher) {
785
- const scope = task._scope || task._source;
786
- if (resolvedMatcher.filePrefix && scope) {
787
- const options = {
788
- context: new uri_1.default(scope).withScheme('file'),
789
- configurationSection: 'tasks'
790
- };
791
- const resolvedPrefix = await this.variableResolverService.resolve(resolvedMatcher.filePrefix, options);
792
- Object.assign(resolvedMatcher, { filePrefix: resolvedPrefix });
793
- }
794
- resolvedMatchers.push(resolvedMatcher);
795
- }
796
- }
797
- }
798
- else {
799
- resolvedMatchers = undefined;
800
- }
801
- return resolvedMatchers;
802
- }
803
- async getTaskCustomization(task) {
804
- const customizationObject = { type: '', _scope: task._scope, runOptions: task.runOptions };
805
- const customizationFound = this.taskConfigurations.getCustomizationForTask(task);
806
- if (customizationFound) {
807
- Object.assign(customizationObject, customizationFound);
808
- }
809
- else {
810
- Object.assign(customizationObject, {
811
- type: task.type,
812
- problemMatcher: task.problemMatcher
813
- });
814
- }
815
- return customizationObject;
816
- }
817
- async removeProblemMarkers(option) {
818
- if (option && option.customization) {
819
- const matchersFromOption = option.customization.problemMatcher || [];
820
- for (const matcher of matchersFromOption) {
821
- if (matcher && matcher.owner) {
822
- const existingMarkers = this.problemManager.findMarkers({ owner: matcher.owner });
823
- const uris = new Set();
824
- existingMarkers.forEach(marker => uris.add(marker.uri));
825
- uris.forEach(uriString => this.problemManager.setMarkers(new uri_1.default(uriString), matcher.owner, []));
826
- }
827
- }
828
- }
829
- }
830
- /**
831
- * Runs the resolved task and opens terminal widget if the task is based on a terminal process
832
- * @param resolvedTask the resolved task
833
- * @param option options to run the resolved task
834
- */
835
- async runResolvedTask(resolvedTask, option) {
836
- const taskLabel = resolvedTask.label;
837
- let taskInfo;
838
- try {
839
- taskInfo = await this.taskServer.run(resolvedTask, this.getContext(), option);
840
- this.lastTask = { resolvedTask, option };
841
- this.logger.debug(`Task created. Task id: ${taskInfo.taskId}`);
842
- /**
843
- * open terminal widget if the task is based on a terminal process (type: 'shell' or 'process')
844
- *
845
- * @todo Use a different mechanism to determine if the task should be attached?
846
- * Reason: Maybe a new task type wants to also be displayed in a terminal.
847
- */
848
- if (typeof taskInfo.terminalId === 'number') {
849
- await this.attach(taskInfo.terminalId, taskInfo);
850
- }
851
- return taskInfo;
852
- }
853
- catch (error) {
854
- const errorStr = `Error launching task '${taskLabel}': ${error.message}`;
855
- this.logger.error(errorStr);
856
- this.messageService.error(errorStr);
857
- if (taskInfo && typeof taskInfo.terminalId === 'number') {
858
- this.shellTerminalServer.onAttachAttempted(taskInfo.terminalId);
859
- }
860
- }
861
- }
862
- getCustomizeProblemMatcherItems() {
863
- const items = [];
864
- items.push({
865
- label: 'Continue without scanning the task output',
866
- value: { problemMatchers: undefined }
867
- });
868
- items.push({
869
- label: 'Never scan the task output',
870
- value: { problemMatchers: [] }
871
- });
872
- items.push({
873
- label: 'Learn more about scanning the task output',
874
- value: { problemMatchers: undefined, learnMore: true }
875
- });
876
- items.push({ type: 'separator', label: 'registered parsers' });
877
- const registeredProblemMatchers = this.problemMatcherRegistry.getAll();
878
- items.push(...registeredProblemMatchers.map(matcher => ({
879
- label: matcher.label,
880
- value: { problemMatchers: [matcher] },
881
- description: matcher.name.startsWith('$') ? matcher.name : `$${matcher.name}`
882
- })));
883
- return items;
884
- }
885
- /**
886
- * Run selected text in the last active terminal.
887
- */
888
- async runSelectedText() {
889
- if (!this.editorManager.currentEditor) {
890
- return;
891
- }
892
- const startLine = this.editorManager.currentEditor.editor.selection.start.line;
893
- const startCharacter = this.editorManager.currentEditor.editor.selection.start.character;
894
- const endLine = this.editorManager.currentEditor.editor.selection.end.line;
895
- const endCharacter = this.editorManager.currentEditor.editor.selection.end.character;
896
- let selectedRange = vscode_languageserver_protocol_1.Range.create(startLine, startCharacter, endLine, endCharacter);
897
- // if no text is selected, default to selecting entire line
898
- if (startLine === endLine && startCharacter === endCharacter) {
899
- selectedRange = vscode_languageserver_protocol_1.Range.create(startLine, 0, endLine + 1, 0);
900
- }
901
- const selectedText = this.editorManager.currentEditor.editor.document.getText(selectedRange).trimRight() + '\n';
902
- let terminal = this.terminalService.lastUsedTerminal;
903
- if (!terminal || terminal.kind !== 'user' || (await terminal.hasChildProcesses())) {
904
- terminal = await this.terminalService.newTerminal({ created: new Date().toString() });
905
- await terminal.start();
906
- this.terminalService.open(terminal);
907
- }
908
- terminal.sendText(selectedText);
909
- }
910
- async attach(terminalId, taskInfo) {
911
- let widgetOpenMode = 'open';
912
- if (taskInfo) {
913
- const terminalWidget = this.terminalService.getByTerminalId(terminalId);
914
- if (terminalWidget) {
915
- this.messageService.error('Task is already running in terminal');
916
- return this.terminalService.open(terminalWidget, { mode: 'activate' });
917
- }
918
- if (common_2.TaskOutputPresentation.shouldAlwaysRevealTerminal(taskInfo.config)) {
919
- if (common_2.TaskOutputPresentation.shouldSetFocusToTerminal(taskInfo.config)) { // assign focus to the terminal if presentation.focus is true
920
- widgetOpenMode = 'activate';
921
- }
922
- else { // show the terminal but not assign focus
923
- widgetOpenMode = 'reveal';
924
- }
925
- }
926
- }
927
- const { taskId } = taskInfo;
928
- // Create / find a terminal widget to display an execution output of a task that was launched as a command inside a shell.
929
- const widget = await this.taskTerminalWidgetManager.open({
930
- created: new Date().toString(),
931
- id: this.getTerminalWidgetId(terminalId),
932
- title: taskInfo
933
- ? `Task: ${taskInfo.config.label}`
934
- : `Task: #${taskId}`,
935
- destroyTermOnClose: true
936
- }, {
937
- widgetOptions: { area: 'bottom' },
938
- mode: widgetOpenMode,
939
- taskInfo
940
- });
941
- return widget.start(terminalId);
942
- }
943
- getTerminalWidgetId(terminalId) {
944
- const terminalWidget = this.terminalService.getByTerminalId(terminalId);
945
- if (terminalWidget) {
946
- return terminalWidget.id;
947
- }
948
- }
949
- /**
950
- * Opens an editor to configure the given task.
951
- *
952
- * @param token The cache token for the user interaction in progress
953
- * @param task The task to configure
954
- */
955
- async configure(token, task) {
956
- Object.assign(task, { label: this.taskNameResolver.resolve(task) });
957
- await this.taskConfigurations.configure(token, task);
958
- }
959
- isEventForThisClient(context) {
960
- if (context === this.getContext()) {
961
- return true;
962
- }
963
- return false;
964
- }
965
- taskConfigurationChanged(event) {
966
- // do nothing for now
967
- }
968
- getContext() {
969
- var _a;
970
- return (_a = this.workspaceService.workspace) === null || _a === void 0 ? void 0 : _a.resource.toString();
971
- }
972
- /** Kill task for a given id if task is found */
973
- async kill(id) {
974
- try {
975
- await this.taskServer.kill(id);
976
- }
977
- catch (error) {
978
- this.logger.error(`Error killing task '${id}': ${error}`);
979
- this.messageService.error(`Error killing task '${id}': ${error}`);
980
- return;
981
- }
982
- this.logger.debug(`Task killed. Task id: ${id}`);
983
- }
984
- async isBackgroundTaskEnded(id) {
985
- const completedTask = this.runningTasks.get(id);
986
- return completedTask && completedTask.isBackgroundTaskEnded.promise;
987
- }
988
- async getExitCode(id) {
989
- const completedTask = this.runningTasks.get(id);
990
- return completedTask && completedTask.exitCode.promise;
991
- }
992
- async getTerminateSignal(id) {
993
- const completedTask = this.runningTasks.get(id);
994
- return completedTask && completedTask.terminateSignal.promise;
995
- }
996
- };
997
- __decorate([
998
- (0, inversify_1.inject)(browser_1.FrontendApplication),
999
- __metadata("design:type", browser_1.FrontendApplication)
1000
- ], TaskService.prototype, "app", void 0);
1001
- __decorate([
1002
- (0, inversify_1.inject)(browser_1.ApplicationShell),
1003
- __metadata("design:type", browser_1.ApplicationShell)
1004
- ], TaskService.prototype, "shell", void 0);
1005
- __decorate([
1006
- (0, inversify_1.inject)(common_2.TaskServer),
1007
- __metadata("design:type", Object)
1008
- ], TaskService.prototype, "taskServer", void 0);
1009
- __decorate([
1010
- (0, inversify_1.inject)(common_1.ILogger),
1011
- (0, inversify_1.named)('task'),
1012
- __metadata("design:type", Object)
1013
- ], TaskService.prototype, "logger", void 0);
1014
- __decorate([
1015
- (0, inversify_1.inject)(browser_1.WidgetManager),
1016
- __metadata("design:type", browser_1.WidgetManager)
1017
- ], TaskService.prototype, "widgetManager", void 0);
1018
- __decorate([
1019
- (0, inversify_1.inject)(task_watcher_1.TaskWatcher),
1020
- __metadata("design:type", task_watcher_1.TaskWatcher)
1021
- ], TaskService.prototype, "taskWatcher", void 0);
1022
- __decorate([
1023
- (0, inversify_1.inject)(message_service_1.MessageService),
1024
- __metadata("design:type", message_service_1.MessageService)
1025
- ], TaskService.prototype, "messageService", void 0);
1026
- __decorate([
1027
- (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
1028
- __metadata("design:type", workspace_service_1.WorkspaceService)
1029
- ], TaskService.prototype, "workspaceService", void 0);
1030
- __decorate([
1031
- (0, inversify_1.inject)(task_configurations_1.TaskConfigurations),
1032
- __metadata("design:type", task_configurations_1.TaskConfigurations)
1033
- ], TaskService.prototype, "taskConfigurations", void 0);
1034
- __decorate([
1035
- (0, inversify_1.inject)(provided_task_configurations_1.ProvidedTaskConfigurations),
1036
- __metadata("design:type", provided_task_configurations_1.ProvidedTaskConfigurations)
1037
- ], TaskService.prototype, "providedTaskConfigurations", void 0);
1038
- __decorate([
1039
- (0, inversify_1.inject)(browser_3.VariableResolverService),
1040
- __metadata("design:type", browser_3.VariableResolverService)
1041
- ], TaskService.prototype, "variableResolverService", void 0);
1042
- __decorate([
1043
- (0, inversify_1.inject)(task_contribution_1.TaskResolverRegistry),
1044
- __metadata("design:type", task_contribution_1.TaskResolverRegistry)
1045
- ], TaskService.prototype, "taskResolverRegistry", void 0);
1046
- __decorate([
1047
- (0, inversify_1.inject)(terminal_service_1.TerminalService),
1048
- __metadata("design:type", Object)
1049
- ], TaskService.prototype, "terminalService", void 0);
1050
- __decorate([
1051
- (0, inversify_1.inject)(browser_2.EditorManager),
1052
- __metadata("design:type", browser_2.EditorManager)
1053
- ], TaskService.prototype, "editorManager", void 0);
1054
- __decorate([
1055
- (0, inversify_1.inject)(problem_manager_1.ProblemManager),
1056
- __metadata("design:type", problem_manager_1.ProblemManager)
1057
- ], TaskService.prototype, "problemManager", void 0);
1058
- __decorate([
1059
- (0, inversify_1.inject)(task_definition_registry_1.TaskDefinitionRegistry),
1060
- __metadata("design:type", task_definition_registry_1.TaskDefinitionRegistry)
1061
- ], TaskService.prototype, "taskDefinitionRegistry", void 0);
1062
- __decorate([
1063
- (0, inversify_1.inject)(task_problem_matcher_registry_1.ProblemMatcherRegistry),
1064
- __metadata("design:type", task_problem_matcher_registry_1.ProblemMatcherRegistry)
1065
- ], TaskService.prototype, "problemMatcherRegistry", void 0);
1066
- __decorate([
1067
- (0, inversify_1.inject)(quick_pick_service_1.QuickPickService),
1068
- __metadata("design:type", Object)
1069
- ], TaskService.prototype, "quickPickService", void 0);
1070
- __decorate([
1071
- (0, inversify_1.inject)(opener_service_1.OpenerService),
1072
- __metadata("design:type", Object)
1073
- ], TaskService.prototype, "openerService", void 0);
1074
- __decorate([
1075
- (0, inversify_1.inject)(shell_terminal_protocol_1.ShellTerminalServerProxy),
1076
- __metadata("design:type", Object)
1077
- ], TaskService.prototype, "shellTerminalServer", void 0);
1078
- __decorate([
1079
- (0, inversify_1.inject)(task_name_resolver_1.TaskNameResolver),
1080
- __metadata("design:type", task_name_resolver_1.TaskNameResolver)
1081
- ], TaskService.prototype, "taskNameResolver", void 0);
1082
- __decorate([
1083
- (0, inversify_1.inject)(task_source_resolver_1.TaskSourceResolver),
1084
- __metadata("design:type", task_source_resolver_1.TaskSourceResolver)
1085
- ], TaskService.prototype, "taskSourceResolver", void 0);
1086
- __decorate([
1087
- (0, inversify_1.inject)(task_schema_updater_1.TaskSchemaUpdater),
1088
- __metadata("design:type", task_schema_updater_1.TaskSchemaUpdater)
1089
- ], TaskService.prototype, "taskSchemaUpdater", void 0);
1090
- __decorate([
1091
- (0, inversify_1.inject)(task_configuration_manager_1.TaskConfigurationManager),
1092
- __metadata("design:type", task_configuration_manager_1.TaskConfigurationManager)
1093
- ], TaskService.prototype, "taskConfigurationManager", void 0);
1094
- __decorate([
1095
- (0, inversify_1.inject)(common_1.CommandService),
1096
- __metadata("design:type", Object)
1097
- ], TaskService.prototype, "commands", void 0);
1098
- __decorate([
1099
- (0, inversify_1.inject)(label_provider_1.LabelProvider),
1100
- __metadata("design:type", label_provider_1.LabelProvider)
1101
- ], TaskService.prototype, "labelProvider", void 0);
1102
- __decorate([
1103
- (0, inversify_1.inject)(monaco_workspace_1.MonacoWorkspace),
1104
- __metadata("design:type", monaco_workspace_1.MonacoWorkspace)
1105
- ], TaskService.prototype, "monacoWorkspace", void 0);
1106
- __decorate([
1107
- (0, inversify_1.inject)(task_terminal_widget_manager_1.TaskTerminalWidgetManager),
1108
- __metadata("design:type", task_terminal_widget_manager_1.TaskTerminalWidgetManager)
1109
- ], TaskService.prototype, "taskTerminalWidgetManager", void 0);
1110
- __decorate([
1111
- (0, inversify_1.postConstruct)(),
1112
- __metadata("design:type", Function),
1113
- __metadata("design:paramtypes", []),
1114
- __metadata("design:returntype", void 0)
1115
- ], TaskService.prototype, "init", null);
1116
- TaskService = __decorate([
1117
- (0, inversify_1.injectable)()
1118
- ], TaskService);
1119
- exports.TaskService = TaskService;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 Ericsson and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.TaskService = exports.TaskEndedTypes = void 0;
28
+ const browser_1 = require("@theia/core/lib/browser");
29
+ const opener_service_1 = require("@theia/core/lib/browser/opener-service");
30
+ const common_1 = require("@theia/core/lib/common");
31
+ const message_service_1 = require("@theia/core/lib/common/message-service");
32
+ const promise_util_1 = require("@theia/core/lib/common/promise-util");
33
+ const quick_pick_service_1 = require("@theia/core/lib/common/quick-pick-service");
34
+ const label_provider_1 = require("@theia/core/lib/browser/label-provider");
35
+ const uri_1 = require("@theia/core/lib/common/uri");
36
+ const browser_2 = require("@theia/editor/lib/browser");
37
+ const problem_manager_1 = require("@theia/markers/lib/browser/problem/problem-manager");
38
+ const terminal_service_1 = require("@theia/terminal/lib/browser/base/terminal-service");
39
+ const browser_3 = require("@theia/variable-resolver/lib/browser");
40
+ const workspace_service_1 = require("@theia/workspace/lib/browser/workspace-service");
41
+ const inversify_1 = require("@theia/core/shared/inversify");
42
+ const vscode_languageserver_protocol_1 = require("@theia/core/shared/vscode-languageserver-protocol");
43
+ const common_2 = require("../common");
44
+ const task_watcher_1 = require("../common/task-watcher");
45
+ const provided_task_configurations_1 = require("./provided-task-configurations");
46
+ const task_configurations_1 = require("./task-configurations");
47
+ const task_contribution_1 = require("./task-contribution");
48
+ const task_definition_registry_1 = require("./task-definition-registry");
49
+ const task_name_resolver_1 = require("./task-name-resolver");
50
+ const task_source_resolver_1 = require("./task-source-resolver");
51
+ const task_problem_matcher_registry_1 = require("./task-problem-matcher-registry");
52
+ const task_schema_updater_1 = require("./task-schema-updater");
53
+ const task_configuration_manager_1 = require("./task-configuration-manager");
54
+ const problem_widget_1 = require("@theia/markers/lib/browser/problem/problem-widget");
55
+ const task_node_1 = require("./task-node");
56
+ const monaco_workspace_1 = require("@theia/monaco/lib/browser/monaco-workspace");
57
+ const task_terminal_widget_manager_1 = require("./task-terminal-widget-manager");
58
+ const shell_terminal_protocol_1 = require("@theia/terminal/lib/common/shell-terminal-protocol");
59
+ const async_mutex_1 = require("async-mutex");
60
+ var TaskEndedTypes;
61
+ (function (TaskEndedTypes) {
62
+ TaskEndedTypes[TaskEndedTypes["TaskExited"] = 0] = "TaskExited";
63
+ TaskEndedTypes[TaskEndedTypes["BackgroundTaskEnded"] = 1] = "BackgroundTaskEnded";
64
+ })(TaskEndedTypes = exports.TaskEndedTypes || (exports.TaskEndedTypes = {}));
65
+ let TaskService = class TaskService {
66
+ constructor() {
67
+ /**
68
+ * The last executed task.
69
+ */
70
+ this.lastTask = { resolvedTask: undefined, option: undefined };
71
+ this.cachedRecentTasks = [];
72
+ this.runningTasks = new Map();
73
+ this.taskStartingLock = new async_mutex_1.Mutex();
74
+ }
75
+ init() {
76
+ this.getRunningTasks().then(tasks => tasks.forEach(task => {
77
+ if (!this.runningTasks.has(task.taskId)) {
78
+ this.runningTasks.set(task.taskId, {
79
+ exitCode: new promise_util_1.Deferred(), terminateSignal: new promise_util_1.Deferred(),
80
+ isBackgroundTaskEnded: new promise_util_1.Deferred()
81
+ });
82
+ }
83
+ }));
84
+ // notify user that task has started
85
+ this.taskWatcher.onTaskCreated((event) => {
86
+ if (!this.isEventForThisClient(event.ctx)) {
87
+ return;
88
+ }
89
+ this.runningTasks.set(event.taskId, {
90
+ exitCode: new promise_util_1.Deferred(),
91
+ terminateSignal: new promise_util_1.Deferred(),
92
+ isBackgroundTaskEnded: new promise_util_1.Deferred()
93
+ });
94
+ });
95
+ this.taskWatcher.onOutputProcessed(async (event) => {
96
+ if (!this.isEventForThisClient(event.ctx)) {
97
+ return;
98
+ }
99
+ if (event.problems) {
100
+ const runningTasksInfo = await this.getRunningTasks();
101
+ // check if the task is active
102
+ const matchedRunningTaskInfo = runningTasksInfo.find(taskInfo => {
103
+ const taskConfig = taskInfo.config;
104
+ return this.taskDefinitionRegistry.compareTasks(taskConfig, event.config);
105
+ });
106
+ const isTaskActiveAndOutputSilent = matchedRunningTaskInfo &&
107
+ matchedRunningTaskInfo.config.presentation && matchedRunningTaskInfo.config.presentation.reveal === common_2.RevealKind.Silent;
108
+ event.problems.forEach(problem => {
109
+ const existingMarkers = this.problemManager.findMarkers({ owner: problem.description.owner });
110
+ const uris = new Set();
111
+ existingMarkers.forEach(marker => uris.add(marker.uri));
112
+ if (common_2.ProblemMatchData.is(problem) && problem.resource) {
113
+ // When task.presentation.reveal === RevealKind.Silent, put focus on the terminal only if it is an error
114
+ if (isTaskActiveAndOutputSilent && problem.marker.severity === vscode_languageserver_protocol_1.DiagnosticSeverity.Error) {
115
+ const terminalId = matchedRunningTaskInfo.terminalId;
116
+ if (terminalId) {
117
+ const terminal = this.terminalService.getByTerminalId(terminalId);
118
+ if (terminal) {
119
+ const focus = !!matchedRunningTaskInfo.config.presentation.focus;
120
+ if (focus) { // assign focus to the terminal if presentation.focus is true
121
+ this.terminalService.open(terminal, { mode: 'activate' });
122
+ }
123
+ else { // show the terminal but not assign focus
124
+ this.terminalService.open(terminal, { mode: 'reveal' });
125
+ }
126
+ }
127
+ }
128
+ }
129
+ const uri = new uri_1.default(problem.resource.path).withScheme(problem.resource.scheme);
130
+ const document = this.monacoWorkspace.getTextDocument(uri.toString());
131
+ if (problem.description.applyTo === common_2.ApplyToKind.openDocuments && !!document ||
132
+ problem.description.applyTo === common_2.ApplyToKind.closedDocuments && !document ||
133
+ problem.description.applyTo === common_2.ApplyToKind.allDocuments) {
134
+ if (uris.has(uri.toString())) {
135
+ const newData = [
136
+ ...existingMarkers
137
+ .filter(marker => marker.uri === uri.toString())
138
+ .map(markerData => markerData.data),
139
+ problem.marker
140
+ ];
141
+ this.problemManager.setMarkers(uri, problem.description.owner, newData);
142
+ }
143
+ else {
144
+ this.problemManager.setMarkers(uri, problem.description.owner, [problem.marker]);
145
+ }
146
+ }
147
+ }
148
+ else { // should have received an event for finding the "background task begins" pattern
149
+ uris.forEach(uriString => this.problemManager.setMarkers(new uri_1.default(uriString), problem.description.owner, []));
150
+ }
151
+ });
152
+ }
153
+ });
154
+ this.taskWatcher.onBackgroundTaskEnded((event) => {
155
+ if (!this.isEventForThisClient(event.ctx)) {
156
+ return;
157
+ }
158
+ if (!this.runningTasks.has(event.taskId)) {
159
+ this.runningTasks.set(event.taskId, {
160
+ exitCode: new promise_util_1.Deferred(),
161
+ terminateSignal: new promise_util_1.Deferred(),
162
+ isBackgroundTaskEnded: new promise_util_1.Deferred()
163
+ });
164
+ }
165
+ this.runningTasks.get(event.taskId).isBackgroundTaskEnded.resolve(true);
166
+ });
167
+ // notify user that task has finished
168
+ this.taskWatcher.onTaskExit((event) => {
169
+ if (!this.isEventForThisClient(event.ctx)) {
170
+ return;
171
+ }
172
+ if (!this.runningTasks.has(event.taskId)) {
173
+ this.runningTasks.set(event.taskId, {
174
+ exitCode: new promise_util_1.Deferred(),
175
+ terminateSignal: new promise_util_1.Deferred(),
176
+ isBackgroundTaskEnded: new promise_util_1.Deferred()
177
+ });
178
+ }
179
+ this.runningTasks.get(event.taskId).exitCode.resolve(event.code);
180
+ this.runningTasks.get(event.taskId).terminateSignal.resolve(event.signal);
181
+ setTimeout(() => this.runningTasks.delete(event.taskId), 60 * 1000);
182
+ const taskConfig = event.config;
183
+ const taskIdentifier = taskConfig ? this.getTaskIdentifier(taskConfig) : event.taskId.toString();
184
+ if (event.code !== undefined) {
185
+ if (event.code !== 0) {
186
+ const eventTaskConfig = event.config;
187
+ if (eventTaskConfig && eventTaskConfig.presentation && eventTaskConfig.presentation.reveal === common_2.RevealKind.Silent && event.terminalId) {
188
+ const terminal = this.terminalService.getByTerminalId(event.terminalId);
189
+ const focus = !!eventTaskConfig.presentation.focus;
190
+ if (terminal) {
191
+ if (focus) { // assign focus to the terminal if presentation.focus is true
192
+ this.terminalService.open(terminal, { mode: 'activate' });
193
+ }
194
+ else { // show the terminal but not assign focus
195
+ this.terminalService.open(terminal, { mode: 'reveal' });
196
+ }
197
+ }
198
+ }
199
+ this.messageService.error(`Task '${taskIdentifier}' has exited with code ${event.code}.`);
200
+ }
201
+ }
202
+ else if (event.signal !== undefined) {
203
+ this.messageService.info(`Task '${taskIdentifier}' was terminated by signal ${event.signal}.`);
204
+ }
205
+ else {
206
+ console.error('Invalid TaskExitedEvent received, neither code nor signal is set.');
207
+ }
208
+ });
209
+ }
210
+ getTaskIdentifier(taskConfig) {
211
+ const taskName = this.taskNameResolver.resolve(taskConfig);
212
+ const sourceStrUri = this.taskSourceResolver.resolve(taskConfig);
213
+ return `${taskName} (${this.labelProvider.getName(new uri_1.default(sourceStrUri))})`;
214
+ }
215
+ /**
216
+ * Client should call this method to indicate that a new user-level action related to tasks has been started,
217
+ * like invoking "Run Task..."
218
+ * This method returns a token that can be used with various methods in this service.
219
+ * As long as a client uses the same token, task providers will only asked once to contribute
220
+ * tasks and the set of tasks will be cached. Each time the a new token is used, the cache of
221
+ * contributed tasks is cleared.
222
+ * @returns a token to be used for task-related actions
223
+ */
224
+ startUserAction() {
225
+ return this.providedTaskConfigurations.startUserAction();
226
+ }
227
+ /**
228
+ * Returns an array of the task configurations configured in tasks.json and provided by the extensions.
229
+ * @param token The cache token for the user interaction in progress
230
+ */
231
+ async getTasks(token) {
232
+ const configuredTasks = await this.getConfiguredTasks(token);
233
+ const providedTasks = await this.getProvidedTasks(token);
234
+ const notCustomizedProvidedTasks = providedTasks.filter(provided => !configuredTasks.some(configured => this.taskDefinitionRegistry.compareTasks(configured, provided)));
235
+ return [...configuredTasks, ...notCustomizedProvidedTasks];
236
+ }
237
+ /**
238
+ * Returns an array of the valid task configurations which are configured in tasks.json files
239
+ * @param token The cache token for the user interaction in progress
240
+ *
241
+ */
242
+ async getConfiguredTasks(token) {
243
+ const invalidTaskConfig = this.taskConfigurations.getInvalidTaskConfigurations()[0];
244
+ if (invalidTaskConfig) {
245
+ const widget = await this.widgetManager.getOrCreateWidget(problem_widget_1.PROBLEMS_WIDGET_ID);
246
+ const isProblemsWidgetVisible = widget && widget.isVisible;
247
+ const currentEditorUri = this.editorManager.currentEditor && this.editorManager.currentEditor.editor.getResourceUri();
248
+ let isInvalidTaskConfigFileOpen = false;
249
+ if (currentEditorUri) {
250
+ const folderUri = this.workspaceService.getWorkspaceRootUri(currentEditorUri);
251
+ if (folderUri && folderUri.toString() === invalidTaskConfig._scope) {
252
+ isInvalidTaskConfigFileOpen = true;
253
+ }
254
+ }
255
+ const warningMessage = 'Invalid task configurations are found. Open tasks.json and find details in the Problems view.';
256
+ if (!isProblemsWidgetVisible || !isInvalidTaskConfigFileOpen) {
257
+ this.messageService.warn(warningMessage, 'Open').then(actionOpen => {
258
+ if (actionOpen) {
259
+ if (invalidTaskConfig && invalidTaskConfig._scope) {
260
+ this.taskConfigurationManager.openConfiguration(invalidTaskConfig._scope);
261
+ }
262
+ if (!isProblemsWidgetVisible) {
263
+ this.commands.executeCommand('problemsView:toggle');
264
+ }
265
+ }
266
+ });
267
+ }
268
+ else {
269
+ this.messageService.warn(warningMessage);
270
+ }
271
+ }
272
+ const validTaskConfigs = await this.taskConfigurations.getTasks(token);
273
+ return validTaskConfigs;
274
+ }
275
+ /**
276
+ * Returns an array of the task configurations which are provided by the extensions.
277
+ * @param token The cache token for the user interaction in progress
278
+ */
279
+ getProvidedTasks(token) {
280
+ return this.providedTaskConfigurations.getTasks(token);
281
+ }
282
+ addRecentTasks(tasks) {
283
+ if (Array.isArray(tasks)) {
284
+ tasks.forEach(task => this.addRecentTasks(task));
285
+ }
286
+ else {
287
+ const ind = this.cachedRecentTasks.findIndex(recent => this.taskDefinitionRegistry.compareTasks(recent, tasks));
288
+ if (ind >= 0) {
289
+ this.cachedRecentTasks.splice(ind, 1);
290
+ }
291
+ this.cachedRecentTasks.unshift(tasks);
292
+ }
293
+ }
294
+ get recentTasks() {
295
+ return this.cachedRecentTasks;
296
+ }
297
+ set recentTasks(recent) {
298
+ this.cachedRecentTasks = recent;
299
+ }
300
+ /**
301
+ * Clears the list of recently used tasks.
302
+ */
303
+ clearRecentTasks() {
304
+ this.cachedRecentTasks = [];
305
+ }
306
+ /**
307
+ * Open user ser
308
+ */
309
+ openUserTasks() {
310
+ return this.taskConfigurations.openUserTasks();
311
+ }
312
+ /**
313
+ * Returns a task configuration provided by an extension by task source, scope and label.
314
+ * If there are no task configuration, returns undefined.
315
+ * @param token The cache token for the user interaction in progress
316
+ * @param source The source for configured tasks
317
+ * @param label The label of the task to find
318
+ * @param scope The task scope to look in
319
+ */
320
+ async getProvidedTask(token, source, label, scope) {
321
+ return this.providedTaskConfigurations.getTask(token, source, label, scope);
322
+ }
323
+ /** Returns an array of running tasks 'TaskInfo' objects */
324
+ getRunningTasks() {
325
+ return this.taskServer.getTasks(this.getContext());
326
+ }
327
+ async customExecutionComplete(id, exitCode) {
328
+ return this.taskServer.customExecutionComplete(id, exitCode);
329
+ }
330
+ /** Returns an array of task types that are registered, including the default types */
331
+ getRegisteredTaskTypes() {
332
+ return this.taskSchemaUpdater.getRegisteredTaskTypes();
333
+ }
334
+ /**
335
+ * Get the last executed task.
336
+ *
337
+ * @returns the last executed task or `undefined`.
338
+ */
339
+ getLastTask() {
340
+ return this.lastTask;
341
+ }
342
+ /**
343
+ * Runs a task, by task configuration label.
344
+ * Note, it looks for a task configured in tasks.json only.
345
+ * @param token The cache token for the user interaction in progress
346
+ * @param scope The scope where to look for tasks
347
+ * @param taskLabel the label to look for
348
+ */
349
+ async runConfiguredTask(token, scope, taskLabel) {
350
+ const task = this.taskConfigurations.getTask(scope, taskLabel);
351
+ if (!task) {
352
+ this.logger.error(`Can't get task launch configuration for label: ${taskLabel}`);
353
+ return;
354
+ }
355
+ this.run(token, task._source, taskLabel, scope);
356
+ }
357
+ /**
358
+ * Run the last executed task.
359
+ * @param token The cache token for the user interaction in progress
360
+ */
361
+ async runLastTask(token) {
362
+ var _a, _b;
363
+ if (!((_a = this.lastTask) === null || _a === void 0 ? void 0 : _a.resolvedTask)) {
364
+ return;
365
+ }
366
+ if (!((_b = this.lastTask.resolvedTask.runOptions) === null || _b === void 0 ? void 0 : _b.reevaluateOnRerun)) {
367
+ return this.runResolvedTask(this.lastTask.resolvedTask, this.lastTask.option);
368
+ }
369
+ const { _source, label, _scope } = this.lastTask.resolvedTask;
370
+ return this.run(token, _source, label, _scope);
371
+ }
372
+ /**
373
+ * Runs a task, by the source and label of the task configuration.
374
+ * It looks for configured and detected tasks.
375
+ * @param token The cache token for the user interaction in progress
376
+ * @param source The source for configured tasks
377
+ * @param taskLabel The label to look for
378
+ * @param scope The scope where to look for tasks
379
+ */
380
+ async run(token, source, taskLabel, scope) {
381
+ var _a, _b;
382
+ let task;
383
+ task = this.taskConfigurations.getTask(scope, taskLabel);
384
+ if (!task) { // if a configured task cannot be found, search from detected tasks
385
+ task = await this.getProvidedTask(token, source, taskLabel, scope);
386
+ if (!task) { // find from the customized detected tasks
387
+ task = await this.taskConfigurations.getCustomizedTask(token, scope, taskLabel);
388
+ }
389
+ if (!task) {
390
+ this.logger.error(`Can't get task launch configuration for label: ${taskLabel}`);
391
+ return;
392
+ }
393
+ }
394
+ const customizationObject = await this.getTaskCustomization(task);
395
+ if (!customizationObject.problemMatcher) {
396
+ // ask the user what s/he wants to use to parse the task output
397
+ const items = this.getCustomizeProblemMatcherItems();
398
+ const selected = await this.quickPickService.show(items, {
399
+ placeholder: 'Select for which kind of errors and warnings to scan the task output'
400
+ });
401
+ if (selected && ('value' in selected)) {
402
+ if ((_a = selected.value) === null || _a === void 0 ? void 0 : _a.problemMatchers) {
403
+ let matcherNames = [];
404
+ if (selected.value.problemMatchers && selected.value.problemMatchers.length === 0) { // never parse output for this task
405
+ matcherNames = [];
406
+ }
407
+ else if (selected.value.problemMatchers && selected.value.problemMatchers.length > 0) { // continue with user-selected parser
408
+ matcherNames = selected.value.problemMatchers.map(matcher => matcher.name);
409
+ }
410
+ customizationObject.problemMatcher = matcherNames;
411
+ // write the selected matcher (or the decision of "never parse") into the `tasks.json`
412
+ this.updateTaskConfiguration(token, task, { problemMatcher: matcherNames });
413
+ }
414
+ else if ((_b = selected.value) === null || _b === void 0 ? void 0 : _b.learnMore) { // user wants to learn more about parsing task output
415
+ (0, opener_service_1.open)(this.openerService, new uri_1.default('https://code.visualstudio.com/docs/editor/tasks#_processing-task-output-with-problem-matchers'));
416
+ }
417
+ // else, continue the task with no parser
418
+ }
419
+ else { // do not start the task in case that the user did not select any item from the list
420
+ return;
421
+ }
422
+ }
423
+ const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject);
424
+ const runTaskOption = {
425
+ customization: Object.assign(Object.assign({}, customizationObject), { problemMatcher: resolvedMatchers })
426
+ };
427
+ if (task.dependsOn) {
428
+ return this.runCompoundTask(token, task, runTaskOption);
429
+ }
430
+ else {
431
+ return this.runTask(task, runTaskOption).catch(error => {
432
+ console.error('Error at launching task', error);
433
+ return undefined;
434
+ });
435
+ }
436
+ }
437
+ /**
438
+ * Runs a compound task
439
+ * @param token The cache token for the user interaction in progress
440
+ * @param task The task to be executed
441
+ * @param option options for executing the task
442
+ */
443
+ async runCompoundTask(token, task, option) {
444
+ const tasks = await this.getWorkspaceTasks(token, task._scope);
445
+ try {
446
+ const rootNode = new task_node_1.TaskNode(task, [], []);
447
+ this.detectDirectedAcyclicGraph(task, rootNode, tasks);
448
+ }
449
+ catch (error) {
450
+ console.error(`Error at launching task '${task.label}'`, error);
451
+ this.messageService.error(error.message);
452
+ return undefined;
453
+ }
454
+ return this.runTasksGraph(task, tasks, option).catch(error => {
455
+ console.error(`Error at launching task '${task.label}'`, error);
456
+ return undefined;
457
+ });
458
+ }
459
+ /**
460
+ * A recursive function that runs a task and all its sub tasks that it depends on.
461
+ * A task can be executed only when all of its dependencies have been executed, or when it doesn’t have any dependencies at all.
462
+ */
463
+ async runTasksGraph(task, tasks, option) {
464
+ if (task && task.dependsOn) {
465
+ // In case it is an array of task dependencies
466
+ if (Array.isArray(task.dependsOn) && task.dependsOn.length > 0) {
467
+ const dependentTasks = [];
468
+ for (let i = 0; i < task.dependsOn.length; i++) {
469
+ // It may be a string (a task label) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
470
+ const taskIdentifier = task.dependsOn[i];
471
+ const dependentTask = this.getDependentTask(taskIdentifier, tasks);
472
+ const taskCustomization = await this.getTaskCustomization(dependentTask);
473
+ const resolvedMatchers = await this.resolveProblemMatchers(dependentTask, taskCustomization);
474
+ dependentTasks.push({ 'task': dependentTask, 'taskCustomization': taskCustomization, 'resolvedMatchers': resolvedMatchers });
475
+ // In case the 'dependsOrder' is 'sequence'
476
+ if (task.dependsOrder && task.dependsOrder === common_2.DependsOrder.Sequence) {
477
+ await this.runTasksGraph(dependentTask, tasks, {
478
+ customization: Object.assign(Object.assign({}, taskCustomization), { problemMatcher: resolvedMatchers })
479
+ });
480
+ }
481
+ }
482
+ // In case the 'dependsOrder' is 'parallel'
483
+ if (((!task.dependsOrder) || (task.dependsOrder && task.dependsOrder === common_2.DependsOrder.Parallel))) {
484
+ const promises = dependentTasks.map(item => this.runTasksGraph(item.task, tasks, {
485
+ customization: Object.assign(Object.assign({}, item.taskCustomization), { problemMatcher: item.resolvedMatchers })
486
+ }));
487
+ await Promise.all(promises);
488
+ }
489
+ }
490
+ else if (!Array.isArray(task.dependsOn)) {
491
+ // In case it is a string (a task label) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
492
+ const taskIdentifier = task.dependsOn;
493
+ const dependentTask = this.getDependentTask(taskIdentifier, tasks);
494
+ const taskCustomization = await this.getTaskCustomization(dependentTask);
495
+ const resolvedMatchers = await this.resolveProblemMatchers(dependentTask, taskCustomization);
496
+ await this.runTasksGraph(dependentTask, tasks, {
497
+ customization: Object.assign(Object.assign({}, taskCustomization), { problemMatcher: resolvedMatchers })
498
+ });
499
+ }
500
+ }
501
+ const taskInfo = await this.runTask(task, option);
502
+ if (taskInfo) {
503
+ const getExitCodePromise = this.getExitCode(taskInfo.taskId).then(result => ({ taskEndedType: TaskEndedTypes.TaskExited, value: result }));
504
+ const isBackgroundTaskEndedPromise = this.isBackgroundTaskEnded(taskInfo.taskId).then(result => ({ taskEndedType: TaskEndedTypes.BackgroundTaskEnded, value: result }));
505
+ // After start running the task, we wait for the task process to exit and if it is a background task, we also wait for a feedback
506
+ // that a background task is active, as soon as one of the promises fulfills, we can continue and analyze the results.
507
+ const taskEndedInfo = await Promise.race([getExitCodePromise, isBackgroundTaskEndedPromise]);
508
+ if ((taskEndedInfo.taskEndedType === TaskEndedTypes.TaskExited && taskEndedInfo.value !== 0) ||
509
+ (taskEndedInfo.taskEndedType === TaskEndedTypes.BackgroundTaskEnded && !taskEndedInfo.value)) {
510
+ throw new Error('The task: ' + task.label + ' terminated with exit code ' + taskEndedInfo.value + '.');
511
+ }
512
+ }
513
+ return taskInfo;
514
+ }
515
+ /**
516
+ * Creates a graph of dependencies tasks from the root task and verify there is no DAG (Directed Acyclic Graph).
517
+ * In case of detection of a circular dependency, an error is thrown with a message which describes the detected circular reference.
518
+ */
519
+ detectDirectedAcyclicGraph(task, taskNode, tasks) {
520
+ if (task && task.dependsOn) {
521
+ // In case the 'dependsOn' is an array
522
+ if (Array.isArray(task.dependsOn) && task.dependsOn.length > 0) {
523
+ for (let i = 0; i < task.dependsOn.length; i++) {
524
+ const childNode = this.createChildTaskNode(task, taskNode, task.dependsOn[i], tasks);
525
+ this.detectDirectedAcyclicGraph(childNode.taskConfiguration, childNode.node, tasks);
526
+ }
527
+ }
528
+ else if (!Array.isArray(task.dependsOn)) {
529
+ const childNode = this.createChildTaskNode(task, taskNode, task.dependsOn, tasks);
530
+ this.detectDirectedAcyclicGraph(childNode.taskConfiguration, childNode.node, tasks);
531
+ }
532
+ }
533
+ }
534
+ // 'childTaskIdentifier' may be a string (a task label) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
535
+ createChildTaskNode(task, taskNode, childTaskIdentifier, tasks) {
536
+ const childTaskConfiguration = this.getDependentTask(childTaskIdentifier, tasks);
537
+ // If current task and child task are identical or if
538
+ // one of the child tasks is identical to one of the current task ancestors, then raise an error
539
+ if (this.taskDefinitionRegistry.compareTasks(task, childTaskConfiguration) ||
540
+ taskNode.parentsID.filter(t => this.taskDefinitionRegistry.compareTasks(childTaskConfiguration, t)).length > 0) {
541
+ const fromNode = task.label;
542
+ const toNode = childTaskConfiguration.label;
543
+ throw new Error('Circular reference detected: ' + fromNode + ' --> ' + toNode);
544
+ }
545
+ const childNode = new task_node_1.TaskNode(childTaskConfiguration, [], Object.assign([], taskNode.parentsID));
546
+ childNode.addParentDependency(taskNode.taskId);
547
+ taskNode.addChildDependency(childNode);
548
+ return { 'taskConfiguration': childTaskConfiguration, 'node': childNode };
549
+ }
550
+ /**
551
+ * Gets task configuration by task label or by a JSON object which represents a task identifier
552
+ *
553
+ * @param taskIdentifier The task label (string) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
554
+ * @param tasks an array of the task configurations
555
+ * @returns the correct TaskConfiguration object which matches the taskIdentifier
556
+ */
557
+ getDependentTask(taskIdentifier, tasks) {
558
+ const notEnoughDataError = 'The information provided in the "dependsOn" is not enough for matching the correct task !';
559
+ let currentTaskChildConfiguration;
560
+ if (typeof (taskIdentifier) !== 'string') {
561
+ // TaskIdentifier object does not support tasks of type 'shell' (The same behavior as in VS Code).
562
+ // So if we want the 'dependsOn' property to include tasks of type 'shell',
563
+ // then we must mention their labels (in the 'dependsOn' property) and not to create a task identifier object for them.
564
+ currentTaskChildConfiguration = this.getTaskByTaskIdentifier(taskIdentifier, tasks);
565
+ if (!currentTaskChildConfiguration.type) {
566
+ this.messageService.error(notEnoughDataError);
567
+ throw new Error(notEnoughDataError);
568
+ }
569
+ return currentTaskChildConfiguration;
570
+ }
571
+ else {
572
+ currentTaskChildConfiguration = tasks.filter(t => taskIdentifier === this.taskNameResolver.resolve(t))[0];
573
+ return currentTaskChildConfiguration;
574
+ }
575
+ }
576
+ /**
577
+ * Gets the matched task from an array of task configurations by TaskIdentifier.
578
+ * In case that more than one task configuration matches, we returns the first one.
579
+ *
580
+ * @param taskIdentifier The task label (string) or a JSON object which represents a TaskIdentifier (e.g. {"type":"npm", "script":"script1"})
581
+ * @param tasks An array of task configurations.
582
+ * @returns The correct TaskConfiguration object which matches the taskIdentifier.
583
+ */
584
+ getTaskByTaskIdentifier(taskIdentifier, tasks) {
585
+ const requiredProperties = Object.keys(taskIdentifier);
586
+ const taskWithAllProperties = tasks.find(task => requiredProperties.every(property => task.hasOwnProperty(property) && task[property] === taskIdentifier[property]));
587
+ return taskWithAllProperties !== null && taskWithAllProperties !== void 0 ? taskWithAllProperties : { label: '', _scope: '', type: '' }; // Fall back to empty TaskConfiguration
588
+ }
589
+ async runTask(task, option) {
590
+ console.debug('entering runTask');
591
+ const releaseLock = await this.taskStartingLock.acquire();
592
+ console.debug('got lock');
593
+ try {
594
+ // resolve problemMatchers
595
+ if (!option && task.problemMatcher) {
596
+ const customizationObject = { type: task.taskType, problemMatcher: task.problemMatcher, runOptions: task.runOptions };
597
+ const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject);
598
+ option = {
599
+ customization: Object.assign(Object.assign({}, customizationObject), { problemMatcher: resolvedMatchers })
600
+ };
601
+ }
602
+ const runningTasksInfo = await this.getRunningTasks();
603
+ // check if the task is active
604
+ const matchedRunningTaskInfo = runningTasksInfo.find(taskInfo => {
605
+ const taskConfig = taskInfo.config;
606
+ return this.taskDefinitionRegistry.compareTasks(taskConfig, task);
607
+ });
608
+ console.debug(`running task ${JSON.stringify(task)}, already running = ${!!matchedRunningTaskInfo}`);
609
+ if (matchedRunningTaskInfo) { // the task is active
610
+ releaseLock();
611
+ console.debug('released lock');
612
+ const taskName = this.taskNameResolver.resolve(task);
613
+ const terminalId = matchedRunningTaskInfo.terminalId;
614
+ if (terminalId) {
615
+ const terminal = this.terminalService.getByTerminalId(terminalId);
616
+ if (terminal) {
617
+ if (common_2.TaskOutputPresentation.shouldSetFocusToTerminal(task)) { // assign focus to the terminal if presentation.focus is true
618
+ this.terminalService.open(terminal, { mode: 'activate' });
619
+ }
620
+ else if (common_2.TaskOutputPresentation.shouldAlwaysRevealTerminal(task)) { // show the terminal but not assign focus
621
+ this.terminalService.open(terminal, { mode: 'reveal' });
622
+ }
623
+ }
624
+ }
625
+ const selectedAction = await this.messageService.info(`The task '${taskName}' is already active`, 'Terminate Task', 'Restart Task');
626
+ if (selectedAction === 'Terminate Task') {
627
+ await this.terminateTask(matchedRunningTaskInfo);
628
+ }
629
+ else if (selectedAction === 'Restart Task') {
630
+ return this.restartTask(matchedRunningTaskInfo, option);
631
+ }
632
+ }
633
+ else { // run task as the task is not active
634
+ console.debug('task about to start');
635
+ const taskInfo = await this.doRunTask(task, option);
636
+ releaseLock();
637
+ console.debug('release lock 2');
638
+ return taskInfo;
639
+ }
640
+ }
641
+ catch (e) {
642
+ releaseLock();
643
+ throw e;
644
+ }
645
+ }
646
+ /**
647
+ * Terminates a task that is actively running.
648
+ * @param activeTaskInfo the TaskInfo of the task that is actively running
649
+ */
650
+ async terminateTask(activeTaskInfo) {
651
+ const taskId = activeTaskInfo.taskId;
652
+ return this.kill(taskId);
653
+ }
654
+ /**
655
+ * Terminates a task that is actively running, and restarts it.
656
+ * @param activeTaskInfo the TaskInfo of the task that is actively running
657
+ */
658
+ async restartTask(activeTaskInfo, option) {
659
+ await this.terminateTask(activeTaskInfo);
660
+ return this.doRunTask(activeTaskInfo.config, option);
661
+ }
662
+ async doRunTask(task, option) {
663
+ let overridePropertiesFunction = () => { };
664
+ if (option && option.customization) {
665
+ const taskDefinition = this.taskDefinitionRegistry.getDefinition(task);
666
+ if (taskDefinition) { // use the customization object to override the task config
667
+ overridePropertiesFunction = tsk => {
668
+ Object.keys(option.customization).forEach(customizedProperty => {
669
+ // properties used to define the task cannot be customized
670
+ if (customizedProperty !== 'type' && !taskDefinition.properties.all.some(pDefinition => pDefinition === customizedProperty)) {
671
+ tsk[customizedProperty] = option.customization[customizedProperty];
672
+ }
673
+ });
674
+ };
675
+ }
676
+ }
677
+ overridePropertiesFunction(task);
678
+ this.addRecentTasks(task);
679
+ try {
680
+ const resolver = await this.taskResolverRegistry.getTaskResolver(task.type);
681
+ const resolvedTask = resolver ? await resolver.resolveTask(task) : task;
682
+ const executionResolver = this.taskResolverRegistry.getExecutionResolver(resolvedTask.taskType || resolvedTask.type);
683
+ overridePropertiesFunction(resolvedTask);
684
+ const taskToRun = executionResolver ? await executionResolver.resolveTask(resolvedTask) : resolvedTask;
685
+ await this.removeProblemMarkers(option);
686
+ return this.runResolvedTask(taskToRun, option);
687
+ }
688
+ catch (error) {
689
+ const errMessage = `Error resolving task '${task.label}': ${error}`;
690
+ this.logger.error(errMessage);
691
+ }
692
+ return undefined;
693
+ }
694
+ /**
695
+ * Runs the first task with the given label.
696
+ *
697
+ * @param token The cache token for the user interaction in progress
698
+ * @param taskLabel The label of the task to be executed
699
+ */
700
+ async runTaskByLabel(token, taskLabel) {
701
+ const tasks = await this.getTasks(token);
702
+ for (const task of tasks) {
703
+ if (task.label === taskLabel) {
704
+ return this.runTask(task);
705
+ }
706
+ }
707
+ return;
708
+ }
709
+ /**
710
+ * Runs a task identified by the given identifier, but only if found in the given workspace folder
711
+ *
712
+ * @param token The cache token for the user interaction in progress
713
+ * @param workspaceFolderUri The folder to restrict the search to
714
+ * @param taskIdentifier The identifier to look for
715
+ */
716
+ async runWorkspaceTask(token, workspaceFolderUri, taskIdentifier) {
717
+ const tasks = await this.getWorkspaceTasks(token, workspaceFolderUri);
718
+ const task = this.getDependentTask(taskIdentifier, tasks);
719
+ if (!task) {
720
+ return undefined;
721
+ }
722
+ const taskCustomization = await this.getTaskCustomization(task);
723
+ const resolvedMatchers = await this.resolveProblemMatchers(task, taskCustomization);
724
+ try {
725
+ const rootNode = new task_node_1.TaskNode(task, [], []);
726
+ this.detectDirectedAcyclicGraph(task, rootNode, tasks);
727
+ }
728
+ catch (error) {
729
+ this.logger.error(error.message);
730
+ this.messageService.error(error.message);
731
+ return undefined;
732
+ }
733
+ return this.runTasksGraph(task, tasks, {
734
+ customization: Object.assign(Object.assign({}, taskCustomization), { problemMatcher: resolvedMatchers })
735
+ }).catch(error => {
736
+ console.log(error.message);
737
+ return undefined;
738
+ });
739
+ }
740
+ /**
741
+ * Updates the task configuration in the `tasks.json`.
742
+ * The task config, together with updates, will be written into the `tasks.json` if it is not found in the file.
743
+ *
744
+ * @param token The cache token for the user interaction in progress
745
+ * @param task task that the updates will be applied to
746
+ * @param update the updates to be applied
747
+ */
748
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
749
+ async updateTaskConfiguration(token, task, update) {
750
+ if (update.problemMatcher) {
751
+ if (Array.isArray(update.problemMatcher)) {
752
+ update.problemMatcher.forEach((name, index) => {
753
+ if (!name.startsWith('$')) {
754
+ update.problemMatcher[index] = `$${update.problemMatcher[index]}`;
755
+ }
756
+ });
757
+ }
758
+ else if (!update.problemMatcher.startsWith('$')) {
759
+ update.problemMatcher = `$${update.problemMatcher}`;
760
+ }
761
+ }
762
+ this.taskConfigurations.updateTaskConfig(token, task, update);
763
+ }
764
+ async getWorkspaceTasks(token, restrictToFolder) {
765
+ const tasks = await this.getTasks(token);
766
+ // if we pass undefined, return everything, otherwise only tasks with the same uri or workspace/global scope tasks
767
+ return tasks.filter(t => typeof t._scope !== 'string' || t._scope === restrictToFolder);
768
+ }
769
+ async resolveProblemMatchers(task, customizationObject) {
770
+ const notResolvedMatchers = customizationObject.problemMatcher ?
771
+ (Array.isArray(customizationObject.problemMatcher) ? customizationObject.problemMatcher : [customizationObject.problemMatcher]) : undefined;
772
+ let resolvedMatchers = [];
773
+ if (notResolvedMatchers) {
774
+ // resolve matchers before passing them to the server
775
+ for (const matcher of notResolvedMatchers) {
776
+ let resolvedMatcher;
777
+ await this.problemMatcherRegistry.onReady();
778
+ if (typeof matcher === 'string') {
779
+ resolvedMatcher = this.problemMatcherRegistry.get(matcher);
780
+ }
781
+ else {
782
+ resolvedMatcher = await this.problemMatcherRegistry.getProblemMatcherFromContribution(matcher);
783
+ }
784
+ if (resolvedMatcher) {
785
+ const scope = task._scope || task._source;
786
+ if (resolvedMatcher.filePrefix && scope) {
787
+ const options = {
788
+ context: new uri_1.default(scope).withScheme('file'),
789
+ configurationSection: 'tasks'
790
+ };
791
+ const resolvedPrefix = await this.variableResolverService.resolve(resolvedMatcher.filePrefix, options);
792
+ Object.assign(resolvedMatcher, { filePrefix: resolvedPrefix });
793
+ }
794
+ resolvedMatchers.push(resolvedMatcher);
795
+ }
796
+ }
797
+ }
798
+ else {
799
+ resolvedMatchers = undefined;
800
+ }
801
+ return resolvedMatchers;
802
+ }
803
+ async getTaskCustomization(task) {
804
+ const customizationObject = { type: '', _scope: task._scope, runOptions: task.runOptions };
805
+ const customizationFound = this.taskConfigurations.getCustomizationForTask(task);
806
+ if (customizationFound) {
807
+ Object.assign(customizationObject, customizationFound);
808
+ }
809
+ else {
810
+ Object.assign(customizationObject, {
811
+ type: task.type,
812
+ problemMatcher: task.problemMatcher
813
+ });
814
+ }
815
+ return customizationObject;
816
+ }
817
+ async removeProblemMarkers(option) {
818
+ if (option && option.customization) {
819
+ const matchersFromOption = option.customization.problemMatcher || [];
820
+ for (const matcher of matchersFromOption) {
821
+ if (matcher && matcher.owner) {
822
+ const existingMarkers = this.problemManager.findMarkers({ owner: matcher.owner });
823
+ const uris = new Set();
824
+ existingMarkers.forEach(marker => uris.add(marker.uri));
825
+ uris.forEach(uriString => this.problemManager.setMarkers(new uri_1.default(uriString), matcher.owner, []));
826
+ }
827
+ }
828
+ }
829
+ }
830
+ /**
831
+ * Runs the resolved task and opens terminal widget if the task is based on a terminal process
832
+ * @param resolvedTask the resolved task
833
+ * @param option options to run the resolved task
834
+ */
835
+ async runResolvedTask(resolvedTask, option) {
836
+ const taskLabel = resolvedTask.label;
837
+ let taskInfo;
838
+ try {
839
+ taskInfo = await this.taskServer.run(resolvedTask, this.getContext(), option);
840
+ this.lastTask = { resolvedTask, option };
841
+ this.logger.debug(`Task created. Task id: ${taskInfo.taskId}`);
842
+ /**
843
+ * open terminal widget if the task is based on a terminal process (type: 'shell' or 'process')
844
+ *
845
+ * @todo Use a different mechanism to determine if the task should be attached?
846
+ * Reason: Maybe a new task type wants to also be displayed in a terminal.
847
+ */
848
+ if (typeof taskInfo.terminalId === 'number') {
849
+ await this.attach(taskInfo.terminalId, taskInfo);
850
+ }
851
+ return taskInfo;
852
+ }
853
+ catch (error) {
854
+ const errorStr = `Error launching task '${taskLabel}': ${error.message}`;
855
+ this.logger.error(errorStr);
856
+ this.messageService.error(errorStr);
857
+ if (taskInfo && typeof taskInfo.terminalId === 'number') {
858
+ this.shellTerminalServer.onAttachAttempted(taskInfo.terminalId);
859
+ }
860
+ }
861
+ }
862
+ getCustomizeProblemMatcherItems() {
863
+ const items = [];
864
+ items.push({
865
+ label: 'Continue without scanning the task output',
866
+ value: { problemMatchers: undefined }
867
+ });
868
+ items.push({
869
+ label: 'Never scan the task output',
870
+ value: { problemMatchers: [] }
871
+ });
872
+ items.push({
873
+ label: 'Learn more about scanning the task output',
874
+ value: { problemMatchers: undefined, learnMore: true }
875
+ });
876
+ items.push({ type: 'separator', label: 'registered parsers' });
877
+ const registeredProblemMatchers = this.problemMatcherRegistry.getAll();
878
+ items.push(...registeredProblemMatchers.map(matcher => ({
879
+ label: matcher.label,
880
+ value: { problemMatchers: [matcher] },
881
+ description: matcher.name.startsWith('$') ? matcher.name : `$${matcher.name}`
882
+ })));
883
+ return items;
884
+ }
885
+ /**
886
+ * Run selected text in the last active terminal.
887
+ */
888
+ async runSelectedText() {
889
+ if (!this.editorManager.currentEditor) {
890
+ return;
891
+ }
892
+ const startLine = this.editorManager.currentEditor.editor.selection.start.line;
893
+ const startCharacter = this.editorManager.currentEditor.editor.selection.start.character;
894
+ const endLine = this.editorManager.currentEditor.editor.selection.end.line;
895
+ const endCharacter = this.editorManager.currentEditor.editor.selection.end.character;
896
+ let selectedRange = vscode_languageserver_protocol_1.Range.create(startLine, startCharacter, endLine, endCharacter);
897
+ // if no text is selected, default to selecting entire line
898
+ if (startLine === endLine && startCharacter === endCharacter) {
899
+ selectedRange = vscode_languageserver_protocol_1.Range.create(startLine, 0, endLine + 1, 0);
900
+ }
901
+ const selectedText = this.editorManager.currentEditor.editor.document.getText(selectedRange).trimRight() + '\n';
902
+ let terminal = this.terminalService.lastUsedTerminal;
903
+ if (!terminal || terminal.kind !== 'user' || (await terminal.hasChildProcesses())) {
904
+ terminal = await this.terminalService.newTerminal({ created: new Date().toString() });
905
+ await terminal.start();
906
+ this.terminalService.open(terminal);
907
+ }
908
+ terminal.sendText(selectedText);
909
+ }
910
+ async attach(terminalId, taskInfo) {
911
+ let widgetOpenMode = 'open';
912
+ if (taskInfo) {
913
+ const terminalWidget = this.terminalService.getByTerminalId(terminalId);
914
+ if (terminalWidget) {
915
+ this.messageService.error('Task is already running in terminal');
916
+ return this.terminalService.open(terminalWidget, { mode: 'activate' });
917
+ }
918
+ if (common_2.TaskOutputPresentation.shouldAlwaysRevealTerminal(taskInfo.config)) {
919
+ if (common_2.TaskOutputPresentation.shouldSetFocusToTerminal(taskInfo.config)) { // assign focus to the terminal if presentation.focus is true
920
+ widgetOpenMode = 'activate';
921
+ }
922
+ else { // show the terminal but not assign focus
923
+ widgetOpenMode = 'reveal';
924
+ }
925
+ }
926
+ }
927
+ const { taskId } = taskInfo;
928
+ // Create / find a terminal widget to display an execution output of a task that was launched as a command inside a shell.
929
+ const widget = await this.taskTerminalWidgetManager.open({
930
+ created: new Date().toString(),
931
+ id: this.getTerminalWidgetId(terminalId),
932
+ title: taskInfo
933
+ ? `Task: ${taskInfo.config.label}`
934
+ : `Task: #${taskId}`,
935
+ destroyTermOnClose: true
936
+ }, {
937
+ widgetOptions: { area: 'bottom' },
938
+ mode: widgetOpenMode,
939
+ taskInfo
940
+ });
941
+ return widget.start(terminalId);
942
+ }
943
+ getTerminalWidgetId(terminalId) {
944
+ const terminalWidget = this.terminalService.getByTerminalId(terminalId);
945
+ if (terminalWidget) {
946
+ return terminalWidget.id;
947
+ }
948
+ }
949
+ /**
950
+ * Opens an editor to configure the given task.
951
+ *
952
+ * @param token The cache token for the user interaction in progress
953
+ * @param task The task to configure
954
+ */
955
+ async configure(token, task) {
956
+ Object.assign(task, { label: this.taskNameResolver.resolve(task) });
957
+ await this.taskConfigurations.configure(token, task);
958
+ }
959
+ isEventForThisClient(context) {
960
+ if (context === this.getContext()) {
961
+ return true;
962
+ }
963
+ return false;
964
+ }
965
+ taskConfigurationChanged(event) {
966
+ // do nothing for now
967
+ }
968
+ getContext() {
969
+ var _a;
970
+ return (_a = this.workspaceService.workspace) === null || _a === void 0 ? void 0 : _a.resource.toString();
971
+ }
972
+ /** Kill task for a given id if task is found */
973
+ async kill(id) {
974
+ try {
975
+ await this.taskServer.kill(id);
976
+ }
977
+ catch (error) {
978
+ this.logger.error(`Error killing task '${id}': ${error}`);
979
+ this.messageService.error(`Error killing task '${id}': ${error}`);
980
+ return;
981
+ }
982
+ this.logger.debug(`Task killed. Task id: ${id}`);
983
+ }
984
+ async isBackgroundTaskEnded(id) {
985
+ const completedTask = this.runningTasks.get(id);
986
+ return completedTask && completedTask.isBackgroundTaskEnded.promise;
987
+ }
988
+ async getExitCode(id) {
989
+ const completedTask = this.runningTasks.get(id);
990
+ return completedTask && completedTask.exitCode.promise;
991
+ }
992
+ async getTerminateSignal(id) {
993
+ const completedTask = this.runningTasks.get(id);
994
+ return completedTask && completedTask.terminateSignal.promise;
995
+ }
996
+ };
997
+ __decorate([
998
+ (0, inversify_1.inject)(browser_1.FrontendApplication),
999
+ __metadata("design:type", browser_1.FrontendApplication)
1000
+ ], TaskService.prototype, "app", void 0);
1001
+ __decorate([
1002
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
1003
+ __metadata("design:type", browser_1.ApplicationShell)
1004
+ ], TaskService.prototype, "shell", void 0);
1005
+ __decorate([
1006
+ (0, inversify_1.inject)(common_2.TaskServer),
1007
+ __metadata("design:type", Object)
1008
+ ], TaskService.prototype, "taskServer", void 0);
1009
+ __decorate([
1010
+ (0, inversify_1.inject)(common_1.ILogger),
1011
+ (0, inversify_1.named)('task'),
1012
+ __metadata("design:type", Object)
1013
+ ], TaskService.prototype, "logger", void 0);
1014
+ __decorate([
1015
+ (0, inversify_1.inject)(browser_1.WidgetManager),
1016
+ __metadata("design:type", browser_1.WidgetManager)
1017
+ ], TaskService.prototype, "widgetManager", void 0);
1018
+ __decorate([
1019
+ (0, inversify_1.inject)(task_watcher_1.TaskWatcher),
1020
+ __metadata("design:type", task_watcher_1.TaskWatcher)
1021
+ ], TaskService.prototype, "taskWatcher", void 0);
1022
+ __decorate([
1023
+ (0, inversify_1.inject)(message_service_1.MessageService),
1024
+ __metadata("design:type", message_service_1.MessageService)
1025
+ ], TaskService.prototype, "messageService", void 0);
1026
+ __decorate([
1027
+ (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
1028
+ __metadata("design:type", workspace_service_1.WorkspaceService)
1029
+ ], TaskService.prototype, "workspaceService", void 0);
1030
+ __decorate([
1031
+ (0, inversify_1.inject)(task_configurations_1.TaskConfigurations),
1032
+ __metadata("design:type", task_configurations_1.TaskConfigurations)
1033
+ ], TaskService.prototype, "taskConfigurations", void 0);
1034
+ __decorate([
1035
+ (0, inversify_1.inject)(provided_task_configurations_1.ProvidedTaskConfigurations),
1036
+ __metadata("design:type", provided_task_configurations_1.ProvidedTaskConfigurations)
1037
+ ], TaskService.prototype, "providedTaskConfigurations", void 0);
1038
+ __decorate([
1039
+ (0, inversify_1.inject)(browser_3.VariableResolverService),
1040
+ __metadata("design:type", browser_3.VariableResolverService)
1041
+ ], TaskService.prototype, "variableResolverService", void 0);
1042
+ __decorate([
1043
+ (0, inversify_1.inject)(task_contribution_1.TaskResolverRegistry),
1044
+ __metadata("design:type", task_contribution_1.TaskResolverRegistry)
1045
+ ], TaskService.prototype, "taskResolverRegistry", void 0);
1046
+ __decorate([
1047
+ (0, inversify_1.inject)(terminal_service_1.TerminalService),
1048
+ __metadata("design:type", Object)
1049
+ ], TaskService.prototype, "terminalService", void 0);
1050
+ __decorate([
1051
+ (0, inversify_1.inject)(browser_2.EditorManager),
1052
+ __metadata("design:type", browser_2.EditorManager)
1053
+ ], TaskService.prototype, "editorManager", void 0);
1054
+ __decorate([
1055
+ (0, inversify_1.inject)(problem_manager_1.ProblemManager),
1056
+ __metadata("design:type", problem_manager_1.ProblemManager)
1057
+ ], TaskService.prototype, "problemManager", void 0);
1058
+ __decorate([
1059
+ (0, inversify_1.inject)(task_definition_registry_1.TaskDefinitionRegistry),
1060
+ __metadata("design:type", task_definition_registry_1.TaskDefinitionRegistry)
1061
+ ], TaskService.prototype, "taskDefinitionRegistry", void 0);
1062
+ __decorate([
1063
+ (0, inversify_1.inject)(task_problem_matcher_registry_1.ProblemMatcherRegistry),
1064
+ __metadata("design:type", task_problem_matcher_registry_1.ProblemMatcherRegistry)
1065
+ ], TaskService.prototype, "problemMatcherRegistry", void 0);
1066
+ __decorate([
1067
+ (0, inversify_1.inject)(quick_pick_service_1.QuickPickService),
1068
+ __metadata("design:type", Object)
1069
+ ], TaskService.prototype, "quickPickService", void 0);
1070
+ __decorate([
1071
+ (0, inversify_1.inject)(opener_service_1.OpenerService),
1072
+ __metadata("design:type", Object)
1073
+ ], TaskService.prototype, "openerService", void 0);
1074
+ __decorate([
1075
+ (0, inversify_1.inject)(shell_terminal_protocol_1.ShellTerminalServerProxy),
1076
+ __metadata("design:type", Object)
1077
+ ], TaskService.prototype, "shellTerminalServer", void 0);
1078
+ __decorate([
1079
+ (0, inversify_1.inject)(task_name_resolver_1.TaskNameResolver),
1080
+ __metadata("design:type", task_name_resolver_1.TaskNameResolver)
1081
+ ], TaskService.prototype, "taskNameResolver", void 0);
1082
+ __decorate([
1083
+ (0, inversify_1.inject)(task_source_resolver_1.TaskSourceResolver),
1084
+ __metadata("design:type", task_source_resolver_1.TaskSourceResolver)
1085
+ ], TaskService.prototype, "taskSourceResolver", void 0);
1086
+ __decorate([
1087
+ (0, inversify_1.inject)(task_schema_updater_1.TaskSchemaUpdater),
1088
+ __metadata("design:type", task_schema_updater_1.TaskSchemaUpdater)
1089
+ ], TaskService.prototype, "taskSchemaUpdater", void 0);
1090
+ __decorate([
1091
+ (0, inversify_1.inject)(task_configuration_manager_1.TaskConfigurationManager),
1092
+ __metadata("design:type", task_configuration_manager_1.TaskConfigurationManager)
1093
+ ], TaskService.prototype, "taskConfigurationManager", void 0);
1094
+ __decorate([
1095
+ (0, inversify_1.inject)(common_1.CommandService),
1096
+ __metadata("design:type", Object)
1097
+ ], TaskService.prototype, "commands", void 0);
1098
+ __decorate([
1099
+ (0, inversify_1.inject)(label_provider_1.LabelProvider),
1100
+ __metadata("design:type", label_provider_1.LabelProvider)
1101
+ ], TaskService.prototype, "labelProvider", void 0);
1102
+ __decorate([
1103
+ (0, inversify_1.inject)(monaco_workspace_1.MonacoWorkspace),
1104
+ __metadata("design:type", monaco_workspace_1.MonacoWorkspace)
1105
+ ], TaskService.prototype, "monacoWorkspace", void 0);
1106
+ __decorate([
1107
+ (0, inversify_1.inject)(task_terminal_widget_manager_1.TaskTerminalWidgetManager),
1108
+ __metadata("design:type", task_terminal_widget_manager_1.TaskTerminalWidgetManager)
1109
+ ], TaskService.prototype, "taskTerminalWidgetManager", void 0);
1110
+ __decorate([
1111
+ (0, inversify_1.postConstruct)(),
1112
+ __metadata("design:type", Function),
1113
+ __metadata("design:paramtypes", []),
1114
+ __metadata("design:returntype", void 0)
1115
+ ], TaskService.prototype, "init", null);
1116
+ TaskService = __decorate([
1117
+ (0, inversify_1.injectable)()
1118
+ ], TaskService);
1119
+ exports.TaskService = TaskService;
1120
1120
  //# sourceMappingURL=task-service.js.map