@theia/task 1.45.0 → 1.46.0-next.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +193 -193
  2. package/lib/browser/index.d.ts +6 -6
  3. package/lib/browser/index.js +33 -33
  4. package/lib/browser/process/process-task-contribution.d.ts +6 -6
  5. package/lib/browser/process/process-task-contribution.js +43 -43
  6. package/lib/browser/process/process-task-frontend-module.d.ts +2 -2
  7. package/lib/browser/process/process-task-frontend-module.js +27 -27
  8. package/lib/browser/process/process-task-resolver.d.ts +17 -17
  9. package/lib/browser/process/process-task-resolver.js +101 -101
  10. package/lib/browser/provided-task-configurations.d.ts +43 -43
  11. package/lib/browser/provided-task-configurations.js +213 -213
  12. package/lib/browser/provided-task-configurations.spec.d.ts +1 -1
  13. package/lib/browser/provided-task-configurations.spec.js +43 -43
  14. package/lib/browser/quick-open-task.d.ts +144 -144
  15. package/lib/browser/quick-open-task.d.ts.map +1 -1
  16. package/lib/browser/quick-open-task.js +752 -748
  17. package/lib/browser/quick-open-task.js.map +1 -1
  18. package/lib/browser/task-configuration-manager.d.ts +64 -64
  19. package/lib/browser/task-configuration-manager.js +261 -261
  20. package/lib/browser/task-configuration-model.d.ts +32 -32
  21. package/lib/browser/task-configuration-model.js +79 -79
  22. package/lib/browser/task-configurations.d.ts +127 -127
  23. package/lib/browser/task-configurations.js +486 -486
  24. package/lib/browser/task-contribution.d.ts +182 -182
  25. package/lib/browser/task-contribution.js +206 -206
  26. package/lib/browser/task-definition-registry.d.ts +38 -38
  27. package/lib/browser/task-definition-registry.js +134 -134
  28. package/lib/browser/task-definition-registry.spec.d.ts +1 -1
  29. package/lib/browser/task-definition-registry.spec.js +170 -170
  30. package/lib/browser/task-frontend-contribution.d.ts +56 -56
  31. package/lib/browser/task-frontend-contribution.js +358 -358
  32. package/lib/browser/task-frontend-module.d.ts +5 -5
  33. package/lib/browser/task-frontend-module.js +79 -79
  34. package/lib/browser/task-name-resolver.d.ts +13 -13
  35. package/lib/browser/task-name-resolver.js +67 -67
  36. package/lib/browser/task-node.d.ts +9 -9
  37. package/lib/browser/task-node.js +17 -17
  38. package/lib/browser/task-preferences.d.ts +4 -4
  39. package/lib/browser/task-preferences.js +40 -40
  40. package/lib/browser/task-problem-matcher-registry.d.ts +40 -40
  41. package/lib/browser/task-problem-matcher-registry.js +309 -309
  42. package/lib/browser/task-problem-pattern-registry.d.ts +23 -23
  43. package/lib/browser/task-problem-pattern-registry.js +210 -210
  44. package/lib/browser/task-schema-updater.d.ts +58 -58
  45. package/lib/browser/task-schema-updater.js +688 -688
  46. package/lib/browser/task-service.d.ts +279 -279
  47. package/lib/browser/task-service.js +1119 -1119
  48. package/lib/browser/task-source-resolver.d.ts +9 -9
  49. package/lib/browser/task-source-resolver.js +51 -51
  50. package/lib/browser/task-templates.d.ts +13 -13
  51. package/lib/browser/task-templates.js +161 -161
  52. package/lib/browser/task-terminal-widget-manager.d.ts +44 -44
  53. package/lib/browser/task-terminal-widget-manager.js +228 -228
  54. package/lib/browser/tasks-monaco-contribution.d.ts +1 -1
  55. package/lib/browser/tasks-monaco-contribution.js +27 -27
  56. package/lib/common/index.d.ts +4 -4
  57. package/lib/common/index.js +31 -31
  58. package/lib/common/problem-matcher-protocol.d.ts +124 -124
  59. package/lib/common/problem-matcher-protocol.js +132 -132
  60. package/lib/common/process/task-protocol.d.ts +68 -68
  61. package/lib/common/process/task-protocol.js +33 -33
  62. package/lib/common/task-common-module.d.ts +7 -7
  63. package/lib/common/task-common-module.js +33 -33
  64. package/lib/common/task-protocol.d.ts +192 -192
  65. package/lib/common/task-protocol.js +137 -137
  66. package/lib/common/task-util.d.ts +22 -22
  67. package/lib/common/task-util.js +46 -46
  68. package/lib/common/task-watcher.d.ts +17 -17
  69. package/lib/common/task-watcher.js +86 -86
  70. package/lib/node/custom/custom-task-runner-backend-module.d.ts +2 -2
  71. package/lib/node/custom/custom-task-runner-backend-module.js +36 -36
  72. package/lib/node/custom/custom-task-runner-contribution.d.ts +6 -6
  73. package/lib/node/custom/custom-task-runner-contribution.js +42 -42
  74. package/lib/node/custom/custom-task-runner.d.ts +15 -15
  75. package/lib/node/custom/custom-task-runner.js +69 -69
  76. package/lib/node/custom/custom-task.d.ts +20 -20
  77. package/lib/node/custom/custom-task.js +78 -78
  78. package/lib/node/index.d.ts +3 -3
  79. package/lib/node/index.js +30 -30
  80. package/lib/node/process/process-task-runner-backend-module.d.ts +2 -2
  81. package/lib/node/process/process-task-runner-backend-module.js +36 -36
  82. package/lib/node/process/process-task-runner-contribution.d.ts +6 -6
  83. package/lib/node/process/process-task-runner-contribution.js +43 -43
  84. package/lib/node/process/process-task-runner.d.ts +60 -60
  85. package/lib/node/process/process-task-runner.js +355 -355
  86. package/lib/node/process/process-task.d.ts +26 -26
  87. package/lib/node/process/process-task.js +135 -135
  88. package/lib/node/process/process-task.spec.d.ts +1 -1
  89. package/lib/node/process/process-task.spec.js +29 -29
  90. package/lib/node/task-abstract-line-matcher.d.ts +49 -49
  91. package/lib/node/task-abstract-line-matcher.js +273 -273
  92. package/lib/node/task-backend-application-contribution.d.ts +8 -8
  93. package/lib/node/task-backend-application-contribution.js +48 -48
  94. package/lib/node/task-backend-module.d.ts +3 -3
  95. package/lib/node/task-backend-module.js +50 -50
  96. package/lib/node/task-line-matchers.d.ts +27 -27
  97. package/lib/node/task-line-matchers.js +121 -121
  98. package/lib/node/task-manager.d.ts +55 -55
  99. package/lib/node/task-manager.js +135 -135
  100. package/lib/node/task-problem-collector.d.ts +10 -10
  101. package/lib/node/task-problem-collector.js +57 -57
  102. package/lib/node/task-problem-collector.spec.d.ts +1 -1
  103. package/lib/node/task-problem-collector.spec.js +310 -310
  104. package/lib/node/task-runner-protocol.d.ts +16 -16
  105. package/lib/node/task-runner-protocol.js +19 -19
  106. package/lib/node/task-runner.d.ts +50 -50
  107. package/lib/node/task-runner.js +97 -97
  108. package/lib/node/task-server.d.ts +39 -39
  109. package/lib/node/task-server.js +237 -237
  110. package/lib/node/task-server.slow-spec.d.ts +1 -1
  111. package/lib/node/task-server.slow-spec.js +395 -395
  112. package/lib/node/task.d.ts +50 -50
  113. package/lib/node/task.js +77 -77
  114. package/lib/node/test/task-test-container.d.ts +2 -2
  115. package/lib/node/test/task-test-container.js +58 -58
  116. package/package.json +14 -14
  117. package/src/browser/index.ts +22 -22
  118. package/src/browser/process/process-task-contribution.ts +31 -31
  119. package/src/browser/process/process-task-frontend-module.ts +27 -27
  120. package/src/browser/process/process-task-resolver.ts +89 -89
  121. package/src/browser/provided-task-configurations.spec.ts +46 -46
  122. package/src/browser/provided-task-configurations.ts +213 -213
  123. package/src/browser/quick-open-task.ts +831 -827
  124. package/src/browser/style/index.css +19 -19
  125. package/src/browser/task-configuration-manager.ts +256 -256
  126. package/src/browser/task-configuration-model.ts +101 -101
  127. package/src/browser/task-configurations.ts +508 -508
  128. package/src/browser/task-contribution.ts +266 -266
  129. package/src/browser/task-definition-registry.spec.ts +203 -203
  130. package/src/browser/task-definition-registry.ts +131 -131
  131. package/src/browser/task-frontend-contribution.ts +402 -402
  132. package/src/browser/task-frontend-module.ts +86 -86
  133. package/src/browser/task-name-resolver.ts +55 -55
  134. package/src/browser/task-node.ts +37 -37
  135. package/src/browser/task-preferences.ts +40 -40
  136. package/src/browser/task-problem-matcher-registry.ts +308 -308
  137. package/src/browser/task-problem-pattern-registry.ts +196 -196
  138. package/src/browser/task-schema-updater.ts +701 -701
  139. package/src/browser/task-service.ts +1164 -1164
  140. package/src/browser/task-source-resolver.ts +36 -36
  141. package/src/browser/task-templates.ts +168 -168
  142. package/src/browser/task-terminal-widget-manager.ts +224 -224
  143. package/src/browser/tasks-monaco-contribution.ts +27 -27
  144. package/src/common/index.ts +20 -20
  145. package/src/common/problem-matcher-protocol.ts +234 -234
  146. package/src/common/process/task-protocol.ts +97 -97
  147. package/src/common/task-common-module.ts +34 -34
  148. package/src/common/task-protocol.ts +317 -317
  149. package/src/common/task-util.ts +43 -43
  150. package/src/common/task-watcher.ts +78 -78
  151. package/src/node/custom/custom-task-runner-backend-module.ts +37 -37
  152. package/src/node/custom/custom-task-runner-contribution.ts +30 -30
  153. package/src/node/custom/custom-task-runner.ts +60 -60
  154. package/src/node/custom/custom-task.ts +73 -73
  155. package/src/node/index.ts +19 -19
  156. package/src/node/process/process-task-runner-backend-module.ts +37 -37
  157. package/src/node/process/process-task-runner-contribution.ts +31 -31
  158. package/src/node/process/process-task-runner.ts +371 -371
  159. package/src/node/process/process-task.spec.ts +30 -30
  160. package/src/node/process/process-task.ts +144 -144
  161. package/src/node/task-abstract-line-matcher.ts +312 -312
  162. package/src/node/task-backend-application-contribution.ts +36 -36
  163. package/src/node/task-backend-module.ts +57 -57
  164. package/src/node/task-line-matchers.ts +127 -127
  165. package/src/node/task-manager.ts +129 -129
  166. package/src/node/task-problem-collector.spec.ts +338 -338
  167. package/src/node/task-problem-collector.ts +62 -62
  168. package/src/node/task-runner-protocol.ts +33 -33
  169. package/src/node/task-runner.ts +96 -96
  170. package/src/node/task-server.slow-spec.ts +444 -444
  171. package/src/node/task-server.ts +263 -263
  172. package/src/node/task.ts +103 -103
  173. package/src/node/test/task-test-container.ts +63 -63
