@theia/task 1.53.0-next.55 → 1.53.0-next.64
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 +193 -193
- package/lib/browser/task-schema-updater.js +1 -1
- package/package.json +12 -12
- package/src/browser/index.ts +22 -22
- package/src/browser/process/process-task-contribution.ts +31 -31
- package/src/browser/process/process-task-frontend-module.ts +27 -27
- package/src/browser/process/process-task-resolver.ts +89 -89
- package/src/browser/provided-task-configurations.spec.ts +46 -46
- package/src/browser/provided-task-configurations.ts +213 -213
- package/src/browser/quick-open-task.ts +831 -831
- package/src/browser/style/index.css +19 -19
- package/src/browser/task-configuration-manager.ts +256 -256
- package/src/browser/task-configuration-model.ts +101 -101
- package/src/browser/task-configurations.ts +508 -508
- package/src/browser/task-contribution.ts +266 -266
- package/src/browser/task-definition-registry.spec.ts +203 -203
- package/src/browser/task-definition-registry.ts +131 -131
- package/src/browser/task-frontend-contribution.ts +402 -402
- package/src/browser/task-frontend-module.ts +86 -86
- package/src/browser/task-name-resolver.ts +55 -55
- package/src/browser/task-node.ts +37 -37
- package/src/browser/task-preferences.ts +40 -40
- package/src/browser/task-problem-matcher-registry.ts +308 -308
- package/src/browser/task-problem-pattern-registry.ts +196 -196
- package/src/browser/task-schema-updater.ts +701 -701
- package/src/browser/task-service.ts +1164 -1164
- package/src/browser/task-source-resolver.ts +36 -36
- package/src/browser/task-templates.ts +168 -168
- package/src/browser/task-terminal-widget-manager.ts +224 -224
- package/src/browser/tasks-monaco-contribution.ts +27 -27
- package/src/common/index.ts +20 -20
- package/src/common/problem-matcher-protocol.ts +234 -234
- package/src/common/process/task-protocol.ts +97 -97
- package/src/common/task-common-module.ts +34 -34
- package/src/common/task-protocol.ts +317 -317
- package/src/common/task-util.ts +43 -43
- package/src/common/task-watcher.ts +78 -78
- package/src/node/custom/custom-task-runner-backend-module.ts +37 -37
- package/src/node/custom/custom-task-runner-contribution.ts +30 -30
- package/src/node/custom/custom-task-runner.ts +60 -60
- package/src/node/custom/custom-task.ts +73 -73
- package/src/node/index.ts +19 -19
- package/src/node/process/process-task-runner-backend-module.ts +37 -37
- package/src/node/process/process-task-runner-contribution.ts +31 -31
- package/src/node/process/process-task-runner.ts +371 -371
- package/src/node/process/process-task.spec.ts +30 -30
- package/src/node/process/process-task.ts +144 -144
- package/src/node/task-abstract-line-matcher.ts +312 -312
- package/src/node/task-backend-application-contribution.ts +36 -36
- package/src/node/task-backend-module.ts +57 -57
- package/src/node/task-line-matchers.ts +127 -127
- package/src/node/task-manager.ts +129 -129
- package/src/node/task-problem-collector.spec.ts +338 -338
- package/src/node/task-problem-collector.ts +62 -62
- package/src/node/task-runner-protocol.ts +33 -33
- package/src/node/task-runner.ts +96 -96
- package/src/node/task-server.slow-spec.ts +444 -444
- package/src/node/task-server.ts +263 -263
- package/src/node/task.ts +103 -103
- package/src/node/test/task-test-container.ts +63 -63
|
@@ -1,266 +1,266 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Disposable } from '@theia/core/lib/common/disposable';
|
|
19
|
-
import { TaskConfiguration } from '../common/task-protocol';
|
|
20
|
-
import { WaitUntilEvent, Emitter } from '@theia/core/lib/common/event';
|
|
21
|
-
|
|
22
|
-
export const TaskContribution = Symbol('TaskContribution');
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A {@link TaskContribution} allows to contribute custom {@link TaskResolver}s and/or {@link TaskProvider}s.
|
|
26
|
-
*
|
|
27
|
-
* ### Example usage
|
|
28
|
-
* ```typescript
|
|
29
|
-
* @injectable()
|
|
30
|
-
* export class ProcessTaskContribution implements TaskContribution {
|
|
31
|
-
*
|
|
32
|
-
* @inject(ProcessTaskResolver)
|
|
33
|
-
* protected readonly processTaskResolver: ProcessTaskResolver;
|
|
34
|
-
*
|
|
35
|
-
* registerResolvers(resolvers: TaskResolverRegistry): void {
|
|
36
|
-
* resolvers.register('process', this.processTaskResolver);
|
|
37
|
-
* resolvers.register('shell', this.processTaskResolver);
|
|
38
|
-
* }
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export interface TaskContribution {
|
|
43
|
-
/**
|
|
44
|
-
* Register task resolvers using the given `TaskResolverRegistry`.
|
|
45
|
-
* @param resolvers the task resolver registry.
|
|
46
|
-
*/
|
|
47
|
-
registerResolvers?(resolvers: TaskResolverRegistry): void;
|
|
48
|
-
/**
|
|
49
|
-
* Register task providers using the given `TaskProviderRegistry`.
|
|
50
|
-
* @param resolvers the task provider registry.
|
|
51
|
-
*/
|
|
52
|
-
registerProviders?(providers: TaskProviderRegistry): void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* A {@link TaskResolver} is used to preprocess/resolve a task before sending
|
|
57
|
-
* it to the Task Server. For instance, the resolver can be used to add missing information to the configuration
|
|
58
|
-
* (e.g default values for optional parameters).
|
|
59
|
-
*/
|
|
60
|
-
export interface TaskResolver {
|
|
61
|
-
/**
|
|
62
|
-
* Resolves a `TaskConfiguration` before sending it for execution to the `TaskServer` (Backend).
|
|
63
|
-
* @param taskConfig the configuration that should be resolved.
|
|
64
|
-
*
|
|
65
|
-
* @returns a promise of the resolved `TaskConfiguration`.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
resolveTask(taskConfig: TaskConfiguration): Promise<TaskConfiguration>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* A {@link TaskProvider} can be used to define the set of tasks that should
|
|
73
|
-
* be provided to the system. i.e. that are available for the user to run.
|
|
74
|
-
*/
|
|
75
|
-
export interface TaskProvider {
|
|
76
|
-
/**
|
|
77
|
-
* Retrieves the task configurations which are provided programmatically to the system.
|
|
78
|
-
*
|
|
79
|
-
* @returns a promise of the provided tasks configurations.
|
|
80
|
-
*/
|
|
81
|
-
provideTasks(): Promise<TaskConfiguration[]>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface WillResolveTaskProvider extends WaitUntilEvent {
|
|
85
|
-
taskType?: string
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The {@link TaskResolverRegistry} is the common component for registration and provision of
|
|
90
|
-
* {@link TaskResolver}s. Theia will collect all {@link TaskContribution}s and invoke {@link TaskContribution#registerResolvers}
|
|
91
|
-
* for each contribution.
|
|
92
|
-
*/
|
|
93
|
-
@injectable()
|
|
94
|
-
export class TaskResolverRegistry {
|
|
95
|
-
|
|
96
|
-
protected readonly onWillProvideTaskResolverEmitter = new Emitter<WillResolveTaskProvider>();
|
|
97
|
-
/**
|
|
98
|
-
* Emit when the registry provides a registered resolver. i.e. when the {@link TaskResolverRegistry#getResolver}
|
|
99
|
-
* function is called.
|
|
100
|
-
*/
|
|
101
|
-
readonly onWillProvideTaskResolver = this.onWillProvideTaskResolverEmitter.event;
|
|
102
|
-
|
|
103
|
-
protected taskResolvers: Map<string, TaskResolver> = new Map();
|
|
104
|
-
protected executionResolvers: Map<string, TaskResolver> = new Map();
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Registers the given {@link TaskResolver} to resolve the `TaskConfiguration` of the specified type.
|
|
108
|
-
* If there is already a `TaskResolver` registered for the specified type the registration will
|
|
109
|
-
* be overwritten with the new value.
|
|
110
|
-
*
|
|
111
|
-
* @deprecated since 1.12.0 use `registerTaskResolver` instead.
|
|
112
|
-
*
|
|
113
|
-
* @param type the task configuration type for which the given resolver should be registered.
|
|
114
|
-
* @param resolver the task resolver that should be registered.
|
|
115
|
-
*
|
|
116
|
-
* @returns a `Disposable` that can be invoked to unregister the given resolver
|
|
117
|
-
*/
|
|
118
|
-
register(type: string, resolver: TaskResolver): Disposable {
|
|
119
|
-
return this.registerTaskResolver(type, resolver);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Registers the given {@link TaskResolver} to resolve the `TaskConfiguration` of the specified type.
|
|
124
|
-
* If there is already a `TaskResolver` registered for the specified type the registration will
|
|
125
|
-
* be overwritten with the new value.
|
|
126
|
-
*
|
|
127
|
-
* @param type the task configuration type for which the given resolver should be registered.
|
|
128
|
-
* @param resolver the task resolver that should be registered.
|
|
129
|
-
*
|
|
130
|
-
* @returns a `Disposable` that can be invoked to unregister the given resolver
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
registerTaskResolver(type: string, resolver: TaskResolver): Disposable {
|
|
134
|
-
if (this.taskResolvers.has(type)) {
|
|
135
|
-
console.warn(`Overriding task resolver for ${type}`);
|
|
136
|
-
}
|
|
137
|
-
this.taskResolvers.set(type, resolver);
|
|
138
|
-
return {
|
|
139
|
-
dispose: () => this.taskResolvers.delete(type)
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Retrieves the {@link TaskResolver} registered for the given type task configuration type.
|
|
145
|
-
*
|
|
146
|
-
* @deprecated since 1.12.0 use `getTaskResolver()` instead.
|
|
147
|
-
*
|
|
148
|
-
* @param type the task configuration type
|
|
149
|
-
*
|
|
150
|
-
* @returns a promise of the registered `TaskResolver` or `undefined` if no resolver is registered for the given type.
|
|
151
|
-
*/
|
|
152
|
-
async getResolver(type: string): Promise<TaskResolver | undefined> {
|
|
153
|
-
return this.getTaskResolver(type);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Retrieves the {@link TaskResolver} registered for the given type task configuration type.
|
|
158
|
-
* @param type the task configuration type
|
|
159
|
-
*
|
|
160
|
-
* @returns a promise of the registered `TaskResolver` or `undefined` if no resolver is registered for the given type.
|
|
161
|
-
*/
|
|
162
|
-
async getTaskResolver(type: string): Promise<TaskResolver | undefined> {
|
|
163
|
-
await WaitUntilEvent.fire(this.onWillProvideTaskResolverEmitter, { taskType: type });
|
|
164
|
-
return this.taskResolvers.get(type);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Registers the given {@link TaskResolver} to resolve the `TaskConfiguration` for the
|
|
169
|
-
* specified type of execution ('shell', 'process' or 'customExecution').
|
|
170
|
-
* If there is already a `TaskResolver` registered for the specified type the registration will
|
|
171
|
-
* be overwritten with the new value.
|
|
172
|
-
*
|
|
173
|
-
* @param type the task execution type for which the given resolver should be registered.
|
|
174
|
-
* @param resolver the task resolver that should be registered.
|
|
175
|
-
*
|
|
176
|
-
* @returns a `Disposable` that can be invoked to unregister the given resolver
|
|
177
|
-
*/
|
|
178
|
-
registerExecutionResolver(type: string, resolver: TaskResolver): Disposable {
|
|
179
|
-
if (this.executionResolvers.has(type)) {
|
|
180
|
-
console.warn(`Overriding execution resolver for ${type}`);
|
|
181
|
-
}
|
|
182
|
-
this.executionResolvers.set(type, resolver);
|
|
183
|
-
return {
|
|
184
|
-
dispose: () => this.executionResolvers.delete(type)
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Retrieves the {@link TaskResolver} registered for the given type of execution ('shell', 'process' or 'customExecution')..
|
|
190
|
-
* @param type the task configuration type
|
|
191
|
-
*
|
|
192
|
-
* @returns a promise of the registered `TaskResolver` or `undefined` if no resolver is registered for the given type.
|
|
193
|
-
*/
|
|
194
|
-
getExecutionResolver(executionType: string): TaskResolver | undefined {
|
|
195
|
-
return this.executionResolvers.get(executionType);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* The {@link TaskProviderRegistry} is the common component for registration and provision of
|
|
201
|
-
* {@link TaskProvider}s. Theia will collect all {@link TaskContribution}s and invoke {@link TaskContribution#registerProviders}
|
|
202
|
-
* for each contribution.
|
|
203
|
-
*/
|
|
204
|
-
@injectable()
|
|
205
|
-
export class TaskProviderRegistry {
|
|
206
|
-
|
|
207
|
-
protected readonly onWillProvideTaskProviderEmitter = new Emitter<WillResolveTaskProvider>();
|
|
208
|
-
/**
|
|
209
|
-
* Emit when the registry provides a registered task provider. i.e. when the {@link TaskProviderRegistry#getProvider}
|
|
210
|
-
* function is called.
|
|
211
|
-
*/
|
|
212
|
-
readonly onWillProvideTaskProvider = this.onWillProvideTaskProviderEmitter.event;
|
|
213
|
-
|
|
214
|
-
protected providers: Map<string, TaskProvider>;
|
|
215
|
-
|
|
216
|
-
@postConstruct()
|
|
217
|
-
protected init(): void {
|
|
218
|
-
this.providers = new Map();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Registers the given {@link TaskProvider} for task configurations of the specified type
|
|
223
|
-
* @param type the task configuration type for which the given provider should be registered.
|
|
224
|
-
* @param provider the `TaskProvider` that should be registered.
|
|
225
|
-
*
|
|
226
|
-
* @returns a `Disposable` that can be invoked to unregister the given resolver.
|
|
227
|
-
*/
|
|
228
|
-
register(type: string, provider: TaskProvider, handle?: number): Disposable {
|
|
229
|
-
const key = handle === undefined ? type : `${type}::${handle}`;
|
|
230
|
-
this.providers.set(key, provider);
|
|
231
|
-
return {
|
|
232
|
-
dispose: () => this.providers.delete(key)
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Initiates activation of a TaskProvider with the given type
|
|
238
|
-
* @param type the task configuration type, '*' indicates, all providers.
|
|
239
|
-
*/
|
|
240
|
-
async activateProvider(type: string): Promise<void> {
|
|
241
|
-
await WaitUntilEvent.fire(this.onWillProvideTaskProviderEmitter, { taskType: type });
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Retrieves the {@link TaskProvider} registered for the given type task configuration type.
|
|
246
|
-
* If there is already a `TaskProvider` registered for the specified type the registration will
|
|
247
|
-
* be overwritten with the new value.
|
|
248
|
-
* @param type the task configuration type.
|
|
249
|
-
*
|
|
250
|
-
* @returns a promise of the registered `TaskProvider`` or `undefined` if no provider is registered for the given type.
|
|
251
|
-
*/
|
|
252
|
-
async getProvider(type: string): Promise<TaskProvider | undefined> {
|
|
253
|
-
await this.activateProvider(type);
|
|
254
|
-
return this.providers.get(type);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Retrieve all registered {@link TaskProvider}s.
|
|
259
|
-
*
|
|
260
|
-
* Use {@link activateProvider} to control registration of providers as needed.
|
|
261
|
-
* @returns a promise of all registered {@link TaskProvider}s.
|
|
262
|
-
*/
|
|
263
|
-
async getProviders(): Promise<TaskProvider[]> {
|
|
264
|
-
return [...this.providers.values()];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Disposable } from '@theia/core/lib/common/disposable';
|
|
19
|
+
import { TaskConfiguration } from '../common/task-protocol';
|
|
20
|
+
import { WaitUntilEvent, Emitter } from '@theia/core/lib/common/event';
|
|
21
|
+
|
|
22
|
+
export const TaskContribution = Symbol('TaskContribution');
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A {@link TaskContribution} allows to contribute custom {@link TaskResolver}s and/or {@link TaskProvider}s.
|
|
26
|
+
*
|
|
27
|
+
* ### Example usage
|
|
28
|
+
* ```typescript
|
|
29
|
+
* @injectable()
|
|
30
|
+
* export class ProcessTaskContribution implements TaskContribution {
|
|
31
|
+
*
|
|
32
|
+
* @inject(ProcessTaskResolver)
|
|
33
|
+
* protected readonly processTaskResolver: ProcessTaskResolver;
|
|
34
|
+
*
|
|
35
|
+
* registerResolvers(resolvers: TaskResolverRegistry): void {
|
|
36
|
+
* resolvers.register('process', this.processTaskResolver);
|
|
37
|
+
* resolvers.register('shell', this.processTaskResolver);
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export interface TaskContribution {
|
|
43
|
+
/**
|
|
44
|
+
* Register task resolvers using the given `TaskResolverRegistry`.
|
|
45
|
+
* @param resolvers the task resolver registry.
|
|
46
|
+
*/
|
|
47
|
+
registerResolvers?(resolvers: TaskResolverRegistry): void;
|
|
48
|
+
/**
|
|
49
|
+
* Register task providers using the given `TaskProviderRegistry`.
|
|
50
|
+
* @param resolvers the task provider registry.
|
|
51
|
+
*/
|
|
52
|
+
registerProviders?(providers: TaskProviderRegistry): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A {@link TaskResolver} is used to preprocess/resolve a task before sending
|
|
57
|
+
* it to the Task Server. For instance, the resolver can be used to add missing information to the configuration
|
|
58
|
+
* (e.g default values for optional parameters).
|
|
59
|
+
*/
|
|
60
|
+
export interface TaskResolver {
|
|
61
|
+
/**
|
|
62
|
+
* Resolves a `TaskConfiguration` before sending it for execution to the `TaskServer` (Backend).
|
|
63
|
+
* @param taskConfig the configuration that should be resolved.
|
|
64
|
+
*
|
|
65
|
+
* @returns a promise of the resolved `TaskConfiguration`.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
resolveTask(taskConfig: TaskConfiguration): Promise<TaskConfiguration>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A {@link TaskProvider} can be used to define the set of tasks that should
|
|
73
|
+
* be provided to the system. i.e. that are available for the user to run.
|
|
74
|
+
*/
|
|
75
|
+
export interface TaskProvider {
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves the task configurations which are provided programmatically to the system.
|
|
78
|
+
*
|
|
79
|
+
* @returns a promise of the provided tasks configurations.
|
|
80
|
+
*/
|
|
81
|
+
provideTasks(): Promise<TaskConfiguration[]>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface WillResolveTaskProvider extends WaitUntilEvent {
|
|
85
|
+
taskType?: string
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The {@link TaskResolverRegistry} is the common component for registration and provision of
|
|
90
|
+
* {@link TaskResolver}s. Theia will collect all {@link TaskContribution}s and invoke {@link TaskContribution#registerResolvers}
|
|
91
|
+
* for each contribution.
|
|
92
|
+
*/
|
|
93
|
+
@injectable()
|
|
94
|
+
export class TaskResolverRegistry {
|
|
95
|
+
|
|
96
|
+
protected readonly onWillProvideTaskResolverEmitter = new Emitter<WillResolveTaskProvider>();
|
|
97
|
+
/**
|
|
98
|
+
* Emit when the registry provides a registered resolver. i.e. when the {@link TaskResolverRegistry#getResolver}
|
|
99
|
+
* function is called.
|
|
100
|
+
*/
|
|
101
|
+
readonly onWillProvideTaskResolver = this.onWillProvideTaskResolverEmitter.event;
|
|
102
|
+
|
|
103
|
+
protected taskResolvers: Map<string, TaskResolver> = new Map();
|
|
104
|
+
protected executionResolvers: Map<string, TaskResolver> = new Map();
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Registers the given {@link TaskResolver} to resolve the `TaskConfiguration` of the specified type.
|
|
108
|
+
* If there is already a `TaskResolver` registered for the specified type the registration will
|
|
109
|
+
* be overwritten with the new value.
|
|
110
|
+
*
|
|
111
|
+
* @deprecated since 1.12.0 use `registerTaskResolver` instead.
|
|
112
|
+
*
|
|
113
|
+
* @param type the task configuration type for which the given resolver should be registered.
|
|
114
|
+
* @param resolver the task resolver that should be registered.
|
|
115
|
+
*
|
|
116
|
+
* @returns a `Disposable` that can be invoked to unregister the given resolver
|
|
117
|
+
*/
|
|
118
|
+
register(type: string, resolver: TaskResolver): Disposable {
|
|
119
|
+
return this.registerTaskResolver(type, resolver);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Registers the given {@link TaskResolver} to resolve the `TaskConfiguration` of the specified type.
|
|
124
|
+
* If there is already a `TaskResolver` registered for the specified type the registration will
|
|
125
|
+
* be overwritten with the new value.
|
|
126
|
+
*
|
|
127
|
+
* @param type the task configuration type for which the given resolver should be registered.
|
|
128
|
+
* @param resolver the task resolver that should be registered.
|
|
129
|
+
*
|
|
130
|
+
* @returns a `Disposable` that can be invoked to unregister the given resolver
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
registerTaskResolver(type: string, resolver: TaskResolver): Disposable {
|
|
134
|
+
if (this.taskResolvers.has(type)) {
|
|
135
|
+
console.warn(`Overriding task resolver for ${type}`);
|
|
136
|
+
}
|
|
137
|
+
this.taskResolvers.set(type, resolver);
|
|
138
|
+
return {
|
|
139
|
+
dispose: () => this.taskResolvers.delete(type)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Retrieves the {@link TaskResolver} registered for the given type task configuration type.
|
|
145
|
+
*
|
|
146
|
+
* @deprecated since 1.12.0 use `getTaskResolver()` instead.
|
|
147
|
+
*
|
|
148
|
+
* @param type the task configuration type
|
|
149
|
+
*
|
|
150
|
+
* @returns a promise of the registered `TaskResolver` or `undefined` if no resolver is registered for the given type.
|
|
151
|
+
*/
|
|
152
|
+
async getResolver(type: string): Promise<TaskResolver | undefined> {
|
|
153
|
+
return this.getTaskResolver(type);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves the {@link TaskResolver} registered for the given type task configuration type.
|
|
158
|
+
* @param type the task configuration type
|
|
159
|
+
*
|
|
160
|
+
* @returns a promise of the registered `TaskResolver` or `undefined` if no resolver is registered for the given type.
|
|
161
|
+
*/
|
|
162
|
+
async getTaskResolver(type: string): Promise<TaskResolver | undefined> {
|
|
163
|
+
await WaitUntilEvent.fire(this.onWillProvideTaskResolverEmitter, { taskType: type });
|
|
164
|
+
return this.taskResolvers.get(type);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Registers the given {@link TaskResolver} to resolve the `TaskConfiguration` for the
|
|
169
|
+
* specified type of execution ('shell', 'process' or 'customExecution').
|
|
170
|
+
* If there is already a `TaskResolver` registered for the specified type the registration will
|
|
171
|
+
* be overwritten with the new value.
|
|
172
|
+
*
|
|
173
|
+
* @param type the task execution type for which the given resolver should be registered.
|
|
174
|
+
* @param resolver the task resolver that should be registered.
|
|
175
|
+
*
|
|
176
|
+
* @returns a `Disposable` that can be invoked to unregister the given resolver
|
|
177
|
+
*/
|
|
178
|
+
registerExecutionResolver(type: string, resolver: TaskResolver): Disposable {
|
|
179
|
+
if (this.executionResolvers.has(type)) {
|
|
180
|
+
console.warn(`Overriding execution resolver for ${type}`);
|
|
181
|
+
}
|
|
182
|
+
this.executionResolvers.set(type, resolver);
|
|
183
|
+
return {
|
|
184
|
+
dispose: () => this.executionResolvers.delete(type)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves the {@link TaskResolver} registered for the given type of execution ('shell', 'process' or 'customExecution')..
|
|
190
|
+
* @param type the task configuration type
|
|
191
|
+
*
|
|
192
|
+
* @returns a promise of the registered `TaskResolver` or `undefined` if no resolver is registered for the given type.
|
|
193
|
+
*/
|
|
194
|
+
getExecutionResolver(executionType: string): TaskResolver | undefined {
|
|
195
|
+
return this.executionResolvers.get(executionType);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The {@link TaskProviderRegistry} is the common component for registration and provision of
|
|
201
|
+
* {@link TaskProvider}s. Theia will collect all {@link TaskContribution}s and invoke {@link TaskContribution#registerProviders}
|
|
202
|
+
* for each contribution.
|
|
203
|
+
*/
|
|
204
|
+
@injectable()
|
|
205
|
+
export class TaskProviderRegistry {
|
|
206
|
+
|
|
207
|
+
protected readonly onWillProvideTaskProviderEmitter = new Emitter<WillResolveTaskProvider>();
|
|
208
|
+
/**
|
|
209
|
+
* Emit when the registry provides a registered task provider. i.e. when the {@link TaskProviderRegistry#getProvider}
|
|
210
|
+
* function is called.
|
|
211
|
+
*/
|
|
212
|
+
readonly onWillProvideTaskProvider = this.onWillProvideTaskProviderEmitter.event;
|
|
213
|
+
|
|
214
|
+
protected providers: Map<string, TaskProvider>;
|
|
215
|
+
|
|
216
|
+
@postConstruct()
|
|
217
|
+
protected init(): void {
|
|
218
|
+
this.providers = new Map();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Registers the given {@link TaskProvider} for task configurations of the specified type
|
|
223
|
+
* @param type the task configuration type for which the given provider should be registered.
|
|
224
|
+
* @param provider the `TaskProvider` that should be registered.
|
|
225
|
+
*
|
|
226
|
+
* @returns a `Disposable` that can be invoked to unregister the given resolver.
|
|
227
|
+
*/
|
|
228
|
+
register(type: string, provider: TaskProvider, handle?: number): Disposable {
|
|
229
|
+
const key = handle === undefined ? type : `${type}::${handle}`;
|
|
230
|
+
this.providers.set(key, provider);
|
|
231
|
+
return {
|
|
232
|
+
dispose: () => this.providers.delete(key)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Initiates activation of a TaskProvider with the given type
|
|
238
|
+
* @param type the task configuration type, '*' indicates, all providers.
|
|
239
|
+
*/
|
|
240
|
+
async activateProvider(type: string): Promise<void> {
|
|
241
|
+
await WaitUntilEvent.fire(this.onWillProvideTaskProviderEmitter, { taskType: type });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Retrieves the {@link TaskProvider} registered for the given type task configuration type.
|
|
246
|
+
* If there is already a `TaskProvider` registered for the specified type the registration will
|
|
247
|
+
* be overwritten with the new value.
|
|
248
|
+
* @param type the task configuration type.
|
|
249
|
+
*
|
|
250
|
+
* @returns a promise of the registered `TaskProvider`` or `undefined` if no provider is registered for the given type.
|
|
251
|
+
*/
|
|
252
|
+
async getProvider(type: string): Promise<TaskProvider | undefined> {
|
|
253
|
+
await this.activateProvider(type);
|
|
254
|
+
return this.providers.get(type);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Retrieve all registered {@link TaskProvider}s.
|
|
259
|
+
*
|
|
260
|
+
* Use {@link activateProvider} to control registration of providers as needed.
|
|
261
|
+
* @returns a promise of all registered {@link TaskProvider}s.
|
|
262
|
+
*/
|
|
263
|
+
async getProviders(): Promise<TaskProvider[]> {
|
|
264
|
+
return [...this.providers.values()];
|
|
265
|
+
}
|
|
266
|
+
}
|