@opensumi/ide-task 2.12.1-next-079c1930
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/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +41 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/parser.d.ts +316 -0
- package/lib/browser/parser.d.ts.map +1 -0
- package/lib/browser/parser.js +481 -0
- package/lib/browser/parser.js.map +1 -0
- package/lib/browser/problem-collector.d.ts +27 -0
- package/lib/browser/problem-collector.d.ts.map +1 -0
- package/lib/browser/problem-collector.js +61 -0
- package/lib/browser/problem-collector.js.map +1 -0
- package/lib/browser/problem-line-matcher.d.ts +92 -0
- package/lib/browser/problem-line-matcher.d.ts.map +1 -0
- package/lib/browser/problem-line-matcher.js +378 -0
- package/lib/browser/problem-line-matcher.js.map +1 -0
- package/lib/browser/task-config.d.ts +385 -0
- package/lib/browser/task-config.d.ts.map +1 -0
- package/lib/browser/task-config.js +1427 -0
- package/lib/browser/task-config.js.map +1 -0
- package/lib/browser/task-preferences.contribution.d.ts +6 -0
- package/lib/browser/task-preferences.contribution.d.ts.map +1 -0
- package/lib/browser/task-preferences.contribution.js +17 -0
- package/lib/browser/task-preferences.contribution.js.map +1 -0
- package/lib/browser/task-preferences.d.ts +3 -0
- package/lib/browser/task-preferences.d.ts.map +1 -0
- package/lib/browser/task-preferences.js +15 -0
- package/lib/browser/task-preferences.js.map +1 -0
- package/lib/browser/task-preferences.provider.d.ts +6 -0
- package/lib/browser/task-preferences.provider.d.ts.map +1 -0
- package/lib/browser/task-preferences.provider.js +29 -0
- package/lib/browser/task-preferences.provider.js.map +1 -0
- package/lib/browser/task.contribution.d.ts +8 -0
- package/lib/browser/task.contribution.d.ts.map +1 -0
- package/lib/browser/task.contribution.js +35 -0
- package/lib/browser/task.contribution.js.map +1 -0
- package/lib/browser/task.schema.d.ts +4 -0
- package/lib/browser/task.schema.d.ts.map +1 -0
- package/lib/browser/task.schema.js +294 -0
- package/lib/browser/task.schema.js.map +1 -0
- package/lib/browser/task.service.d.ts +43 -0
- package/lib/browser/task.service.d.ts.map +1 -0
- package/lib/browser/task.service.js +354 -0
- package/lib/browser/task.service.js.map +1 -0
- package/lib/browser/terminal-task-system.d.ts +80 -0
- package/lib/browser/terminal-task-system.d.ts.map +1 -0
- package/lib/browser/terminal-task-system.js +391 -0
- package/lib/browser/terminal-task-system.js.map +1 -0
- package/lib/common/index.d.ts +130 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +7 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/task.d.ts +572 -0
- package/lib/common/task.d.ts.map +1 -0
- package/lib/common/task.js +523 -0
- package/lib/common/task.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/node/index.d.ts +6 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +17 -0
- package/lib/node/index.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,1427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createCustomTask = exports.parse = exports.JsonSchemaVersion = exports.ExecutionEngine = exports.RunOptions = exports.RunOnOptions = exports.CommandString = exports.TaskIdentifier = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
10
|
+
const TaskTypes = (0, tslib_1.__importStar)(require("../common/task"));
|
|
11
|
+
const parser_1 = require("./parser");
|
|
12
|
+
var TaskIdentifier;
|
|
13
|
+
(function (TaskIdentifier) {
|
|
14
|
+
function is(value) {
|
|
15
|
+
const candidate = value;
|
|
16
|
+
return candidate !== undefined && (0, ide_core_common_1.isString)(value.type);
|
|
17
|
+
}
|
|
18
|
+
TaskIdentifier.is = is;
|
|
19
|
+
})(TaskIdentifier = exports.TaskIdentifier || (exports.TaskIdentifier = {}));
|
|
20
|
+
var CommandString;
|
|
21
|
+
(function (CommandString) {
|
|
22
|
+
function value(value) {
|
|
23
|
+
if ((0, ide_core_common_1.isString)(value)) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
else if ((0, ide_core_common_1.isStringArray)(value)) {
|
|
27
|
+
return value.join(' ');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if ((0, ide_core_common_1.isString)(value.value)) {
|
|
31
|
+
return value.value;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return value.value.join(' ');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
CommandString.value = value;
|
|
39
|
+
})(CommandString = exports.CommandString || (exports.CommandString = {}));
|
|
40
|
+
var ProblemMatcherKind;
|
|
41
|
+
(function (ProblemMatcherKind) {
|
|
42
|
+
ProblemMatcherKind[ProblemMatcherKind["Unknown"] = 0] = "Unknown";
|
|
43
|
+
ProblemMatcherKind[ProblemMatcherKind["String"] = 1] = "String";
|
|
44
|
+
ProblemMatcherKind[ProblemMatcherKind["ProblemMatcher"] = 2] = "ProblemMatcher";
|
|
45
|
+
ProblemMatcherKind[ProblemMatcherKind["Array"] = 3] = "Array";
|
|
46
|
+
})(ProblemMatcherKind || (ProblemMatcherKind = {}));
|
|
47
|
+
const EMPTY_ARRAY = [];
|
|
48
|
+
Object.freeze(EMPTY_ARRAY);
|
|
49
|
+
function assignProperty(target, source, key) {
|
|
50
|
+
const sourceAtKey = source[key];
|
|
51
|
+
if (sourceAtKey !== undefined) {
|
|
52
|
+
target[key] = sourceAtKey;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function fillProperty(target, source, key) {
|
|
56
|
+
const sourceAtKey = source[key];
|
|
57
|
+
if (target[key] === undefined && sourceAtKey !== undefined) {
|
|
58
|
+
target[key] = sourceAtKey;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function _isEmpty(value, properties) {
|
|
62
|
+
if (value === undefined || value === null || properties === undefined) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
for (const meta of properties) {
|
|
66
|
+
const property = value[meta.property];
|
|
67
|
+
if (property !== undefined && property !== null) {
|
|
68
|
+
if (meta.type !== undefined && !meta.type.isEmpty(property)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
else if (!Array.isArray(property) || property.length > 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
function _assignProperties(target, source, properties) {
|
|
79
|
+
if (!source || _isEmpty(source, properties)) {
|
|
80
|
+
return target;
|
|
81
|
+
}
|
|
82
|
+
if (!target || _isEmpty(target, properties)) {
|
|
83
|
+
return source;
|
|
84
|
+
}
|
|
85
|
+
for (const meta of properties) {
|
|
86
|
+
const property = meta.property;
|
|
87
|
+
let value;
|
|
88
|
+
if (meta.type !== undefined) {
|
|
89
|
+
value = meta.type.assignProperties(target[property], source[property]);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
value = source[property];
|
|
93
|
+
}
|
|
94
|
+
if (value !== undefined && value !== null) {
|
|
95
|
+
target[property] = value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
function _fillProperties(target, source, properties) {
|
|
101
|
+
if (!source || _isEmpty(source, properties)) {
|
|
102
|
+
return target;
|
|
103
|
+
}
|
|
104
|
+
if (!target || _isEmpty(target, properties)) {
|
|
105
|
+
return source;
|
|
106
|
+
}
|
|
107
|
+
for (const meta of properties) {
|
|
108
|
+
const property = meta.property;
|
|
109
|
+
let value;
|
|
110
|
+
if (meta.type) {
|
|
111
|
+
value = meta.type.fillProperties(target[property], source[property]);
|
|
112
|
+
}
|
|
113
|
+
else if (target[property] === undefined) {
|
|
114
|
+
value = source[property];
|
|
115
|
+
}
|
|
116
|
+
if (value !== undefined && value !== null) {
|
|
117
|
+
target[property] = value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
function _fillDefaults(target, defaults, properties, context) {
|
|
123
|
+
if (target && Object.isFrozen(target)) {
|
|
124
|
+
return target;
|
|
125
|
+
}
|
|
126
|
+
if (target === undefined || target === null || defaults === undefined || defaults === null) {
|
|
127
|
+
if (defaults !== undefined && defaults !== null) {
|
|
128
|
+
return (0, ide_core_common_1.deepClone)(defaults);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const meta of properties) {
|
|
135
|
+
const property = meta.property;
|
|
136
|
+
if (target[property] !== undefined) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
let value;
|
|
140
|
+
if (meta.type) {
|
|
141
|
+
value = meta.type.fillDefaults(target[property], context);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
value = defaults[property];
|
|
145
|
+
}
|
|
146
|
+
if (value !== undefined && value !== null) {
|
|
147
|
+
target[property] = value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return target;
|
|
151
|
+
}
|
|
152
|
+
function _freeze(target, properties) {
|
|
153
|
+
if (target === undefined || target === null) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
if (Object.isFrozen(target)) {
|
|
157
|
+
return target;
|
|
158
|
+
}
|
|
159
|
+
for (const meta of properties) {
|
|
160
|
+
if (meta.type) {
|
|
161
|
+
const value = target[meta.property];
|
|
162
|
+
if (value) {
|
|
163
|
+
meta.type.freeze(value);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
Object.freeze(target);
|
|
168
|
+
return target;
|
|
169
|
+
}
|
|
170
|
+
var RunOnOptions;
|
|
171
|
+
(function (RunOnOptions) {
|
|
172
|
+
function fromString(value) {
|
|
173
|
+
if (!value) {
|
|
174
|
+
return TaskTypes.RunOnOptions.default;
|
|
175
|
+
}
|
|
176
|
+
switch (value.toLowerCase()) {
|
|
177
|
+
case 'folderopen':
|
|
178
|
+
return TaskTypes.RunOnOptions.folderOpen;
|
|
179
|
+
case 'default':
|
|
180
|
+
default:
|
|
181
|
+
return TaskTypes.RunOnOptions.default;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
RunOnOptions.fromString = fromString;
|
|
185
|
+
})(RunOnOptions = exports.RunOnOptions || (exports.RunOnOptions = {}));
|
|
186
|
+
var RunOptions;
|
|
187
|
+
(function (RunOptions) {
|
|
188
|
+
function fromConfiguration(value) {
|
|
189
|
+
return {
|
|
190
|
+
reevaluateOnRerun: value ? value.reevaluateOnRerun : true,
|
|
191
|
+
runOn: value ? RunOnOptions.fromString(value.runOn) : TaskTypes.RunOnOptions.default,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
RunOptions.fromConfiguration = fromConfiguration;
|
|
195
|
+
})(RunOptions = exports.RunOptions || (exports.RunOptions = {}));
|
|
196
|
+
class ParseContext {
|
|
197
|
+
}
|
|
198
|
+
var ShellConfiguration;
|
|
199
|
+
(function (ShellConfiguration) {
|
|
200
|
+
const properties = [{ property: 'executable' }, { property: 'args' }, { property: 'quoting' }];
|
|
201
|
+
function is(value) {
|
|
202
|
+
const candidate = value;
|
|
203
|
+
return candidate && ((0, ide_core_common_1.isString)(candidate.executable) || (0, ide_core_common_1.isStringArray)(candidate.args));
|
|
204
|
+
}
|
|
205
|
+
ShellConfiguration.is = is;
|
|
206
|
+
function from(config, context) {
|
|
207
|
+
if (!is(config)) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
const result = {};
|
|
211
|
+
if (config.executable !== undefined) {
|
|
212
|
+
result.executable = config.executable;
|
|
213
|
+
}
|
|
214
|
+
if (config.args !== undefined) {
|
|
215
|
+
result.args = config.args.slice();
|
|
216
|
+
}
|
|
217
|
+
if (config.quoting !== undefined) {
|
|
218
|
+
result.quoting = (0, ide_core_common_1.deepClone)(config.quoting);
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
ShellConfiguration.from = from;
|
|
223
|
+
function isEmpty(value) {
|
|
224
|
+
return _isEmpty(value, properties);
|
|
225
|
+
}
|
|
226
|
+
ShellConfiguration.isEmpty = isEmpty;
|
|
227
|
+
function assignProperties(target, source) {
|
|
228
|
+
return _assignProperties(target, source, properties);
|
|
229
|
+
}
|
|
230
|
+
ShellConfiguration.assignProperties = assignProperties;
|
|
231
|
+
function fillProperties(target, source) {
|
|
232
|
+
return _fillProperties(target, source, properties);
|
|
233
|
+
}
|
|
234
|
+
ShellConfiguration.fillProperties = fillProperties;
|
|
235
|
+
function fillDefaults(value, context) {
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
ShellConfiguration.fillDefaults = fillDefaults;
|
|
239
|
+
function freeze(value) {
|
|
240
|
+
if (!value) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
return Object.freeze(value);
|
|
244
|
+
}
|
|
245
|
+
ShellConfiguration.freeze = freeze;
|
|
246
|
+
})(ShellConfiguration || (ShellConfiguration = {}));
|
|
247
|
+
var CommandOptions;
|
|
248
|
+
(function (CommandOptions) {
|
|
249
|
+
const properties = [{ property: 'cwd' }, { property: 'env' }, { property: 'shell', type: ShellConfiguration }];
|
|
250
|
+
const defaults = { cwd: '${workspaceFolder}' };
|
|
251
|
+
function from(options, context) {
|
|
252
|
+
const result = {};
|
|
253
|
+
if (options.cwd !== undefined) {
|
|
254
|
+
if ((0, ide_core_common_1.isString)(options.cwd)) {
|
|
255
|
+
result.cwd = options.cwd;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
context.taskLoadIssues.push((0, ide_core_common_1.formatLocalize)('ConfigurationParser.invalidCWD', 'Warning: options.cwd must be of type string. Ignoring value {0}\n', options.cwd));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (options.env !== undefined) {
|
|
262
|
+
result.env = (0, ide_core_common_1.deepClone)(options.env);
|
|
263
|
+
}
|
|
264
|
+
result.shell = ShellConfiguration.from(options.shell, context);
|
|
265
|
+
return isEmpty(result) ? undefined : result;
|
|
266
|
+
}
|
|
267
|
+
CommandOptions.from = from;
|
|
268
|
+
function isEmpty(value) {
|
|
269
|
+
return _isEmpty(value, properties);
|
|
270
|
+
}
|
|
271
|
+
CommandOptions.isEmpty = isEmpty;
|
|
272
|
+
function assignProperties(target, source) {
|
|
273
|
+
if ((source === undefined) || isEmpty(source)) {
|
|
274
|
+
return target;
|
|
275
|
+
}
|
|
276
|
+
if ((target === undefined) || isEmpty(target)) {
|
|
277
|
+
return source;
|
|
278
|
+
}
|
|
279
|
+
assignProperty(target, source, 'cwd');
|
|
280
|
+
if (target.env === undefined) {
|
|
281
|
+
target.env = source.env;
|
|
282
|
+
}
|
|
283
|
+
else if (source.env !== undefined) {
|
|
284
|
+
const env = Object.create(null);
|
|
285
|
+
if (target.env !== undefined) {
|
|
286
|
+
Object.keys(target.env).forEach((key) => env[key] = target.env[key]);
|
|
287
|
+
}
|
|
288
|
+
if (source.env !== undefined) {
|
|
289
|
+
Object.keys(source.env).forEach((key) => env[key] = source.env[key]);
|
|
290
|
+
}
|
|
291
|
+
target.env = env;
|
|
292
|
+
}
|
|
293
|
+
target.shell = ShellConfiguration.assignProperties(target.shell, source.shell);
|
|
294
|
+
return target;
|
|
295
|
+
}
|
|
296
|
+
CommandOptions.assignProperties = assignProperties;
|
|
297
|
+
function fillProperties(target, source) {
|
|
298
|
+
return _fillProperties(target, source, properties);
|
|
299
|
+
}
|
|
300
|
+
CommandOptions.fillProperties = fillProperties;
|
|
301
|
+
function fillDefaults(value, context) {
|
|
302
|
+
return _fillDefaults(value, defaults, properties, context);
|
|
303
|
+
}
|
|
304
|
+
CommandOptions.fillDefaults = fillDefaults;
|
|
305
|
+
function freeze(value) {
|
|
306
|
+
return _freeze(value, properties);
|
|
307
|
+
}
|
|
308
|
+
CommandOptions.freeze = freeze;
|
|
309
|
+
})(CommandOptions || (CommandOptions = {}));
|
|
310
|
+
var CommandConfiguration;
|
|
311
|
+
(function (CommandConfiguration) {
|
|
312
|
+
let PresentationOptions;
|
|
313
|
+
(function (PresentationOptions) {
|
|
314
|
+
const properties = [{ property: 'echo' }, { property: 'reveal' }, { property: 'revealProblems' }, { property: 'focus' }, { property: 'panel' }, { property: 'showReuseMessage' }, { property: 'clear' }, { property: 'group' }];
|
|
315
|
+
function from(config, context) {
|
|
316
|
+
let echo;
|
|
317
|
+
let reveal;
|
|
318
|
+
let revealProblems;
|
|
319
|
+
let focus;
|
|
320
|
+
let panel;
|
|
321
|
+
let showReuseMessage;
|
|
322
|
+
let clear;
|
|
323
|
+
let group;
|
|
324
|
+
let hasProps = false;
|
|
325
|
+
if ((0, ide_core_common_1.isBoolean)(config.echoCommand)) {
|
|
326
|
+
echo = config.echoCommand;
|
|
327
|
+
hasProps = true;
|
|
328
|
+
}
|
|
329
|
+
if ((0, ide_core_common_1.isString)(config.showOutput)) {
|
|
330
|
+
reveal = TaskTypes.RevealKind.fromString(config.showOutput);
|
|
331
|
+
hasProps = true;
|
|
332
|
+
}
|
|
333
|
+
const presentation = config.presentation || config.terminal;
|
|
334
|
+
if (presentation) {
|
|
335
|
+
if ((0, ide_core_common_1.isBoolean)(presentation.echo)) {
|
|
336
|
+
echo = presentation.echo;
|
|
337
|
+
}
|
|
338
|
+
if ((0, ide_core_common_1.isString)(presentation.reveal)) {
|
|
339
|
+
reveal = TaskTypes.RevealKind.fromString(presentation.reveal);
|
|
340
|
+
}
|
|
341
|
+
if ((0, ide_core_common_1.isString)(presentation.revealProblems)) {
|
|
342
|
+
revealProblems = TaskTypes.RevealProblemKind.fromString(presentation.revealProblems);
|
|
343
|
+
}
|
|
344
|
+
if ((0, ide_core_common_1.isBoolean)(presentation.focus)) {
|
|
345
|
+
focus = presentation.focus;
|
|
346
|
+
}
|
|
347
|
+
if ((0, ide_core_common_1.isString)(presentation.panel)) {
|
|
348
|
+
panel = TaskTypes.PanelKind.fromString(presentation.panel);
|
|
349
|
+
}
|
|
350
|
+
if ((0, ide_core_common_1.isBoolean)(presentation.showReuseMessage)) {
|
|
351
|
+
showReuseMessage = presentation.showReuseMessage;
|
|
352
|
+
}
|
|
353
|
+
if ((0, ide_core_common_1.isBoolean)(presentation.clear)) {
|
|
354
|
+
clear = presentation.clear;
|
|
355
|
+
}
|
|
356
|
+
if ((0, ide_core_common_1.isString)(presentation.group)) {
|
|
357
|
+
group = presentation.group;
|
|
358
|
+
}
|
|
359
|
+
hasProps = true;
|
|
360
|
+
}
|
|
361
|
+
if (!hasProps) {
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
return { echo: echo, reveal: reveal, revealProblems: revealProblems, focus: focus, panel: panel, showReuseMessage: showReuseMessage, clear: clear, group };
|
|
365
|
+
}
|
|
366
|
+
PresentationOptions.from = from;
|
|
367
|
+
function assignProperties(target, source) {
|
|
368
|
+
return _assignProperties(target, source, properties);
|
|
369
|
+
}
|
|
370
|
+
PresentationOptions.assignProperties = assignProperties;
|
|
371
|
+
function fillProperties(target, source) {
|
|
372
|
+
return _fillProperties(target, source, properties);
|
|
373
|
+
}
|
|
374
|
+
PresentationOptions.fillProperties = fillProperties;
|
|
375
|
+
function fillDefaults(value, context) {
|
|
376
|
+
const defaultEcho = context.engine === TaskTypes.ExecutionEngine.Terminal ? true : false;
|
|
377
|
+
return _fillDefaults(value, { echo: defaultEcho, reveal: TaskTypes.RevealKind.Always, revealProblems: TaskTypes.RevealProblemKind.Never, focus: false, panel: TaskTypes.PanelKind.Shared, showReuseMessage: true, clear: false }, properties, context);
|
|
378
|
+
}
|
|
379
|
+
PresentationOptions.fillDefaults = fillDefaults;
|
|
380
|
+
function freeze(value) {
|
|
381
|
+
return _freeze(value, properties);
|
|
382
|
+
}
|
|
383
|
+
PresentationOptions.freeze = freeze;
|
|
384
|
+
function isEmpty(value) {
|
|
385
|
+
return _isEmpty(value, properties);
|
|
386
|
+
}
|
|
387
|
+
PresentationOptions.isEmpty = isEmpty;
|
|
388
|
+
})(PresentationOptions = CommandConfiguration.PresentationOptions || (CommandConfiguration.PresentationOptions = {}));
|
|
389
|
+
let ShellString;
|
|
390
|
+
(function (ShellString) {
|
|
391
|
+
function from(value) {
|
|
392
|
+
if (value === undefined || value === null) {
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
if ((0, ide_core_common_1.isString)(value)) {
|
|
396
|
+
return value;
|
|
397
|
+
}
|
|
398
|
+
else if ((0, ide_core_common_1.isStringArray)(value)) {
|
|
399
|
+
return value.join(' ');
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
const quoting = TaskTypes.ShellQuoting.from(value.quoting);
|
|
403
|
+
const result = (0, ide_core_common_1.isString)(value.value) ? value.value : (0, ide_core_common_1.isStringArray)(value.value) ? value.value.join(' ') : undefined;
|
|
404
|
+
if (result) {
|
|
405
|
+
return {
|
|
406
|
+
value: result,
|
|
407
|
+
quoting,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
ShellString.from = from;
|
|
416
|
+
})(ShellString || (ShellString = {}));
|
|
417
|
+
const properties = [
|
|
418
|
+
{ property: 'runtime' }, { property: 'name' }, { property: 'options', type: CommandOptions },
|
|
419
|
+
{ property: 'args' }, { property: 'taskSelector' }, { property: 'suppressTaskName' },
|
|
420
|
+
{ property: 'presentation', type: PresentationOptions },
|
|
421
|
+
];
|
|
422
|
+
function from(config, context) {
|
|
423
|
+
let result = fromBase(config, context);
|
|
424
|
+
let osConfig;
|
|
425
|
+
if (config.windows && context.platform === 3 /* Windows */) {
|
|
426
|
+
osConfig = fromBase(config.windows, context);
|
|
427
|
+
}
|
|
428
|
+
else if (config.osx && context.platform === 1 /* Mac */) {
|
|
429
|
+
osConfig = fromBase(config.osx, context);
|
|
430
|
+
}
|
|
431
|
+
else if (config.linux && context.platform === 2 /* Linux */) {
|
|
432
|
+
osConfig = fromBase(config.linux, context);
|
|
433
|
+
}
|
|
434
|
+
if (osConfig) {
|
|
435
|
+
result = assignProperties(result, osConfig, context.schemaVersion === 2 /* V2_0_0 */);
|
|
436
|
+
}
|
|
437
|
+
return isEmpty(result) ? undefined : result;
|
|
438
|
+
}
|
|
439
|
+
CommandConfiguration.from = from;
|
|
440
|
+
function fromBase(config, context) {
|
|
441
|
+
const name = ShellString.from(config.command);
|
|
442
|
+
let runtime;
|
|
443
|
+
if ((0, ide_core_common_1.isString)(config.type)) {
|
|
444
|
+
if (config.type === 'shell' || config.type === 'process') {
|
|
445
|
+
runtime = TaskTypes.RuntimeType.fromString(config.type);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const isShellConfiguration = ShellConfiguration.is(config.isShellCommand);
|
|
449
|
+
if ((0, ide_core_common_1.isBoolean)(config.isShellCommand) || isShellConfiguration) {
|
|
450
|
+
runtime = TaskTypes.RuntimeType.Shell;
|
|
451
|
+
}
|
|
452
|
+
else if (config.isShellCommand !== undefined) {
|
|
453
|
+
runtime = !!config.isShellCommand ? TaskTypes.RuntimeType.Shell : TaskTypes.RuntimeType.Process;
|
|
454
|
+
}
|
|
455
|
+
const result = {
|
|
456
|
+
name,
|
|
457
|
+
runtime: runtime,
|
|
458
|
+
presentation: PresentationOptions.from(config, context),
|
|
459
|
+
};
|
|
460
|
+
if (config.args !== undefined) {
|
|
461
|
+
result.args = [];
|
|
462
|
+
for (const arg of config.args) {
|
|
463
|
+
const converted = ShellString.from(arg);
|
|
464
|
+
if (converted !== undefined) {
|
|
465
|
+
result.args.push(converted);
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
context.taskLoadIssues.push((0, ide_core_common_1.formatLocalize)('ConfigurationParser.inValidArg', 'Error: command argument must either be a string or a quoted string. Provided value is:\n{0}', arg ? JSON.stringify(arg, undefined, 4) : 'undefined'));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (config.options !== undefined) {
|
|
473
|
+
result.options = CommandOptions.from(config.options, context);
|
|
474
|
+
if (result.options && result.options.shell === undefined && isShellConfiguration) {
|
|
475
|
+
result.options.shell = ShellConfiguration.from(config.isShellCommand, context);
|
|
476
|
+
if (context.engine !== TaskTypes.ExecutionEngine.Terminal) {
|
|
477
|
+
context.taskLoadIssues.push((0, ide_core_common_1.formatLocalize)('ConfigurationParser.noShell', 'Warning: shell configuration is only supported when executing tasks in the terminal.'));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if ((0, ide_core_common_1.isString)(config.taskSelector)) {
|
|
482
|
+
result.taskSelector = config.taskSelector;
|
|
483
|
+
}
|
|
484
|
+
if ((0, ide_core_common_1.isBoolean)(config.suppressTaskName)) {
|
|
485
|
+
result.suppressTaskName = config.suppressTaskName;
|
|
486
|
+
}
|
|
487
|
+
return isEmpty(result) ? undefined : result;
|
|
488
|
+
}
|
|
489
|
+
function hasCommand(value) {
|
|
490
|
+
return value && !!value.name;
|
|
491
|
+
}
|
|
492
|
+
CommandConfiguration.hasCommand = hasCommand;
|
|
493
|
+
function isEmpty(value) {
|
|
494
|
+
return _isEmpty(value, properties);
|
|
495
|
+
}
|
|
496
|
+
CommandConfiguration.isEmpty = isEmpty;
|
|
497
|
+
function assignProperties(target, source, overwriteArgs) {
|
|
498
|
+
if (isEmpty(source)) {
|
|
499
|
+
return target;
|
|
500
|
+
}
|
|
501
|
+
if (isEmpty(target)) {
|
|
502
|
+
return source;
|
|
503
|
+
}
|
|
504
|
+
assignProperty(target, source, 'name');
|
|
505
|
+
assignProperty(target, source, 'runtime');
|
|
506
|
+
assignProperty(target, source, 'taskSelector');
|
|
507
|
+
assignProperty(target, source, 'suppressTaskName');
|
|
508
|
+
if (source.args !== undefined) {
|
|
509
|
+
if (target.args === undefined || overwriteArgs) {
|
|
510
|
+
target.args = source.args;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
target.args = target.args.concat(source.args);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
target.presentation = PresentationOptions.assignProperties(target.presentation, source.presentation);
|
|
517
|
+
target.options = CommandOptions.assignProperties(target.options, source.options);
|
|
518
|
+
return target;
|
|
519
|
+
}
|
|
520
|
+
CommandConfiguration.assignProperties = assignProperties;
|
|
521
|
+
function fillProperties(target, source) {
|
|
522
|
+
return _fillProperties(target, source, properties);
|
|
523
|
+
}
|
|
524
|
+
CommandConfiguration.fillProperties = fillProperties;
|
|
525
|
+
function fillGlobals(target, source, taskName) {
|
|
526
|
+
if ((source === undefined) || isEmpty(source)) {
|
|
527
|
+
return target;
|
|
528
|
+
}
|
|
529
|
+
target = target || {
|
|
530
|
+
name: undefined,
|
|
531
|
+
runtime: undefined,
|
|
532
|
+
presentation: undefined,
|
|
533
|
+
};
|
|
534
|
+
if (target.name === undefined) {
|
|
535
|
+
fillProperty(target, source, 'name');
|
|
536
|
+
fillProperty(target, source, 'taskSelector');
|
|
537
|
+
fillProperty(target, source, 'suppressTaskName');
|
|
538
|
+
let args = source.args ? source.args.slice() : [];
|
|
539
|
+
if (!target.suppressTaskName && taskName) {
|
|
540
|
+
if (target.taskSelector !== undefined) {
|
|
541
|
+
args.push(target.taskSelector + taskName);
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
args.push(taskName);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (target.args) {
|
|
548
|
+
args = args.concat(target.args);
|
|
549
|
+
}
|
|
550
|
+
target.args = args;
|
|
551
|
+
}
|
|
552
|
+
fillProperty(target, source, 'runtime');
|
|
553
|
+
target.presentation = PresentationOptions.fillProperties(target.presentation, source.presentation);
|
|
554
|
+
target.options = CommandOptions.fillProperties(target.options, source.options);
|
|
555
|
+
return target;
|
|
556
|
+
}
|
|
557
|
+
CommandConfiguration.fillGlobals = fillGlobals;
|
|
558
|
+
function fillDefaults(value, context) {
|
|
559
|
+
if (!value || Object.isFrozen(value)) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (value.name !== undefined && value.runtime === undefined) {
|
|
563
|
+
value.runtime = TaskTypes.RuntimeType.Process;
|
|
564
|
+
}
|
|
565
|
+
value.presentation = PresentationOptions.fillDefaults(value.presentation, context);
|
|
566
|
+
if (!isEmpty(value)) {
|
|
567
|
+
value.options = CommandOptions.fillDefaults(value.options, context);
|
|
568
|
+
}
|
|
569
|
+
if (value.args === undefined) {
|
|
570
|
+
value.args = EMPTY_ARRAY;
|
|
571
|
+
}
|
|
572
|
+
if (value.suppressTaskName === undefined) {
|
|
573
|
+
value.suppressTaskName = (context.schemaVersion === 2 /* V2_0_0 */);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
CommandConfiguration.fillDefaults = fillDefaults;
|
|
577
|
+
function freeze(value) {
|
|
578
|
+
return _freeze(value, properties);
|
|
579
|
+
}
|
|
580
|
+
CommandConfiguration.freeze = freeze;
|
|
581
|
+
})(CommandConfiguration || (CommandConfiguration = {}));
|
|
582
|
+
var ProblemMatcherConverter;
|
|
583
|
+
(function (ProblemMatcherConverter) {
|
|
584
|
+
function namedFrom(declares, context) {
|
|
585
|
+
const result = Object.create(null);
|
|
586
|
+
if (!(0, ide_core_common_1.isArray)(declares)) {
|
|
587
|
+
return result;
|
|
588
|
+
}
|
|
589
|
+
declares.forEach((value) => {
|
|
590
|
+
const namedProblemMatcher = (new parser_1.ProblemMatcherParser(context.problemReporter)).parse(value, context.getProblemPattern, context.getProblemMatcher);
|
|
591
|
+
// @ts-ignore
|
|
592
|
+
if (parser_1.Config.isNamedProblemMatcher(namedProblemMatcher)) {
|
|
593
|
+
result[namedProblemMatcher.name] = namedProblemMatcher;
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('ConfigurationParser.noName', 'Error: Problem Matcher in declare scope must have a name:\n{0}\n', JSON.stringify(value, undefined, 4)));
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
return result;
|
|
600
|
+
}
|
|
601
|
+
ProblemMatcherConverter.namedFrom = namedFrom;
|
|
602
|
+
function from(config, context) {
|
|
603
|
+
const result = [];
|
|
604
|
+
if (config === undefined) {
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
const kind = getProblemMatcherKind(config);
|
|
608
|
+
if (kind === ProblemMatcherKind.Unknown) {
|
|
609
|
+
context.problemReporter.warn((0, ide_core_common_1.formatLocalize)('ConfigurationParser.unknownMatcherKind', 'Warning: the defined problem matcher is unknown. Supported types are string | ProblemMatcher | Array<string | ProblemMatcher>.\n{0}\n', JSON.stringify(config, null, 4)));
|
|
610
|
+
return result;
|
|
611
|
+
}
|
|
612
|
+
else if (kind === ProblemMatcherKind.String || kind === ProblemMatcherKind.ProblemMatcher) {
|
|
613
|
+
const matcher = resolveProblemMatcher(config, context);
|
|
614
|
+
if (matcher) {
|
|
615
|
+
result.push(matcher);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
else if (kind === ProblemMatcherKind.Array) {
|
|
619
|
+
const problemMatchers = config;
|
|
620
|
+
problemMatchers.forEach((problemMatcher) => {
|
|
621
|
+
const matcher = resolveProblemMatcher(problemMatcher, context);
|
|
622
|
+
if (matcher) {
|
|
623
|
+
result.push(matcher);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
return result;
|
|
628
|
+
}
|
|
629
|
+
ProblemMatcherConverter.from = from;
|
|
630
|
+
function getProblemMatcherKind(value) {
|
|
631
|
+
if ((0, ide_core_common_1.isString)(value)) {
|
|
632
|
+
return ProblemMatcherKind.String;
|
|
633
|
+
}
|
|
634
|
+
else if ((0, ide_core_common_1.isArray)(value)) {
|
|
635
|
+
return ProblemMatcherKind.Array;
|
|
636
|
+
}
|
|
637
|
+
else if (!(0, ide_core_common_1.isUndefined)(value)) {
|
|
638
|
+
return ProblemMatcherKind.ProblemMatcher;
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
return ProblemMatcherKind.Unknown;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function resolveProblemMatcher(value, context) {
|
|
645
|
+
if ((0, ide_core_common_1.isString)(value)) {
|
|
646
|
+
let variableName = value;
|
|
647
|
+
if (variableName.length > 1 && variableName[0] === '$') {
|
|
648
|
+
variableName = variableName.substring(1);
|
|
649
|
+
const global = context.getProblemMatcher(variableName);
|
|
650
|
+
if (global) {
|
|
651
|
+
return (0, ide_core_common_1.deepClone)(global);
|
|
652
|
+
}
|
|
653
|
+
let localProblemMatcher = context.namedProblemMatchers[variableName];
|
|
654
|
+
if (localProblemMatcher) {
|
|
655
|
+
localProblemMatcher = (0, ide_core_common_1.deepClone)(localProblemMatcher);
|
|
656
|
+
// remove the name attr
|
|
657
|
+
// 让他从一个 NamedProblemMatcher 到 ProblemMatcher
|
|
658
|
+
delete localProblemMatcher.name;
|
|
659
|
+
return localProblemMatcher;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
context.taskLoadIssues.push((0, ide_core_common_1.formatLocalize)('ConfigurationParser.invalidVariableReference', 'Error: Invalid problemMatcher reference: {0}\n', value));
|
|
663
|
+
return undefined;
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
const json = value;
|
|
667
|
+
return new parser_1.ProblemMatcherParser(context.problemReporter).parse(json, context.getProblemPattern, context.getProblemMatcher);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
})(ProblemMatcherConverter || (ProblemMatcherConverter = {}));
|
|
671
|
+
const source = {
|
|
672
|
+
kind: TaskTypes.TaskSourceKind.Workspace,
|
|
673
|
+
label: 'Workspace',
|
|
674
|
+
config: undefined,
|
|
675
|
+
};
|
|
676
|
+
var GroupKind;
|
|
677
|
+
(function (GroupKind) {
|
|
678
|
+
function from(external) {
|
|
679
|
+
if (external === undefined) {
|
|
680
|
+
return undefined;
|
|
681
|
+
}
|
|
682
|
+
if ((0, ide_core_common_1.isString)(external)) {
|
|
683
|
+
if (TaskTypes.TaskGroup.is(external)) {
|
|
684
|
+
return [external, "user" /* user */];
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
return undefined;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (!(0, ide_core_common_1.isString)(external.kind) || !TaskTypes.TaskGroup.is(external.kind)) {
|
|
691
|
+
return undefined;
|
|
692
|
+
}
|
|
693
|
+
const group = external.kind;
|
|
694
|
+
const isDefault = !!external.isDefault;
|
|
695
|
+
return [group, isDefault ? "default" /* default */ : "user" /* user */];
|
|
696
|
+
}
|
|
697
|
+
GroupKind.from = from;
|
|
698
|
+
})(GroupKind || (GroupKind = {}));
|
|
699
|
+
var TaskDependency;
|
|
700
|
+
(function (TaskDependency) {
|
|
701
|
+
function from(external, context) {
|
|
702
|
+
if ((0, ide_core_common_1.isString)(external)) {
|
|
703
|
+
return { workspaceFolder: context.workspaceFolder, task: external };
|
|
704
|
+
}
|
|
705
|
+
else if (TaskIdentifier.is(external)) {
|
|
706
|
+
return { workspaceFolder: context.workspaceFolder, task: context.createTaskIdentifier(external, context.problemReporter) };
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
return undefined;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
TaskDependency.from = from;
|
|
713
|
+
})(TaskDependency || (TaskDependency = {}));
|
|
714
|
+
var DependsOrder;
|
|
715
|
+
(function (DependsOrder) {
|
|
716
|
+
function from(order) {
|
|
717
|
+
switch (order) {
|
|
718
|
+
case "sequence" /* sequence */:
|
|
719
|
+
return "sequence" /* sequence */;
|
|
720
|
+
case "parallel" /* parallel */:
|
|
721
|
+
default:
|
|
722
|
+
return "parallel" /* parallel */;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
DependsOrder.from = from;
|
|
726
|
+
})(DependsOrder || (DependsOrder = {}));
|
|
727
|
+
var ConfigurationProperties;
|
|
728
|
+
(function (ConfigurationProperties) {
|
|
729
|
+
const properties = [
|
|
730
|
+
{ property: 'name' },
|
|
731
|
+
{ property: 'identifier' },
|
|
732
|
+
{ property: 'group' },
|
|
733
|
+
{ property: 'isBackground' },
|
|
734
|
+
{ property: 'promptOnClose' },
|
|
735
|
+
{ property: 'dependsOn' },
|
|
736
|
+
{ property: 'presentation', type: CommandConfiguration.PresentationOptions },
|
|
737
|
+
{ property: 'problemMatchers' },
|
|
738
|
+
];
|
|
739
|
+
function from(external, context, includeCommandOptions, properties) {
|
|
740
|
+
if (!external) {
|
|
741
|
+
return undefined;
|
|
742
|
+
}
|
|
743
|
+
const result = {};
|
|
744
|
+
if (properties) {
|
|
745
|
+
for (const propertyName of Object.keys(properties)) {
|
|
746
|
+
if (external[propertyName] !== undefined) {
|
|
747
|
+
result[propertyName] = (0, ide_core_common_1.deepClone)(external[propertyName]);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if ((0, ide_core_common_1.isString)(external.taskName)) {
|
|
752
|
+
result.name = external.taskName;
|
|
753
|
+
}
|
|
754
|
+
if ((0, ide_core_common_1.isString)(external.label) && context.schemaVersion === 2 /* V2_0_0 */) {
|
|
755
|
+
result.name = external.label;
|
|
756
|
+
}
|
|
757
|
+
if ((0, ide_core_common_1.isString)(external.identifier)) {
|
|
758
|
+
result.identifier = external.identifier;
|
|
759
|
+
}
|
|
760
|
+
if (external.isBackground !== undefined) {
|
|
761
|
+
result.isBackground = !!external.isBackground;
|
|
762
|
+
}
|
|
763
|
+
if (external.promptOnClose !== undefined) {
|
|
764
|
+
result.promptOnClose = !!external.promptOnClose;
|
|
765
|
+
}
|
|
766
|
+
if (external.group !== undefined) {
|
|
767
|
+
if ((0, ide_core_common_1.isString)(external.group) && TaskTypes.TaskGroup.is(external.group)) {
|
|
768
|
+
result.group = external.group;
|
|
769
|
+
result.groupType = "user" /* user */;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
const values = GroupKind.from(external.group);
|
|
773
|
+
if (values) {
|
|
774
|
+
result.group = values[0];
|
|
775
|
+
result.groupType = values[1];
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (external.dependsOn !== undefined) {
|
|
780
|
+
if ((0, ide_core_common_1.isArray)(external.dependsOn)) {
|
|
781
|
+
result.dependsOn = external.dependsOn.reduce((dependencies, item) => {
|
|
782
|
+
const dependency = TaskDependency.from(item, context);
|
|
783
|
+
if (dependency) {
|
|
784
|
+
dependencies.push(dependency);
|
|
785
|
+
}
|
|
786
|
+
return dependencies;
|
|
787
|
+
}, []);
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
const dependsOnValue = TaskDependency.from(external.dependsOn, context);
|
|
791
|
+
result.dependsOn = dependsOnValue ? [dependsOnValue] : undefined;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
result.dependsOrder = DependsOrder.from(external.dependsOrder);
|
|
795
|
+
if (includeCommandOptions && (external.presentation !== undefined || external.terminal !== undefined)) {
|
|
796
|
+
result.presentation = CommandConfiguration.PresentationOptions.from(external, context);
|
|
797
|
+
}
|
|
798
|
+
if (includeCommandOptions && (external.options !== undefined)) {
|
|
799
|
+
result.options = CommandOptions.from(external.options, context);
|
|
800
|
+
}
|
|
801
|
+
if (external.problemMatcher) {
|
|
802
|
+
result.problemMatchers = ProblemMatcherConverter.from(external.problemMatcher, context);
|
|
803
|
+
}
|
|
804
|
+
return isEmpty(result) ? undefined : result;
|
|
805
|
+
}
|
|
806
|
+
ConfigurationProperties.from = from;
|
|
807
|
+
function isEmpty(value) {
|
|
808
|
+
return _isEmpty(value, properties);
|
|
809
|
+
}
|
|
810
|
+
ConfigurationProperties.isEmpty = isEmpty;
|
|
811
|
+
})(ConfigurationProperties || (ConfigurationProperties = {}));
|
|
812
|
+
var ConfiguringTask;
|
|
813
|
+
(function (ConfiguringTask) {
|
|
814
|
+
const grunt = 'grunt.';
|
|
815
|
+
const jake = 'jake.';
|
|
816
|
+
const gulp = 'gulp.';
|
|
817
|
+
const npm = 'vscode.npm.';
|
|
818
|
+
const typescript = 'vscode.typescript.';
|
|
819
|
+
function from(external, context, index, taskDefinitionRegister) {
|
|
820
|
+
if (!external) {
|
|
821
|
+
return undefined;
|
|
822
|
+
}
|
|
823
|
+
const type = external.type;
|
|
824
|
+
const customize = external.customize;
|
|
825
|
+
if (!type && !customize) {
|
|
826
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('ConfigurationParser.noTaskType', 'Error: tasks configuration must have a type property. The configuration will be ignored.\n{0}\n', JSON.stringify(external, null, 4)));
|
|
827
|
+
return undefined;
|
|
828
|
+
}
|
|
829
|
+
const typeDeclaration = type ? taskDefinitionRegister.get(type) : undefined;
|
|
830
|
+
if (!typeDeclaration) {
|
|
831
|
+
const message = (0, ide_core_common_1.formatLocalize)('ConfigurationParser.noTypeDefinition', 'Error: there is no registered task type \'{0}\'. Did you miss to install an extension that provides a corresponding task provider?', type);
|
|
832
|
+
context.problemReporter.error(message);
|
|
833
|
+
return undefined;
|
|
834
|
+
}
|
|
835
|
+
let identifier;
|
|
836
|
+
if ((0, ide_core_common_1.isString)(customize)) {
|
|
837
|
+
if (customize.indexOf(grunt) === 0) {
|
|
838
|
+
identifier = { type: 'grunt', task: customize.substring(grunt.length) };
|
|
839
|
+
}
|
|
840
|
+
else if (customize.indexOf(jake) === 0) {
|
|
841
|
+
identifier = { type: 'jake', task: customize.substring(jake.length) };
|
|
842
|
+
}
|
|
843
|
+
else if (customize.indexOf(gulp) === 0) {
|
|
844
|
+
identifier = { type: 'gulp', task: customize.substring(gulp.length) };
|
|
845
|
+
}
|
|
846
|
+
else if (customize.indexOf(npm) === 0) {
|
|
847
|
+
identifier = { type: 'npm', script: customize.substring(npm.length + 4) };
|
|
848
|
+
}
|
|
849
|
+
else if (customize.indexOf(typescript) === 0) {
|
|
850
|
+
identifier = { type: 'typescript', tsconfig: customize.substring(typescript.length + 6) };
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
if ((0, ide_core_common_1.isString)(external.type)) {
|
|
855
|
+
identifier = external;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
if (identifier === undefined) {
|
|
859
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('ConfigurationParsTaskTypes.er.missingType', 'Error: the task configuration \'{0}\' is missing the required property \'type\'. The task configuration will be ignored.', JSON.stringify(external, undefined, 0)));
|
|
860
|
+
return undefined;
|
|
861
|
+
}
|
|
862
|
+
const taskIdentifier = context.createTaskIdentifier(identifier, context.problemReporter);
|
|
863
|
+
if (taskIdentifier === undefined) {
|
|
864
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('ConfigurationParTaskTypes.ser.incorrectType', 'Error: the task configuration \'{0}\' is using an unknown type. The task configuration will be ignored.', JSON.stringify(external, undefined, 0)));
|
|
865
|
+
return undefined;
|
|
866
|
+
}
|
|
867
|
+
const configElement = {
|
|
868
|
+
workspaceFolder: context.workspaceFolder,
|
|
869
|
+
file: '.vscode/json',
|
|
870
|
+
index,
|
|
871
|
+
element: external,
|
|
872
|
+
};
|
|
873
|
+
const result = new TaskTypes.ConfiguringTask(`${typeDeclaration.extensionId}.${taskIdentifier._key}`, Object.assign({}, source, { config: configElement }), undefined, type, taskIdentifier, RunOptions.fromConfiguration(external.runOptions), {});
|
|
874
|
+
const configuration = ConfigurationProperties.from(external, context, true, typeDeclaration.properties);
|
|
875
|
+
if (configuration) {
|
|
876
|
+
result.configurationProperties = Object.assign(result.configurationProperties, configuration);
|
|
877
|
+
if (result.configurationProperties.name) {
|
|
878
|
+
result._label = result.configurationProperties.name;
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
let label = result.configures.type;
|
|
882
|
+
if (typeDeclaration.required && typeDeclaration.required.length > 0) {
|
|
883
|
+
for (const required of typeDeclaration.required) {
|
|
884
|
+
const value = result.configures[required];
|
|
885
|
+
if (value) {
|
|
886
|
+
label = label + ' ' + value;
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
result._label = label;
|
|
892
|
+
}
|
|
893
|
+
if (!result.configurationProperties.identifier) {
|
|
894
|
+
result.configurationProperties.identifier = taskIdentifier._key;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return result;
|
|
898
|
+
}
|
|
899
|
+
ConfiguringTask.from = from;
|
|
900
|
+
})(ConfiguringTask || (ConfiguringTask = {}));
|
|
901
|
+
var CustomTask;
|
|
902
|
+
(function (CustomTask) {
|
|
903
|
+
function from(external, context, index) {
|
|
904
|
+
if (!external) {
|
|
905
|
+
return undefined;
|
|
906
|
+
}
|
|
907
|
+
let type = external.type;
|
|
908
|
+
if (type === undefined || type === null) {
|
|
909
|
+
type = TaskTypes.CUSTOMIZED_TASK_TYPE;
|
|
910
|
+
}
|
|
911
|
+
if (type !== TaskTypes.CUSTOMIZED_TASK_TYPE && type !== 'shell' && type !== 'process') {
|
|
912
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('ConfigurationParser.notCustom', 'Error: tasks is not declared as a custom task. The configuration will be ignored.\n{0}\n', JSON.stringify(external, null, 4)));
|
|
913
|
+
return undefined;
|
|
914
|
+
}
|
|
915
|
+
let taskName = external.taskName;
|
|
916
|
+
if ((0, ide_core_common_1.isString)(external.label) && context.schemaVersion === 2 /* V2_0_0 */) {
|
|
917
|
+
taskName = external.label;
|
|
918
|
+
}
|
|
919
|
+
if (!taskName) {
|
|
920
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('ConfigurationParser.noTaskName', 'Error: a task must provide a label property. The task will be ignored.\n{0}\n', JSON.stringify(external, null, 4)));
|
|
921
|
+
return undefined;
|
|
922
|
+
}
|
|
923
|
+
const result = new TaskTypes.CustomTask(context.uuidMap.getUUID(taskName), Object.assign({}, source, { config: { index, element: external, file: '.vscode/json', workspaceFolder: context.workspaceFolder } }), taskName, TaskTypes.CUSTOMIZED_TASK_TYPE, undefined, false, RunOptions.fromConfiguration(external.runOptions), {
|
|
924
|
+
name: taskName,
|
|
925
|
+
identifier: taskName,
|
|
926
|
+
});
|
|
927
|
+
const configuration = ConfigurationProperties.from(external, context, false);
|
|
928
|
+
if (configuration) {
|
|
929
|
+
result.configurationProperties = Object.assign(result.configurationProperties, configuration);
|
|
930
|
+
}
|
|
931
|
+
const supportLegacy = true; // context.schemaVersion === JsonSchemaVersion.V2_0_0;
|
|
932
|
+
if (supportLegacy) {
|
|
933
|
+
const legacy = external;
|
|
934
|
+
if (result.configurationProperties.isBackground === undefined && legacy.isWatching !== undefined) {
|
|
935
|
+
result.configurationProperties.isBackground = !!legacy.isWatching;
|
|
936
|
+
}
|
|
937
|
+
if (result.configurationProperties.group === undefined) {
|
|
938
|
+
if (legacy.isBuildCommand === true) {
|
|
939
|
+
result.configurationProperties.group = TaskTypes.TaskGroup.Build;
|
|
940
|
+
}
|
|
941
|
+
else if (legacy.isTestCommand === true) {
|
|
942
|
+
result.configurationProperties.group = TaskTypes.TaskGroup.Test;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
const command = CommandConfiguration.from(external, context);
|
|
947
|
+
if (command) {
|
|
948
|
+
result.command = command;
|
|
949
|
+
}
|
|
950
|
+
if (external.command !== undefined) {
|
|
951
|
+
// if the task has its own command then we suppress the
|
|
952
|
+
// task name by default.
|
|
953
|
+
command.suppressTaskName = true;
|
|
954
|
+
}
|
|
955
|
+
return result;
|
|
956
|
+
}
|
|
957
|
+
CustomTask.from = from;
|
|
958
|
+
function fillGlobals(task, globals) {
|
|
959
|
+
// We only merge a command from a global definition if there is no dependsOn
|
|
960
|
+
// or there is a dependsOn and a defined command.
|
|
961
|
+
if (CommandConfiguration.hasCommand(task.command) || task.configurationProperties.dependsOn === undefined) {
|
|
962
|
+
task.command = CommandConfiguration.fillGlobals(task.command, globals.command, task.configurationProperties.name);
|
|
963
|
+
}
|
|
964
|
+
if (task.configurationProperties.problemMatchers === undefined && globals.problemMatcher !== undefined) {
|
|
965
|
+
task.configurationProperties.problemMatchers = (0, ide_core_common_1.deepClone)(globals.problemMatcher);
|
|
966
|
+
task.hasDefinedMatchers = true;
|
|
967
|
+
}
|
|
968
|
+
// promptOnClose is inferred from isBackground if available
|
|
969
|
+
if (task.configurationProperties.promptOnClose === undefined && task.configurationProperties.isBackground === undefined && globals.promptOnClose !== undefined) {
|
|
970
|
+
task.configurationProperties.promptOnClose = globals.promptOnClose;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
CustomTask.fillGlobals = fillGlobals;
|
|
974
|
+
function fillDefaults(task, context) {
|
|
975
|
+
CommandConfiguration.fillDefaults(task.command, context);
|
|
976
|
+
if (task.configurationProperties.promptOnClose === undefined) {
|
|
977
|
+
task.configurationProperties.promptOnClose = task.configurationProperties.isBackground !== undefined ? !task.configurationProperties.isBackground : true;
|
|
978
|
+
}
|
|
979
|
+
if (task.configurationProperties.isBackground === undefined) {
|
|
980
|
+
task.configurationProperties.isBackground = false;
|
|
981
|
+
}
|
|
982
|
+
if (task.configurationProperties.problemMatchers === undefined) {
|
|
983
|
+
task.configurationProperties.problemMatchers = EMPTY_ARRAY;
|
|
984
|
+
}
|
|
985
|
+
if (task.configurationProperties.group !== undefined && task.configurationProperties.groupType === undefined) {
|
|
986
|
+
task.configurationProperties.groupType = "user" /* user */;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
CustomTask.fillDefaults = fillDefaults;
|
|
990
|
+
function createCustomTask(contributedTask, configuredProps) {
|
|
991
|
+
const result = new TaskTypes.CustomTask(configuredProps._id, Object.assign({}, configuredProps._source, { customizes: contributedTask.defines }), configuredProps.configurationProperties.name || contributedTask._label, TaskTypes.CUSTOMIZED_TASK_TYPE, contributedTask.command, false, contributedTask.runOptions, {
|
|
992
|
+
name: configuredProps.configurationProperties.name || contributedTask.configurationProperties.name,
|
|
993
|
+
identifier: configuredProps.configurationProperties.identifier || contributedTask.configurationProperties.identifier,
|
|
994
|
+
});
|
|
995
|
+
result.addTaskLoadMessages(configuredProps.taskLoadMessages);
|
|
996
|
+
const resultConfigProps = result.configurationProperties;
|
|
997
|
+
assignProperty(resultConfigProps, configuredProps.configurationProperties, 'group');
|
|
998
|
+
assignProperty(resultConfigProps, configuredProps.configurationProperties, 'groupType');
|
|
999
|
+
assignProperty(resultConfigProps, configuredProps.configurationProperties, 'isBackground');
|
|
1000
|
+
assignProperty(resultConfigProps, configuredProps.configurationProperties, 'dependsOn');
|
|
1001
|
+
assignProperty(resultConfigProps, configuredProps.configurationProperties, 'problemMatchers');
|
|
1002
|
+
assignProperty(resultConfigProps, configuredProps.configurationProperties, 'promptOnClose');
|
|
1003
|
+
result.command.presentation = CommandConfiguration.PresentationOptions.assignProperties(result.command.presentation, configuredProps.configurationProperties.presentation);
|
|
1004
|
+
result.command.options = CommandOptions.assignProperties(result.command.options, configuredProps.configurationProperties.options);
|
|
1005
|
+
const contributedConfigProps = contributedTask.configurationProperties;
|
|
1006
|
+
fillProperty(resultConfigProps, contributedConfigProps, 'group');
|
|
1007
|
+
fillProperty(resultConfigProps, contributedConfigProps, 'groupType');
|
|
1008
|
+
fillProperty(resultConfigProps, contributedConfigProps, 'isBackground');
|
|
1009
|
+
fillProperty(resultConfigProps, contributedConfigProps, 'dependsOn');
|
|
1010
|
+
fillProperty(resultConfigProps, contributedConfigProps, 'problemMatchers');
|
|
1011
|
+
fillProperty(resultConfigProps, contributedConfigProps, 'promptOnClose');
|
|
1012
|
+
result.command.presentation = CommandConfiguration.PresentationOptions.fillProperties(result.command.presentation, contributedConfigProps.presentation);
|
|
1013
|
+
result.command.options = CommandOptions.fillProperties(result.command.options, contributedConfigProps.options);
|
|
1014
|
+
if (contributedTask.hasDefinedMatchers === true) {
|
|
1015
|
+
result.hasDefinedMatchers = true;
|
|
1016
|
+
}
|
|
1017
|
+
return result;
|
|
1018
|
+
}
|
|
1019
|
+
CustomTask.createCustomTask = createCustomTask;
|
|
1020
|
+
})(CustomTask || (CustomTask = {}));
|
|
1021
|
+
var TaskParser;
|
|
1022
|
+
(function (TaskParser) {
|
|
1023
|
+
function isCustomTask(value) {
|
|
1024
|
+
const type = value.type;
|
|
1025
|
+
const customize = value.customize;
|
|
1026
|
+
return customize === undefined && (type === undefined || type === null || type === TaskTypes.CUSTOMIZED_TASK_TYPE || type === 'shell' || type === 'process');
|
|
1027
|
+
}
|
|
1028
|
+
function from(externals, globals, context, taskDefinitionRegister) {
|
|
1029
|
+
const result = { custom: [], configured: [] };
|
|
1030
|
+
if (!externals) {
|
|
1031
|
+
return result;
|
|
1032
|
+
}
|
|
1033
|
+
const defaultBuildTask = { task: undefined, rank: -1 };
|
|
1034
|
+
const defaultTestTask = { task: undefined, rank: -1 };
|
|
1035
|
+
// tslint:disable-next-line: variable-name
|
|
1036
|
+
const schema2_0_0 = context.schemaVersion === 2 /* V2_0_0 */;
|
|
1037
|
+
const baseLoadIssues = (0, ide_core_common_1.deepClone)(context.taskLoadIssues);
|
|
1038
|
+
for (let index = 0; index < externals.length; index++) {
|
|
1039
|
+
const external = externals[index];
|
|
1040
|
+
if (isCustomTask(external)) {
|
|
1041
|
+
const customTask = CustomTask.from(external, context, index);
|
|
1042
|
+
if (customTask) {
|
|
1043
|
+
CustomTask.fillGlobals(customTask, globals);
|
|
1044
|
+
CustomTask.fillDefaults(customTask, context);
|
|
1045
|
+
if (schema2_0_0) {
|
|
1046
|
+
if ((customTask.command === undefined || customTask.command.name === undefined) && (customTask.configurationProperties.dependsOn === undefined || customTask.configurationProperties.dependsOn.length === 0)) {
|
|
1047
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('taskConfiguration.noCommandOrDependsOn', 'Error: the task \'{0}\' neither specifies a command nor a dependsOn property. The task will be ignored. Its definition is:\n{1}', customTask.configurationProperties.name, JSON.stringify(external, undefined, 4)));
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
else {
|
|
1052
|
+
if (customTask.command === undefined || customTask.command.name === undefined) {
|
|
1053
|
+
context.problemReporter.warn((0, ide_core_common_1.formatLocalize)('taskConfiguration.noCommand', 'Error: the task \'{0}\' doesn\'t define a command. The task will be ignored. Its definition is:\n{1}', customTask.configurationProperties.name, JSON.stringify(external, undefined, 4)));
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (customTask.configurationProperties.group === TaskTypes.TaskGroup.Build && defaultBuildTask.rank < 2) {
|
|
1058
|
+
defaultBuildTask.task = customTask;
|
|
1059
|
+
defaultBuildTask.rank = 2;
|
|
1060
|
+
}
|
|
1061
|
+
else if (customTask.configurationProperties.group === TaskTypes.TaskGroup.Test && defaultTestTask.rank < 2) {
|
|
1062
|
+
defaultTestTask.task = customTask;
|
|
1063
|
+
defaultTestTask.rank = 2;
|
|
1064
|
+
}
|
|
1065
|
+
else if (customTask.configurationProperties.name === 'build' && defaultBuildTask.rank < 1) {
|
|
1066
|
+
defaultBuildTask.task = customTask;
|
|
1067
|
+
defaultBuildTask.rank = 1;
|
|
1068
|
+
}
|
|
1069
|
+
else if (customTask.configurationProperties.name === 'test' && defaultTestTask.rank < 1) {
|
|
1070
|
+
defaultTestTask.task = customTask;
|
|
1071
|
+
defaultTestTask.rank = 1;
|
|
1072
|
+
}
|
|
1073
|
+
customTask.addTaskLoadMessages(context.taskLoadIssues);
|
|
1074
|
+
result.custom.push(customTask);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
else {
|
|
1078
|
+
const configuredTask = ConfiguringTask.from(external, context, index, taskDefinitionRegister);
|
|
1079
|
+
if (configuredTask) {
|
|
1080
|
+
configuredTask.addTaskLoadMessages(context.taskLoadIssues);
|
|
1081
|
+
result.configured.push(configuredTask);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
context.taskLoadIssues = (0, ide_core_common_1.deepClone)(baseLoadIssues);
|
|
1085
|
+
}
|
|
1086
|
+
if ((defaultBuildTask.rank > -1) && (defaultBuildTask.rank < 2) && defaultBuildTask.task) {
|
|
1087
|
+
defaultBuildTask.task.configurationProperties.group = TaskTypes.TaskGroup.Build;
|
|
1088
|
+
defaultBuildTask.task.configurationProperties.groupType = "user" /* user */;
|
|
1089
|
+
}
|
|
1090
|
+
else if ((defaultTestTask.rank > -1) && (defaultTestTask.rank < 2) && defaultTestTask.task) {
|
|
1091
|
+
defaultTestTask.task.configurationProperties.group = TaskTypes.TaskGroup.Test;
|
|
1092
|
+
defaultTestTask.task.configurationProperties.groupType = "user" /* user */;
|
|
1093
|
+
}
|
|
1094
|
+
return result;
|
|
1095
|
+
}
|
|
1096
|
+
TaskParser.from = from;
|
|
1097
|
+
function assignTasks(target, source) {
|
|
1098
|
+
if (source === undefined || source.length === 0) {
|
|
1099
|
+
return target;
|
|
1100
|
+
}
|
|
1101
|
+
if (target === undefined || target.length === 0) {
|
|
1102
|
+
return source;
|
|
1103
|
+
}
|
|
1104
|
+
if (source) {
|
|
1105
|
+
// Tasks are keyed by ID but we need to merge by name
|
|
1106
|
+
const map = Object.create(null);
|
|
1107
|
+
target.forEach((task) => {
|
|
1108
|
+
map[task.configurationProperties.name] = task;
|
|
1109
|
+
});
|
|
1110
|
+
source.forEach((task) => {
|
|
1111
|
+
map[task.configurationProperties.name] = task;
|
|
1112
|
+
});
|
|
1113
|
+
const newTarget = [];
|
|
1114
|
+
target.forEach((task) => {
|
|
1115
|
+
newTarget.push(map[task.configurationProperties.name]);
|
|
1116
|
+
delete map[task.configurationProperties.name];
|
|
1117
|
+
});
|
|
1118
|
+
Object.keys(map).forEach((key) => newTarget.push(map[key]));
|
|
1119
|
+
target = newTarget;
|
|
1120
|
+
}
|
|
1121
|
+
return target;
|
|
1122
|
+
}
|
|
1123
|
+
TaskParser.assignTasks = assignTasks;
|
|
1124
|
+
})(TaskParser || (TaskParser = {}));
|
|
1125
|
+
var Globals;
|
|
1126
|
+
(function (Globals) {
|
|
1127
|
+
function from(config, context) {
|
|
1128
|
+
let result = fromBase(config, context);
|
|
1129
|
+
let osGlobals;
|
|
1130
|
+
if (config.windows && context.platform === 3 /* Windows */) {
|
|
1131
|
+
osGlobals = fromBase(config.windows, context);
|
|
1132
|
+
}
|
|
1133
|
+
else if (config.osx && context.platform === 1 /* Mac */) {
|
|
1134
|
+
osGlobals = fromBase(config.osx, context);
|
|
1135
|
+
}
|
|
1136
|
+
else if (config.linux && context.platform === 2 /* Linux */) {
|
|
1137
|
+
osGlobals = fromBase(config.linux, context);
|
|
1138
|
+
}
|
|
1139
|
+
if (osGlobals) {
|
|
1140
|
+
result = Globals.assignProperties(result, osGlobals);
|
|
1141
|
+
}
|
|
1142
|
+
const command = CommandConfiguration.from(config, context);
|
|
1143
|
+
if (command) {
|
|
1144
|
+
result.command = command;
|
|
1145
|
+
}
|
|
1146
|
+
Globals.fillDefaults(result, context);
|
|
1147
|
+
Globals.freeze(result);
|
|
1148
|
+
return result;
|
|
1149
|
+
}
|
|
1150
|
+
Globals.from = from;
|
|
1151
|
+
function fromBase(config, context) {
|
|
1152
|
+
const result = {};
|
|
1153
|
+
if (config.suppressTaskName !== undefined) {
|
|
1154
|
+
result.suppressTaskName = !!config.suppressTaskName;
|
|
1155
|
+
}
|
|
1156
|
+
if (config.promptOnClose !== undefined) {
|
|
1157
|
+
result.promptOnClose = !!config.promptOnClose;
|
|
1158
|
+
}
|
|
1159
|
+
if (config.problemMatcher) {
|
|
1160
|
+
result.problemMatcher = ProblemMatcherConverter.from(config.problemMatcher, context);
|
|
1161
|
+
}
|
|
1162
|
+
return result;
|
|
1163
|
+
}
|
|
1164
|
+
Globals.fromBase = fromBase;
|
|
1165
|
+
function isEmpty(value) {
|
|
1166
|
+
return !value || value.command === undefined && value.promptOnClose === undefined && value.suppressTaskName === undefined;
|
|
1167
|
+
}
|
|
1168
|
+
Globals.isEmpty = isEmpty;
|
|
1169
|
+
function assignProperties(target, source) {
|
|
1170
|
+
if (isEmpty(source)) {
|
|
1171
|
+
return target;
|
|
1172
|
+
}
|
|
1173
|
+
if (isEmpty(target)) {
|
|
1174
|
+
return source;
|
|
1175
|
+
}
|
|
1176
|
+
assignProperty(target, source, 'promptOnClose');
|
|
1177
|
+
assignProperty(target, source, 'suppressTaskName');
|
|
1178
|
+
return target;
|
|
1179
|
+
}
|
|
1180
|
+
Globals.assignProperties = assignProperties;
|
|
1181
|
+
function fillDefaults(value, context) {
|
|
1182
|
+
if (!value) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
CommandConfiguration.fillDefaults(value.command, context);
|
|
1186
|
+
if (value.suppressTaskName === undefined) {
|
|
1187
|
+
value.suppressTaskName = (context.schemaVersion === 2 /* V2_0_0 */);
|
|
1188
|
+
}
|
|
1189
|
+
if (value.promptOnClose === undefined) {
|
|
1190
|
+
value.promptOnClose = true;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
Globals.fillDefaults = fillDefaults;
|
|
1194
|
+
function freeze(value) {
|
|
1195
|
+
Object.freeze(value);
|
|
1196
|
+
if (value.command) {
|
|
1197
|
+
CommandConfiguration.freeze(value.command);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
Globals.freeze = freeze;
|
|
1201
|
+
})(Globals || (Globals = {}));
|
|
1202
|
+
var ExecutionEngine;
|
|
1203
|
+
(function (ExecutionEngine) {
|
|
1204
|
+
function from(config) {
|
|
1205
|
+
const runner = config.runner || config._runner;
|
|
1206
|
+
let result;
|
|
1207
|
+
if (runner) {
|
|
1208
|
+
switch (runner) {
|
|
1209
|
+
case 'terminal':
|
|
1210
|
+
result = TaskTypes.ExecutionEngine.Terminal;
|
|
1211
|
+
break;
|
|
1212
|
+
case 'process':
|
|
1213
|
+
result = TaskTypes.ExecutionEngine.Process;
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
const schemaVersion = JsonSchemaVersion.from(config);
|
|
1218
|
+
if (schemaVersion === 1 /* V0_1_0 */) {
|
|
1219
|
+
return result || TaskTypes.ExecutionEngine.Process;
|
|
1220
|
+
}
|
|
1221
|
+
else if (schemaVersion === 2 /* V2_0_0 */) {
|
|
1222
|
+
return TaskTypes.ExecutionEngine.Terminal;
|
|
1223
|
+
}
|
|
1224
|
+
else {
|
|
1225
|
+
throw new Error('Shouldn\'t happen.');
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
ExecutionEngine.from = from;
|
|
1229
|
+
})(ExecutionEngine = exports.ExecutionEngine || (exports.ExecutionEngine = {}));
|
|
1230
|
+
var JsonSchemaVersion;
|
|
1231
|
+
(function (JsonSchemaVersion) {
|
|
1232
|
+
const _default = 2 /* V2_0_0 */;
|
|
1233
|
+
function from(config) {
|
|
1234
|
+
const version = config.version;
|
|
1235
|
+
if (!version) {
|
|
1236
|
+
return _default;
|
|
1237
|
+
}
|
|
1238
|
+
switch (version) {
|
|
1239
|
+
case '0.1.0':
|
|
1240
|
+
return 1 /* V0_1_0 */;
|
|
1241
|
+
case '2.0.0':
|
|
1242
|
+
return 2 /* V2_0_0 */;
|
|
1243
|
+
default:
|
|
1244
|
+
return _default;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
JsonSchemaVersion.from = from;
|
|
1248
|
+
})(JsonSchemaVersion = exports.JsonSchemaVersion || (exports.JsonSchemaVersion = {}));
|
|
1249
|
+
class UUIDMap {
|
|
1250
|
+
constructor(other) {
|
|
1251
|
+
this.current = Object.create(null);
|
|
1252
|
+
if (other) {
|
|
1253
|
+
for (const key of Object.keys(other.current)) {
|
|
1254
|
+
const value = other.current[key];
|
|
1255
|
+
if (Array.isArray(value)) {
|
|
1256
|
+
this.current[key] = value.slice();
|
|
1257
|
+
}
|
|
1258
|
+
else {
|
|
1259
|
+
this.current[key] = value;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
start() {
|
|
1265
|
+
this.last = this.current;
|
|
1266
|
+
this.current = Object.create(null);
|
|
1267
|
+
}
|
|
1268
|
+
getUUID(identifier) {
|
|
1269
|
+
const lastValue = this.last ? this.last[identifier] : undefined;
|
|
1270
|
+
let result;
|
|
1271
|
+
if (lastValue !== undefined) {
|
|
1272
|
+
if (Array.isArray(lastValue)) {
|
|
1273
|
+
result = lastValue.shift();
|
|
1274
|
+
if (lastValue.length === 0) {
|
|
1275
|
+
delete this.last[identifier];
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
result = lastValue;
|
|
1280
|
+
delete this.last[identifier];
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
if (result === undefined) {
|
|
1284
|
+
result = (0, ide_core_common_1.uuid)();
|
|
1285
|
+
}
|
|
1286
|
+
const currentValue = this.current[identifier];
|
|
1287
|
+
if (currentValue === undefined) {
|
|
1288
|
+
this.current[identifier] = result;
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
if (Array.isArray(currentValue)) {
|
|
1292
|
+
currentValue.push(result);
|
|
1293
|
+
}
|
|
1294
|
+
else {
|
|
1295
|
+
const arrayValue = [currentValue];
|
|
1296
|
+
arrayValue.push(result);
|
|
1297
|
+
this.current[identifier] = arrayValue;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
return result;
|
|
1301
|
+
}
|
|
1302
|
+
finish() {
|
|
1303
|
+
this.last = undefined;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
class ConfigurationParser {
|
|
1307
|
+
constructor(workspaceFolder, platform, problemReporter, uuidMap, createTaskIdentifier, getProblemMatcher, getProblemPattern) {
|
|
1308
|
+
this.createTaskIdentifier = createTaskIdentifier;
|
|
1309
|
+
this.getProblemMatcher = getProblemMatcher;
|
|
1310
|
+
this.getProblemPattern = getProblemPattern;
|
|
1311
|
+
this.workspaceFolder = workspaceFolder;
|
|
1312
|
+
this.platform = platform;
|
|
1313
|
+
this.problemReporter = problemReporter;
|
|
1314
|
+
this.uuidMap = uuidMap;
|
|
1315
|
+
}
|
|
1316
|
+
run(fileConfig, taskDefinitionRegister) {
|
|
1317
|
+
const engine = ExecutionEngine.from(fileConfig);
|
|
1318
|
+
const schemaVersion = JsonSchemaVersion.from(fileConfig);
|
|
1319
|
+
const context = {
|
|
1320
|
+
workspaceFolder: this.workspaceFolder,
|
|
1321
|
+
problemReporter: this.problemReporter,
|
|
1322
|
+
uuidMap: this.uuidMap,
|
|
1323
|
+
namedProblemMatchers: {},
|
|
1324
|
+
engine,
|
|
1325
|
+
schemaVersion,
|
|
1326
|
+
platform: this.platform,
|
|
1327
|
+
taskLoadIssues: [],
|
|
1328
|
+
createTaskIdentifier: this.createTaskIdentifier,
|
|
1329
|
+
getProblemMatcher: this.getProblemMatcher,
|
|
1330
|
+
getProblemPattern: this.getProblemPattern,
|
|
1331
|
+
};
|
|
1332
|
+
const taskParseResult = this.createTaskRunnerConfiguration(fileConfig, context, taskDefinitionRegister);
|
|
1333
|
+
return {
|
|
1334
|
+
validationStatus: this.problemReporter.status,
|
|
1335
|
+
custom: taskParseResult.custom,
|
|
1336
|
+
configured: taskParseResult.configured,
|
|
1337
|
+
engine,
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
createTaskRunnerConfiguration(fileConfig, context, taskDefinitionRegister) {
|
|
1341
|
+
const globals = Globals.from(fileConfig, context);
|
|
1342
|
+
if (this.problemReporter.status.isFatal()) {
|
|
1343
|
+
return { custom: [], configured: [] };
|
|
1344
|
+
}
|
|
1345
|
+
context.namedProblemMatchers = ProblemMatcherConverter.namedFrom(fileConfig.declares, context);
|
|
1346
|
+
let globalTasks;
|
|
1347
|
+
let externalGlobalTasks;
|
|
1348
|
+
if (fileConfig.windows && context.platform === 3 /* Windows */) {
|
|
1349
|
+
globalTasks = TaskParser.from(fileConfig.windows.tasks, globals, context, taskDefinitionRegister).custom;
|
|
1350
|
+
externalGlobalTasks = fileConfig.windows.tasks;
|
|
1351
|
+
}
|
|
1352
|
+
else if (fileConfig.osx && context.platform === 1 /* Mac */) {
|
|
1353
|
+
globalTasks = TaskParser.from(fileConfig.osx.tasks, globals, context, taskDefinitionRegister).custom;
|
|
1354
|
+
externalGlobalTasks = fileConfig.osx.tasks;
|
|
1355
|
+
}
|
|
1356
|
+
else if (fileConfig.linux && context.platform === 2 /* Linux */) {
|
|
1357
|
+
globalTasks = TaskParser.from(fileConfig.linux.tasks, globals, context, taskDefinitionRegister).custom;
|
|
1358
|
+
externalGlobalTasks = fileConfig.linux.tasks;
|
|
1359
|
+
}
|
|
1360
|
+
if (context.schemaVersion === 2 /* V2_0_0 */ && globalTasks && globalTasks.length > 0 && externalGlobalTasks && externalGlobalTasks.length > 0) {
|
|
1361
|
+
const taskContent = [];
|
|
1362
|
+
for (const task of externalGlobalTasks) {
|
|
1363
|
+
taskContent.push(JSON.stringify(task, null, 4));
|
|
1364
|
+
}
|
|
1365
|
+
context.problemReporter.error((0, ide_core_common_1.formatLocalize)('TaskParse.noOsSpecificGlobalTasks', 'Task version 2.0.0 doesn\'t support global OS specific Convert them to a task with a OS specific command. Affected tasks are:\n{0}', taskContent.join('\n')));
|
|
1366
|
+
}
|
|
1367
|
+
let result = { custom: [], configured: [] };
|
|
1368
|
+
if (fileConfig.tasks) {
|
|
1369
|
+
result = TaskParser.from(fileConfig.tasks, globals, context, taskDefinitionRegister);
|
|
1370
|
+
}
|
|
1371
|
+
if (globalTasks) {
|
|
1372
|
+
result.custom = TaskParser.assignTasks(result.custom, globalTasks);
|
|
1373
|
+
}
|
|
1374
|
+
if ((!result.custom || result.custom.length === 0) && (globals.command && globals.command.name)) {
|
|
1375
|
+
const matchers = ProblemMatcherConverter.from(fileConfig.problemMatcher, context);
|
|
1376
|
+
const isBackground = fileConfig.isBackground ? !!fileConfig.isBackground : fileConfig.isWatching ? !!fileConfig.isWatching : undefined;
|
|
1377
|
+
const name = TaskTypes.CommandString.value(globals.command.name);
|
|
1378
|
+
const task = new TaskTypes.CustomTask(context.uuidMap.getUUID(name), Object.assign({}, source, { config: { index: -1, element: fileConfig, workspaceFolder: context.workspaceFolder } }), name, TaskTypes.CUSTOMIZED_TASK_TYPE, {
|
|
1379
|
+
name: undefined,
|
|
1380
|
+
runtime: undefined,
|
|
1381
|
+
presentation: undefined,
|
|
1382
|
+
suppressTaskName: true,
|
|
1383
|
+
}, false, { reevaluateOnRerun: true }, {
|
|
1384
|
+
name,
|
|
1385
|
+
identifier: name,
|
|
1386
|
+
group: TaskTypes.TaskGroup.Build,
|
|
1387
|
+
isBackground,
|
|
1388
|
+
problemMatchers: matchers,
|
|
1389
|
+
});
|
|
1390
|
+
const value = GroupKind.from(fileConfig.group);
|
|
1391
|
+
if (value) {
|
|
1392
|
+
task.configurationProperties.group = value[0];
|
|
1393
|
+
task.configurationProperties.groupType = value[1];
|
|
1394
|
+
}
|
|
1395
|
+
else if (fileConfig.group === 'none') {
|
|
1396
|
+
task.configurationProperties.group = undefined;
|
|
1397
|
+
}
|
|
1398
|
+
CustomTask.fillGlobals(task, globals);
|
|
1399
|
+
CustomTask.fillDefaults(task, context);
|
|
1400
|
+
result.custom = [task];
|
|
1401
|
+
}
|
|
1402
|
+
result.custom = result.custom || [];
|
|
1403
|
+
result.configured = result.configured || [];
|
|
1404
|
+
return result;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
const uuidMaps = new Map();
|
|
1408
|
+
function parse(workspaceFolder, platform, configuration, logger, taskDefinitionRegister, problemMatcherRegister, problemPatternRegister) {
|
|
1409
|
+
let uuidMap = uuidMaps.get(workspaceFolder.uri.toString());
|
|
1410
|
+
if (!uuidMap) {
|
|
1411
|
+
uuidMap = new UUIDMap();
|
|
1412
|
+
uuidMaps.set(workspaceFolder.uri.toString(), uuidMap);
|
|
1413
|
+
}
|
|
1414
|
+
try {
|
|
1415
|
+
uuidMap.start();
|
|
1416
|
+
return (new ConfigurationParser(workspaceFolder, platform, logger, uuidMap, taskDefinitionRegister.createTaskIdentifier, problemMatcherRegister.get, problemPatternRegister.get)).run(configuration, taskDefinitionRegister);
|
|
1417
|
+
}
|
|
1418
|
+
finally {
|
|
1419
|
+
uuidMap.finish();
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
exports.parse = parse;
|
|
1423
|
+
function createCustomTask(contributedTask, configuredProps) {
|
|
1424
|
+
return CustomTask.createCustomTask(contributedTask, configuredProps);
|
|
1425
|
+
}
|
|
1426
|
+
exports.createCustomTask = createCustomTask;
|
|
1427
|
+
//# sourceMappingURL=task-config.js.map
|