@codingame/monaco-vscode-api 1.78.3 → 1.78.4-next.1
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/api2.js +69 -4
- package/dist/coffeescript.js +2 -9
- package/dist/contributions.js +110 -0
- package/dist/cpp.js +2 -16
- package/dist/csharp.js +2 -9
- package/dist/default-extensions/bat.js +5 -8
- package/dist/default-extensions/clojure.js +4 -7
- package/dist/default-extensions/coffeescript.js +5 -8
- package/dist/default-extensions/cpp.js +10 -15
- package/dist/default-extensions/csharp.js +5 -8
- package/dist/default-extensions/css.js +4 -7
- package/dist/default-extensions/dart.js +4 -7
- package/dist/default-extensions/diff.js +4 -7
- package/dist/default-extensions/docker.js +4 -7
- package/dist/default-extensions/fsharp.js +5 -8
- package/dist/default-extensions/go.js +4 -7
- package/dist/default-extensions/groovy.js +5 -8
- package/dist/default-extensions/handlebars.js +4 -7
- package/dist/default-extensions/hlsl.js +4 -7
- package/dist/default-extensions/html.js +6 -9
- package/dist/default-extensions/ini.js +5 -9
- package/dist/default-extensions/java.js +5 -8
- package/dist/default-extensions/javascript.js +8 -13
- package/dist/default-extensions/json.js +5 -9
- package/dist/default-extensions/julia.js +4 -7
- package/dist/default-extensions/latex.js +10 -10
- package/dist/default-extensions/less.js +4 -7
- package/dist/default-extensions/log.js +3 -6
- package/dist/default-extensions/lua.js +4 -7
- package/dist/default-extensions/make.js +4 -7
- package/dist/default-extensions/markdown-basics.js +5 -8
- package/dist/default-extensions/objective-c.js +5 -9
- package/dist/default-extensions/perl.js +6 -9
- package/dist/default-extensions/php.js +6 -9
- package/dist/default-extensions/powershell.js +4 -7
- package/dist/default-extensions/pug.js +4 -7
- package/dist/default-extensions/python.js +5 -8
- package/dist/default-extensions/r.js +4 -7
- package/dist/default-extensions/razor.js +4 -7
- package/dist/default-extensions/ruby.js +4 -7
- package/dist/default-extensions/rust.js +4 -7
- package/dist/default-extensions/scss.js +5 -8
- package/dist/default-extensions/shaderlab.js +4 -7
- package/dist/default-extensions/shellscript.js +4 -7
- package/dist/default-extensions/sql.js +4 -7
- package/dist/default-extensions/swift.js +5 -8
- package/dist/default-extensions/theme-abyss.js +3 -6
- package/dist/default-extensions/theme-defaults.js +11 -14
- package/dist/default-extensions/theme-kimbie-dark.js +3 -6
- package/dist/default-extensions/theme-monokai-dimmed.js +3 -6
- package/dist/default-extensions/theme-monokai.js +3 -6
- package/dist/default-extensions/theme-quietlight.js +3 -6
- package/dist/default-extensions/theme-red.js +3 -6
- package/dist/default-extensions/theme-seti.js +3 -6
- package/dist/default-extensions/theme-solarized-dark.js +3 -6
- package/dist/default-extensions/theme-solarized-light.js +3 -6
- package/dist/default-extensions/theme-tomorrow-night-blue.js +3 -6
- package/dist/default-extensions/typescript-basics.js +8 -13
- package/dist/default-extensions/typescript-language-features.js +6 -0
- package/dist/default-extensions/vb.js +5 -8
- package/dist/default-extensions/xml.js +6 -9
- package/dist/default-extensions/yaml.js +4 -9
- package/dist/extHost.js +19602 -0
- package/dist/extension-tools-b2d018a3.js +1037 -0
- package/dist/extensions.d.ts +9 -2
- package/dist/extensions2.js +77 -0
- package/dist/fsharp.js +2 -9
- package/dist/groovy.js +2 -9
- package/dist/html.js +2 -10
- package/dist/java.js +2 -9
- package/dist/javascript.js +2 -14
- package/dist/keybindings.js +3 -180
- package/dist/latex-cpp-embedded-language-configuration.js +2 -0
- package/dist/latex-language-configuration.js +2 -0
- package/dist/layout.js +41 -0
- package/dist/layoutService.js +12 -0
- package/dist/markdown-latex-combined-language-configuration.js +2 -0
- package/dist/missing-services.js +34881 -0
- package/dist/modelEditor.d.ts +136 -1398
- package/dist/monaco.d.ts +20 -16
- package/dist/monaco.js +370 -44
- package/dist/php.js +2 -10
- package/dist/polyfill.js +29 -10
- package/dist/rollup-extension-directory-plugin.d.ts +10 -0
- package/dist/rollup-extension-directory-plugin.js +82 -0
- package/dist/rollup-vsix-plugin.d.ts +4 -2
- package/dist/rollup-vsix-plugin.js +35 -26
- package/dist/services.d.ts +1 -1
- package/dist/swift.js +2 -9
- package/dist/textEditor.js +34 -0
- package/dist/variableResolver.js +586 -0
- package/dist/vb.js +2 -9
- package/package.json +13 -6
- package/dist/bat.js +0 -9
- package/dist/clojure.js +0 -8
- package/dist/coffeescript2.js +0 -2
- package/dist/cpp2.js +0 -2
- package/dist/csharp2.js +0 -2
- package/dist/css.js +0 -8
- package/dist/dart.js +0 -8
- package/dist/diff.js +0 -8
- package/dist/docker.js +0 -8
- package/dist/fsharp2.js +0 -2
- package/dist/go.js +0 -8
- package/dist/groovy2.js +0 -2
- package/dist/handlebars.js +0 -8
- package/dist/hlsl.js +0 -8
- package/dist/html2.js +0 -2
- package/dist/ini.js +0 -10
- package/dist/java2.js +0 -2
- package/dist/javascript2.js +0 -2
- package/dist/json.js +0 -10
- package/dist/julia.js +0 -8
- package/dist/latex.js +0 -11
- package/dist/less.js +0 -8
- package/dist/log.js +0 -7
- package/dist/lua.js +0 -8
- package/dist/make.js +0 -8
- package/dist/markdown-basics.js +0 -9
- package/dist/objective-c.js +0 -10
- package/dist/perl.js +0 -10
- package/dist/php2.js +0 -2
- package/dist/powershell.js +0 -8
- package/dist/pug.js +0 -8
- package/dist/python.js +0 -9
- package/dist/r.js +0 -8
- package/dist/razor.js +0 -8
- package/dist/ruby.js +0 -8
- package/dist/rust.js +0 -8
- package/dist/scss.js +0 -9
- package/dist/shaderlab.js +0 -8
- package/dist/shellscript.js +0 -8
- package/dist/sql.js +0 -8
- package/dist/swift2.js +0 -2
- package/dist/theme-abyss.js +0 -7
- package/dist/theme-defaults.js +0 -15
- package/dist/theme-kimbie-dark.js +0 -7
- package/dist/theme-monokai-dimmed.js +0 -7
- package/dist/theme-monokai.js +0 -7
- package/dist/theme-quietlight.js +0 -7
- package/dist/theme-red.js +0 -7
- package/dist/theme-seti.js +0 -7
- package/dist/theme-solarized-dark.js +0 -7
- package/dist/theme-solarized-light.js +0 -7
- package/dist/theme-tomorrow-night-blue.js +0 -7
- package/dist/typescript-basics.js +0 -14
- package/dist/vb2.js +0 -2
- package/dist/xml.js +0 -10
- package/dist/yaml.js +0 -10
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* @returns whether the provided parameter is a JavaScript String or not.
|
|
7
|
+
*/
|
|
8
|
+
function isString(str) {
|
|
9
|
+
return (typeof str === 'string');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @returns whether the provided parameter is of type `object` but **not**
|
|
13
|
+
* `null`, an `array`, a `regexp`, nor a `date`.
|
|
14
|
+
*/
|
|
15
|
+
function isObject(obj) {
|
|
16
|
+
// The method can't do a type cast since there are type (like strings) which
|
|
17
|
+
// are subclasses of any put not positvely matched by the function. Hence type
|
|
18
|
+
// narrowing results in wrong results.
|
|
19
|
+
return typeof obj === 'object'
|
|
20
|
+
&& obj !== null
|
|
21
|
+
&& !Array.isArray(obj)
|
|
22
|
+
&& !(obj instanceof RegExp)
|
|
23
|
+
&& !(obj instanceof Date);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*---------------------------------------------------------------------------------------------
|
|
27
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
28
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
29
|
+
*--------------------------------------------------------------------------------------------*/
|
|
30
|
+
let isPseudo = (typeof document !== 'undefined' && document.location && document.location.hash.indexOf('pseudo=true') >= 0);
|
|
31
|
+
function _format(message, args) {
|
|
32
|
+
let result;
|
|
33
|
+
if (args.length === 0) {
|
|
34
|
+
result = message;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result = message.replace(/\{(\d+)\}/g, (match, rest) => {
|
|
38
|
+
const index = rest[0];
|
|
39
|
+
const arg = args[index];
|
|
40
|
+
let result = match;
|
|
41
|
+
if (typeof arg === 'string') {
|
|
42
|
+
result = arg;
|
|
43
|
+
}
|
|
44
|
+
else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {
|
|
45
|
+
result = String(arg);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (isPseudo) {
|
|
51
|
+
// FF3B and FF3D is the Unicode zenkaku representation for [ and ]
|
|
52
|
+
result = '\uFF3B' + result.replace(/[aouei]/g, '$&$&') + '\uFF3D';
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function localize(data, message, ...args) {
|
|
57
|
+
return _format(message, args);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*---------------------------------------------------------------------------------------------
|
|
61
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
62
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
63
|
+
*--------------------------------------------------------------------------------------------*/
|
|
64
|
+
function localizeManifest(extensionManifest, translations, fallbackTranslations) {
|
|
65
|
+
try {
|
|
66
|
+
replaceNLStrings(extensionManifest, translations, fallbackTranslations);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error(error?.message ?? error);
|
|
70
|
+
/*Ignore Error*/
|
|
71
|
+
}
|
|
72
|
+
return extensionManifest;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* This routine makes the following assumptions:
|
|
76
|
+
* The root element is an object literal
|
|
77
|
+
*/
|
|
78
|
+
function replaceNLStrings(extensionManifest, messages, originalMessages) {
|
|
79
|
+
const processEntry = (obj, key, command) => {
|
|
80
|
+
const value = obj[key];
|
|
81
|
+
if (isString(value)) {
|
|
82
|
+
const str = value;
|
|
83
|
+
const length = str.length;
|
|
84
|
+
if (length > 1 && str[0] === '%' && str[length - 1] === '%') {
|
|
85
|
+
const messageKey = str.substr(1, length - 2);
|
|
86
|
+
let translated = messages[messageKey];
|
|
87
|
+
// If the messages come from a language pack they might miss some keys
|
|
88
|
+
// Fill them from the original messages.
|
|
89
|
+
if (translated === undefined && originalMessages) {
|
|
90
|
+
translated = originalMessages[messageKey];
|
|
91
|
+
}
|
|
92
|
+
const message = typeof translated === 'string' ? translated : translated?.message;
|
|
93
|
+
// This branch returns ILocalizedString's instead of Strings so that the Command Palette can contain both the localized and the original value.
|
|
94
|
+
const original = originalMessages?.[messageKey];
|
|
95
|
+
const originalMessage = typeof original === 'string' ? original : original?.message;
|
|
96
|
+
if (!message) {
|
|
97
|
+
if (!originalMessage) {
|
|
98
|
+
console.warn(`[${extensionManifest.name}]: ${localize('missingNLSKey', "Couldn't find message for key {0}.", messageKey)}`);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (
|
|
103
|
+
// if we are translating the title or category of a command
|
|
104
|
+
command && (key === 'title' || key === 'category') &&
|
|
105
|
+
// and the original value is not the same as the translated value
|
|
106
|
+
originalMessage && originalMessage !== message) {
|
|
107
|
+
const localizedString = {
|
|
108
|
+
value: message,
|
|
109
|
+
original: originalMessage
|
|
110
|
+
};
|
|
111
|
+
obj[key] = localizedString;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
obj[key] = message;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (isObject(value)) {
|
|
119
|
+
for (const k in value) {
|
|
120
|
+
if (value.hasOwnProperty(k)) {
|
|
121
|
+
k === 'commands' ? processEntry(value, k, true) : processEntry(value, k, command);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (Array.isArray(value)) {
|
|
126
|
+
for (let i = 0; i < value.length; i++) {
|
|
127
|
+
processEntry(value, i, command);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
for (const key in extensionManifest) {
|
|
132
|
+
if (extensionManifest.hasOwnProperty(key)) {
|
|
133
|
+
processEntry(extensionManifest, key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*---------------------------------------------------------------------------------------------
|
|
139
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
140
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
141
|
+
*--------------------------------------------------------------------------------------------*/
|
|
142
|
+
var ScanError;
|
|
143
|
+
(function (ScanError) {
|
|
144
|
+
ScanError[ScanError["None"] = 0] = "None";
|
|
145
|
+
ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
146
|
+
ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
147
|
+
ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
148
|
+
ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
149
|
+
ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
150
|
+
ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
151
|
+
})(ScanError || (ScanError = {}));
|
|
152
|
+
var SyntaxKind;
|
|
153
|
+
(function (SyntaxKind) {
|
|
154
|
+
SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
155
|
+
SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
156
|
+
SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
157
|
+
SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
158
|
+
SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
|
|
159
|
+
SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
|
|
160
|
+
SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
|
|
161
|
+
SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
|
|
162
|
+
SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
|
|
163
|
+
SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
|
|
164
|
+
SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
|
|
165
|
+
SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
166
|
+
SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
167
|
+
SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
168
|
+
SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
|
|
169
|
+
SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
|
|
170
|
+
SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
|
|
171
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
172
|
+
var ParseErrorCode;
|
|
173
|
+
(function (ParseErrorCode) {
|
|
174
|
+
ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
175
|
+
ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
176
|
+
ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
177
|
+
ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
|
|
178
|
+
ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
|
|
179
|
+
ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
|
|
180
|
+
ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
181
|
+
ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
182
|
+
ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
183
|
+
ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
184
|
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
185
|
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
186
|
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
187
|
+
ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
188
|
+
ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
189
|
+
ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
190
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
191
|
+
var ParseOptions;
|
|
192
|
+
(function (ParseOptions) {
|
|
193
|
+
ParseOptions.DEFAULT = {
|
|
194
|
+
allowTrailingComma: true
|
|
195
|
+
};
|
|
196
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
197
|
+
/**
|
|
198
|
+
* Creates a JSON scanner on the given text.
|
|
199
|
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
|
200
|
+
*/
|
|
201
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
202
|
+
let pos = 0;
|
|
203
|
+
const len = text.length;
|
|
204
|
+
let value = '';
|
|
205
|
+
let tokenOffset = 0;
|
|
206
|
+
let token = 16 /* SyntaxKind.Unknown */;
|
|
207
|
+
let scanError = 0 /* ScanError.None */;
|
|
208
|
+
function scanHexDigits(count) {
|
|
209
|
+
let digits = 0;
|
|
210
|
+
let hexValue = 0;
|
|
211
|
+
while (digits < count) {
|
|
212
|
+
const ch = text.charCodeAt(pos);
|
|
213
|
+
if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
|
|
214
|
+
hexValue = hexValue * 16 + ch - 48 /* CharacterCodes._0 */;
|
|
215
|
+
}
|
|
216
|
+
else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
|
|
217
|
+
hexValue = hexValue * 16 + ch - 65 /* CharacterCodes.A */ + 10;
|
|
218
|
+
}
|
|
219
|
+
else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {
|
|
220
|
+
hexValue = hexValue * 16 + ch - 97 /* CharacterCodes.a */ + 10;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
pos++;
|
|
226
|
+
digits++;
|
|
227
|
+
}
|
|
228
|
+
if (digits < count) {
|
|
229
|
+
hexValue = -1;
|
|
230
|
+
}
|
|
231
|
+
return hexValue;
|
|
232
|
+
}
|
|
233
|
+
function setPosition(newPosition) {
|
|
234
|
+
pos = newPosition;
|
|
235
|
+
value = '';
|
|
236
|
+
tokenOffset = 0;
|
|
237
|
+
token = 16 /* SyntaxKind.Unknown */;
|
|
238
|
+
scanError = 0 /* ScanError.None */;
|
|
239
|
+
}
|
|
240
|
+
function scanNumber() {
|
|
241
|
+
const start = pos;
|
|
242
|
+
if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {
|
|
243
|
+
pos++;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
pos++;
|
|
247
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
248
|
+
pos++;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
|
|
252
|
+
pos++;
|
|
253
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
254
|
+
pos++;
|
|
255
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
256
|
+
pos++;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
|
261
|
+
return text.substring(start, pos);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let end = pos;
|
|
265
|
+
if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {
|
|
266
|
+
pos++;
|
|
267
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {
|
|
268
|
+
pos++;
|
|
269
|
+
}
|
|
270
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
271
|
+
pos++;
|
|
272
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
273
|
+
pos++;
|
|
274
|
+
}
|
|
275
|
+
end = pos;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return text.substring(start, end);
|
|
282
|
+
}
|
|
283
|
+
function scanString() {
|
|
284
|
+
let result = '', start = pos;
|
|
285
|
+
while (true) {
|
|
286
|
+
if (pos >= len) {
|
|
287
|
+
result += text.substring(start, pos);
|
|
288
|
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
const ch = text.charCodeAt(pos);
|
|
292
|
+
if (ch === 34 /* CharacterCodes.doubleQuote */) {
|
|
293
|
+
result += text.substring(start, pos);
|
|
294
|
+
pos++;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
if (ch === 92 /* CharacterCodes.backslash */) {
|
|
298
|
+
result += text.substring(start, pos);
|
|
299
|
+
pos++;
|
|
300
|
+
if (pos >= len) {
|
|
301
|
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
const ch2 = text.charCodeAt(pos++);
|
|
305
|
+
switch (ch2) {
|
|
306
|
+
case 34 /* CharacterCodes.doubleQuote */:
|
|
307
|
+
result += '\"';
|
|
308
|
+
break;
|
|
309
|
+
case 92 /* CharacterCodes.backslash */:
|
|
310
|
+
result += '\\';
|
|
311
|
+
break;
|
|
312
|
+
case 47 /* CharacterCodes.slash */:
|
|
313
|
+
result += '/';
|
|
314
|
+
break;
|
|
315
|
+
case 98 /* CharacterCodes.b */:
|
|
316
|
+
result += '\b';
|
|
317
|
+
break;
|
|
318
|
+
case 102 /* CharacterCodes.f */:
|
|
319
|
+
result += '\f';
|
|
320
|
+
break;
|
|
321
|
+
case 110 /* CharacterCodes.n */:
|
|
322
|
+
result += '\n';
|
|
323
|
+
break;
|
|
324
|
+
case 114 /* CharacterCodes.r */:
|
|
325
|
+
result += '\r';
|
|
326
|
+
break;
|
|
327
|
+
case 116 /* CharacterCodes.t */:
|
|
328
|
+
result += '\t';
|
|
329
|
+
break;
|
|
330
|
+
case 117 /* CharacterCodes.u */: {
|
|
331
|
+
const ch3 = scanHexDigits(4);
|
|
332
|
+
if (ch3 >= 0) {
|
|
333
|
+
result += String.fromCharCode(ch3);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
scanError = 4 /* ScanError.InvalidUnicode */;
|
|
337
|
+
}
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
default:
|
|
341
|
+
scanError = 5 /* ScanError.InvalidEscapeCharacter */;
|
|
342
|
+
}
|
|
343
|
+
start = pos;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (ch >= 0 && ch <= 0x1F) {
|
|
347
|
+
if (isLineBreak(ch)) {
|
|
348
|
+
result += text.substring(start, pos);
|
|
349
|
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
scanError = 6 /* ScanError.InvalidCharacter */;
|
|
354
|
+
// mark as error but continue with string
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
pos++;
|
|
358
|
+
}
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
function scanNext() {
|
|
362
|
+
value = '';
|
|
363
|
+
scanError = 0 /* ScanError.None */;
|
|
364
|
+
tokenOffset = pos;
|
|
365
|
+
if (pos >= len) {
|
|
366
|
+
// at the end
|
|
367
|
+
tokenOffset = len;
|
|
368
|
+
return token = 17 /* SyntaxKind.EOF */;
|
|
369
|
+
}
|
|
370
|
+
let code = text.charCodeAt(pos);
|
|
371
|
+
// trivia: whitespace
|
|
372
|
+
if (isWhitespace(code)) {
|
|
373
|
+
do {
|
|
374
|
+
pos++;
|
|
375
|
+
value += String.fromCharCode(code);
|
|
376
|
+
code = text.charCodeAt(pos);
|
|
377
|
+
} while (isWhitespace(code));
|
|
378
|
+
return token = 15 /* SyntaxKind.Trivia */;
|
|
379
|
+
}
|
|
380
|
+
// trivia: newlines
|
|
381
|
+
if (isLineBreak(code)) {
|
|
382
|
+
pos++;
|
|
383
|
+
value += String.fromCharCode(code);
|
|
384
|
+
if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
|
385
|
+
pos++;
|
|
386
|
+
value += '\n';
|
|
387
|
+
}
|
|
388
|
+
return token = 14 /* SyntaxKind.LineBreakTrivia */;
|
|
389
|
+
}
|
|
390
|
+
switch (code) {
|
|
391
|
+
// tokens: []{}:,
|
|
392
|
+
case 123 /* CharacterCodes.openBrace */:
|
|
393
|
+
pos++;
|
|
394
|
+
return token = 1 /* SyntaxKind.OpenBraceToken */;
|
|
395
|
+
case 125 /* CharacterCodes.closeBrace */:
|
|
396
|
+
pos++;
|
|
397
|
+
return token = 2 /* SyntaxKind.CloseBraceToken */;
|
|
398
|
+
case 91 /* CharacterCodes.openBracket */:
|
|
399
|
+
pos++;
|
|
400
|
+
return token = 3 /* SyntaxKind.OpenBracketToken */;
|
|
401
|
+
case 93 /* CharacterCodes.closeBracket */:
|
|
402
|
+
pos++;
|
|
403
|
+
return token = 4 /* SyntaxKind.CloseBracketToken */;
|
|
404
|
+
case 58 /* CharacterCodes.colon */:
|
|
405
|
+
pos++;
|
|
406
|
+
return token = 6 /* SyntaxKind.ColonToken */;
|
|
407
|
+
case 44 /* CharacterCodes.comma */:
|
|
408
|
+
pos++;
|
|
409
|
+
return token = 5 /* SyntaxKind.CommaToken */;
|
|
410
|
+
// strings
|
|
411
|
+
case 34 /* CharacterCodes.doubleQuote */:
|
|
412
|
+
pos++;
|
|
413
|
+
value = scanString();
|
|
414
|
+
return token = 10 /* SyntaxKind.StringLiteral */;
|
|
415
|
+
// comments
|
|
416
|
+
case 47 /* CharacterCodes.slash */: {
|
|
417
|
+
const start = pos - 1;
|
|
418
|
+
// Single-line comment
|
|
419
|
+
if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
|
420
|
+
pos += 2;
|
|
421
|
+
while (pos < len) {
|
|
422
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
pos++;
|
|
426
|
+
}
|
|
427
|
+
value = text.substring(start, pos);
|
|
428
|
+
return token = 12 /* SyntaxKind.LineCommentTrivia */;
|
|
429
|
+
}
|
|
430
|
+
// Multi-line comment
|
|
431
|
+
if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
|
|
432
|
+
pos += 2;
|
|
433
|
+
const safeLength = len - 1; // For lookahead.
|
|
434
|
+
let commentClosed = false;
|
|
435
|
+
while (pos < safeLength) {
|
|
436
|
+
const ch = text.charCodeAt(pos);
|
|
437
|
+
if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
|
438
|
+
pos += 2;
|
|
439
|
+
commentClosed = true;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
pos++;
|
|
443
|
+
}
|
|
444
|
+
if (!commentClosed) {
|
|
445
|
+
pos++;
|
|
446
|
+
scanError = 1 /* ScanError.UnexpectedEndOfComment */;
|
|
447
|
+
}
|
|
448
|
+
value = text.substring(start, pos);
|
|
449
|
+
return token = 13 /* SyntaxKind.BlockCommentTrivia */;
|
|
450
|
+
}
|
|
451
|
+
// just a single slash
|
|
452
|
+
value += String.fromCharCode(code);
|
|
453
|
+
pos++;
|
|
454
|
+
return token = 16 /* SyntaxKind.Unknown */;
|
|
455
|
+
}
|
|
456
|
+
// numbers
|
|
457
|
+
case 45 /* CharacterCodes.minus */:
|
|
458
|
+
value += String.fromCharCode(code);
|
|
459
|
+
pos++;
|
|
460
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
461
|
+
return token = 16 /* SyntaxKind.Unknown */;
|
|
462
|
+
}
|
|
463
|
+
// found a minus, followed by a number so
|
|
464
|
+
// we fall through to proceed with scanning
|
|
465
|
+
// numbers
|
|
466
|
+
case 48 /* CharacterCodes._0 */:
|
|
467
|
+
case 49 /* CharacterCodes._1 */:
|
|
468
|
+
case 50 /* CharacterCodes._2 */:
|
|
469
|
+
case 51 /* CharacterCodes._3 */:
|
|
470
|
+
case 52 /* CharacterCodes._4 */:
|
|
471
|
+
case 53 /* CharacterCodes._5 */:
|
|
472
|
+
case 54 /* CharacterCodes._6 */:
|
|
473
|
+
case 55 /* CharacterCodes._7 */:
|
|
474
|
+
case 56 /* CharacterCodes._8 */:
|
|
475
|
+
case 57 /* CharacterCodes._9 */:
|
|
476
|
+
value += scanNumber();
|
|
477
|
+
return token = 11 /* SyntaxKind.NumericLiteral */;
|
|
478
|
+
// literals and unknown symbols
|
|
479
|
+
default:
|
|
480
|
+
// is a literal? Read the full word.
|
|
481
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
482
|
+
pos++;
|
|
483
|
+
code = text.charCodeAt(pos);
|
|
484
|
+
}
|
|
485
|
+
if (tokenOffset !== pos) {
|
|
486
|
+
value = text.substring(tokenOffset, pos);
|
|
487
|
+
// keywords: true, false, null
|
|
488
|
+
switch (value) {
|
|
489
|
+
case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;
|
|
490
|
+
case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;
|
|
491
|
+
case 'null': return token = 7 /* SyntaxKind.NullKeyword */;
|
|
492
|
+
}
|
|
493
|
+
return token = 16 /* SyntaxKind.Unknown */;
|
|
494
|
+
}
|
|
495
|
+
// some
|
|
496
|
+
value += String.fromCharCode(code);
|
|
497
|
+
pos++;
|
|
498
|
+
return token = 16 /* SyntaxKind.Unknown */;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function isUnknownContentCharacter(code) {
|
|
502
|
+
if (isWhitespace(code) || isLineBreak(code)) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
switch (code) {
|
|
506
|
+
case 125 /* CharacterCodes.closeBrace */:
|
|
507
|
+
case 93 /* CharacterCodes.closeBracket */:
|
|
508
|
+
case 123 /* CharacterCodes.openBrace */:
|
|
509
|
+
case 91 /* CharacterCodes.openBracket */:
|
|
510
|
+
case 34 /* CharacterCodes.doubleQuote */:
|
|
511
|
+
case 58 /* CharacterCodes.colon */:
|
|
512
|
+
case 44 /* CharacterCodes.comma */:
|
|
513
|
+
case 47 /* CharacterCodes.slash */:
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
function scanNextNonTrivia() {
|
|
519
|
+
let result;
|
|
520
|
+
do {
|
|
521
|
+
result = scanNext();
|
|
522
|
+
} while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
525
|
+
return {
|
|
526
|
+
setPosition: setPosition,
|
|
527
|
+
getPosition: () => pos,
|
|
528
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
529
|
+
getToken: () => token,
|
|
530
|
+
getTokenValue: () => value,
|
|
531
|
+
getTokenOffset: () => tokenOffset,
|
|
532
|
+
getTokenLength: () => pos - tokenOffset,
|
|
533
|
+
getTokenError: () => scanError
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function isWhitespace(ch) {
|
|
537
|
+
return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */ || ch === 11 /* CharacterCodes.verticalTab */ || ch === 12 /* CharacterCodes.formFeed */ ||
|
|
538
|
+
ch === 160 /* CharacterCodes.nonBreakingSpace */ || ch === 5760 /* CharacterCodes.ogham */ || ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ ||
|
|
539
|
+
ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || ch === 8287 /* CharacterCodes.mathematicalSpace */ || ch === 12288 /* CharacterCodes.ideographicSpace */ || ch === 65279 /* CharacterCodes.byteOrderMark */;
|
|
540
|
+
}
|
|
541
|
+
function isLineBreak(ch) {
|
|
542
|
+
return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */ || ch === 8232 /* CharacterCodes.lineSeparator */ || ch === 8233 /* CharacterCodes.paragraphSeparator */;
|
|
543
|
+
}
|
|
544
|
+
function isDigit(ch) {
|
|
545
|
+
return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
|
|
546
|
+
}
|
|
547
|
+
var CharacterCodes;
|
|
548
|
+
(function (CharacterCodes) {
|
|
549
|
+
CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter";
|
|
550
|
+
CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter";
|
|
551
|
+
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
|
|
552
|
+
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
|
|
553
|
+
CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator";
|
|
554
|
+
CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator";
|
|
555
|
+
// REVIEW: do we need to support this? The scanner doesn't, but our IText does. This seems
|
|
556
|
+
// like an odd disparity? (Or maybe it's completely fine for them to be different).
|
|
557
|
+
CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine";
|
|
558
|
+
// Unicode 3.0 space characters
|
|
559
|
+
CharacterCodes[CharacterCodes["space"] = 32] = "space";
|
|
560
|
+
CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace";
|
|
561
|
+
CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad";
|
|
562
|
+
CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad";
|
|
563
|
+
CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace";
|
|
564
|
+
CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace";
|
|
565
|
+
CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace";
|
|
566
|
+
CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace";
|
|
567
|
+
CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace";
|
|
568
|
+
CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace";
|
|
569
|
+
CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace";
|
|
570
|
+
CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace";
|
|
571
|
+
CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace";
|
|
572
|
+
CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace";
|
|
573
|
+
CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace";
|
|
574
|
+
CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace";
|
|
575
|
+
CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace";
|
|
576
|
+
CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham";
|
|
577
|
+
CharacterCodes[CharacterCodes["_"] = 95] = "_";
|
|
578
|
+
CharacterCodes[CharacterCodes["$"] = 36] = "$";
|
|
579
|
+
CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
|
|
580
|
+
CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
|
|
581
|
+
CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
|
|
582
|
+
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
|
583
|
+
CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
|
|
584
|
+
CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
|
|
585
|
+
CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
|
|
586
|
+
CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
|
|
587
|
+
CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
|
|
588
|
+
CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
|
|
589
|
+
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
|
590
|
+
CharacterCodes[CharacterCodes["b"] = 98] = "b";
|
|
591
|
+
CharacterCodes[CharacterCodes["c"] = 99] = "c";
|
|
592
|
+
CharacterCodes[CharacterCodes["d"] = 100] = "d";
|
|
593
|
+
CharacterCodes[CharacterCodes["e"] = 101] = "e";
|
|
594
|
+
CharacterCodes[CharacterCodes["f"] = 102] = "f";
|
|
595
|
+
CharacterCodes[CharacterCodes["g"] = 103] = "g";
|
|
596
|
+
CharacterCodes[CharacterCodes["h"] = 104] = "h";
|
|
597
|
+
CharacterCodes[CharacterCodes["i"] = 105] = "i";
|
|
598
|
+
CharacterCodes[CharacterCodes["j"] = 106] = "j";
|
|
599
|
+
CharacterCodes[CharacterCodes["k"] = 107] = "k";
|
|
600
|
+
CharacterCodes[CharacterCodes["l"] = 108] = "l";
|
|
601
|
+
CharacterCodes[CharacterCodes["m"] = 109] = "m";
|
|
602
|
+
CharacterCodes[CharacterCodes["n"] = 110] = "n";
|
|
603
|
+
CharacterCodes[CharacterCodes["o"] = 111] = "o";
|
|
604
|
+
CharacterCodes[CharacterCodes["p"] = 112] = "p";
|
|
605
|
+
CharacterCodes[CharacterCodes["q"] = 113] = "q";
|
|
606
|
+
CharacterCodes[CharacterCodes["r"] = 114] = "r";
|
|
607
|
+
CharacterCodes[CharacterCodes["s"] = 115] = "s";
|
|
608
|
+
CharacterCodes[CharacterCodes["t"] = 116] = "t";
|
|
609
|
+
CharacterCodes[CharacterCodes["u"] = 117] = "u";
|
|
610
|
+
CharacterCodes[CharacterCodes["v"] = 118] = "v";
|
|
611
|
+
CharacterCodes[CharacterCodes["w"] = 119] = "w";
|
|
612
|
+
CharacterCodes[CharacterCodes["x"] = 120] = "x";
|
|
613
|
+
CharacterCodes[CharacterCodes["y"] = 121] = "y";
|
|
614
|
+
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
|
615
|
+
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
|
616
|
+
CharacterCodes[CharacterCodes["B"] = 66] = "B";
|
|
617
|
+
CharacterCodes[CharacterCodes["C"] = 67] = "C";
|
|
618
|
+
CharacterCodes[CharacterCodes["D"] = 68] = "D";
|
|
619
|
+
CharacterCodes[CharacterCodes["E"] = 69] = "E";
|
|
620
|
+
CharacterCodes[CharacterCodes["F"] = 70] = "F";
|
|
621
|
+
CharacterCodes[CharacterCodes["G"] = 71] = "G";
|
|
622
|
+
CharacterCodes[CharacterCodes["H"] = 72] = "H";
|
|
623
|
+
CharacterCodes[CharacterCodes["I"] = 73] = "I";
|
|
624
|
+
CharacterCodes[CharacterCodes["J"] = 74] = "J";
|
|
625
|
+
CharacterCodes[CharacterCodes["K"] = 75] = "K";
|
|
626
|
+
CharacterCodes[CharacterCodes["L"] = 76] = "L";
|
|
627
|
+
CharacterCodes[CharacterCodes["M"] = 77] = "M";
|
|
628
|
+
CharacterCodes[CharacterCodes["N"] = 78] = "N";
|
|
629
|
+
CharacterCodes[CharacterCodes["O"] = 79] = "O";
|
|
630
|
+
CharacterCodes[CharacterCodes["P"] = 80] = "P";
|
|
631
|
+
CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
|
|
632
|
+
CharacterCodes[CharacterCodes["R"] = 82] = "R";
|
|
633
|
+
CharacterCodes[CharacterCodes["S"] = 83] = "S";
|
|
634
|
+
CharacterCodes[CharacterCodes["T"] = 84] = "T";
|
|
635
|
+
CharacterCodes[CharacterCodes["U"] = 85] = "U";
|
|
636
|
+
CharacterCodes[CharacterCodes["V"] = 86] = "V";
|
|
637
|
+
CharacterCodes[CharacterCodes["W"] = 87] = "W";
|
|
638
|
+
CharacterCodes[CharacterCodes["X"] = 88] = "X";
|
|
639
|
+
CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
|
|
640
|
+
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
|
641
|
+
CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand";
|
|
642
|
+
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
|
|
643
|
+
CharacterCodes[CharacterCodes["at"] = 64] = "at";
|
|
644
|
+
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
|
645
|
+
CharacterCodes[CharacterCodes["bar"] = 124] = "bar";
|
|
646
|
+
CharacterCodes[CharacterCodes["caret"] = 94] = "caret";
|
|
647
|
+
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
|
|
648
|
+
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
|
|
649
|
+
CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen";
|
|
650
|
+
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
|
651
|
+
CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
|
|
652
|
+
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
|
653
|
+
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
|
|
654
|
+
CharacterCodes[CharacterCodes["equals"] = 61] = "equals";
|
|
655
|
+
CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation";
|
|
656
|
+
CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan";
|
|
657
|
+
CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan";
|
|
658
|
+
CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
|
|
659
|
+
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
|
|
660
|
+
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
|
|
661
|
+
CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen";
|
|
662
|
+
CharacterCodes[CharacterCodes["percent"] = 37] = "percent";
|
|
663
|
+
CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
|
|
664
|
+
CharacterCodes[CharacterCodes["question"] = 63] = "question";
|
|
665
|
+
CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon";
|
|
666
|
+
CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote";
|
|
667
|
+
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
|
668
|
+
CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde";
|
|
669
|
+
CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace";
|
|
670
|
+
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
|
|
671
|
+
CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark";
|
|
672
|
+
CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
|
|
673
|
+
CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab";
|
|
674
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
675
|
+
/**
|
|
676
|
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
677
|
+
* Therefore always check the errors list to find out if the input was valid.
|
|
678
|
+
*/
|
|
679
|
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
680
|
+
let currentProperty = null;
|
|
681
|
+
let currentParent = [];
|
|
682
|
+
const previousParents = [];
|
|
683
|
+
function onValue(value) {
|
|
684
|
+
if (Array.isArray(currentParent)) {
|
|
685
|
+
currentParent.push(value);
|
|
686
|
+
}
|
|
687
|
+
else if (currentProperty !== null) {
|
|
688
|
+
currentParent[currentProperty] = value;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
const visitor = {
|
|
692
|
+
onObjectBegin: () => {
|
|
693
|
+
const object = {};
|
|
694
|
+
onValue(object);
|
|
695
|
+
previousParents.push(currentParent);
|
|
696
|
+
currentParent = object;
|
|
697
|
+
currentProperty = null;
|
|
698
|
+
},
|
|
699
|
+
onObjectProperty: (name) => {
|
|
700
|
+
currentProperty = name;
|
|
701
|
+
},
|
|
702
|
+
onObjectEnd: () => {
|
|
703
|
+
currentParent = previousParents.pop();
|
|
704
|
+
},
|
|
705
|
+
onArrayBegin: () => {
|
|
706
|
+
const array = [];
|
|
707
|
+
onValue(array);
|
|
708
|
+
previousParents.push(currentParent);
|
|
709
|
+
currentParent = array;
|
|
710
|
+
currentProperty = null;
|
|
711
|
+
},
|
|
712
|
+
onArrayEnd: () => {
|
|
713
|
+
currentParent = previousParents.pop();
|
|
714
|
+
},
|
|
715
|
+
onLiteralValue: onValue,
|
|
716
|
+
onError: (error, offset, length) => {
|
|
717
|
+
errors.push({ error, offset, length });
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
visit(text, visitor, options);
|
|
721
|
+
return currentParent[0];
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
|
725
|
+
*/
|
|
726
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
727
|
+
const _scanner = createScanner(text, false);
|
|
728
|
+
function toNoArgVisit(visitFunction) {
|
|
729
|
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
|
|
730
|
+
}
|
|
731
|
+
function toOneArgVisit(visitFunction) {
|
|
732
|
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
|
|
733
|
+
}
|
|
734
|
+
const onObjectBegin = toNoArgVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisit(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisit(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisit(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
735
|
+
const disallowComments = options && options.disallowComments;
|
|
736
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
737
|
+
function scanNext() {
|
|
738
|
+
while (true) {
|
|
739
|
+
const token = _scanner.scan();
|
|
740
|
+
switch (_scanner.getTokenError()) {
|
|
741
|
+
case 4 /* ScanError.InvalidUnicode */:
|
|
742
|
+
handleError(14 /* ParseErrorCode.InvalidUnicode */);
|
|
743
|
+
break;
|
|
744
|
+
case 5 /* ScanError.InvalidEscapeCharacter */:
|
|
745
|
+
handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);
|
|
746
|
+
break;
|
|
747
|
+
case 3 /* ScanError.UnexpectedEndOfNumber */:
|
|
748
|
+
handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);
|
|
749
|
+
break;
|
|
750
|
+
case 1 /* ScanError.UnexpectedEndOfComment */:
|
|
751
|
+
if (!disallowComments) {
|
|
752
|
+
handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);
|
|
753
|
+
}
|
|
754
|
+
break;
|
|
755
|
+
case 2 /* ScanError.UnexpectedEndOfString */:
|
|
756
|
+
handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);
|
|
757
|
+
break;
|
|
758
|
+
case 6 /* ScanError.InvalidCharacter */:
|
|
759
|
+
handleError(16 /* ParseErrorCode.InvalidCharacter */);
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
switch (token) {
|
|
763
|
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
|
764
|
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
|
765
|
+
if (disallowComments) {
|
|
766
|
+
handleError(10 /* ParseErrorCode.InvalidCommentToken */);
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
onComment();
|
|
770
|
+
}
|
|
771
|
+
break;
|
|
772
|
+
case 16 /* SyntaxKind.Unknown */:
|
|
773
|
+
handleError(1 /* ParseErrorCode.InvalidSymbol */);
|
|
774
|
+
break;
|
|
775
|
+
case 15 /* SyntaxKind.Trivia */:
|
|
776
|
+
case 14 /* SyntaxKind.LineBreakTrivia */:
|
|
777
|
+
break;
|
|
778
|
+
default:
|
|
779
|
+
return token;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
784
|
+
onError(error);
|
|
785
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
786
|
+
let token = _scanner.getToken();
|
|
787
|
+
while (token !== 17 /* SyntaxKind.EOF */) {
|
|
788
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
789
|
+
scanNext();
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
else if (skipUntil.indexOf(token) !== -1) {
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
token = scanNext();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function parseString(isValue) {
|
|
800
|
+
const value = _scanner.getTokenValue();
|
|
801
|
+
if (isValue) {
|
|
802
|
+
onLiteralValue(value);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
onObjectProperty(value);
|
|
806
|
+
}
|
|
807
|
+
scanNext();
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
function parseLiteral() {
|
|
811
|
+
switch (_scanner.getToken()) {
|
|
812
|
+
case 11 /* SyntaxKind.NumericLiteral */: {
|
|
813
|
+
let value = 0;
|
|
814
|
+
try {
|
|
815
|
+
value = JSON.parse(_scanner.getTokenValue());
|
|
816
|
+
if (typeof value !== 'number') {
|
|
817
|
+
handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
|
|
818
|
+
value = 0;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
catch (e) {
|
|
822
|
+
handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
|
|
823
|
+
}
|
|
824
|
+
onLiteralValue(value);
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
case 7 /* SyntaxKind.NullKeyword */:
|
|
828
|
+
onLiteralValue(null);
|
|
829
|
+
break;
|
|
830
|
+
case 8 /* SyntaxKind.TrueKeyword */:
|
|
831
|
+
onLiteralValue(true);
|
|
832
|
+
break;
|
|
833
|
+
case 9 /* SyntaxKind.FalseKeyword */:
|
|
834
|
+
onLiteralValue(false);
|
|
835
|
+
break;
|
|
836
|
+
default:
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
scanNext();
|
|
840
|
+
return true;
|
|
841
|
+
}
|
|
842
|
+
function parseProperty() {
|
|
843
|
+
if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {
|
|
844
|
+
handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
parseString(false);
|
|
848
|
+
if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {
|
|
849
|
+
onSeparator(':');
|
|
850
|
+
scanNext(); // consume colon
|
|
851
|
+
if (!parseValue()) {
|
|
852
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
857
|
+
}
|
|
858
|
+
return true;
|
|
859
|
+
}
|
|
860
|
+
function parseObject() {
|
|
861
|
+
onObjectBegin();
|
|
862
|
+
scanNext(); // consume open brace
|
|
863
|
+
let needsComma = false;
|
|
864
|
+
while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
|
865
|
+
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
|
866
|
+
if (!needsComma) {
|
|
867
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
868
|
+
}
|
|
869
|
+
onSeparator(',');
|
|
870
|
+
scanNext(); // consume comma
|
|
871
|
+
if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
else if (needsComma) {
|
|
876
|
+
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
|
877
|
+
}
|
|
878
|
+
if (!parseProperty()) {
|
|
879
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
880
|
+
}
|
|
881
|
+
needsComma = true;
|
|
882
|
+
}
|
|
883
|
+
onObjectEnd();
|
|
884
|
+
if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {
|
|
885
|
+
handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
scanNext(); // consume close brace
|
|
889
|
+
}
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
892
|
+
function parseArray() {
|
|
893
|
+
onArrayBegin();
|
|
894
|
+
scanNext(); // consume open bracket
|
|
895
|
+
let needsComma = false;
|
|
896
|
+
while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
|
897
|
+
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
|
898
|
+
if (!needsComma) {
|
|
899
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
900
|
+
}
|
|
901
|
+
onSeparator(',');
|
|
902
|
+
scanNext(); // consume comma
|
|
903
|
+
if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
else if (needsComma) {
|
|
908
|
+
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
|
909
|
+
}
|
|
910
|
+
if (!parseValue()) {
|
|
911
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
912
|
+
}
|
|
913
|
+
needsComma = true;
|
|
914
|
+
}
|
|
915
|
+
onArrayEnd();
|
|
916
|
+
if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {
|
|
917
|
+
handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
scanNext(); // consume close bracket
|
|
921
|
+
}
|
|
922
|
+
return true;
|
|
923
|
+
}
|
|
924
|
+
function parseValue() {
|
|
925
|
+
switch (_scanner.getToken()) {
|
|
926
|
+
case 3 /* SyntaxKind.OpenBracketToken */:
|
|
927
|
+
return parseArray();
|
|
928
|
+
case 1 /* SyntaxKind.OpenBraceToken */:
|
|
929
|
+
return parseObject();
|
|
930
|
+
case 10 /* SyntaxKind.StringLiteral */:
|
|
931
|
+
return parseString(true);
|
|
932
|
+
default:
|
|
933
|
+
return parseLiteral();
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
scanNext();
|
|
937
|
+
if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {
|
|
938
|
+
if (options.allowEmptyContent) {
|
|
939
|
+
return true;
|
|
940
|
+
}
|
|
941
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
if (!parseValue()) {
|
|
945
|
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
946
|
+
return false;
|
|
947
|
+
}
|
|
948
|
+
if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
|
949
|
+
handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);
|
|
950
|
+
}
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/*---------------------------------------------------------------------------------------------
|
|
955
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
956
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
957
|
+
*--------------------------------------------------------------------------------------------*/
|
|
958
|
+
function getParseErrorMessage(errorCode) {
|
|
959
|
+
switch (errorCode) {
|
|
960
|
+
case 1 /* ParseErrorCode.InvalidSymbol */: return localize('error.invalidSymbol', 'Invalid symbol');
|
|
961
|
+
case 2 /* ParseErrorCode.InvalidNumberFormat */: return localize('error.invalidNumberFormat', 'Invalid number format');
|
|
962
|
+
case 3 /* ParseErrorCode.PropertyNameExpected */: return localize('error.propertyNameExpected', 'Property name expected');
|
|
963
|
+
case 4 /* ParseErrorCode.ValueExpected */: return localize('error.valueExpected', 'Value expected');
|
|
964
|
+
case 5 /* ParseErrorCode.ColonExpected */: return localize('error.colonExpected', 'Colon expected');
|
|
965
|
+
case 6 /* ParseErrorCode.CommaExpected */: return localize('error.commaExpected', 'Comma expected');
|
|
966
|
+
case 7 /* ParseErrorCode.CloseBraceExpected */: return localize('error.closeBraceExpected', 'Closing brace expected');
|
|
967
|
+
case 8 /* ParseErrorCode.CloseBracketExpected */: return localize('error.closeBracketExpected', 'Closing bracket expected');
|
|
968
|
+
case 9 /* ParseErrorCode.EndOfFileExpected */: return localize('error.endOfFileExpected', 'End of file expected');
|
|
969
|
+
default:
|
|
970
|
+
return '';
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
function extractCommandPaths(command) {
|
|
975
|
+
if (Array.isArray(command)) {
|
|
976
|
+
return command.flatMap(extractCommandPaths);
|
|
977
|
+
}
|
|
978
|
+
if (command.icon != null) {
|
|
979
|
+
if (typeof command.icon === 'object') {
|
|
980
|
+
return [command.icon.light, command.icon.dark];
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
return [command.icon];
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return [];
|
|
987
|
+
}
|
|
988
|
+
function extractGrammarPaths(grammar) {
|
|
989
|
+
return [grammar.path];
|
|
990
|
+
}
|
|
991
|
+
function extractLanguagePaths(language) {
|
|
992
|
+
const paths = [];
|
|
993
|
+
if (language.icon != null) {
|
|
994
|
+
paths.push(language.icon.dark, language.icon.light);
|
|
995
|
+
}
|
|
996
|
+
if (language.configuration != null) {
|
|
997
|
+
paths.push(language.configuration);
|
|
998
|
+
}
|
|
999
|
+
return paths;
|
|
1000
|
+
}
|
|
1001
|
+
function extractSnippetsPaths(snippet) {
|
|
1002
|
+
return [snippet.path];
|
|
1003
|
+
}
|
|
1004
|
+
function extractThemePaths(theme) {
|
|
1005
|
+
return [theme.path];
|
|
1006
|
+
}
|
|
1007
|
+
function extractPathsFromExtensionManifestContribute(contribute) {
|
|
1008
|
+
const paths = [];
|
|
1009
|
+
if (contribute.commands != null)
|
|
1010
|
+
paths.push(...extractCommandPaths(contribute.commands));
|
|
1011
|
+
if (contribute.grammars != null)
|
|
1012
|
+
paths.push(...contribute.grammars.flatMap(extractGrammarPaths));
|
|
1013
|
+
if (contribute.languages != null)
|
|
1014
|
+
paths.push(...contribute.languages.flatMap(extractLanguagePaths));
|
|
1015
|
+
if (contribute.snippets != null)
|
|
1016
|
+
paths.push(...contribute.snippets.flatMap(extractSnippetsPaths));
|
|
1017
|
+
if (contribute.themes != null)
|
|
1018
|
+
paths.push(...contribute.themes.flatMap(extractThemePaths));
|
|
1019
|
+
if (contribute.iconThemes != null)
|
|
1020
|
+
paths.push(...contribute.iconThemes.flatMap(extractThemePaths));
|
|
1021
|
+
if (contribute.productIconThemes != null)
|
|
1022
|
+
paths.push(...contribute.productIconThemes.flatMap(extractThemePaths));
|
|
1023
|
+
return Array.from(new Set(paths));
|
|
1024
|
+
}
|
|
1025
|
+
function extractPathsFromExtensionManifest(manifest) {
|
|
1026
|
+
return manifest.contributes != null ? extractPathsFromExtensionManifestContribute(manifest.contributes) : [];
|
|
1027
|
+
}
|
|
1028
|
+
function parseJson(path, text) {
|
|
1029
|
+
const errors = [];
|
|
1030
|
+
const result = parse(text, errors);
|
|
1031
|
+
if (errors.length > 0) {
|
|
1032
|
+
throw new Error(`Failed to parse ${path}:\n${errors.map(error => ` ${getParseErrorMessage(error.error)}`).join('\n')}`);
|
|
1033
|
+
}
|
|
1034
|
+
return result;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export { extractPathsFromExtensionManifest as e, localizeManifest as l, parseJson as p };
|