@@ -1,701 +1,701 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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
- // This file is inspired by VSCode and partially copied from https://github.com/Microsoft/vscode/blob/1.33.1/src/vs/workbench/contrib/tasks/common/problemMatcher.ts
17
- // 'problemMatcher.ts' copyright:
18
- /*---------------------------------------------------------------------------------------------
19
- * Copyright (c) Microsoft Corporation. All rights reserved.
20
- * Licensed under the MIT License. See License.txt in the project root for license information.
21
- *--------------------------------------------------------------------------------------------*/
22
-
23
- import * as Ajv from '@theia/core/shared/ajv';
24
- import debounce = require('p-debounce');
25
- import { postConstruct, injectable, inject } from '@theia/core/shared/inversify';
26
- import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
27
- import { InMemoryResources, deepClone, Emitter } from '@theia/core/lib/common';
28
- import { IJSONSchema } from '@theia/core/lib/common/json-schema';
29
- import { inputsSchema } from '@theia/variable-resolver/lib/browser/variable-input-schema';
30
- import URI from '@theia/core/lib/common/uri';
31
- import { ProblemMatcherRegistry } from './task-problem-matcher-registry';
32
- import { TaskDefinitionRegistry } from './task-definition-registry';
33
- import { TaskServer, asVariableName } from '../common';
34
- import { UserStorageUri } from '@theia/userstorage/lib/browser';
35
- import { WorkspaceService } from '@theia/workspace/lib/browser';
36
- import { JSONObject } from '@theia/core/shared/@phosphor/coreutils';
37
-
38
- export const taskSchemaId = 'vscode://schemas/tasks';
39
-
40
- @injectable()
41
- export class TaskSchemaUpdater implements JsonSchemaContribution {
42
-
43
- @inject(InMemoryResources)
44
- protected readonly inmemoryResources: InMemoryResources;
45
-
46
- @inject(ProblemMatcherRegistry)
47
- protected readonly problemMatcherRegistry: ProblemMatcherRegistry;
48
-
49
- @inject(TaskDefinitionRegistry)
50
- protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
51
-
52
- @inject(TaskServer)
53
- protected readonly taskServer: TaskServer;
54
-
55
- @inject(WorkspaceService)
56
- protected readonly workspaceService: WorkspaceService;
57
-
58
- protected readonly onDidChangeTaskSchemaEmitter = new Emitter<void>();
59
- readonly onDidChangeTaskSchema = this.onDidChangeTaskSchemaEmitter.event;
60
-
61
- protected readonly uri = new URI(taskSchemaId);
62
-
63
- @postConstruct()
64
- protected init(): void {
65
- const resource = this.inmemoryResources.add(this.uri, '');
66
- if (resource.onDidChangeContents) {
67
- resource.onDidChangeContents(() => {
68
- this.onDidChangeTaskSchemaEmitter.fire(undefined);
69
- });
70
- }
71
- this.updateProblemMatcherNames();
72
- this.updateSupportedTaskTypes();
73
- // update problem matcher names in the task schema every time a problem matcher is added or disposed
74
- this.problemMatcherRegistry.onDidChangeProblemMatcher(() => this.updateProblemMatcherNames());
75
- // update supported task types in the task schema every time a task definition is registered or removed
76
- this.taskDefinitionRegistry.onDidRegisterTaskDefinition(() => this.updateSupportedTaskTypes());
77
- this.taskDefinitionRegistry.onDidUnregisterTaskDefinition(() => this.updateSupportedTaskTypes());
78
- }
79
-
80
- registerSchemas(context: JsonSchemaRegisterContext): void {
81
- context.registerSchema({
82
- fileMatch: ['tasks.json', UserStorageUri.resolve('tasks.json').toString()],
83
- url: this.uri.toString()
84
- });
85
- this.workspaceService.updateSchema('tasks', { $ref: this.uri.toString() });
86
- }
87
-
88
- readonly update = debounce(() => this.doUpdate(), 0);
89
- protected doUpdate(): void {
90
- taskConfigurationSchema.anyOf = [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas];
91
-
92
- const schema = this.getTaskSchema();
93
- this.doValidate = new Ajv().compile(schema);
94
- const schemaContent = JSON.stringify(schema);
95
- this.inmemoryResources.update(this.uri, schemaContent);
96
- }
97
-
98
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
- validate(data: any): boolean {
100
- return !!this.doValidate && !!this.doValidate(data);
101
- }
102
- protected doValidate: Ajv.ValidateFunction | undefined;
103
-
104
- /**
105
- * Adds given task schema to `taskConfigurationSchema` as `oneOf` subschema.
106
- * Replaces existed subschema by given schema if the corresponding `$id` properties are equal.
107
- *
108
- * Note: please provide `$id` property for subschema to have ability remove/replace it.
109
- * @param schema subschema for adding to `taskConfigurationSchema`
110
- */
111
- addSubschema(schema: IJSONSchema): void {
112
- const schemaId = schema.$id;
113
- if (schemaId) {
114
- this.doRemoveSubschema(schemaId);
115
- }
116
-
117
- customSchemas.push(schema);
118
- this.update();
119
- }
120
-
121
- /**
122
- * Removes task subschema from `taskConfigurationSchema`.
123
- *
124
- * @param arg `$id` property of subschema
125
- */
126
- removeSubschema(arg: string): void {
127
- const isRemoved = this.doRemoveSubschema(arg);
128
- if (isRemoved) {
129
- this.update();
130
- }
131
- }
132
-
133
- /**
134
- * Removes task subschema from `customSchemas`, use `update()` to apply the changes for `taskConfigurationSchema`.
135
- *
136
- * @param arg `$id` property of subschema
137
- * @returns `true` if subschema was removed, `false` otherwise
138
- */
139
- protected doRemoveSubschema(arg: string): boolean {
140
- const index = customSchemas.findIndex(existed => !!existed.$id && existed.$id === arg);
141
- if (index > -1) {
142
- customSchemas.splice(index, 1);
143
- return true;
144
- }
145
- return false;
146
- }
147
-
148
- /** Returns an array of task types that are registered, including the default types */
149
- async getRegisteredTaskTypes(): Promise<string[]> {
150
- const serverSupportedTypes = await this.taskServer.getRegisteredTaskTypes();
151
- const browserSupportedTypes = this.taskDefinitionRegistry.getAll().map(def => def.taskType);
152
- const allTypes = new Set([...serverSupportedTypes, ...browserSupportedTypes]);
153
- return Array.from(allTypes.values()).sort();
154
- }
155
-
156
- private updateSchemasForRegisteredTasks(): void {
157
- customizedDetectedTasks.length = 0;
158
- const definitions = this.taskDefinitionRegistry.getAll();
159
- definitions.forEach(def => {
160
- const customizedDetectedTask: IJSONSchema = {
161
- type: 'object',
162
- required: ['type'],
163
- properties: {}
164
- };
165
- const taskType = {
166
- ...defaultTaskType,
167
- enum: [def.taskType],
168
- default: def.taskType,
169
- description: 'The task type to customize'
170
- };
171
- customizedDetectedTask.properties!.type = taskType;
172
- const required = def.properties.required || [];
173
- def.properties.all.forEach(taskProp => {
174
- if (required.find(requiredProp => requiredProp === taskProp)) { // property is mandatory
175
- customizedDetectedTask.required!.push(taskProp);
176
- }
177
- customizedDetectedTask.properties![taskProp] = { ...def.properties.schema.properties![taskProp] };
178
- });
179
- customizedDetectedTask.properties!.label = taskLabel;
180
- customizedDetectedTask.properties!.problemMatcher = problemMatcher;
181
- customizedDetectedTask.properties!.presentation = presentation;
182
- customizedDetectedTask.properties!.options = commandOptionsSchema;
183
- customizedDetectedTask.properties!.group = group;
184
- customizedDetectedTask.properties!.detail = detail;
185
- customizedDetectedTask.additionalProperties = true;
186
- customizedDetectedTasks.push(customizedDetectedTask);
187
- });
188
- }
189
-
190
- /** Returns the task's JSON schema */
191
- getTaskSchema(): IJSONSchema & { default: JSONObject } {
192
- return {
193
- type: 'object',
194
- default: { version: '2.0.0', tasks: [] },
195
- properties: {
196
- version: {
197
- type: 'string',
198
- default: '2.0.0'
199
- },
200
- tasks: {
201
- type: 'array',
202
- items: {
203
- ...deepClone(taskConfigurationSchema)
204
- }
205
- },
206
- inputs: inputsSchema.definitions!.inputs
207
- },
208
- additionalProperties: false,
209
- allowComments: true,
210
- allowTrailingCommas: true,
211
- };
212
- }
213
-
214
- /** Gets the most up-to-date names of problem matchers from the registry and update the task schema */
215
- private updateProblemMatcherNames(): void {
216
- const matcherNames = this.problemMatcherRegistry.getAll().map(m => asVariableName(m.name));
217
- problemMatcherNames.length = 0;
218
- problemMatcherNames.push(...matcherNames);
219
- this.update();
220
- }
221
-
222
- private async updateSupportedTaskTypes(): Promise<void> {
223
- this.updateSchemasForRegisteredTasks();
224
- this.update();
225
- }
226
- }
227
-
228
- const commandSchema: IJSONSchema = {
229
- type: 'string',
230
- description: 'The actual command or script to execute'
231
- };
232
-
233
- const commandArgSchema: IJSONSchema = {
234
- type: 'array',
235
- description: 'A list of strings, each one being one argument to pass to the command',
236
- items: {
237
- type: 'string'
238
- }
239
- };
240
-
241
- const commandOptionsSchema: IJSONSchema = {
242
- type: 'object',
243
- description: 'The command options used when the command is executed',
244
- properties: {
245
- cwd: {
246
- type: 'string',
247
- description: 'The directory in which the command will be executed',
248
- default: '${workspaceFolder}'
249
- },
250
- env: {
251
- type: 'object',
252
- description: 'The environment of the executed program or shell. If omitted the parent process\' environment is used'
253
- },
254
- shell: {
255
- type: 'object',
256
- description: 'Configuration of the shell when task type is `shell`',
257
- properties: {
258
- executable: {
259
- type: 'string',
260
- description: 'The shell to use'
261
- },
262
- args: {
263
- type: 'array',
264
- description: `The arguments to be passed to the shell executable to run in command mode
265
- (e.g ['-c'] for bash or ['/S', '/C'] for cmd.exe)`,
266
- items: {
267
- type: 'string'
268
- }
269
- }
270
- }
271
- }
272
- }
273
- };
274
-
275
- const problemMatcherNames: string[] = [];
276
- const defaultTaskTypes = ['shell', 'process'];
277
- const supportedTaskTypes = [...defaultTaskTypes];
278
- const taskLabel: IJSONSchema = {
279
- type: 'string',
280
- description: 'A unique string that identifies the task that is also used as task\'s user interface label'
281
- };
282
- const defaultTaskType: IJSONSchema = {
283
- type: 'string',
284
- enum: supportedTaskTypes,
285
- default: defaultTaskTypes[0],
286
- description: 'Determines what type of process will be used to execute the task. Only shell types will have output shown on the user interface'
287
- } as const;
288
- const commandAndArgs = {
289
- command: commandSchema,
290
- args: commandArgSchema,
291
- options: commandOptionsSchema
292
- };
293
-
294
- const group: IJSONSchema = {
295
- oneOf: [
296
- {
297
- type: 'string',
298
- enum: ['build', 'test', 'none'],
299
- enumDescriptions: [
300
- 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
301
- 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
302
- 'Assigns the task to no group'
303
- ]
304
- },
305
- {
306
- type: 'object',
307
- properties: {
308
- kind: {
309
- type: 'string',
310
- default: 'none',
311
- description: 'The task\'s execution group.',
312
- enum: ['build', 'test', 'none'],
313
- enumDescriptions: [
314
- 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
315
- 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
316
- 'Assigns the task to no group'
317
- ]
318
- },
319
- isDefault: {
320
- type: 'boolean',
321
- default: false,
322
- description: 'Defines if this task is the default task in the group.'
323
- }
324
- }
325
- }
326
- ],
327
- // eslint-disable-next-line max-len
328
- description: 'Defines to which execution group this task belongs to. It supports "build" to add it to the build group and "test" to add it to the test group.'
329
- };
330
-
331
- const problemPattern: IJSONSchema = {
332
- default: {
333
- regexp: '^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$',
334
- file: 1,
335
- location: 2,
336
- message: 3
337
- },
338
- type: 'object',
339
- properties: {
340
- regexp: {
341
- type: 'string',
342
- description: 'The regular expression to find an error, warning or info in the output.'
343
- },
344
- kind: {
345
- type: 'string',
346
- description: 'whether the pattern matches a location (file and line) or only a file.'
347
- },
348
- file: {
349
- type: 'integer',
350
- description: 'The match group index of the filename. If omitted 1 is used.'
351
- },
352
- location: {
353
- type: 'integer',
354
- // eslint-disable-next-line max-len
355
- description: 'The match group index of the problem\'s location. Valid location patterns are: (line), (line,column) and (startLine,startColumn,endLine,endColumn). If omitted (line,column) is assumed.'
356
- },
357
- line: {
358
- type: 'integer',
359
- description: 'The match group index of the problem\'s line. Defaults to 2'
360
- },
361
- column: {
362
- type: 'integer',
363
- description: 'The match group index of the problem\'s line character. Defaults to 3'
364
- },
365
- endLine: {
366
- type: 'integer',
367
- description: 'The match group index of the problem\'s end line. Defaults to undefined'
368
- },
369
- endColumn: {
370
- type: 'integer',
371
- description: 'The match group index of the problem\'s end line character. Defaults to undefined'
372
- },
373
- severity: {
374
- type: 'integer',
375
- description: 'The match group index of the problem\'s severity. Defaults to undefined'
376
- },
377
- code: {
378
- type: 'integer',
379
- description: 'The match group index of the problem\'s code. Defaults to undefined'
380
- },
381
- message: {
382
- type: 'integer',
383
- description: 'The match group index of the message. If omitted it defaults to 4 if location is specified. Otherwise it defaults to 5.'
384
- },
385
- loop: {
386
- type: 'boolean',
387
- // eslint-disable-next-line max-len
388
- description: 'In a multi line matcher loop indicated whether this pattern is executed in a loop as long as it matches. Can only specified on a last pattern in a multi line pattern.'
389
- }
390
- }
391
- };
392
-
393
- const multiLineProblemPattern: IJSONSchema = {
394
- type: 'array',
395
- items: problemPattern
396
- };
397
-
398
- const watchingPattern: IJSONSchema = {
399
- type: 'object',
400
- additionalProperties: false,
401
- properties: {
402
- regexp: {
403
- type: 'string',
404
- description: 'The regular expression to detect the begin or end of a background task.'
405
- },
406
- file: {
407
- type: 'integer',
408
- description: 'The match group index of the filename. Can be omitted.'
409
- },
410
- }
411
- };
412
-
413
- const patternType: IJSONSchema = {
414
- anyOf: [
415
- {
416
- type: 'string',
417
- description: 'The name of a contributed or predefined pattern'
418
- },
419
- problemPattern,
420
- multiLineProblemPattern
421
- ],
422
- description: 'A problem pattern or the name of a contributed or predefined problem pattern. Can be omitted if base is specified.'
423
- };
424
-
425
- const problemMatcherObject: IJSONSchema = {
426
- type: 'object',
427
- properties: {
428
- base: {
429
- type: 'string',
430
- enum: problemMatcherNames,
431
- description: 'The name of a base problem matcher to use.'
432
- },
433
- owner: {
434
- type: 'string',
435
- description: 'The owner of the problem inside Code. Can be omitted if base is specified. Defaults to \'external\' if omitted and base is not specified.'
436
- },
437
- source: {
438
- type: 'string',
439
- description: 'A human-readable string describing the source of this diagnostic, e.g. \'typescript\' or \'super lint\'.'
440
- },
441
- severity: {
442
- type: 'string',
443
- enum: ['error', 'warning', 'info'],
444
- description: 'The default severity for captures problems. Is used if the pattern doesn\'t define a match group for severity.'
445
- },
446
- applyTo: {
447
- type: 'string',
448
- enum: ['allDocuments', 'openDocuments', 'closedDocuments'],
449
- description: 'Controls if a problem reported on a text document is applied only to open, closed or all documents.'
450
- },
451
- pattern: patternType,
452
- fileLocation: {
453
- oneOf: [
454
- {
455
- type: 'string',
456
- enum: ['absolute', 'relative', 'autoDetect']
457
- },
458
- {
459
- type: 'array',
460
- items: {
461
- type: 'string'
462
- }
463
- }
464
- ],
465
- description: 'Defines how file names reported in a problem pattern should be interpreted.'
466
- },
467
- background: {
468
- type: 'object',
469
- additionalProperties: false,
470
- description: 'Patterns to track the begin and end of a matcher active on a background task.',
471
- properties: {
472
- activeOnStart: {
473
- type: 'boolean',
474
- description: 'If set to true the background monitor is in active mode when the task starts. This is equals of issuing a line that matches the beginsPattern'
475
- },
476
- beginsPattern: {
477
- oneOf: [
478
- {
479
- type: 'string'
480
- },
481
- watchingPattern
482
- ],
483
- description: 'If matched in the output the start of a background task is signaled.'
484
- },
485
- endsPattern: {
486
- oneOf: [
487
- {
488
- type: 'string'
489
- },
490
- watchingPattern
491
- ],
492
- description: 'If matched in the output the end of a background task is signaled.'
493
- }
494
- }
495
- },
496
- watching: {
497
- type: 'object',
498
- additionalProperties: false,
499
- deprecationMessage: 'The watching property is deprecated. Use background instead.',
500
- description: 'Patterns to track the begin and end of a watching matcher.',
501
- properties: {
502
- activeOnStart: {
503
- type: 'boolean',
504
- description: 'If set to true the watcher is in active mode when the task starts. This is equals of issuing a line that matches the beginPattern'
505
- },
506
- beginsPattern: {
507
- oneOf: [
508
- {
509
- type: 'string'
510
- },
511
- watchingPattern
512
- ],
513
- description: 'If matched in the output the start of a watching task is signaled.'
514
- },
515
- endsPattern: {
516
- oneOf: [
517
- {
518
- type: 'string'
519
- },
520
- watchingPattern
521
- ],
522
- description: 'If matched in the output the end of a watching task is signaled.'
523
- }
524
- }
525
- }
526
- }
527
- };
528
-
529
- const problemMatcher: IJSONSchema = {
530
- anyOf: [
531
- {
532
- type: 'string',
533
- description: 'Name of the problem matcher to parse the output of the task',
534
- enum: problemMatcherNames
535
- },
536
- {
537
- type: 'array',
538
- description: 'Name(s) of the problem matcher(s) to parse the output of the task',
539
- items: {
540
- type: 'string',
541
- enum: problemMatcherNames
542
- }
543
- },
544
- problemMatcherObject,
545
- {
546
- type: 'array',
547
- description: 'User defined problem matcher(s) to parse the output of the task',
548
- items: problemMatcherObject
549
- }
550
- ]
551
- };
552
-
553
- const presentation: IJSONSchema = {
554
- type: 'object',
555
- default: {
556
- echo: true,
557
- reveal: 'always',
558
- focus: false,
559
- panel: 'shared',
560
- showReuseMessage: true,
561
- clear: false
562
- },
563
- description: 'Configures the panel that is used to present the task\'s output and reads its input.',
564
- additionalProperties: true,
565
- properties: {
566
- echo: {
567
- type: 'boolean',
568
- default: true,
569
- description: 'Controls whether the executed command is echoed to the panel. Default is true.'
570
- },
571
- focus: {
572
- type: 'boolean',
573
- default: false,
574
- description: 'Controls whether the panel takes focus. Default is false. If set to true the panel is revealed as well.'
575
- },
576
- reveal: {
577
- type: 'string',
578
- enum: ['always', 'silent', 'never'],
579
- enumDescriptions: [
580
- 'Always reveals the terminal when this task is executed.',
581
- 'Only reveals the terminal if the task exits with an error or the problem matcher finds an error.',
582
- 'Never reveals the terminal when this task is executed.'
583
- ],
584
- default: 'always',
585
- description: 'Controls whether the terminal running the task is revealed or not. May be overridden by option \"revealProblems\". Default is \"always\".'
586
- },
587
- panel: {
588
- type: 'string',
589
- enum: ['shared', 'dedicated', 'new'],
590
- enumDescriptions: [
591
- 'The terminal is shared and the output of other task runs are added to the same terminal.',
592
- // eslint-disable-next-line max-len
593
- 'The terminal is dedicated to a specific task. If that task is executed again, the terminal is reused. However, the output of a different task is presented in a different terminal.',
594
- 'Every execution of that task is using a new clean terminal.'
595
- ],
596
- default: 'shared',
597
- description: 'Controls if the panel is shared between tasks, dedicated to this task or a new one is created on every run.'
598
- },
599
- showReuseMessage: {
600
- type: 'boolean',
601
- default: true,
602
- description: 'Controls whether to show the "Terminal will be reused by tasks" message.'
603
- },
604
- clear: {
605
- type: 'boolean',
606
- default: false,
607
- description: 'Controls whether the terminal is cleared before this task is run.'
608
- }
609
- }
610
- };
611
-
612
- const detail: IJSONSchema = {
613
- type: 'string',
614
- description: 'An optional description of a task that shows in the Run Task quick pick as a detail.'
615
- };
616
-
617
- const taskIdentifier: IJSONSchema = {
618
- type: 'object',
619
- additionalProperties: true,
620
- properties: {
621
- type: {
622
- type: 'string',
623
- description: 'The task identifier.'
624
- }
625
- }
626
- };
627
-
628
- const processTaskConfigurationSchema: IJSONSchema = {
629
- type: 'object',
630
- required: ['type', 'label', 'command'],
631
- properties: {
632
- label: taskLabel,
633
- type: defaultTaskType,
634
- ...commandAndArgs,
635
- isBackground: {
636
- type: 'boolean',
637
- default: false,
638
- description: 'Whether the executed task is kept alive and is running in the background.'
639
- },
640
- dependsOn: {
641
- anyOf: [
642
- {
643
- type: 'string',
644
- description: 'Another task this task depends on.'
645
- },
646
- taskIdentifier,
647
- {
648
- type: 'array',
649
- description: 'The other tasks this task depends on.',
650
- items: {
651
- anyOf: [
652
- {
653
- type: 'string'
654
- },
655
- taskIdentifier
656
- ]
657
- }
658
- }
659
- ],
660
- description: 'Either a string representing another task or an array of other tasks that this task depends on.'
661
- },
662
- dependsOrder: {
663
- type: 'string',
664
- enum: ['parallel', 'sequence'],
665
- enumDescriptions: [
666
- 'Run all dependsOn tasks in parallel.',
667
- 'Run all dependsOn tasks in sequence.'
668
- ],
669
- default: 'parallel',
670
- description: 'Determines the order of the dependsOn tasks for this task. Note that this property is not recursive.'
671
- },
672
- windows: {
673
- type: 'object',
674
- description: 'Windows specific command configuration that overrides the command, args, and options',
675
- properties: commandAndArgs
676
- },
677
- osx: {
678
- type: 'object',
679
- description: 'MacOS specific command configuration that overrides the command, args, and options',
680
- properties: commandAndArgs
681
- },
682
- linux: {
683
- type: 'object',
684
- description: 'Linux specific command configuration that overrides the default command, args, and options',
685
- properties: commandAndArgs
686
- },
687
- group,
688
- problemMatcher,
689
- presentation,
690
- detail,
691
- },
692
- additionalProperties: true
693
- };
694
-
695
- const customizedDetectedTasks: IJSONSchema[] = [];
696
- const customSchemas: IJSONSchema[] = [];
697
-
698
- const taskConfigurationSchema: IJSONSchema = {
699
- $id: taskSchemaId,
700
- anyOf: [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas]
701
- };
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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
+ // This file is inspired by VSCode and partially copied from https://github.com/Microsoft/vscode/blob/1.33.1/src/vs/workbench/contrib/tasks/common/problemMatcher.ts
17
+ // 'problemMatcher.ts' copyright:
18
+ /*---------------------------------------------------------------------------------------------
19
+ * Copyright (c) Microsoft Corporation. All rights reserved.
20
+ * Licensed under the MIT License. See License.txt in the project root for license information.
21
+ *--------------------------------------------------------------------------------------------*/
22
+
23
+ import * as Ajv from '@theia/core/shared/ajv';
24
+ import debounce = require('p-debounce');
25
+ import { postConstruct, injectable, inject } from '@theia/core/shared/inversify';
26
+ import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
27
+ import { InMemoryResources, deepClone, Emitter } from '@theia/core/lib/common';
28
+ import { IJSONSchema } from '@theia/core/lib/common/json-schema';
29
+ import { inputsSchema } from '@theia/variable-resolver/lib/browser/variable-input-schema';
30
+ import URI from '@theia/core/lib/common/uri';
31
+ import { ProblemMatcherRegistry } from './task-problem-matcher-registry';
32
+ import { TaskDefinitionRegistry } from './task-definition-registry';
33
+ import { TaskServer, asVariableName } from '../common';
34
+ import { UserStorageUri } from '@theia/userstorage/lib/browser';
35
+ import { WorkspaceService } from '@theia/workspace/lib/browser';
36
+ import { JSONObject } from '@theia/core/shared/@phosphor/coreutils';
37
+
38
+ export const taskSchemaId = 'vscode://schemas/tasks';
39
+
40
+ @injectable()
41
+ export class TaskSchemaUpdater implements JsonSchemaContribution {
42
+
43
+ @inject(InMemoryResources)
44
+ protected readonly inmemoryResources: InMemoryResources;
45
+
46
+ @inject(ProblemMatcherRegistry)
47
+ protected readonly problemMatcherRegistry: ProblemMatcherRegistry;
48
+
49
+ @inject(TaskDefinitionRegistry)
50
+ protected readonly taskDefinitionRegistry: TaskDefinitionRegistry;
51
+
52
+ @inject(TaskServer)
53
+ protected readonly taskServer: TaskServer;
54
+
55
+ @inject(WorkspaceService)
56
+ protected readonly workspaceService: WorkspaceService;
57
+
58
+ protected readonly onDidChangeTaskSchemaEmitter = new Emitter<void>();
59
+ readonly onDidChangeTaskSchema = this.onDidChangeTaskSchemaEmitter.event;
60
+
61
+ protected readonly uri = new URI(taskSchemaId);
62
+
63
+ @postConstruct()
64
+ protected init(): void {
65
+ const resource = this.inmemoryResources.add(this.uri, '');
66
+ if (resource.onDidChangeContents) {
67
+ resource.onDidChangeContents(() => {
68
+ this.onDidChangeTaskSchemaEmitter.fire(undefined);
69
+ });
70
+ }
71
+ this.updateProblemMatcherNames();
72
+ this.updateSupportedTaskTypes();
73
+ // update problem matcher names in the task schema every time a problem matcher is added or disposed
74
+ this.problemMatcherRegistry.onDidChangeProblemMatcher(() => this.updateProblemMatcherNames());
75
+ // update supported task types in the task schema every time a task definition is registered or removed
76
+ this.taskDefinitionRegistry.onDidRegisterTaskDefinition(() => this.updateSupportedTaskTypes());
77
+ this.taskDefinitionRegistry.onDidUnregisterTaskDefinition(() => this.updateSupportedTaskTypes());
78
+ }
79
+
80
+ registerSchemas(context: JsonSchemaRegisterContext): void {
81
+ context.registerSchema({
82
+ fileMatch: ['tasks.json', UserStorageUri.resolve('tasks.json').toString()],
83
+ url: this.uri.toString()
84
+ });
85
+ this.workspaceService.updateSchema('tasks', { $ref: this.uri.toString() });
86
+ }
87
+
88
+ readonly update = debounce(() => this.doUpdate(), 0);
89
+ protected doUpdate(): void {
90
+ taskConfigurationSchema.anyOf = [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas];
91
+
92
+ const schema = this.getTaskSchema();
93
+ this.doValidate = new Ajv().compile(schema);
94
+ const schemaContent = JSON.stringify(schema);
95
+ this.inmemoryResources.update(this.uri, schemaContent);
96
+ }
97
+
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ validate(data: any): boolean {
100
+ return !!this.doValidate && !!this.doValidate(data);
101
+ }
102
+ protected doValidate: Ajv.ValidateFunction | undefined;
103
+
104
+ /**
105
+ * Adds given task schema to `taskConfigurationSchema` as `oneOf` subschema.
106
+ * Replaces existed subschema by given schema if the corresponding `$id` properties are equal.
107
+ *
108
+ * Note: please provide `$id` property for subschema to have ability remove/replace it.
109
+ * @param schema subschema for adding to `taskConfigurationSchema`
110
+ */
111
+ addSubschema(schema: IJSONSchema): void {
112
+ const schemaId = schema.$id;
113
+ if (schemaId) {
114
+ this.doRemoveSubschema(schemaId);
115
+ }
116
+
117
+ customSchemas.push(schema);
118
+ this.update();
119
+ }
120
+
121
+ /**
122
+ * Removes task subschema from `taskConfigurationSchema`.
123
+ *
124
+ * @param arg `$id` property of subschema
125
+ */
126
+ removeSubschema(arg: string): void {
127
+ const isRemoved = this.doRemoveSubschema(arg);
128
+ if (isRemoved) {
129
+ this.update();
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Removes task subschema from `customSchemas`, use `update()` to apply the changes for `taskConfigurationSchema`.
135
+ *
136
+ * @param arg `$id` property of subschema
137
+ * @returns `true` if subschema was removed, `false` otherwise
138
+ */
139
+ protected doRemoveSubschema(arg: string): boolean {
140
+ const index = customSchemas.findIndex(existed => !!existed.$id && existed.$id === arg);
141
+ if (index > -1) {
142
+ customSchemas.splice(index, 1);
143
+ return true;
144
+ }
145
+ return false;
146
+ }
147
+
148
+ /** Returns an array of task types that are registered, including the default types */
149
+ async getRegisteredTaskTypes(): Promise<string[]> {
150
+ const serverSupportedTypes = await this.taskServer.getRegisteredTaskTypes();
151
+ const browserSupportedTypes = this.taskDefinitionRegistry.getAll().map(def => def.taskType);
152
+ const allTypes = new Set([...serverSupportedTypes, ...browserSupportedTypes]);
153
+ return Array.from(allTypes.values()).sort();
154
+ }
155
+
156
+ private updateSchemasForRegisteredTasks(): void {
157
+ customizedDetectedTasks.length = 0;
158
+ const definitions = this.taskDefinitionRegistry.getAll();
159
+ definitions.forEach(def => {
160
+ const customizedDetectedTask: IJSONSchema = {
161
+ type: 'object',
162
+ required: ['type'],
163
+ properties: {}
164
+ };
165
+ const taskType = {
166
+ ...defaultTaskType,
167
+ enum: [def.taskType],
168
+ default: def.taskType,
169
+ description: 'The task type to customize'
170
+ };
171
+ customizedDetectedTask.properties!.type = taskType;
172
+ const required = def.properties.required || [];
173
+ def.properties.all.forEach(taskProp => {
174
+ if (required.find(requiredProp => requiredProp === taskProp)) { // property is mandatory
175
+ customizedDetectedTask.required!.push(taskProp);
176
+ }
177
+ customizedDetectedTask.properties![taskProp] = { ...def.properties.schema.properties![taskProp] };
178
+ });
179
+ customizedDetectedTask.properties!.label = taskLabel;
180
+ customizedDetectedTask.properties!.problemMatcher = problemMatcher;
181
+ customizedDetectedTask.properties!.presentation = presentation;
182
+ customizedDetectedTask.properties!.options = commandOptionsSchema;
183
+ customizedDetectedTask.properties!.group = group;
184
+ customizedDetectedTask.properties!.detail = detail;
185
+ customizedDetectedTask.additionalProperties = true;
186
+ customizedDetectedTasks.push(customizedDetectedTask);
187
+ });
188
+ }
189
+
190
+ /** Returns the task's JSON schema */
191
+ getTaskSchema(): IJSONSchema & { default: JSONObject } {
192
+ return {
193
+ type: 'object',
194
+ default: { version: '2.0.0', tasks: [] },
195
+ properties: {
196
+ version: {
197
+ type: 'string',
198
+ default: '2.0.0'
199
+ },
200
+ tasks: {
201
+ type: 'array',
202
+ items: {
203
+ ...deepClone(taskConfigurationSchema)
204
+ }
205
+ },
206
+ inputs: inputsSchema.definitions!.inputs
207
+ },
208
+ additionalProperties: false,
209
+ allowComments: true,
210
+ allowTrailingCommas: true,
211
+ };
212
+ }
213
+
214
+ /** Gets the most up-to-date names of problem matchers from the registry and update the task schema */
215
+ private updateProblemMatcherNames(): void {
216
+ const matcherNames = this.problemMatcherRegistry.getAll().map(m => asVariableName(m.name));
217
+ problemMatcherNames.length = 0;
218
+ problemMatcherNames.push(...matcherNames);
219
+ this.update();
220
+ }
221
+
222
+ private async updateSupportedTaskTypes(): Promise<void> {
223
+ this.updateSchemasForRegisteredTasks();
224
+ this.update();
225
+ }
226
+ }
227
+
228
+ const commandSchema: IJSONSchema = {
229
+ type: 'string',
230
+ description: 'The actual command or script to execute'
231
+ };
232
+
233
+ const commandArgSchema: IJSONSchema = {
234
+ type: 'array',
235
+ description: 'A list of strings, each one being one argument to pass to the command',
236
+ items: {
237
+ type: 'string'
238
+ }
239
+ };
240
+
241
+ const commandOptionsSchema: IJSONSchema = {
242
+ type: 'object',
243
+ description: 'The command options used when the command is executed',
244
+ properties: {
245
+ cwd: {
246
+ type: 'string',
247
+ description: 'The directory in which the command will be executed',
248
+ default: '${workspaceFolder}'
249
+ },
250
+ env: {
251
+ type: 'object',
252
+ description: 'The environment of the executed program or shell. If omitted the parent process\' environment is used'
253
+ },
254
+ shell: {
255
+ type: 'object',
256
+ description: 'Configuration of the shell when task type is `shell`',
257
+ properties: {
258
+ executable: {
259
+ type: 'string',
260
+ description: 'The shell to use'
261
+ },
262
+ args: {
263
+ type: 'array',
264
+ description: `The arguments to be passed to the shell executable to run in command mode
265
+ (e.g ['-c'] for bash or ['/S', '/C'] for cmd.exe)`,
266
+ items: {
267
+ type: 'string'
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ };
274
+
275
+ const problemMatcherNames: string[] = [];
276
+ const defaultTaskTypes = ['shell', 'process'];
277
+ const supportedTaskTypes = [...defaultTaskTypes];
278
+ const taskLabel: IJSONSchema = {
279
+ type: 'string',
280
+ description: 'A unique string that identifies the task that is also used as task\'s user interface label'
281
+ };
282
+ const defaultTaskType: IJSONSchema = {
283
+ type: 'string',
284
+ enum: supportedTaskTypes,
285
+ default: defaultTaskTypes[0],
286
+ description: 'Determines what type of process will be used to execute the task. Only shell types will have output shown on the user interface'
287
+ } as const;
288
+ const commandAndArgs = {
289
+ command: commandSchema,
290
+ args: commandArgSchema,
291
+ options: commandOptionsSchema
292
+ };
293
+
294
+ const group: IJSONSchema = {
295
+ oneOf: [
296
+ {
297
+ type: 'string',
298
+ enum: ['build', 'test', 'none'],
299
+ enumDescriptions: [
300
+ 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
301
+ 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
302
+ 'Assigns the task to no group'
303
+ ]
304
+ },
305
+ {
306
+ type: 'object',
307
+ properties: {
308
+ kind: {
309
+ type: 'string',
310
+ default: 'none',
311
+ description: 'The task\'s execution group.',
312
+ enum: ['build', 'test', 'none'],
313
+ enumDescriptions: [
314
+ 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
315
+ 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
316
+ 'Assigns the task to no group'
317
+ ]
318
+ },
319
+ isDefault: {
320
+ type: 'boolean',
321
+ default: false,
322
+ description: 'Defines if this task is the default task in the group.'
323
+ }
324
+ }
325
+ }
326
+ ],
327
+ // eslint-disable-next-line max-len
328
+ description: 'Defines to which execution group this task belongs to. It supports "build" to add it to the build group and "test" to add it to the test group.'
329
+ };
330
+
331
+ const problemPattern: IJSONSchema = {
332
+ default: {
333
+ regexp: '^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$',
334
+ file: 1,
335
+ location: 2,
336
+ message: 3
337
+ },
338
+ type: 'object',
339
+ properties: {
340
+ regexp: {
341
+ type: 'string',
342
+ description: 'The regular expression to find an error, warning or info in the output.'
343
+ },
344
+ kind: {
345
+ type: 'string',
346
+ description: 'whether the pattern matches a location (file and line) or only a file.'
347
+ },
348
+ file: {
349
+ type: 'integer',
350
+ description: 'The match group index of the filename. If omitted 1 is used.'
351
+ },
352
+ location: {
353
+ type: 'integer',
354
+ // eslint-disable-next-line max-len
355
+ description: 'The match group index of the problem\'s location. Valid location patterns are: (line), (line,column) and (startLine,startColumn,endLine,endColumn). If omitted (line,column) is assumed.'
356
+ },
357
+ line: {
358
+ type: 'integer',
359
+ description: 'The match group index of the problem\'s line. Defaults to 2'
360
+ },
361
+ column: {
362
+ type: 'integer',
363
+ description: 'The match group index of the problem\'s line character. Defaults to 3'
364
+ },
365
+ endLine: {
366
+ type: 'integer',
367
+ description: 'The match group index of the problem\'s end line. Defaults to undefined'
368
+ },
369
+ endColumn: {
370
+ type: 'integer',
371
+ description: 'The match group index of the problem\'s end line character. Defaults to undefined'
372
+ },
373
+ severity: {
374
+ type: 'integer',
375
+ description: 'The match group index of the problem\'s severity. Defaults to undefined'
376
+ },
377
+ code: {
378
+ type: 'integer',
379
+ description: 'The match group index of the problem\'s code. Defaults to undefined'
380
+ },
381
+ message: {
382
+ type: 'integer',
383
+ description: 'The match group index of the message. If omitted it defaults to 4 if location is specified. Otherwise it defaults to 5.'
384
+ },
385
+ loop: {
386
+ type: 'boolean',
387
+ // eslint-disable-next-line max-len
388
+ description: 'In a multi line matcher loop indicated whether this pattern is executed in a loop as long as it matches. Can only specified on a last pattern in a multi line pattern.'
389
+ }
390
+ }
391
+ };
392
+
393
+ const multiLineProblemPattern: IJSONSchema = {
394
+ type: 'array',
395
+ items: problemPattern
396
+ };
397
+
398
+ const watchingPattern: IJSONSchema = {
399
+ type: 'object',
400
+ additionalProperties: false,
401
+ properties: {
402
+ regexp: {
403
+ type: 'string',
404
+ description: 'The regular expression to detect the begin or end of a background task.'
405
+ },
406
+ file: {
407
+ type: 'integer',
408
+ description: 'The match group index of the filename. Can be omitted.'
409
+ },
410
+ }
411
+ };
412
+
413
+ const patternType: IJSONSchema = {
414
+ anyOf: [
415
+ {
416
+ type: 'string',
417
+ description: 'The name of a contributed or predefined pattern'
418
+ },
419
+ problemPattern,
420
+ multiLineProblemPattern
421
+ ],
422
+ description: 'A problem pattern or the name of a contributed or predefined problem pattern. Can be omitted if base is specified.'
423
+ };
424
+
425
+ const problemMatcherObject: IJSONSchema = {
426
+ type: 'object',
427
+ properties: {
428
+ base: {
429
+ type: 'string',
430
+ enum: problemMatcherNames,
431
+ description: 'The name of a base problem matcher to use.'
432
+ },
433
+ owner: {
434
+ type: 'string',
435
+ description: 'The owner of the problem inside Code. Can be omitted if base is specified. Defaults to \'external\' if omitted and base is not specified.'
436
+ },
437
+ source: {
438
+ type: 'string',
439
+ description: 'A human-readable string describing the source of this diagnostic, e.g. \'typescript\' or \'super lint\'.'
440
+ },
441
+ severity: {
442
+ type: 'string',
443
+ enum: ['error', 'warning', 'info'],
444
+ description: 'The default severity for captures problems. Is used if the pattern doesn\'t define a match group for severity.'
445
+ },
446
+ applyTo: {
447
+ type: 'string',
448
+ enum: ['allDocuments', 'openDocuments', 'closedDocuments'],
449
+ description: 'Controls if a problem reported on a text document is applied only to open, closed or all documents.'
450
+ },
451
+ pattern: patternType,
452
+ fileLocation: {
453
+ oneOf: [
454
+ {
455
+ type: 'string',
456
+ enum: ['absolute', 'relative', 'autoDetect']
457
+ },
458
+ {
459
+ type: 'array',
460
+ items: {
461
+ type: 'string'
462
+ }
463
+ }
464
+ ],
465
+ description: 'Defines how file names reported in a problem pattern should be interpreted.'
466
+ },
467
+ background: {
468
+ type: 'object',
469
+ additionalProperties: false,
470
+ description: 'Patterns to track the begin and end of a matcher active on a background task.',
471
+ properties: {
472
+ activeOnStart: {
473
+ type: 'boolean',
474
+ description: 'If set to true the background monitor is in active mode when the task starts. This is equals of issuing a line that matches the beginsPattern'
475
+ },
476
+ beginsPattern: {
477
+ oneOf: [
478
+ {
479
+ type: 'string'
480
+ },
481
+ watchingPattern
482
+ ],
483
+ description: 'If matched in the output the start of a background task is signaled.'
484
+ },
485
+ endsPattern: {
486
+ oneOf: [
487
+ {
488
+ type: 'string'
489
+ },
490
+ watchingPattern
491
+ ],
492
+ description: 'If matched in the output the end of a background task is signaled.'
493
+ }
494
+ }
495
+ },
496
+ watching: {
497
+ type: 'object',
498
+ additionalProperties: false,
499
+ deprecationMessage: 'The watching property is deprecated. Use background instead.',
500
+ description: 'Patterns to track the begin and end of a watching matcher.',
501
+ properties: {
502
+ activeOnStart: {
503
+ type: 'boolean',
504
+ description: 'If set to true the watcher is in active mode when the task starts. This is equals of issuing a line that matches the beginPattern'
505
+ },
506
+ beginsPattern: {
507
+ oneOf: [
508
+ {
509
+ type: 'string'
510
+ },
511
+ watchingPattern
512
+ ],
513
+ description: 'If matched in the output the start of a watching task is signaled.'
514
+ },
515
+ endsPattern: {
516
+ oneOf: [
517
+ {
518
+ type: 'string'
519
+ },
520
+ watchingPattern
521
+ ],
522
+ description: 'If matched in the output the end of a watching task is signaled.'
523
+ }
524
+ }
525
+ }
526
+ }
527
+ };
528
+
529
+ const problemMatcher: IJSONSchema = {
530
+ anyOf: [
531
+ {
532
+ type: 'string',
533
+ description: 'Name of the problem matcher to parse the output of the task',
534
+ enum: problemMatcherNames
535
+ },
536
+ {
537
+ type: 'array',
538
+ description: 'Name(s) of the problem matcher(s) to parse the output of the task',
539
+ items: {
540
+ type: 'string',
541
+ enum: problemMatcherNames
542
+ }
543
+ },
544
+ problemMatcherObject,
545
+ {
546
+ type: 'array',
547
+ description: 'User defined problem matcher(s) to parse the output of the task',
548
+ items: problemMatcherObject
549
+ }
550
+ ]
551
+ };
552
+
553
+ const presentation: IJSONSchema = {
554
+ type: 'object',
555
+ default: {
556
+ echo: true,
557
+ reveal: 'always',
558
+ focus: false,
559
+ panel: 'shared',
560
+ showReuseMessage: true,
561
+ clear: false
562
+ },
563
+ description: 'Configures the panel that is used to present the task\'s output and reads its input.',
564
+ additionalProperties: true,
565
+ properties: {
566
+ echo: {
567
+ type: 'boolean',
568
+ default: true,
569
+ description: 'Controls whether the executed command is echoed to the panel. Default is true.'
570
+ },
571
+ focus: {
572
+ type: 'boolean',
573
+ default: false,
574
+ description: 'Controls whether the panel takes focus. Default is false. If set to true the panel is revealed as well.'
575
+ },
576
+ reveal: {
577
+ type: 'string',
578
+ enum: ['always', 'silent', 'never'],
579
+ enumDescriptions: [
580
+ 'Always reveals the terminal when this task is executed.',
581
+ 'Only reveals the terminal if the task exits with an error or the problem matcher finds an error.',
582
+ 'Never reveals the terminal when this task is executed.'
583
+ ],
584
+ default: 'always',
585
+ description: 'Controls whether the terminal running the task is revealed or not. May be overridden by option \"revealProblems\". Default is \"always\".'
586
+ },
587
+ panel: {
588
+ type: 'string',
589
+ enum: ['shared', 'dedicated', 'new'],
590
+ enumDescriptions: [
591
+ 'The terminal is shared and the output of other task runs are added to the same terminal.',
592
+ // eslint-disable-next-line max-len
593
+ 'The terminal is dedicated to a specific task. If that task is executed again, the terminal is reused. However, the output of a different task is presented in a different terminal.',
594
+ 'Every execution of that task is using a new clean terminal.'
595
+ ],
596
+ default: 'shared',
597
+ description: 'Controls if the panel is shared between tasks, dedicated to this task or a new one is created on every run.'
598
+ },
599
+ showReuseMessage: {
600
+ type: 'boolean',
601
+ default: true,
602
+ description: 'Controls whether to show the "Terminal will be reused by tasks" message.'
603
+ },
604
+ clear: {
605
+ type: 'boolean',
606
+ default: false,
607
+ description: 'Controls whether the terminal is cleared before this task is run.'
608
+ }
609
+ }
610
+ };
611
+
612
+ const detail: IJSONSchema = {
613
+ type: 'string',
614
+ description: 'An optional description of a task that shows in the Run Task quick pick as a detail.'
615
+ };
616
+
617
+ const taskIdentifier: IJSONSchema = {
618
+ type: 'object',
619
+ additionalProperties: true,
620
+ properties: {
621
+ type: {
622
+ type: 'string',
623
+ description: 'The task identifier.'
624
+ }
625
+ }
626
+ };
627
+
628
+ const processTaskConfigurationSchema: IJSONSchema = {
629
+ type: 'object',
630
+ required: ['type', 'label', 'command'],
631
+ properties: {
632
+ label: taskLabel,
633
+ type: defaultTaskType,
634
+ ...commandAndArgs,
635
+ isBackground: {
636
+ type: 'boolean',
637
+ default: false,
638
+ description: 'Whether the executed task is kept alive and is running in the background.'
639
+ },
640
+ dependsOn: {
641
+ anyOf: [
642
+ {
643
+ type: 'string',
644
+ description: 'Another task this task depends on.'
645
+ },
646
+ taskIdentifier,
647
+ {
648
+ type: 'array',
649
+ description: 'The other tasks this task depends on.',
650
+ items: {
651
+ anyOf: [
652
+ {
653
+ type: 'string'
654
+ },
655
+ taskIdentifier
656
+ ]
657
+ }
658
+ }
659
+ ],
660
+ description: 'Either a string representing another task or an array of other tasks that this task depends on.'
661
+ },
662
+ dependsOrder: {
663
+ type: 'string',
664
+ enum: ['parallel', 'sequence'],
665
+ enumDescriptions: [
666
+ 'Run all dependsOn tasks in parallel.',
667
+ 'Run all dependsOn tasks in sequence.'
668
+ ],
669
+ default: 'parallel',
670
+ description: 'Determines the order of the dependsOn tasks for this task. Note that this property is not recursive.'
671
+ },
672
+ windows: {
673
+ type: 'object',
674
+ description: 'Windows specific command configuration that overrides the command, args, and options',
675
+ properties: commandAndArgs
676
+ },
677
+ osx: {
678
+ type: 'object',
679
+ description: 'MacOS specific command configuration that overrides the command, args, and options',
680
+ properties: commandAndArgs
681
+ },
682
+ linux: {
683
+ type: 'object',
684
+ description: 'Linux specific command configuration that overrides the default command, args, and options',
685
+ properties: commandAndArgs
686
+ },
687
+ group,
688
+ problemMatcher,
689
+ presentation,
690
+ detail,
691
+ },
692
+ additionalProperties: true
693
+ };
694
+
695
+ const customizedDetectedTasks: IJSONSchema[] = [];
696
+ const customSchemas: IJSONSchema[] = [];
697
+
698
+ const taskConfigurationSchema: IJSONSchema = {
699
+ $id: taskSchemaId,
700
+ anyOf: [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas]
701
+ };