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