@codingame/monaco-vscode-api 1.78.4-next.3 → 1.78.4
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/dist/monaco.d.ts +11 -11
- package/dist/services.d.ts +1 -1
- package/package.json +1 -1
- package/dist/contributions.js +0 -110
- package/dist/extHost.js +0 -19602
- package/dist/extensions2.js +0 -77
- package/dist/layout.js +0 -41
- package/dist/layoutService.js +0 -12
- package/dist/missing-services.js +0 -34881
- package/dist/textEditor.js +0 -34
- package/dist/variableResolver.js +0 -586
package/dist/textEditor.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ACTIVE_GROUP, SIDE_GROUP, preferredSideBySideGroupDirection } from './missing-services.js';
|
|
2
|
-
var EditorActivation;
|
|
3
|
-
( (function(EditorActivation) {
|
|
4
|
-
EditorActivation[EditorActivation["ACTIVATE"] = 1] = "ACTIVATE";
|
|
5
|
-
EditorActivation[EditorActivation["RESTORE"] = 2] = "RESTORE";
|
|
6
|
-
EditorActivation[EditorActivation["PRESERVE"] = 3] = "PRESERVE";
|
|
7
|
-
})(EditorActivation || (EditorActivation = {})));
|
|
8
|
-
var EditorResolution;
|
|
9
|
-
( (function(EditorResolution) {
|
|
10
|
-
EditorResolution[EditorResolution["PICK"] = 0] = "PICK";
|
|
11
|
-
EditorResolution[EditorResolution["EXCLUSIVE_ONLY"] = 1] = "EXCLUSIVE_ONLY";
|
|
12
|
-
})(EditorResolution || (EditorResolution = {})));
|
|
13
|
-
function columnToEditorGroup(editorGroupService, configurationService, column = ACTIVE_GROUP) {
|
|
14
|
-
if (column === ACTIVE_GROUP || column === SIDE_GROUP) {
|
|
15
|
-
return column;
|
|
16
|
-
}
|
|
17
|
-
let groupInColumn = editorGroupService.getGroups(2 )[column];
|
|
18
|
-
if (!groupInColumn && column < 9) {
|
|
19
|
-
for (let i = 0; i <= column; i++) {
|
|
20
|
-
const editorGroups = editorGroupService.getGroups(2 );
|
|
21
|
-
if (!editorGroups[i]) {
|
|
22
|
-
editorGroupService.addGroup(editorGroups[i - 1], preferredSideBySideGroupDirection(configurationService));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
groupInColumn = editorGroupService.getGroups(2 )[column];
|
|
26
|
-
}
|
|
27
|
-
return groupInColumn?.id ?? SIDE_GROUP;
|
|
28
|
-
}
|
|
29
|
-
function editorGroupToColumn(editorGroupService, editorGroup) {
|
|
30
|
-
const group = (typeof editorGroup === 'number') ? editorGroupService.getGroup(editorGroup) : editorGroup;
|
|
31
|
-
return editorGroupService.getGroups(2 ).indexOf(group ?? editorGroupService.activeGroup);
|
|
32
|
-
}
|
|
33
|
-
class AbstractTextEditor {}
|
|
34
|
-
export { AbstractTextEditor, EditorActivation, EditorResolution, columnToEditorGroup, editorGroupToColumn };
|
package/dist/variableResolver.js
DELETED
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
import { Range$1, replaceAsync, VariableKind, VariableError, isAbsolute } from './missing-services.js';
|
|
2
|
-
import { equalsIgnoreCase } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
3
|
-
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
4
|
-
import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
5
|
-
import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
6
|
-
import { deepClone } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
7
|
-
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
8
|
-
import { isWindows, isMacintosh, isLinux } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
9
|
-
import { isString, isObject, isUndefinedOrNull } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
10
|
-
import { sep, basename, dirname, extname, relative } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
11
|
-
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
12
|
-
import { normalizeDriveLetter } from 'monaco-editor/esm/vs/base/common/labels.js';
|
|
13
|
-
import { cwd } from 'monaco-editor/esm/vs/base/common/process.js';
|
|
14
|
-
const _formatPIIRegexp = /{([^}]+)}/g;
|
|
15
|
-
function formatPII(value, excludePII, args) {
|
|
16
|
-
return value.replace(_formatPIIRegexp, function (match, group) {
|
|
17
|
-
if (excludePII && group.length > 0 && group[0] !== '_') {
|
|
18
|
-
return match;
|
|
19
|
-
}
|
|
20
|
-
return args && args.hasOwnProperty(group) ?
|
|
21
|
-
args[group] :
|
|
22
|
-
match;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function filterExceptionsFromTelemetry(data) {
|
|
26
|
-
const output = {};
|
|
27
|
-
for (const key of ( (Object.keys(data)))) {
|
|
28
|
-
if (!key.startsWith('!')) {
|
|
29
|
-
output[key] = data[key];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return output;
|
|
33
|
-
}
|
|
34
|
-
function isSessionAttach(session) {
|
|
35
|
-
return session.configuration.request === 'attach' && !getExtensionHostDebugSession(session) && (!session.parentSession || isSessionAttach(session.parentSession));
|
|
36
|
-
}
|
|
37
|
-
function getExtensionHostDebugSession(session) {
|
|
38
|
-
let type = session.configuration.type;
|
|
39
|
-
if (!type) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (type === 'vslsShare') {
|
|
43
|
-
type = session.configuration.adapterProxy.configuration.type;
|
|
44
|
-
}
|
|
45
|
-
if (equalsIgnoreCase(type, 'extensionhost') || equalsIgnoreCase(type, 'pwa-extensionhost')) {
|
|
46
|
-
return session;
|
|
47
|
-
}
|
|
48
|
-
return session.parentSession ? getExtensionHostDebugSession(session.parentSession) : undefined;
|
|
49
|
-
}
|
|
50
|
-
function isDebuggerMainContribution(dbg) {
|
|
51
|
-
return dbg.type && (dbg.label || dbg.program || dbg.runtime);
|
|
52
|
-
}
|
|
53
|
-
function getExactExpressionStartAndEnd(lineContent, looseStart, looseEnd) {
|
|
54
|
-
let matchingExpression = undefined;
|
|
55
|
-
let startOffset = 0;
|
|
56
|
-
const expression = /([^()\[\]{}<>\s+\-/%~#^;=|,`!]|\->)+/g;
|
|
57
|
-
let result = null;
|
|
58
|
-
while (result = expression.exec(lineContent)) {
|
|
59
|
-
const start = result.index + 1;
|
|
60
|
-
const end = start + result[0].length;
|
|
61
|
-
if (start <= looseStart && end >= looseEnd) {
|
|
62
|
-
matchingExpression = result[0];
|
|
63
|
-
startOffset = start;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (matchingExpression) {
|
|
68
|
-
const subExpression = /\w+/g;
|
|
69
|
-
let subExpressionResult = null;
|
|
70
|
-
while (subExpressionResult = subExpression.exec(matchingExpression)) {
|
|
71
|
-
const subEnd = subExpressionResult.index + 1 + startOffset + subExpressionResult[0].length;
|
|
72
|
-
if (subEnd >= looseEnd) {
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (subExpressionResult) {
|
|
77
|
-
matchingExpression = matchingExpression.substring(0, subExpression.lastIndex);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return matchingExpression ?
|
|
81
|
-
{ start: startOffset, end: startOffset + matchingExpression.length - 1 } :
|
|
82
|
-
{ start: 0, end: 0 };
|
|
83
|
-
}
|
|
84
|
-
async function getEvaluatableExpressionAtPosition(languageFeaturesService, model, position, token) {
|
|
85
|
-
if (languageFeaturesService.evaluatableExpressionProvider.has(model)) {
|
|
86
|
-
const supports = languageFeaturesService.evaluatableExpressionProvider.ordered(model);
|
|
87
|
-
const results = coalesce(await Promise.all(( (supports.map(async (support) => {
|
|
88
|
-
try {
|
|
89
|
-
return await support.provideEvaluatableExpression(model, position, token ?? CancellationToken.None);
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
})))));
|
|
95
|
-
if (results.length > 0) {
|
|
96
|
-
let matchingExpression = results[0].expression;
|
|
97
|
-
const range = results[0].range;
|
|
98
|
-
if (!matchingExpression) {
|
|
99
|
-
const lineContent = model.getLineContent(position.lineNumber);
|
|
100
|
-
matchingExpression = lineContent.substring(range.startColumn - 1, range.endColumn - 1);
|
|
101
|
-
}
|
|
102
|
-
return { range, matchingExpression };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
const lineContent = model.getLineContent(position.lineNumber);
|
|
107
|
-
const { start, end } = getExactExpressionStartAndEnd(lineContent, position.column, position.column);
|
|
108
|
-
const matchingExpression = lineContent.substring(start - 1, end);
|
|
109
|
-
return {
|
|
110
|
-
matchingExpression,
|
|
111
|
-
range: ( (new Range$1(
|
|
112
|
-
position.lineNumber,
|
|
113
|
-
start,
|
|
114
|
-
position.lineNumber,
|
|
115
|
-
start + matchingExpression.length
|
|
116
|
-
)))
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
const _schemePattern = /^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/;
|
|
122
|
-
function isUri(s) {
|
|
123
|
-
return !!(s && s.match(_schemePattern));
|
|
124
|
-
}
|
|
125
|
-
function stringToUri(source) {
|
|
126
|
-
if (typeof source.path === 'string') {
|
|
127
|
-
if (typeof source.sourceReference === 'number' && source.sourceReference > 0) ;
|
|
128
|
-
else {
|
|
129
|
-
if (isUri(source.path)) {
|
|
130
|
-
return ( URI.parse(source.path));
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
if (isAbsolute(source.path)) {
|
|
134
|
-
return URI.file(source.path);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return source.path;
|
|
140
|
-
}
|
|
141
|
-
function uriToString(source) {
|
|
142
|
-
if (typeof source.path === 'object') {
|
|
143
|
-
const u = URI.revive(source.path);
|
|
144
|
-
if (u) {
|
|
145
|
-
if (u.scheme === Schemas.file) {
|
|
146
|
-
return u.fsPath;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
return (
|
|
150
|
-
(u.toString())
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return source.path;
|
|
156
|
-
}
|
|
157
|
-
function convertToDAPaths(message, toUri) {
|
|
158
|
-
const fixPath = toUri ? stringToUri : uriToString;
|
|
159
|
-
const msg = deepClone(message);
|
|
160
|
-
convertPaths(msg, (toDA, source) => {
|
|
161
|
-
if (toDA && source) {
|
|
162
|
-
source.path = fixPath(source);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return msg;
|
|
166
|
-
}
|
|
167
|
-
function convertToVSCPaths(message, toUri) {
|
|
168
|
-
const fixPath = toUri ? stringToUri : uriToString;
|
|
169
|
-
const msg = deepClone(message);
|
|
170
|
-
convertPaths(msg, (toDA, source) => {
|
|
171
|
-
if (!toDA && source) {
|
|
172
|
-
source.path = fixPath(source);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
return msg;
|
|
176
|
-
}
|
|
177
|
-
function convertPaths(msg, fixSourcePath) {
|
|
178
|
-
switch (msg.type) {
|
|
179
|
-
case 'event': {
|
|
180
|
-
const event = msg;
|
|
181
|
-
switch (event.event) {
|
|
182
|
-
case 'output':
|
|
183
|
-
fixSourcePath(false, event.body.source);
|
|
184
|
-
break;
|
|
185
|
-
case 'loadedSource':
|
|
186
|
-
fixSourcePath(false, event.body.source);
|
|
187
|
-
break;
|
|
188
|
-
case 'breakpoint':
|
|
189
|
-
fixSourcePath(false, event.body.breakpoint.source);
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
case 'request': {
|
|
195
|
-
const request = msg;
|
|
196
|
-
switch (request.command) {
|
|
197
|
-
case 'setBreakpoints':
|
|
198
|
-
fixSourcePath(true, request.arguments.source);
|
|
199
|
-
break;
|
|
200
|
-
case 'breakpointLocations':
|
|
201
|
-
fixSourcePath(true, request.arguments.source);
|
|
202
|
-
break;
|
|
203
|
-
case 'source':
|
|
204
|
-
fixSourcePath(true, request.arguments.source);
|
|
205
|
-
break;
|
|
206
|
-
case 'gotoTargets':
|
|
207
|
-
fixSourcePath(true, request.arguments.source);
|
|
208
|
-
break;
|
|
209
|
-
case 'launchVSCode':
|
|
210
|
-
request.arguments.args.forEach((arg) => fixSourcePath(false, arg));
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
case 'response': {
|
|
216
|
-
const response = msg;
|
|
217
|
-
if (response.success && response.body) {
|
|
218
|
-
switch (response.command) {
|
|
219
|
-
case 'stackTrace':
|
|
220
|
-
response.body.stackFrames.forEach(frame => fixSourcePath(false, frame.source));
|
|
221
|
-
break;
|
|
222
|
-
case 'loadedSources':
|
|
223
|
-
response.body.sources.forEach(source => fixSourcePath(false, source));
|
|
224
|
-
break;
|
|
225
|
-
case 'scopes':
|
|
226
|
-
response.body.scopes.forEach(scope => fixSourcePath(false, scope.source));
|
|
227
|
-
break;
|
|
228
|
-
case 'setFunctionBreakpoints':
|
|
229
|
-
response.body.breakpoints.forEach(bp => fixSourcePath(false, bp.source));
|
|
230
|
-
break;
|
|
231
|
-
case 'setBreakpoints':
|
|
232
|
-
response.body.breakpoints.forEach(bp => fixSourcePath(false, bp.source));
|
|
233
|
-
break;
|
|
234
|
-
case 'disassemble':
|
|
235
|
-
{
|
|
236
|
-
const di = response;
|
|
237
|
-
di.body?.instructions.forEach(di => fixSourcePath(false, di.location));
|
|
238
|
-
}
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function getVisibleAndSorted(array) {
|
|
247
|
-
return array.filter(config => !config.presentation?.hidden).sort((first, second) => {
|
|
248
|
-
if (!first.presentation) {
|
|
249
|
-
if (!second.presentation) {
|
|
250
|
-
return 0;
|
|
251
|
-
}
|
|
252
|
-
return 1;
|
|
253
|
-
}
|
|
254
|
-
if (!second.presentation) {
|
|
255
|
-
return -1;
|
|
256
|
-
}
|
|
257
|
-
if (!first.presentation.group) {
|
|
258
|
-
if (!second.presentation.group) {
|
|
259
|
-
return compareOrders(first.presentation.order, second.presentation.order);
|
|
260
|
-
}
|
|
261
|
-
return 1;
|
|
262
|
-
}
|
|
263
|
-
if (!second.presentation.group) {
|
|
264
|
-
return -1;
|
|
265
|
-
}
|
|
266
|
-
if (first.presentation.group !== second.presentation.group) {
|
|
267
|
-
return first.presentation.group.localeCompare(second.presentation.group);
|
|
268
|
-
}
|
|
269
|
-
return compareOrders(first.presentation.order, second.presentation.order);
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
function compareOrders(first, second) {
|
|
273
|
-
if (typeof first !== 'number') {
|
|
274
|
-
if (typeof second !== 'number') {
|
|
275
|
-
return 0;
|
|
276
|
-
}
|
|
277
|
-
return 1;
|
|
278
|
-
}
|
|
279
|
-
if (typeof second !== 'number') {
|
|
280
|
-
return -1;
|
|
281
|
-
}
|
|
282
|
-
return first - second;
|
|
283
|
-
}
|
|
284
|
-
async function saveAllBeforeDebugStart(configurationService, editorService) {
|
|
285
|
-
const saveBeforeStartConfig = configurationService.getValue('debug.saveBeforeStart', { overrideIdentifier: editorService.activeTextEditorLanguageId });
|
|
286
|
-
if (saveBeforeStartConfig !== 'none') {
|
|
287
|
-
await editorService.saveAll();
|
|
288
|
-
if (saveBeforeStartConfig === 'allEditorsInActiveGroup') {
|
|
289
|
-
const activeEditor = editorService.activeEditorPane;
|
|
290
|
-
if (activeEditor && activeEditor.input.resource?.scheme === Schemas.untitled) {
|
|
291
|
-
await editorService.save({ editor: activeEditor.input, groupId: activeEditor.group.id });
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
await configurationService.reloadConfiguration();
|
|
296
|
-
}
|
|
297
|
-
class AbstractVariableResolverService {
|
|
298
|
-
constructor(_context, _labelService, _userHomePromise, _envVariablesPromise) {
|
|
299
|
-
this._contributedVariables = ( (new Map()));
|
|
300
|
-
this._context = _context;
|
|
301
|
-
this._labelService = _labelService;
|
|
302
|
-
this._userHomePromise = _userHomePromise;
|
|
303
|
-
if (_envVariablesPromise) {
|
|
304
|
-
this._envVariablesPromise = _envVariablesPromise.then(envVariables => {
|
|
305
|
-
return this.prepareEnv(envVariables);
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
prepareEnv(envVariables) {
|
|
310
|
-
if (isWindows) {
|
|
311
|
-
const ev = Object.create(null);
|
|
312
|
-
( (Object.keys(envVariables))).forEach(key => {
|
|
313
|
-
ev[key.toLowerCase()] = envVariables[key];
|
|
314
|
-
});
|
|
315
|
-
return ev;
|
|
316
|
-
}
|
|
317
|
-
return envVariables;
|
|
318
|
-
}
|
|
319
|
-
resolveWithEnvironment(environment, root, value) {
|
|
320
|
-
return this.recursiveResolve({ env: this.prepareEnv(environment), userHome: undefined }, root ? root.uri : undefined, value);
|
|
321
|
-
}
|
|
322
|
-
async resolveAsync(root, value) {
|
|
323
|
-
const environment = {
|
|
324
|
-
env: await this._envVariablesPromise,
|
|
325
|
-
userHome: await this._userHomePromise
|
|
326
|
-
};
|
|
327
|
-
return this.recursiveResolve(environment, root ? root.uri : undefined, value);
|
|
328
|
-
}
|
|
329
|
-
async resolveAnyBase(workspaceFolder, config, commandValueMapping, resolvedVariables) {
|
|
330
|
-
const result = deepClone(config);
|
|
331
|
-
if (isWindows && result.windows) {
|
|
332
|
-
( (Object.keys(result.windows))).forEach(key => result[key] = result.windows[key]);
|
|
333
|
-
}
|
|
334
|
-
else if (isMacintosh && result.osx) {
|
|
335
|
-
( (Object.keys(result.osx))).forEach(key => result[key] = result.osx[key]);
|
|
336
|
-
}
|
|
337
|
-
else if (isLinux && result.linux) {
|
|
338
|
-
( (Object.keys(result.linux))).forEach(key => result[key] = result.linux[key]);
|
|
339
|
-
}
|
|
340
|
-
delete result.windows;
|
|
341
|
-
delete result.osx;
|
|
342
|
-
delete result.linux;
|
|
343
|
-
const environmentPromises = {
|
|
344
|
-
env: await this._envVariablesPromise,
|
|
345
|
-
userHome: await this._userHomePromise
|
|
346
|
-
};
|
|
347
|
-
return this.recursiveResolve(environmentPromises, workspaceFolder ? workspaceFolder.uri : undefined, result, commandValueMapping, resolvedVariables);
|
|
348
|
-
}
|
|
349
|
-
async resolveAnyAsync(workspaceFolder, config, commandValueMapping) {
|
|
350
|
-
return this.resolveAnyBase(workspaceFolder, config, commandValueMapping);
|
|
351
|
-
}
|
|
352
|
-
async resolveAnyMap(workspaceFolder, config, commandValueMapping) {
|
|
353
|
-
const resolvedVariables = ( (new Map()));
|
|
354
|
-
const newConfig = await this.resolveAnyBase(workspaceFolder, config, commandValueMapping, resolvedVariables);
|
|
355
|
-
return { newConfig, resolvedVariables };
|
|
356
|
-
}
|
|
357
|
-
resolveWithInteractionReplace(folder, config, section, variables) {
|
|
358
|
-
throw new Error('resolveWithInteractionReplace not implemented.');
|
|
359
|
-
}
|
|
360
|
-
resolveWithInteraction(folder, config, section, variables) {
|
|
361
|
-
throw new Error('resolveWithInteraction not implemented.');
|
|
362
|
-
}
|
|
363
|
-
contributeVariable(variable, resolution) {
|
|
364
|
-
if (this._contributedVariables.has(variable)) {
|
|
365
|
-
throw new Error('Variable ' + variable + ' is contributed twice.');
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
this._contributedVariables.set(variable, resolution);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
async recursiveResolve(environment, folderUri, value, commandValueMapping, resolvedVariables) {
|
|
372
|
-
if (isString(value)) {
|
|
373
|
-
return this.resolveString(environment, folderUri, value, commandValueMapping, resolvedVariables);
|
|
374
|
-
}
|
|
375
|
-
else if (Array.isArray(value)) {
|
|
376
|
-
return Promise.all(( (value.map(
|
|
377
|
-
s => this.recursiveResolve(environment, folderUri, s, commandValueMapping, resolvedVariables)
|
|
378
|
-
))));
|
|
379
|
-
}
|
|
380
|
-
else if (isObject(value)) {
|
|
381
|
-
const result = Object.create(null);
|
|
382
|
-
const replaced = await Promise.all(( (( (Object.keys(value))).map(async (key) => {
|
|
383
|
-
const replaced = await this.resolveString(environment, folderUri, key, commandValueMapping, resolvedVariables);
|
|
384
|
-
return [replaced, await this.recursiveResolve(environment, folderUri, value[key], commandValueMapping, resolvedVariables)];
|
|
385
|
-
}))));
|
|
386
|
-
for (const [key, value] of replaced) {
|
|
387
|
-
result[key] = value;
|
|
388
|
-
}
|
|
389
|
-
return result;
|
|
390
|
-
}
|
|
391
|
-
return value;
|
|
392
|
-
}
|
|
393
|
-
resolveString(environment, folderUri, value, commandValueMapping, resolvedVariables) {
|
|
394
|
-
return replaceAsync(value, AbstractVariableResolverService.VARIABLE_REGEXP, async (match, variable) => {
|
|
395
|
-
if (variable.includes(AbstractVariableResolverService.VARIABLE_LHS)) {
|
|
396
|
-
return match;
|
|
397
|
-
}
|
|
398
|
-
let resolvedValue = await this.evaluateSingleVariable(environment, match, variable, folderUri, commandValueMapping);
|
|
399
|
-
resolvedVariables?.set(variable, resolvedValue);
|
|
400
|
-
if ((resolvedValue !== match) && isString(resolvedValue) && resolvedValue.match(AbstractVariableResolverService.VARIABLE_REGEXP)) {
|
|
401
|
-
resolvedValue = await this.resolveString(environment, folderUri, resolvedValue, commandValueMapping, resolvedVariables);
|
|
402
|
-
}
|
|
403
|
-
return resolvedValue;
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
fsPath(displayUri) {
|
|
407
|
-
return this._labelService ? this._labelService.getUriLabel(displayUri, { noPrefix: true }) : displayUri.fsPath;
|
|
408
|
-
}
|
|
409
|
-
async evaluateSingleVariable(environment, match, variable, folderUri, commandValueMapping) {
|
|
410
|
-
let argument;
|
|
411
|
-
const parts = variable.split(':');
|
|
412
|
-
if (parts.length > 1) {
|
|
413
|
-
variable = parts[0];
|
|
414
|
-
argument = parts[1];
|
|
415
|
-
}
|
|
416
|
-
const getFilePath = (variableKind) => {
|
|
417
|
-
const filePath = this._context.getFilePath();
|
|
418
|
-
if (filePath) {
|
|
419
|
-
return normalizeDriveLetter(filePath);
|
|
420
|
-
}
|
|
421
|
-
throw new VariableError(variableKind, (localize('canNotResolveFile', "Variable {0} can not be resolved. Please open an editor.", match)));
|
|
422
|
-
};
|
|
423
|
-
const getFolderPathForFile = (variableKind) => {
|
|
424
|
-
const filePath = getFilePath(variableKind);
|
|
425
|
-
if (this._context.getWorkspaceFolderPathForFile) {
|
|
426
|
-
const folderPath = this._context.getWorkspaceFolderPathForFile();
|
|
427
|
-
if (folderPath) {
|
|
428
|
-
return normalizeDriveLetter(folderPath);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
throw new VariableError(variableKind, localize('canNotResolveFolderForFile', "Variable {0}: can not find workspace folder of '{1}'.", match, basename(filePath)));
|
|
432
|
-
};
|
|
433
|
-
const getFolderUri = (variableKind) => {
|
|
434
|
-
if (argument) {
|
|
435
|
-
const folder = this._context.getFolderUri(argument);
|
|
436
|
-
if (folder) {
|
|
437
|
-
return folder;
|
|
438
|
-
}
|
|
439
|
-
throw new VariableError(variableKind, localize('canNotFindFolder', "Variable {0} can not be resolved. No such folder '{1}'.", match, argument));
|
|
440
|
-
}
|
|
441
|
-
if (folderUri) {
|
|
442
|
-
return folderUri;
|
|
443
|
-
}
|
|
444
|
-
if (this._context.getWorkspaceFolderCount() > 1) {
|
|
445
|
-
throw new VariableError(variableKind, localize('canNotResolveWorkspaceFolderMultiRoot', "Variable {0} can not be resolved in a multi folder workspace. Scope this variable using ':' and a workspace folder name.", match));
|
|
446
|
-
}
|
|
447
|
-
throw new VariableError(variableKind, localize('canNotResolveWorkspaceFolder', "Variable {0} can not be resolved. Please open a folder.", match));
|
|
448
|
-
};
|
|
449
|
-
switch (variable) {
|
|
450
|
-
case 'env':
|
|
451
|
-
if (argument) {
|
|
452
|
-
if (environment.env) {
|
|
453
|
-
const env = environment.env[isWindows ? argument.toLowerCase() : argument];
|
|
454
|
-
if (isString(env)) {
|
|
455
|
-
return env;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
return '';
|
|
459
|
-
}
|
|
460
|
-
throw new VariableError(VariableKind.Env, localize('missingEnvVarName', "Variable {0} can not be resolved because no environment variable name is given.", match));
|
|
461
|
-
case 'config':
|
|
462
|
-
if (argument) {
|
|
463
|
-
const config = this._context.getConfigurationValue(folderUri, argument);
|
|
464
|
-
if (isUndefinedOrNull(config)) {
|
|
465
|
-
throw new VariableError(VariableKind.Config, localize('configNotFound', "Variable {0} can not be resolved because setting '{1}' not found.", match, argument));
|
|
466
|
-
}
|
|
467
|
-
if (isObject(config)) {
|
|
468
|
-
throw new VariableError(VariableKind.Config, localize('configNoString', "Variable {0} can not be resolved because '{1}' is a structured value.", match, argument));
|
|
469
|
-
}
|
|
470
|
-
return config;
|
|
471
|
-
}
|
|
472
|
-
throw new VariableError(VariableKind.Config, localize('missingConfigName', "Variable {0} can not be resolved because no settings name is given.", match));
|
|
473
|
-
case 'command':
|
|
474
|
-
return this.resolveFromMap(VariableKind.Command, match, argument, commandValueMapping, 'command');
|
|
475
|
-
case 'input':
|
|
476
|
-
return this.resolveFromMap(VariableKind.Input, match, argument, commandValueMapping, 'input');
|
|
477
|
-
case 'extensionInstallFolder':
|
|
478
|
-
if (argument) {
|
|
479
|
-
const ext = await this._context.getExtension(argument);
|
|
480
|
-
if (!ext) {
|
|
481
|
-
throw new VariableError(VariableKind.ExtensionInstallFolder, localize('extensionNotInstalled', "Variable {0} can not be resolved because the extension {1} is not installed.", match, argument));
|
|
482
|
-
}
|
|
483
|
-
return this.fsPath(ext.extensionLocation);
|
|
484
|
-
}
|
|
485
|
-
throw new VariableError(VariableKind.ExtensionInstallFolder, localize('missingExtensionName', "Variable {0} can not be resolved because no extension name is given.", match));
|
|
486
|
-
default: {
|
|
487
|
-
switch (variable) {
|
|
488
|
-
case 'workspaceRoot':
|
|
489
|
-
case 'workspaceFolder':
|
|
490
|
-
return normalizeDriveLetter(this.fsPath(getFolderUri(VariableKind.WorkspaceFolder)));
|
|
491
|
-
case 'cwd':
|
|
492
|
-
return ((folderUri || argument) ? normalizeDriveLetter(this.fsPath(getFolderUri(VariableKind.Cwd))) : cwd());
|
|
493
|
-
case 'workspaceRootFolderName':
|
|
494
|
-
case 'workspaceFolderBasename':
|
|
495
|
-
return normalizeDriveLetter(basename(this.fsPath(getFolderUri(VariableKind.WorkspaceFolderBasename))));
|
|
496
|
-
case 'userHome': {
|
|
497
|
-
if (environment.userHome) {
|
|
498
|
-
return environment.userHome;
|
|
499
|
-
}
|
|
500
|
-
throw new VariableError(VariableKind.UserHome, localize('canNotResolveUserHome', "Variable {0} can not be resolved. UserHome path is not defined", match));
|
|
501
|
-
}
|
|
502
|
-
case 'lineNumber': {
|
|
503
|
-
const lineNumber = this._context.getLineNumber();
|
|
504
|
-
if (lineNumber) {
|
|
505
|
-
return lineNumber;
|
|
506
|
-
}
|
|
507
|
-
throw new VariableError(VariableKind.LineNumber, localize('canNotResolveLineNumber', "Variable {0} can not be resolved. Make sure to have a line selected in the active editor.", match));
|
|
508
|
-
}
|
|
509
|
-
case 'selectedText': {
|
|
510
|
-
const selectedText = this._context.getSelectedText();
|
|
511
|
-
if (selectedText) {
|
|
512
|
-
return selectedText;
|
|
513
|
-
}
|
|
514
|
-
throw new VariableError(VariableKind.SelectedText, localize('canNotResolveSelectedText', "Variable {0} can not be resolved. Make sure to have some text selected in the active editor.", match));
|
|
515
|
-
}
|
|
516
|
-
case 'file':
|
|
517
|
-
return getFilePath(VariableKind.File);
|
|
518
|
-
case 'fileWorkspaceFolder':
|
|
519
|
-
return getFolderPathForFile(VariableKind.FileWorkspaceFolder);
|
|
520
|
-
case 'relativeFile':
|
|
521
|
-
if (folderUri || argument) {
|
|
522
|
-
return relative(this.fsPath(getFolderUri(VariableKind.RelativeFile)), getFilePath(VariableKind.RelativeFile));
|
|
523
|
-
}
|
|
524
|
-
return getFilePath(VariableKind.RelativeFile);
|
|
525
|
-
case 'relativeFileDirname': {
|
|
526
|
-
const dirname$1 = dirname(getFilePath(VariableKind.RelativeFileDirname));
|
|
527
|
-
if (folderUri || argument) {
|
|
528
|
-
const relative$1 = relative(this.fsPath(getFolderUri(VariableKind.RelativeFileDirname)), dirname$1);
|
|
529
|
-
return relative$1.length === 0 ? '.' : relative$1;
|
|
530
|
-
}
|
|
531
|
-
return dirname$1;
|
|
532
|
-
}
|
|
533
|
-
case 'fileDirname':
|
|
534
|
-
return dirname(getFilePath(VariableKind.FileDirname));
|
|
535
|
-
case 'fileExtname':
|
|
536
|
-
return extname(getFilePath(VariableKind.FileExtname));
|
|
537
|
-
case 'fileBasename':
|
|
538
|
-
return basename(getFilePath(VariableKind.FileBasename));
|
|
539
|
-
case 'fileBasenameNoExtension': {
|
|
540
|
-
const basename$1 = basename(getFilePath(VariableKind.FileBasenameNoExtension));
|
|
541
|
-
return (basename$1.slice(0, basename$1.length - extname(basename$1).length));
|
|
542
|
-
}
|
|
543
|
-
case 'fileDirnameBasename':
|
|
544
|
-
return basename(dirname(getFilePath(VariableKind.FileDirnameBasename)));
|
|
545
|
-
case 'execPath': {
|
|
546
|
-
const ep = this._context.getExecPath();
|
|
547
|
-
if (ep) {
|
|
548
|
-
return ep;
|
|
549
|
-
}
|
|
550
|
-
return match;
|
|
551
|
-
}
|
|
552
|
-
case 'execInstallFolder': {
|
|
553
|
-
const ar = this._context.getAppRoot();
|
|
554
|
-
if (ar) {
|
|
555
|
-
return ar;
|
|
556
|
-
}
|
|
557
|
-
return match;
|
|
558
|
-
}
|
|
559
|
-
case 'pathSeparator':
|
|
560
|
-
return sep;
|
|
561
|
-
default:
|
|
562
|
-
try {
|
|
563
|
-
const key = argument ? `${variable}:${argument}` : variable;
|
|
564
|
-
return this.resolveFromMap(VariableKind.Unknown, match, key, commandValueMapping, undefined);
|
|
565
|
-
}
|
|
566
|
-
catch (error) {
|
|
567
|
-
return match;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
resolveFromMap(variableKind, match, argument, commandValueMapping, prefix) {
|
|
574
|
-
if (argument && commandValueMapping) {
|
|
575
|
-
const v = (prefix === undefined) ? commandValueMapping[argument] : commandValueMapping[prefix + ':' + argument];
|
|
576
|
-
if (typeof v === 'string') {
|
|
577
|
-
return v;
|
|
578
|
-
}
|
|
579
|
-
throw new VariableError(variableKind, localize('noValueForCommand', "Variable {0} can not be resolved because the command has no value.", match));
|
|
580
|
-
}
|
|
581
|
-
return match;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
AbstractVariableResolverService.VARIABLE_LHS = '${';
|
|
585
|
-
AbstractVariableResolverService.VARIABLE_REGEXP = /\$\{(.*?)\}/g;
|
|
586
|
-
export { AbstractVariableResolverService, convertToDAPaths, convertToVSCPaths, filterExceptionsFromTelemetry, formatPII, getEvaluatableExpressionAtPosition, getExtensionHostDebugSession, getVisibleAndSorted, isDebuggerMainContribution, isSessionAttach, isUri, saveAllBeforeDebugStart };
|