monaco-editor11 1.2.4 → 1.2.6
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/css.worker-wrapper.d.ts +2 -0
- package/dist/css.worker.mjs +34360 -0
- package/dist/editor.worker-wrapper.d.ts +2 -0
- package/dist/editor.worker.mjs +8 -0
- package/dist/index-CrPgw_Bc.mjs +1443 -0
- package/dist/initialize-CGhjAWpj.mjs +9105 -0
- package/dist/json.worker-wrapper.d.ts +2 -0
- package/dist/json.worker.mjs +4039 -0
- package/dist/ts.worker-wrapper.d.ts +2 -0
- package/dist/ts.worker.mjs +227506 -0
- package/dist/worker-wrapper.d.ts +2 -0
- package/package.json +3 -3
- package/dist/monaco-editor11.umd.js +0 -1
- /package/dist/{monaco-editor11.es.js → app.mjs} +0 -0
|
@@ -0,0 +1,4039 @@
|
|
|
1
|
+
import { a as ct } from "./initialize-CGhjAWpj.mjs";
|
|
2
|
+
import { M as de, t as b, D as z, R as $, a as fe, C as ut, I as E, b as J, T as ke, L as Ee, S as G, U as se, F as ve, P as R, c as je, d as K } from "./index-CrPgw_Bc.mjs";
|
|
3
|
+
function Me(t, e = !1) {
|
|
4
|
+
const n = t.length;
|
|
5
|
+
let r = 0, s = "", i = 0, a = 16, o = 0, m = 0, f = 0, h = 0, l = 0;
|
|
6
|
+
function u(c, v) {
|
|
7
|
+
let g = 0, S = 0;
|
|
8
|
+
for (; g < c; ) {
|
|
9
|
+
let A = t.charCodeAt(r);
|
|
10
|
+
if (A >= 48 && A <= 57)
|
|
11
|
+
S = S * 16 + A - 48;
|
|
12
|
+
else if (A >= 65 && A <= 70)
|
|
13
|
+
S = S * 16 + A - 65 + 10;
|
|
14
|
+
else if (A >= 97 && A <= 102)
|
|
15
|
+
S = S * 16 + A - 97 + 10;
|
|
16
|
+
else
|
|
17
|
+
break;
|
|
18
|
+
r++, g++;
|
|
19
|
+
}
|
|
20
|
+
return g < c && (S = -1), S;
|
|
21
|
+
}
|
|
22
|
+
function k(c) {
|
|
23
|
+
r = c, s = "", i = 0, a = 16, l = 0;
|
|
24
|
+
}
|
|
25
|
+
function p() {
|
|
26
|
+
let c = r;
|
|
27
|
+
if (t.charCodeAt(r) === 48)
|
|
28
|
+
r++;
|
|
29
|
+
else
|
|
30
|
+
for (r++; r < t.length && te(t.charCodeAt(r)); )
|
|
31
|
+
r++;
|
|
32
|
+
if (r < t.length && t.charCodeAt(r) === 46)
|
|
33
|
+
if (r++, r < t.length && te(t.charCodeAt(r)))
|
|
34
|
+
for (r++; r < t.length && te(t.charCodeAt(r)); )
|
|
35
|
+
r++;
|
|
36
|
+
else
|
|
37
|
+
return l = 3, t.substring(c, r);
|
|
38
|
+
let v = r;
|
|
39
|
+
if (r < t.length && (t.charCodeAt(r) === 69 || t.charCodeAt(r) === 101))
|
|
40
|
+
if (r++, (r < t.length && t.charCodeAt(r) === 43 || t.charCodeAt(r) === 45) && r++, r < t.length && te(t.charCodeAt(r))) {
|
|
41
|
+
for (r++; r < t.length && te(t.charCodeAt(r)); )
|
|
42
|
+
r++;
|
|
43
|
+
v = r;
|
|
44
|
+
} else
|
|
45
|
+
l = 3;
|
|
46
|
+
return t.substring(c, v);
|
|
47
|
+
}
|
|
48
|
+
function y() {
|
|
49
|
+
let c = "", v = r;
|
|
50
|
+
for (; ; ) {
|
|
51
|
+
if (r >= n) {
|
|
52
|
+
c += t.substring(v, r), l = 2;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const g = t.charCodeAt(r);
|
|
56
|
+
if (g === 34) {
|
|
57
|
+
c += t.substring(v, r), r++;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (g === 92) {
|
|
61
|
+
if (c += t.substring(v, r), r++, r >= n) {
|
|
62
|
+
l = 2;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
switch (t.charCodeAt(r++)) {
|
|
66
|
+
case 34:
|
|
67
|
+
c += '"';
|
|
68
|
+
break;
|
|
69
|
+
case 92:
|
|
70
|
+
c += "\\";
|
|
71
|
+
break;
|
|
72
|
+
case 47:
|
|
73
|
+
c += "/";
|
|
74
|
+
break;
|
|
75
|
+
case 98:
|
|
76
|
+
c += "\b";
|
|
77
|
+
break;
|
|
78
|
+
case 102:
|
|
79
|
+
c += "\f";
|
|
80
|
+
break;
|
|
81
|
+
case 110:
|
|
82
|
+
c += `
|
|
83
|
+
`;
|
|
84
|
+
break;
|
|
85
|
+
case 114:
|
|
86
|
+
c += "\r";
|
|
87
|
+
break;
|
|
88
|
+
case 116:
|
|
89
|
+
c += " ";
|
|
90
|
+
break;
|
|
91
|
+
case 117:
|
|
92
|
+
const A = u(4);
|
|
93
|
+
A >= 0 ? c += String.fromCharCode(A) : l = 4;
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
l = 5;
|
|
97
|
+
}
|
|
98
|
+
v = r;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (g >= 0 && g <= 31)
|
|
102
|
+
if (oe(g)) {
|
|
103
|
+
c += t.substring(v, r), l = 2;
|
|
104
|
+
break;
|
|
105
|
+
} else
|
|
106
|
+
l = 6;
|
|
107
|
+
r++;
|
|
108
|
+
}
|
|
109
|
+
return c;
|
|
110
|
+
}
|
|
111
|
+
function d() {
|
|
112
|
+
if (s = "", l = 0, i = r, m = o, h = f, r >= n)
|
|
113
|
+
return i = n, a = 17;
|
|
114
|
+
let c = t.charCodeAt(r);
|
|
115
|
+
if (Se(c)) {
|
|
116
|
+
do
|
|
117
|
+
r++, s += String.fromCharCode(c), c = t.charCodeAt(r);
|
|
118
|
+
while (Se(c));
|
|
119
|
+
return a = 15;
|
|
120
|
+
}
|
|
121
|
+
if (oe(c))
|
|
122
|
+
return r++, s += String.fromCharCode(c), c === 13 && t.charCodeAt(r) === 10 && (r++, s += `
|
|
123
|
+
`), o++, f = r, a = 14;
|
|
124
|
+
switch (c) {
|
|
125
|
+
// tokens: []{}:,
|
|
126
|
+
case 123:
|
|
127
|
+
return r++, a = 1;
|
|
128
|
+
case 125:
|
|
129
|
+
return r++, a = 2;
|
|
130
|
+
case 91:
|
|
131
|
+
return r++, a = 3;
|
|
132
|
+
case 93:
|
|
133
|
+
return r++, a = 4;
|
|
134
|
+
case 58:
|
|
135
|
+
return r++, a = 6;
|
|
136
|
+
case 44:
|
|
137
|
+
return r++, a = 5;
|
|
138
|
+
// strings
|
|
139
|
+
case 34:
|
|
140
|
+
return r++, s = y(), a = 10;
|
|
141
|
+
// comments
|
|
142
|
+
case 47:
|
|
143
|
+
const v = r - 1;
|
|
144
|
+
if (t.charCodeAt(r + 1) === 47) {
|
|
145
|
+
for (r += 2; r < n && !oe(t.charCodeAt(r)); )
|
|
146
|
+
r++;
|
|
147
|
+
return s = t.substring(v, r), a = 12;
|
|
148
|
+
}
|
|
149
|
+
if (t.charCodeAt(r + 1) === 42) {
|
|
150
|
+
r += 2;
|
|
151
|
+
const g = n - 1;
|
|
152
|
+
let S = !1;
|
|
153
|
+
for (; r < g; ) {
|
|
154
|
+
const A = t.charCodeAt(r);
|
|
155
|
+
if (A === 42 && t.charCodeAt(r + 1) === 47) {
|
|
156
|
+
r += 2, S = !0;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
r++, oe(A) && (A === 13 && t.charCodeAt(r) === 10 && r++, o++, f = r);
|
|
160
|
+
}
|
|
161
|
+
return S || (r++, l = 1), s = t.substring(v, r), a = 13;
|
|
162
|
+
}
|
|
163
|
+
return s += String.fromCharCode(c), r++, a = 16;
|
|
164
|
+
// numbers
|
|
165
|
+
case 45:
|
|
166
|
+
if (s += String.fromCharCode(c), r++, r === n || !te(t.charCodeAt(r)))
|
|
167
|
+
return a = 16;
|
|
168
|
+
// found a minus, followed by a number so
|
|
169
|
+
// we fall through to proceed with scanning
|
|
170
|
+
// numbers
|
|
171
|
+
case 48:
|
|
172
|
+
case 49:
|
|
173
|
+
case 50:
|
|
174
|
+
case 51:
|
|
175
|
+
case 52:
|
|
176
|
+
case 53:
|
|
177
|
+
case 54:
|
|
178
|
+
case 55:
|
|
179
|
+
case 56:
|
|
180
|
+
case 57:
|
|
181
|
+
return s += p(), a = 11;
|
|
182
|
+
// literals and unknown symbols
|
|
183
|
+
default:
|
|
184
|
+
for (; r < n && T(c); )
|
|
185
|
+
r++, c = t.charCodeAt(r);
|
|
186
|
+
if (i !== r) {
|
|
187
|
+
switch (s = t.substring(i, r), s) {
|
|
188
|
+
case "true":
|
|
189
|
+
return a = 8;
|
|
190
|
+
case "false":
|
|
191
|
+
return a = 9;
|
|
192
|
+
case "null":
|
|
193
|
+
return a = 7;
|
|
194
|
+
}
|
|
195
|
+
return a = 16;
|
|
196
|
+
}
|
|
197
|
+
return s += String.fromCharCode(c), r++, a = 16;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function T(c) {
|
|
201
|
+
if (Se(c) || oe(c))
|
|
202
|
+
return !1;
|
|
203
|
+
switch (c) {
|
|
204
|
+
case 125:
|
|
205
|
+
case 93:
|
|
206
|
+
case 123:
|
|
207
|
+
case 91:
|
|
208
|
+
case 34:
|
|
209
|
+
case 58:
|
|
210
|
+
case 44:
|
|
211
|
+
case 47:
|
|
212
|
+
return !1;
|
|
213
|
+
}
|
|
214
|
+
return !0;
|
|
215
|
+
}
|
|
216
|
+
function N() {
|
|
217
|
+
let c;
|
|
218
|
+
do
|
|
219
|
+
c = d();
|
|
220
|
+
while (c >= 12 && c <= 15);
|
|
221
|
+
return c;
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
setPosition: k,
|
|
225
|
+
getPosition: () => r,
|
|
226
|
+
scan: e ? N : d,
|
|
227
|
+
getToken: () => a,
|
|
228
|
+
getTokenValue: () => s,
|
|
229
|
+
getTokenOffset: () => i,
|
|
230
|
+
getTokenLength: () => r - i,
|
|
231
|
+
getTokenStartLine: () => m,
|
|
232
|
+
getTokenStartCharacter: () => i - h,
|
|
233
|
+
getTokenError: () => l
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function Se(t) {
|
|
237
|
+
return t === 32 || t === 9;
|
|
238
|
+
}
|
|
239
|
+
function oe(t) {
|
|
240
|
+
return t === 10 || t === 13;
|
|
241
|
+
}
|
|
242
|
+
function te(t) {
|
|
243
|
+
return t >= 48 && t <= 57;
|
|
244
|
+
}
|
|
245
|
+
var De;
|
|
246
|
+
(function(t) {
|
|
247
|
+
t[t.lineFeed = 10] = "lineFeed", t[t.carriageReturn = 13] = "carriageReturn", t[t.space = 32] = "space", t[t._0 = 48] = "_0", t[t._1 = 49] = "_1", t[t._2 = 50] = "_2", t[t._3 = 51] = "_3", t[t._4 = 52] = "_4", t[t._5 = 53] = "_5", t[t._6 = 54] = "_6", t[t._7 = 55] = "_7", t[t._8 = 56] = "_8", t[t._9 = 57] = "_9", t[t.a = 97] = "a", t[t.b = 98] = "b", t[t.c = 99] = "c", t[t.d = 100] = "d", t[t.e = 101] = "e", t[t.f = 102] = "f", t[t.g = 103] = "g", t[t.h = 104] = "h", t[t.i = 105] = "i", t[t.j = 106] = "j", t[t.k = 107] = "k", t[t.l = 108] = "l", t[t.m = 109] = "m", t[t.n = 110] = "n", t[t.o = 111] = "o", t[t.p = 112] = "p", t[t.q = 113] = "q", t[t.r = 114] = "r", t[t.s = 115] = "s", t[t.t = 116] = "t", t[t.u = 117] = "u", t[t.v = 118] = "v", t[t.w = 119] = "w", t[t.x = 120] = "x", t[t.y = 121] = "y", t[t.z = 122] = "z", t[t.A = 65] = "A", t[t.B = 66] = "B", t[t.C = 67] = "C", t[t.D = 68] = "D", t[t.E = 69] = "E", t[t.F = 70] = "F", t[t.G = 71] = "G", t[t.H = 72] = "H", t[t.I = 73] = "I", t[t.J = 74] = "J", t[t.K = 75] = "K", t[t.L = 76] = "L", t[t.M = 77] = "M", t[t.N = 78] = "N", t[t.O = 79] = "O", t[t.P = 80] = "P", t[t.Q = 81] = "Q", t[t.R = 82] = "R", t[t.S = 83] = "S", t[t.T = 84] = "T", t[t.U = 85] = "U", t[t.V = 86] = "V", t[t.W = 87] = "W", t[t.X = 88] = "X", t[t.Y = 89] = "Y", t[t.Z = 90] = "Z", t[t.asterisk = 42] = "asterisk", t[t.backslash = 92] = "backslash", t[t.closeBrace = 125] = "closeBrace", t[t.closeBracket = 93] = "closeBracket", t[t.colon = 58] = "colon", t[t.comma = 44] = "comma", t[t.dot = 46] = "dot", t[t.doubleQuote = 34] = "doubleQuote", t[t.minus = 45] = "minus", t[t.openBrace = 123] = "openBrace", t[t.openBracket = 91] = "openBracket", t[t.plus = 43] = "plus", t[t.slash = 47] = "slash", t[t.formFeed = 12] = "formFeed", t[t.tab = 9] = "tab";
|
|
248
|
+
})(De || (De = {}));
|
|
249
|
+
const U = new Array(20).fill(0).map((t, e) => " ".repeat(e)), ne = 200, _e = {
|
|
250
|
+
" ": {
|
|
251
|
+
"\n": new Array(ne).fill(0).map((t, e) => `
|
|
252
|
+
` + " ".repeat(e)),
|
|
253
|
+
"\r": new Array(ne).fill(0).map((t, e) => "\r" + " ".repeat(e)),
|
|
254
|
+
"\r\n": new Array(ne).fill(0).map((t, e) => `\r
|
|
255
|
+
` + " ".repeat(e))
|
|
256
|
+
},
|
|
257
|
+
" ": {
|
|
258
|
+
"\n": new Array(ne).fill(0).map((t, e) => `
|
|
259
|
+
` + " ".repeat(e)),
|
|
260
|
+
"\r": new Array(ne).fill(0).map((t, e) => "\r" + " ".repeat(e)),
|
|
261
|
+
"\r\n": new Array(ne).fill(0).map((t, e) => `\r
|
|
262
|
+
` + " ".repeat(e))
|
|
263
|
+
}
|
|
264
|
+
}, pt = [`
|
|
265
|
+
`, "\r", `\r
|
|
266
|
+
`];
|
|
267
|
+
function mt(t, e, n) {
|
|
268
|
+
let r, s, i, a, o;
|
|
269
|
+
if (e) {
|
|
270
|
+
for (a = e.offset, o = a + e.length, i = a; i > 0 && !Be(t, i - 1); )
|
|
271
|
+
i--;
|
|
272
|
+
let g = o;
|
|
273
|
+
for (; g < t.length && !Be(t, g); )
|
|
274
|
+
g++;
|
|
275
|
+
s = t.substring(i, g), r = ht(s, n);
|
|
276
|
+
} else
|
|
277
|
+
s = t, r = 0, i = 0, a = 0, o = t.length;
|
|
278
|
+
const m = gt(n, t), f = pt.includes(m);
|
|
279
|
+
let h = 0, l = 0, u;
|
|
280
|
+
n.insertSpaces ? u = U[n.tabSize || 4] ?? re(U[1], n.tabSize || 4) : u = " ";
|
|
281
|
+
const k = u === " " ? " " : " ";
|
|
282
|
+
let p = Me(s, !1), y = !1;
|
|
283
|
+
function d() {
|
|
284
|
+
if (h > 1)
|
|
285
|
+
return re(m, h) + re(u, r + l);
|
|
286
|
+
const g = u.length * (r + l);
|
|
287
|
+
return !f || g > _e[k][m].length ? m + re(u, r + l) : g <= 0 ? m : _e[k][m][g];
|
|
288
|
+
}
|
|
289
|
+
function T() {
|
|
290
|
+
let g = p.scan();
|
|
291
|
+
for (h = 0; g === 15 || g === 14; )
|
|
292
|
+
g === 14 && n.keepLines ? h += 1 : g === 14 && (h = 1), g = p.scan();
|
|
293
|
+
return y = g === 16 || p.getTokenError() !== 0, g;
|
|
294
|
+
}
|
|
295
|
+
const N = [];
|
|
296
|
+
function c(g, S, A) {
|
|
297
|
+
!y && (!e || S < o && A > a) && t.substring(S, A) !== g && N.push({ offset: S, length: A - S, content: g });
|
|
298
|
+
}
|
|
299
|
+
let v = T();
|
|
300
|
+
if (n.keepLines && h > 0 && c(re(m, h), 0, 0), v !== 17) {
|
|
301
|
+
let g = p.getTokenOffset() + i, S = u.length * r < 20 && n.insertSpaces ? U[u.length * r] : re(u, r);
|
|
302
|
+
c(S, i, g);
|
|
303
|
+
}
|
|
304
|
+
for (; v !== 17; ) {
|
|
305
|
+
let g = p.getTokenOffset() + p.getTokenLength() + i, S = T(), A = "", x = !1;
|
|
306
|
+
for (; h === 0 && (S === 12 || S === 13); ) {
|
|
307
|
+
let L = p.getTokenOffset() + i;
|
|
308
|
+
c(U[1], g, L), g = p.getTokenOffset() + p.getTokenLength() + i, x = S === 12, A = x ? d() : "", S = T();
|
|
309
|
+
}
|
|
310
|
+
if (S === 2)
|
|
311
|
+
v !== 1 && l--, n.keepLines && h > 0 || !n.keepLines && v !== 1 ? A = d() : n.keepLines && (A = U[1]);
|
|
312
|
+
else if (S === 4)
|
|
313
|
+
v !== 3 && l--, n.keepLines && h > 0 || !n.keepLines && v !== 3 ? A = d() : n.keepLines && (A = U[1]);
|
|
314
|
+
else {
|
|
315
|
+
switch (v) {
|
|
316
|
+
case 3:
|
|
317
|
+
case 1:
|
|
318
|
+
l++, n.keepLines && h > 0 || !n.keepLines ? A = d() : A = U[1];
|
|
319
|
+
break;
|
|
320
|
+
case 5:
|
|
321
|
+
n.keepLines && h > 0 || !n.keepLines ? A = d() : A = U[1];
|
|
322
|
+
break;
|
|
323
|
+
case 12:
|
|
324
|
+
A = d();
|
|
325
|
+
break;
|
|
326
|
+
case 13:
|
|
327
|
+
h > 0 ? A = d() : x || (A = U[1]);
|
|
328
|
+
break;
|
|
329
|
+
case 6:
|
|
330
|
+
n.keepLines && h > 0 ? A = d() : x || (A = U[1]);
|
|
331
|
+
break;
|
|
332
|
+
case 10:
|
|
333
|
+
n.keepLines && h > 0 ? A = d() : S === 6 && !x && (A = "");
|
|
334
|
+
break;
|
|
335
|
+
case 7:
|
|
336
|
+
case 8:
|
|
337
|
+
case 9:
|
|
338
|
+
case 11:
|
|
339
|
+
case 2:
|
|
340
|
+
case 4:
|
|
341
|
+
n.keepLines && h > 0 ? A = d() : (S === 12 || S === 13) && !x ? A = U[1] : S !== 5 && S !== 17 && (y = !0);
|
|
342
|
+
break;
|
|
343
|
+
case 16:
|
|
344
|
+
y = !0;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
h > 0 && (S === 12 || S === 13) && (A = d());
|
|
348
|
+
}
|
|
349
|
+
S === 17 && (n.keepLines && h > 0 ? A = d() : A = n.insertFinalNewline ? m : "");
|
|
350
|
+
const w = p.getTokenOffset() + i;
|
|
351
|
+
c(A, g, w), v = S;
|
|
352
|
+
}
|
|
353
|
+
return N;
|
|
354
|
+
}
|
|
355
|
+
function re(t, e) {
|
|
356
|
+
let n = "";
|
|
357
|
+
for (let r = 0; r < e; r++)
|
|
358
|
+
n += t;
|
|
359
|
+
return n;
|
|
360
|
+
}
|
|
361
|
+
function ht(t, e) {
|
|
362
|
+
let n = 0, r = 0;
|
|
363
|
+
const s = e.tabSize || 4;
|
|
364
|
+
for (; n < t.length; ) {
|
|
365
|
+
let i = t.charAt(n);
|
|
366
|
+
if (i === U[1])
|
|
367
|
+
r++;
|
|
368
|
+
else if (i === " ")
|
|
369
|
+
r += s;
|
|
370
|
+
else
|
|
371
|
+
break;
|
|
372
|
+
n++;
|
|
373
|
+
}
|
|
374
|
+
return Math.floor(r / s);
|
|
375
|
+
}
|
|
376
|
+
function gt(t, e) {
|
|
377
|
+
for (let n = 0; n < e.length; n++) {
|
|
378
|
+
const r = e.charAt(n);
|
|
379
|
+
if (r === "\r")
|
|
380
|
+
return n + 1 < e.length && e.charAt(n + 1) === `
|
|
381
|
+
` ? `\r
|
|
382
|
+
` : "\r";
|
|
383
|
+
if (r === `
|
|
384
|
+
`)
|
|
385
|
+
return `
|
|
386
|
+
`;
|
|
387
|
+
}
|
|
388
|
+
return t && t.eol || `
|
|
389
|
+
`;
|
|
390
|
+
}
|
|
391
|
+
function Be(t, e) {
|
|
392
|
+
return `\r
|
|
393
|
+
`.indexOf(t.charAt(e)) !== -1;
|
|
394
|
+
}
|
|
395
|
+
var ye;
|
|
396
|
+
(function(t) {
|
|
397
|
+
t.DEFAULT = {
|
|
398
|
+
allowTrailingComma: !1
|
|
399
|
+
};
|
|
400
|
+
})(ye || (ye = {}));
|
|
401
|
+
function dt(t, e = [], n = ye.DEFAULT) {
|
|
402
|
+
let r = null, s = [];
|
|
403
|
+
const i = [];
|
|
404
|
+
function a(m) {
|
|
405
|
+
Array.isArray(s) ? s.push(m) : r !== null && (s[r] = m);
|
|
406
|
+
}
|
|
407
|
+
return bt(t, {
|
|
408
|
+
onObjectBegin: () => {
|
|
409
|
+
const m = {};
|
|
410
|
+
a(m), i.push(s), s = m, r = null;
|
|
411
|
+
},
|
|
412
|
+
onObjectProperty: (m) => {
|
|
413
|
+
r = m;
|
|
414
|
+
},
|
|
415
|
+
onObjectEnd: () => {
|
|
416
|
+
s = i.pop();
|
|
417
|
+
},
|
|
418
|
+
onArrayBegin: () => {
|
|
419
|
+
const m = [];
|
|
420
|
+
a(m), i.push(s), s = m, r = null;
|
|
421
|
+
},
|
|
422
|
+
onArrayEnd: () => {
|
|
423
|
+
s = i.pop();
|
|
424
|
+
},
|
|
425
|
+
onLiteralValue: a,
|
|
426
|
+
onError: (m, f, h) => {
|
|
427
|
+
e.push({ error: m, offset: f, length: h });
|
|
428
|
+
}
|
|
429
|
+
}, n), s[0];
|
|
430
|
+
}
|
|
431
|
+
function Ye(t) {
|
|
432
|
+
if (!t.parent || !t.parent.children)
|
|
433
|
+
return [];
|
|
434
|
+
const e = Ye(t.parent);
|
|
435
|
+
if (t.parent.type === "property") {
|
|
436
|
+
const n = t.parent.children[0].value;
|
|
437
|
+
e.push(n);
|
|
438
|
+
} else if (t.parent.type === "array") {
|
|
439
|
+
const n = t.parent.children.indexOf(t);
|
|
440
|
+
n !== -1 && e.push(n);
|
|
441
|
+
}
|
|
442
|
+
return e;
|
|
443
|
+
}
|
|
444
|
+
function xe(t) {
|
|
445
|
+
switch (t.type) {
|
|
446
|
+
case "array":
|
|
447
|
+
return t.children.map(xe);
|
|
448
|
+
case "object":
|
|
449
|
+
const e = /* @__PURE__ */ Object.create(null);
|
|
450
|
+
for (let n of t.children) {
|
|
451
|
+
const r = n.children[1];
|
|
452
|
+
r && (e[n.children[0].value] = xe(r));
|
|
453
|
+
}
|
|
454
|
+
return e;
|
|
455
|
+
case "null":
|
|
456
|
+
case "string":
|
|
457
|
+
case "number":
|
|
458
|
+
case "boolean":
|
|
459
|
+
return t.value;
|
|
460
|
+
default:
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function yt(t, e, n = !1) {
|
|
465
|
+
return e >= t.offset && e < t.offset + t.length || n && e === t.offset + t.length;
|
|
466
|
+
}
|
|
467
|
+
function Ce(t, e, n = !1) {
|
|
468
|
+
if (yt(t, e, n)) {
|
|
469
|
+
const r = t.children;
|
|
470
|
+
if (Array.isArray(r))
|
|
471
|
+
for (let s = 0; s < r.length && r[s].offset <= e; s++) {
|
|
472
|
+
const i = Ce(r[s], e, n);
|
|
473
|
+
if (i)
|
|
474
|
+
return i;
|
|
475
|
+
}
|
|
476
|
+
return t;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function bt(t, e, n = ye.DEFAULT) {
|
|
480
|
+
const r = Me(t, !1), s = [];
|
|
481
|
+
function i(P) {
|
|
482
|
+
return P ? () => P(r.getTokenOffset(), r.getTokenLength(), r.getTokenStartLine(), r.getTokenStartCharacter()) : () => !0;
|
|
483
|
+
}
|
|
484
|
+
function a(P) {
|
|
485
|
+
return P ? () => P(r.getTokenOffset(), r.getTokenLength(), r.getTokenStartLine(), r.getTokenStartCharacter(), () => s.slice()) : () => !0;
|
|
486
|
+
}
|
|
487
|
+
function o(P) {
|
|
488
|
+
return P ? (V) => P(V, r.getTokenOffset(), r.getTokenLength(), r.getTokenStartLine(), r.getTokenStartCharacter()) : () => !0;
|
|
489
|
+
}
|
|
490
|
+
function m(P) {
|
|
491
|
+
return P ? (V) => P(V, r.getTokenOffset(), r.getTokenLength(), r.getTokenStartLine(), r.getTokenStartCharacter(), () => s.slice()) : () => !0;
|
|
492
|
+
}
|
|
493
|
+
const f = a(e.onObjectBegin), h = m(e.onObjectProperty), l = i(e.onObjectEnd), u = a(e.onArrayBegin), k = i(e.onArrayEnd), p = m(e.onLiteralValue), y = o(e.onSeparator), d = i(e.onComment), T = o(e.onError), N = n && n.disallowComments, c = n && n.allowTrailingComma;
|
|
494
|
+
function v() {
|
|
495
|
+
for (; ; ) {
|
|
496
|
+
const P = r.scan();
|
|
497
|
+
switch (r.getTokenError()) {
|
|
498
|
+
case 4:
|
|
499
|
+
g(
|
|
500
|
+
14
|
|
501
|
+
/* ParseErrorCode.InvalidUnicode */
|
|
502
|
+
);
|
|
503
|
+
break;
|
|
504
|
+
case 5:
|
|
505
|
+
g(
|
|
506
|
+
15
|
|
507
|
+
/* ParseErrorCode.InvalidEscapeCharacter */
|
|
508
|
+
);
|
|
509
|
+
break;
|
|
510
|
+
case 3:
|
|
511
|
+
g(
|
|
512
|
+
13
|
|
513
|
+
/* ParseErrorCode.UnexpectedEndOfNumber */
|
|
514
|
+
);
|
|
515
|
+
break;
|
|
516
|
+
case 1:
|
|
517
|
+
N || g(
|
|
518
|
+
11
|
|
519
|
+
/* ParseErrorCode.UnexpectedEndOfComment */
|
|
520
|
+
);
|
|
521
|
+
break;
|
|
522
|
+
case 2:
|
|
523
|
+
g(
|
|
524
|
+
12
|
|
525
|
+
/* ParseErrorCode.UnexpectedEndOfString */
|
|
526
|
+
);
|
|
527
|
+
break;
|
|
528
|
+
case 6:
|
|
529
|
+
g(
|
|
530
|
+
16
|
|
531
|
+
/* ParseErrorCode.InvalidCharacter */
|
|
532
|
+
);
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
switch (P) {
|
|
536
|
+
case 12:
|
|
537
|
+
case 13:
|
|
538
|
+
N ? g(
|
|
539
|
+
10
|
|
540
|
+
/* ParseErrorCode.InvalidCommentToken */
|
|
541
|
+
) : d();
|
|
542
|
+
break;
|
|
543
|
+
case 16:
|
|
544
|
+
g(
|
|
545
|
+
1
|
|
546
|
+
/* ParseErrorCode.InvalidSymbol */
|
|
547
|
+
);
|
|
548
|
+
break;
|
|
549
|
+
case 15:
|
|
550
|
+
case 14:
|
|
551
|
+
break;
|
|
552
|
+
default:
|
|
553
|
+
return P;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function g(P, V = [], $e = []) {
|
|
558
|
+
if (T(P), V.length + $e.length > 0) {
|
|
559
|
+
let pe = r.getToken();
|
|
560
|
+
for (; pe !== 17; ) {
|
|
561
|
+
if (V.indexOf(pe) !== -1) {
|
|
562
|
+
v();
|
|
563
|
+
break;
|
|
564
|
+
} else if ($e.indexOf(pe) !== -1)
|
|
565
|
+
break;
|
|
566
|
+
pe = v();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
function S(P) {
|
|
571
|
+
const V = r.getTokenValue();
|
|
572
|
+
return P ? p(V) : (h(V), s.push(V)), v(), !0;
|
|
573
|
+
}
|
|
574
|
+
function A() {
|
|
575
|
+
switch (r.getToken()) {
|
|
576
|
+
case 11:
|
|
577
|
+
const P = r.getTokenValue();
|
|
578
|
+
let V = Number(P);
|
|
579
|
+
isNaN(V) && (g(
|
|
580
|
+
2
|
|
581
|
+
/* ParseErrorCode.InvalidNumberFormat */
|
|
582
|
+
), V = 0), p(V);
|
|
583
|
+
break;
|
|
584
|
+
case 7:
|
|
585
|
+
p(null);
|
|
586
|
+
break;
|
|
587
|
+
case 8:
|
|
588
|
+
p(!0);
|
|
589
|
+
break;
|
|
590
|
+
case 9:
|
|
591
|
+
p(!1);
|
|
592
|
+
break;
|
|
593
|
+
default:
|
|
594
|
+
return !1;
|
|
595
|
+
}
|
|
596
|
+
return v(), !0;
|
|
597
|
+
}
|
|
598
|
+
function x() {
|
|
599
|
+
return r.getToken() !== 10 ? (g(3, [], [
|
|
600
|
+
2,
|
|
601
|
+
5
|
|
602
|
+
/* SyntaxKind.CommaToken */
|
|
603
|
+
]), !1) : (S(!1), r.getToken() === 6 ? (y(":"), v(), I() || g(4, [], [
|
|
604
|
+
2,
|
|
605
|
+
5
|
|
606
|
+
/* SyntaxKind.CommaToken */
|
|
607
|
+
])) : g(5, [], [
|
|
608
|
+
2,
|
|
609
|
+
5
|
|
610
|
+
/* SyntaxKind.CommaToken */
|
|
611
|
+
]), s.pop(), !0);
|
|
612
|
+
}
|
|
613
|
+
function w() {
|
|
614
|
+
f(), v();
|
|
615
|
+
let P = !1;
|
|
616
|
+
for (; r.getToken() !== 2 && r.getToken() !== 17; ) {
|
|
617
|
+
if (r.getToken() === 5) {
|
|
618
|
+
if (P || g(4, [], []), y(","), v(), r.getToken() === 2 && c)
|
|
619
|
+
break;
|
|
620
|
+
} else P && g(6, [], []);
|
|
621
|
+
x() || g(4, [], [
|
|
622
|
+
2,
|
|
623
|
+
5
|
|
624
|
+
/* SyntaxKind.CommaToken */
|
|
625
|
+
]), P = !0;
|
|
626
|
+
}
|
|
627
|
+
return l(), r.getToken() !== 2 ? g(7, [
|
|
628
|
+
2
|
|
629
|
+
/* SyntaxKind.CloseBraceToken */
|
|
630
|
+
], []) : v(), !0;
|
|
631
|
+
}
|
|
632
|
+
function L() {
|
|
633
|
+
u(), v();
|
|
634
|
+
let P = !0, V = !1;
|
|
635
|
+
for (; r.getToken() !== 4 && r.getToken() !== 17; ) {
|
|
636
|
+
if (r.getToken() === 5) {
|
|
637
|
+
if (V || g(4, [], []), y(","), v(), r.getToken() === 4 && c)
|
|
638
|
+
break;
|
|
639
|
+
} else V && g(6, [], []);
|
|
640
|
+
P ? (s.push(0), P = !1) : s[s.length - 1]++, I() || g(4, [], [
|
|
641
|
+
4,
|
|
642
|
+
5
|
|
643
|
+
/* SyntaxKind.CommaToken */
|
|
644
|
+
]), V = !0;
|
|
645
|
+
}
|
|
646
|
+
return k(), P || s.pop(), r.getToken() !== 4 ? g(8, [
|
|
647
|
+
4
|
|
648
|
+
/* SyntaxKind.CloseBracketToken */
|
|
649
|
+
], []) : v(), !0;
|
|
650
|
+
}
|
|
651
|
+
function I() {
|
|
652
|
+
switch (r.getToken()) {
|
|
653
|
+
case 3:
|
|
654
|
+
return L();
|
|
655
|
+
case 1:
|
|
656
|
+
return w();
|
|
657
|
+
case 10:
|
|
658
|
+
return S(!0);
|
|
659
|
+
default:
|
|
660
|
+
return A();
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return v(), r.getToken() === 17 ? n.allowEmptyContent ? !0 : (g(4, [], []), !1) : I() ? (r.getToken() !== 17 && g(9, [], []), !0) : (g(4, [], []), !1);
|
|
664
|
+
}
|
|
665
|
+
const Y = Me;
|
|
666
|
+
var Ue;
|
|
667
|
+
(function(t) {
|
|
668
|
+
t[t.None = 0] = "None", t[t.UnexpectedEndOfComment = 1] = "UnexpectedEndOfComment", t[t.UnexpectedEndOfString = 2] = "UnexpectedEndOfString", t[t.UnexpectedEndOfNumber = 3] = "UnexpectedEndOfNumber", t[t.InvalidUnicode = 4] = "InvalidUnicode", t[t.InvalidEscapeCharacter = 5] = "InvalidEscapeCharacter", t[t.InvalidCharacter = 6] = "InvalidCharacter";
|
|
669
|
+
})(Ue || (Ue = {}));
|
|
670
|
+
var Re;
|
|
671
|
+
(function(t) {
|
|
672
|
+
t[t.OpenBraceToken = 1] = "OpenBraceToken", t[t.CloseBraceToken = 2] = "CloseBraceToken", t[t.OpenBracketToken = 3] = "OpenBracketToken", t[t.CloseBracketToken = 4] = "CloseBracketToken", t[t.CommaToken = 5] = "CommaToken", t[t.ColonToken = 6] = "ColonToken", t[t.NullKeyword = 7] = "NullKeyword", t[t.TrueKeyword = 8] = "TrueKeyword", t[t.FalseKeyword = 9] = "FalseKeyword", t[t.StringLiteral = 10] = "StringLiteral", t[t.NumericLiteral = 11] = "NumericLiteral", t[t.LineCommentTrivia = 12] = "LineCommentTrivia", t[t.BlockCommentTrivia = 13] = "BlockCommentTrivia", t[t.LineBreakTrivia = 14] = "LineBreakTrivia", t[t.Trivia = 15] = "Trivia", t[t.Unknown = 16] = "Unknown", t[t.EOF = 17] = "EOF";
|
|
673
|
+
})(Re || (Re = {}));
|
|
674
|
+
const kt = dt, vt = Ce, St = Ye, Tt = xe;
|
|
675
|
+
var Je;
|
|
676
|
+
(function(t) {
|
|
677
|
+
t[t.InvalidSymbol = 1] = "InvalidSymbol", t[t.InvalidNumberFormat = 2] = "InvalidNumberFormat", t[t.PropertyNameExpected = 3] = "PropertyNameExpected", t[t.ValueExpected = 4] = "ValueExpected", t[t.ColonExpected = 5] = "ColonExpected", t[t.CommaExpected = 6] = "CommaExpected", t[t.CloseBraceExpected = 7] = "CloseBraceExpected", t[t.CloseBracketExpected = 8] = "CloseBracketExpected", t[t.EndOfFileExpected = 9] = "EndOfFileExpected", t[t.InvalidCommentToken = 10] = "InvalidCommentToken", t[t.UnexpectedEndOfComment = 11] = "UnexpectedEndOfComment", t[t.UnexpectedEndOfString = 12] = "UnexpectedEndOfString", t[t.UnexpectedEndOfNumber = 13] = "UnexpectedEndOfNumber", t[t.InvalidUnicode = 14] = "InvalidUnicode", t[t.InvalidEscapeCharacter = 15] = "InvalidEscapeCharacter", t[t.InvalidCharacter = 16] = "InvalidCharacter";
|
|
678
|
+
})(Je || (Je = {}));
|
|
679
|
+
function At(t, e, n) {
|
|
680
|
+
return mt(t, e, n);
|
|
681
|
+
}
|
|
682
|
+
function ie(t, e) {
|
|
683
|
+
if (t === e)
|
|
684
|
+
return !0;
|
|
685
|
+
if (t == null || e === null || e === void 0 || typeof t != typeof e || typeof t != "object" || Array.isArray(t) !== Array.isArray(e))
|
|
686
|
+
return !1;
|
|
687
|
+
let n, r;
|
|
688
|
+
if (Array.isArray(t)) {
|
|
689
|
+
if (t.length !== e.length)
|
|
690
|
+
return !1;
|
|
691
|
+
for (n = 0; n < t.length; n++)
|
|
692
|
+
if (!ie(t[n], e[n]))
|
|
693
|
+
return !1;
|
|
694
|
+
} else {
|
|
695
|
+
const s = [];
|
|
696
|
+
for (r in t)
|
|
697
|
+
s.push(r);
|
|
698
|
+
s.sort();
|
|
699
|
+
const i = [];
|
|
700
|
+
for (r in e)
|
|
701
|
+
i.push(r);
|
|
702
|
+
if (i.sort(), !ie(s, i))
|
|
703
|
+
return !1;
|
|
704
|
+
for (n = 0; n < s.length; n++)
|
|
705
|
+
if (!ie(t[s[n]], e[s[n]]))
|
|
706
|
+
return !1;
|
|
707
|
+
}
|
|
708
|
+
return !0;
|
|
709
|
+
}
|
|
710
|
+
function D(t) {
|
|
711
|
+
return typeof t == "number";
|
|
712
|
+
}
|
|
713
|
+
function q(t) {
|
|
714
|
+
return typeof t < "u";
|
|
715
|
+
}
|
|
716
|
+
function H(t) {
|
|
717
|
+
return typeof t == "boolean";
|
|
718
|
+
}
|
|
719
|
+
function et(t) {
|
|
720
|
+
return typeof t == "string";
|
|
721
|
+
}
|
|
722
|
+
function Q(t) {
|
|
723
|
+
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
724
|
+
}
|
|
725
|
+
function Nt(t, e) {
|
|
726
|
+
if (t.length < e.length)
|
|
727
|
+
return !1;
|
|
728
|
+
for (let n = 0; n < e.length; n++)
|
|
729
|
+
if (t[n] !== e[n])
|
|
730
|
+
return !1;
|
|
731
|
+
return !0;
|
|
732
|
+
}
|
|
733
|
+
function ce(t, e) {
|
|
734
|
+
const n = t.length - e.length;
|
|
735
|
+
return n > 0 ? t.lastIndexOf(e) === n : n === 0 ? t === e : !1;
|
|
736
|
+
}
|
|
737
|
+
function be(t) {
|
|
738
|
+
let e = "";
|
|
739
|
+
Nt(t, "(?i)") && (t = t.substring(4), e = "i");
|
|
740
|
+
try {
|
|
741
|
+
return new RegExp(t, e + "u");
|
|
742
|
+
} catch {
|
|
743
|
+
try {
|
|
744
|
+
return new RegExp(t, e);
|
|
745
|
+
} catch {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
function qe(t) {
|
|
751
|
+
let e = 0;
|
|
752
|
+
for (let n = 0; n < t.length; n++) {
|
|
753
|
+
e++;
|
|
754
|
+
const r = t.charCodeAt(n);
|
|
755
|
+
55296 <= r && r <= 56319 && n++;
|
|
756
|
+
}
|
|
757
|
+
return e;
|
|
758
|
+
}
|
|
759
|
+
var O;
|
|
760
|
+
(function(t) {
|
|
761
|
+
t[t.Undefined = 0] = "Undefined", t[t.EnumValueMismatch = 1] = "EnumValueMismatch", t[t.Deprecated = 2] = "Deprecated", t[t.UnexpectedEndOfComment = 257] = "UnexpectedEndOfComment", t[t.UnexpectedEndOfString = 258] = "UnexpectedEndOfString", t[t.UnexpectedEndOfNumber = 259] = "UnexpectedEndOfNumber", t[t.InvalidUnicode = 260] = "InvalidUnicode", t[t.InvalidEscapeCharacter = 261] = "InvalidEscapeCharacter", t[t.InvalidCharacter = 262] = "InvalidCharacter", t[t.PropertyExpected = 513] = "PropertyExpected", t[t.CommaExpected = 514] = "CommaExpected", t[t.ColonExpected = 515] = "ColonExpected", t[t.ValueExpected = 516] = "ValueExpected", t[t.CommaOrCloseBacketExpected = 517] = "CommaOrCloseBacketExpected", t[t.CommaOrCloseBraceExpected = 518] = "CommaOrCloseBraceExpected", t[t.TrailingComma = 519] = "TrailingComma", t[t.DuplicateKey = 520] = "DuplicateKey", t[t.CommentNotPermitted = 521] = "CommentNotPermitted", t[t.PropertyKeysMustBeDoublequoted = 528] = "PropertyKeysMustBeDoublequoted", t[t.SchemaResolveError = 768] = "SchemaResolveError", t[t.SchemaUnsupportedFeature = 769] = "SchemaUnsupportedFeature";
|
|
762
|
+
})(O || (O = {}));
|
|
763
|
+
var W;
|
|
764
|
+
(function(t) {
|
|
765
|
+
t[t.v3 = 3] = "v3", t[t.v4 = 4] = "v4", t[t.v6 = 6] = "v6", t[t.v7 = 7] = "v7", t[t.v2019_09 = 19] = "v2019_09", t[t.v2020_12 = 20] = "v2020_12";
|
|
766
|
+
})(W || (W = {}));
|
|
767
|
+
var we;
|
|
768
|
+
(function(t) {
|
|
769
|
+
t.LATEST = {
|
|
770
|
+
textDocument: {
|
|
771
|
+
completion: {
|
|
772
|
+
completionItem: {
|
|
773
|
+
documentationFormat: [de.Markdown, de.PlainText],
|
|
774
|
+
commitCharactersSupport: !0,
|
|
775
|
+
labelDetailsSupport: !0
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
})(we || (we = {}));
|
|
781
|
+
const xt = {
|
|
782
|
+
"color-hex": { errorMessage: b("Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA."), pattern: /^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$/ },
|
|
783
|
+
"date-time": { errorMessage: b("String is not a RFC3339 date-time."), pattern: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i },
|
|
784
|
+
date: { errorMessage: b("String is not a RFC3339 date."), pattern: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/i },
|
|
785
|
+
time: { errorMessage: b("String is not a RFC3339 time."), pattern: /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i },
|
|
786
|
+
email: { errorMessage: b("String is not an e-mail address."), pattern: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}))$/ },
|
|
787
|
+
hostname: { errorMessage: b("String is not a hostname."), pattern: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i },
|
|
788
|
+
ipv4: { errorMessage: b("String is not an IPv4 address."), pattern: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/ },
|
|
789
|
+
ipv6: { errorMessage: b("String is not an IPv6 address."), pattern: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i }
|
|
790
|
+
};
|
|
791
|
+
class ee {
|
|
792
|
+
constructor(e, n, r = 0) {
|
|
793
|
+
this.offset = n, this.length = r, this.parent = e;
|
|
794
|
+
}
|
|
795
|
+
get children() {
|
|
796
|
+
return [];
|
|
797
|
+
}
|
|
798
|
+
toString() {
|
|
799
|
+
return "type: " + this.type + " (" + this.offset + "/" + this.length + ")" + (this.parent ? " parent: {" + this.parent.toString() + "}" : "");
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
class wt extends ee {
|
|
803
|
+
constructor(e, n) {
|
|
804
|
+
super(e, n), this.type = "null", this.value = null;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
class We extends ee {
|
|
808
|
+
constructor(e, n, r) {
|
|
809
|
+
super(e, r), this.type = "boolean", this.value = n;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
class Ot extends ee {
|
|
813
|
+
constructor(e, n) {
|
|
814
|
+
super(e, n), this.type = "array", this.items = [];
|
|
815
|
+
}
|
|
816
|
+
get children() {
|
|
817
|
+
return this.items;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
class Pt extends ee {
|
|
821
|
+
constructor(e, n) {
|
|
822
|
+
super(e, n), this.type = "number", this.isInteger = !0, this.value = Number.NaN;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
class Te extends ee {
|
|
826
|
+
constructor(e, n, r) {
|
|
827
|
+
super(e, n, r), this.type = "string", this.value = "";
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
class It extends ee {
|
|
831
|
+
constructor(e, n, r) {
|
|
832
|
+
super(e, n), this.type = "property", this.colonOffset = -1, this.keyNode = r;
|
|
833
|
+
}
|
|
834
|
+
get children() {
|
|
835
|
+
return this.valueNode ? [this.keyNode, this.valueNode] : [this.keyNode];
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
class Lt extends ee {
|
|
839
|
+
constructor(e, n) {
|
|
840
|
+
super(e, n), this.type = "object", this.properties = [];
|
|
841
|
+
}
|
|
842
|
+
get children() {
|
|
843
|
+
return this.properties;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
function B(t) {
|
|
847
|
+
return H(t) ? t ? {} : { not: {} } : t;
|
|
848
|
+
}
|
|
849
|
+
var ze;
|
|
850
|
+
(function(t) {
|
|
851
|
+
t[t.Key = 0] = "Key", t[t.Enum = 1] = "Enum";
|
|
852
|
+
})(ze || (ze = {}));
|
|
853
|
+
const Vt = {
|
|
854
|
+
"http://json-schema.org/draft-03/schema#": W.v3,
|
|
855
|
+
"http://json-schema.org/draft-04/schema#": W.v4,
|
|
856
|
+
"http://json-schema.org/draft-06/schema#": W.v6,
|
|
857
|
+
"http://json-schema.org/draft-07/schema#": W.v7,
|
|
858
|
+
"https://json-schema.org/draft/2019-09/schema": W.v2019_09,
|
|
859
|
+
"https://json-schema.org/draft/2020-12/schema": W.v2020_12
|
|
860
|
+
};
|
|
861
|
+
class He {
|
|
862
|
+
constructor(e) {
|
|
863
|
+
this.schemaDraft = e;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
class Fe {
|
|
867
|
+
constructor(e = -1, n) {
|
|
868
|
+
this.focusOffset = e, this.exclude = n, this.schemas = [];
|
|
869
|
+
}
|
|
870
|
+
add(e) {
|
|
871
|
+
this.schemas.push(e);
|
|
872
|
+
}
|
|
873
|
+
merge(e) {
|
|
874
|
+
Array.prototype.push.apply(this.schemas, e.schemas);
|
|
875
|
+
}
|
|
876
|
+
include(e) {
|
|
877
|
+
return (this.focusOffset === -1 || tt(e, this.focusOffset)) && e !== this.exclude;
|
|
878
|
+
}
|
|
879
|
+
newSub() {
|
|
880
|
+
return new Fe(-1, this.exclude);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
class ue {
|
|
884
|
+
constructor() {
|
|
885
|
+
}
|
|
886
|
+
get schemas() {
|
|
887
|
+
return [];
|
|
888
|
+
}
|
|
889
|
+
add(e) {
|
|
890
|
+
}
|
|
891
|
+
merge(e) {
|
|
892
|
+
}
|
|
893
|
+
include(e) {
|
|
894
|
+
return !0;
|
|
895
|
+
}
|
|
896
|
+
newSub() {
|
|
897
|
+
return this;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
ue.instance = new ue();
|
|
901
|
+
class _ {
|
|
902
|
+
constructor() {
|
|
903
|
+
this.problems = [], this.propertiesMatches = 0, this.processedProperties = /* @__PURE__ */ new Set(), this.propertiesValueMatches = 0, this.primaryValueMatches = 0, this.enumValueMatch = !1, this.enumValues = void 0;
|
|
904
|
+
}
|
|
905
|
+
hasProblems() {
|
|
906
|
+
return !!this.problems.length;
|
|
907
|
+
}
|
|
908
|
+
merge(e) {
|
|
909
|
+
this.problems = this.problems.concat(e.problems), this.propertiesMatches += e.propertiesMatches, this.propertiesValueMatches += e.propertiesValueMatches, this.mergeProcessedProperties(e);
|
|
910
|
+
}
|
|
911
|
+
mergeEnumValues(e) {
|
|
912
|
+
if (!this.enumValueMatch && !e.enumValueMatch && this.enumValues && e.enumValues) {
|
|
913
|
+
this.enumValues = this.enumValues.concat(e.enumValues);
|
|
914
|
+
for (const n of this.problems)
|
|
915
|
+
n.code === O.EnumValueMismatch && (n.message = b("Value is not accepted. Valid values: {0}.", this.enumValues.map((r) => JSON.stringify(r)).join(", ")));
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
mergePropertyMatch(e) {
|
|
919
|
+
this.problems = this.problems.concat(e.problems), this.propertiesMatches++, (e.enumValueMatch || !e.hasProblems() && e.propertiesMatches) && this.propertiesValueMatches++, e.enumValueMatch && e.enumValues && e.enumValues.length === 1 && this.primaryValueMatches++;
|
|
920
|
+
}
|
|
921
|
+
mergeProcessedProperties(e) {
|
|
922
|
+
e.processedProperties.forEach((n) => this.processedProperties.add(n));
|
|
923
|
+
}
|
|
924
|
+
compare(e) {
|
|
925
|
+
const n = this.hasProblems();
|
|
926
|
+
return n !== e.hasProblems() ? n ? -1 : 1 : this.enumValueMatch !== e.enumValueMatch ? e.enumValueMatch ? -1 : 1 : this.primaryValueMatches !== e.primaryValueMatches ? this.primaryValueMatches - e.primaryValueMatches : this.propertiesValueMatches !== e.propertiesValueMatches ? this.propertiesValueMatches - e.propertiesValueMatches : this.propertiesMatches - e.propertiesMatches;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
function Mt(t, e = []) {
|
|
930
|
+
return new nt(t, e, []);
|
|
931
|
+
}
|
|
932
|
+
function C(t) {
|
|
933
|
+
return Tt(t);
|
|
934
|
+
}
|
|
935
|
+
function Oe(t) {
|
|
936
|
+
return St(t);
|
|
937
|
+
}
|
|
938
|
+
function tt(t, e, n = !1) {
|
|
939
|
+
return e >= t.offset && e < t.offset + t.length || n && e === t.offset + t.length;
|
|
940
|
+
}
|
|
941
|
+
class nt {
|
|
942
|
+
constructor(e, n = [], r = []) {
|
|
943
|
+
this.root = e, this.syntaxErrors = n, this.comments = r;
|
|
944
|
+
}
|
|
945
|
+
getNodeFromOffset(e, n = !1) {
|
|
946
|
+
if (this.root)
|
|
947
|
+
return vt(this.root, e, n);
|
|
948
|
+
}
|
|
949
|
+
visit(e) {
|
|
950
|
+
if (this.root) {
|
|
951
|
+
const n = (r) => {
|
|
952
|
+
let s = e(r);
|
|
953
|
+
const i = r.children;
|
|
954
|
+
if (Array.isArray(i))
|
|
955
|
+
for (let a = 0; a < i.length && s; a++)
|
|
956
|
+
s = n(i[a]);
|
|
957
|
+
return s;
|
|
958
|
+
};
|
|
959
|
+
n(this.root);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
validate(e, n, r = z.Warning, s) {
|
|
963
|
+
if (this.root && n) {
|
|
964
|
+
const i = new _();
|
|
965
|
+
return j(this.root, n, i, ue.instance, new He(s ?? Ke(n))), i.problems.map((a) => {
|
|
966
|
+
const o = $.create(e.positionAt(a.location.offset), e.positionAt(a.location.offset + a.location.length));
|
|
967
|
+
return fe.create(o, a.message, a.severity ?? r, a.code);
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
getMatchingSchemas(e, n = -1, r) {
|
|
972
|
+
if (this.root && e) {
|
|
973
|
+
const s = new Fe(n, r), i = Ke(e), a = new He(i);
|
|
974
|
+
return j(this.root, e, new _(), s, a), s.schemas;
|
|
975
|
+
}
|
|
976
|
+
return [];
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
function Ke(t, e = W.v2020_12) {
|
|
980
|
+
let n = t.$schema;
|
|
981
|
+
return n ? Vt[n] ?? e : e;
|
|
982
|
+
}
|
|
983
|
+
function j(t, e, n, r, s) {
|
|
984
|
+
if (!t || !r.include(t))
|
|
985
|
+
return;
|
|
986
|
+
if (t.type === "property")
|
|
987
|
+
return j(t.valueNode, e, n, r, s);
|
|
988
|
+
const i = t;
|
|
989
|
+
switch (a(), i.type) {
|
|
990
|
+
case "object":
|
|
991
|
+
h(i);
|
|
992
|
+
break;
|
|
993
|
+
case "array":
|
|
994
|
+
f(i);
|
|
995
|
+
break;
|
|
996
|
+
case "string":
|
|
997
|
+
m(i);
|
|
998
|
+
break;
|
|
999
|
+
case "number":
|
|
1000
|
+
o(i);
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
r.add({ node: i, schema: e });
|
|
1004
|
+
function a() {
|
|
1005
|
+
var N;
|
|
1006
|
+
function l(c) {
|
|
1007
|
+
return i.type === c || c === "integer" && i.type === "number" && i.isInteger;
|
|
1008
|
+
}
|
|
1009
|
+
if (Array.isArray(e.type) ? e.type.some(l) || n.problems.push({
|
|
1010
|
+
location: { offset: i.offset, length: i.length },
|
|
1011
|
+
message: e.errorMessage || b("Incorrect type. Expected one of {0}.", e.type.join(", "))
|
|
1012
|
+
}) : e.type && (l(e.type) || n.problems.push({
|
|
1013
|
+
location: { offset: i.offset, length: i.length },
|
|
1014
|
+
message: e.errorMessage || b('Incorrect type. Expected "{0}".', e.type)
|
|
1015
|
+
})), Array.isArray(e.allOf))
|
|
1016
|
+
for (const c of e.allOf) {
|
|
1017
|
+
const v = new _(), g = r.newSub();
|
|
1018
|
+
j(i, B(c), v, g, s), n.merge(v), r.merge(g);
|
|
1019
|
+
}
|
|
1020
|
+
const u = B(e.not);
|
|
1021
|
+
if (u) {
|
|
1022
|
+
const c = new _(), v = r.newSub();
|
|
1023
|
+
j(i, u, c, v, s), c.hasProblems() || n.problems.push({
|
|
1024
|
+
location: { offset: i.offset, length: i.length },
|
|
1025
|
+
message: e.errorMessage || b("Matches a schema that is not allowed.")
|
|
1026
|
+
});
|
|
1027
|
+
for (const g of v.schemas)
|
|
1028
|
+
g.inverted = !g.inverted, r.add(g);
|
|
1029
|
+
}
|
|
1030
|
+
const k = (c, v) => {
|
|
1031
|
+
const g = [];
|
|
1032
|
+
let S;
|
|
1033
|
+
for (const A of c) {
|
|
1034
|
+
const x = B(A), w = new _(), L = r.newSub();
|
|
1035
|
+
if (j(i, x, w, L, s), w.hasProblems() || g.push(x), !S)
|
|
1036
|
+
S = { schema: x, validationResult: w, matchingSchemas: L };
|
|
1037
|
+
else if (!v && !w.hasProblems() && !S.validationResult.hasProblems())
|
|
1038
|
+
S.matchingSchemas.merge(L), S.validationResult.propertiesMatches += w.propertiesMatches, S.validationResult.propertiesValueMatches += w.propertiesValueMatches, S.validationResult.mergeProcessedProperties(w);
|
|
1039
|
+
else {
|
|
1040
|
+
const I = w.compare(S.validationResult);
|
|
1041
|
+
I > 0 ? S = { schema: x, validationResult: w, matchingSchemas: L } : I === 0 && (S.matchingSchemas.merge(L), S.validationResult.mergeEnumValues(w));
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return g.length > 1 && v && n.problems.push({
|
|
1045
|
+
location: { offset: i.offset, length: 1 },
|
|
1046
|
+
message: b("Matches multiple schemas when only one must validate.")
|
|
1047
|
+
}), S && (n.merge(S.validationResult), r.merge(S.matchingSchemas)), g.length;
|
|
1048
|
+
};
|
|
1049
|
+
Array.isArray(e.anyOf) && k(e.anyOf, !1), Array.isArray(e.oneOf) && k(e.oneOf, !0);
|
|
1050
|
+
const p = (c) => {
|
|
1051
|
+
const v = new _(), g = r.newSub();
|
|
1052
|
+
j(i, B(c), v, g, s), n.merge(v), r.merge(g);
|
|
1053
|
+
}, y = (c, v, g) => {
|
|
1054
|
+
const S = B(c), A = new _(), x = r.newSub();
|
|
1055
|
+
j(i, S, A, x, s), r.merge(x), n.mergeProcessedProperties(A), A.hasProblems() ? g && p(g) : v && p(v);
|
|
1056
|
+
}, d = B(e.if);
|
|
1057
|
+
if (d && y(d, B(e.then), B(e.else)), Array.isArray(e.enum)) {
|
|
1058
|
+
const c = C(i);
|
|
1059
|
+
let v = !1;
|
|
1060
|
+
for (const g of e.enum)
|
|
1061
|
+
if (ie(c, g)) {
|
|
1062
|
+
v = !0;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
n.enumValues = e.enum, n.enumValueMatch = v, v || n.problems.push({
|
|
1066
|
+
location: { offset: i.offset, length: i.length },
|
|
1067
|
+
code: O.EnumValueMismatch,
|
|
1068
|
+
message: e.errorMessage || b("Value is not accepted. Valid values: {0}.", e.enum.map((g) => JSON.stringify(g)).join(", "))
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
if (q(e.const)) {
|
|
1072
|
+
const c = C(i);
|
|
1073
|
+
ie(c, e.const) ? n.enumValueMatch = !0 : (n.problems.push({
|
|
1074
|
+
location: { offset: i.offset, length: i.length },
|
|
1075
|
+
code: O.EnumValueMismatch,
|
|
1076
|
+
message: e.errorMessage || b("Value must be {0}.", JSON.stringify(e.const))
|
|
1077
|
+
}), n.enumValueMatch = !1), n.enumValues = [e.const];
|
|
1078
|
+
}
|
|
1079
|
+
let T = e.deprecationMessage;
|
|
1080
|
+
if (T || e.deprecated) {
|
|
1081
|
+
T = T || b("Value is deprecated");
|
|
1082
|
+
let c = ((N = i.parent) == null ? void 0 : N.type) === "property" ? i.parent : i;
|
|
1083
|
+
n.problems.push({
|
|
1084
|
+
location: { offset: c.offset, length: c.length },
|
|
1085
|
+
severity: z.Warning,
|
|
1086
|
+
message: T,
|
|
1087
|
+
code: O.Deprecated
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function o(l) {
|
|
1092
|
+
const u = l.value;
|
|
1093
|
+
function k(v) {
|
|
1094
|
+
var S;
|
|
1095
|
+
const g = /^(-?\d+)(?:\.(\d+))?(?:e([-+]\d+))?$/.exec(v.toString());
|
|
1096
|
+
return g && {
|
|
1097
|
+
value: Number(g[1] + (g[2] || "")),
|
|
1098
|
+
multiplier: (((S = g[2]) == null ? void 0 : S.length) || 0) - (parseInt(g[3]) || 0)
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
if (D(e.multipleOf)) {
|
|
1102
|
+
let v = -1;
|
|
1103
|
+
if (Number.isInteger(e.multipleOf))
|
|
1104
|
+
v = u % e.multipleOf;
|
|
1105
|
+
else {
|
|
1106
|
+
let g = k(e.multipleOf), S = k(u);
|
|
1107
|
+
if (g && S) {
|
|
1108
|
+
const A = 10 ** Math.abs(S.multiplier - g.multiplier);
|
|
1109
|
+
S.multiplier < g.multiplier ? S.value *= A : g.value *= A, v = S.value % g.value;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
v !== 0 && n.problems.push({
|
|
1113
|
+
location: { offset: l.offset, length: l.length },
|
|
1114
|
+
message: b("Value is not divisible by {0}.", e.multipleOf)
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
function p(v, g) {
|
|
1118
|
+
if (D(g))
|
|
1119
|
+
return g;
|
|
1120
|
+
if (H(g) && g)
|
|
1121
|
+
return v;
|
|
1122
|
+
}
|
|
1123
|
+
function y(v, g) {
|
|
1124
|
+
if (!H(g) || !g)
|
|
1125
|
+
return v;
|
|
1126
|
+
}
|
|
1127
|
+
const d = p(e.minimum, e.exclusiveMinimum);
|
|
1128
|
+
D(d) && u <= d && n.problems.push({
|
|
1129
|
+
location: { offset: l.offset, length: l.length },
|
|
1130
|
+
message: b("Value is below the exclusive minimum of {0}.", d)
|
|
1131
|
+
});
|
|
1132
|
+
const T = p(e.maximum, e.exclusiveMaximum);
|
|
1133
|
+
D(T) && u >= T && n.problems.push({
|
|
1134
|
+
location: { offset: l.offset, length: l.length },
|
|
1135
|
+
message: b("Value is above the exclusive maximum of {0}.", T)
|
|
1136
|
+
});
|
|
1137
|
+
const N = y(e.minimum, e.exclusiveMinimum);
|
|
1138
|
+
D(N) && u < N && n.problems.push({
|
|
1139
|
+
location: { offset: l.offset, length: l.length },
|
|
1140
|
+
message: b("Value is below the minimum of {0}.", N)
|
|
1141
|
+
});
|
|
1142
|
+
const c = y(e.maximum, e.exclusiveMaximum);
|
|
1143
|
+
D(c) && u > c && n.problems.push({
|
|
1144
|
+
location: { offset: l.offset, length: l.length },
|
|
1145
|
+
message: b("Value is above the maximum of {0}.", c)
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
function m(l) {
|
|
1149
|
+
if (D(e.minLength) && qe(l.value) < e.minLength && n.problems.push({
|
|
1150
|
+
location: { offset: l.offset, length: l.length },
|
|
1151
|
+
message: b("String is shorter than the minimum length of {0}.", e.minLength)
|
|
1152
|
+
}), D(e.maxLength) && qe(l.value) > e.maxLength && n.problems.push({
|
|
1153
|
+
location: { offset: l.offset, length: l.length },
|
|
1154
|
+
message: b("String is longer than the maximum length of {0}.", e.maxLength)
|
|
1155
|
+
}), et(e.pattern)) {
|
|
1156
|
+
const u = be(e.pattern);
|
|
1157
|
+
u != null && u.test(l.value) || n.problems.push({
|
|
1158
|
+
location: { offset: l.offset, length: l.length },
|
|
1159
|
+
message: e.patternErrorMessage || e.errorMessage || b('String does not match the pattern of "{0}".', e.pattern)
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
if (e.format)
|
|
1163
|
+
switch (e.format) {
|
|
1164
|
+
case "uri":
|
|
1165
|
+
case "uri-reference":
|
|
1166
|
+
{
|
|
1167
|
+
let k;
|
|
1168
|
+
if (!l.value)
|
|
1169
|
+
k = b("URI expected.");
|
|
1170
|
+
else {
|
|
1171
|
+
const p = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/.exec(l.value);
|
|
1172
|
+
p ? !p[2] && e.format === "uri" && (k = b("URI with a scheme is expected.")) : k = b("URI is expected.");
|
|
1173
|
+
}
|
|
1174
|
+
k && n.problems.push({
|
|
1175
|
+
location: { offset: l.offset, length: l.length },
|
|
1176
|
+
message: e.patternErrorMessage || e.errorMessage || b("String is not a URI: {0}", k)
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
break;
|
|
1180
|
+
case "color-hex":
|
|
1181
|
+
case "date-time":
|
|
1182
|
+
case "date":
|
|
1183
|
+
case "time":
|
|
1184
|
+
case "email":
|
|
1185
|
+
case "hostname":
|
|
1186
|
+
case "ipv4":
|
|
1187
|
+
case "ipv6":
|
|
1188
|
+
const u = xt[e.format];
|
|
1189
|
+
(!l.value || !u.pattern.exec(l.value)) && n.problems.push({
|
|
1190
|
+
location: { offset: l.offset, length: l.length },
|
|
1191
|
+
message: e.patternErrorMessage || e.errorMessage || u.errorMessage
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
function f(l) {
|
|
1196
|
+
let u, k;
|
|
1197
|
+
s.schemaDraft >= W.v2020_12 ? (u = e.prefixItems, k = Array.isArray(e.items) ? void 0 : e.items) : (u = Array.isArray(e.items) ? e.items : void 0, k = Array.isArray(e.items) ? e.additionalItems : e.items);
|
|
1198
|
+
let p = 0;
|
|
1199
|
+
if (u !== void 0) {
|
|
1200
|
+
const T = Math.min(u.length, l.items.length);
|
|
1201
|
+
for (; p < T; p++) {
|
|
1202
|
+
const N = u[p], c = B(N), v = new _(), g = l.items[p];
|
|
1203
|
+
g && (j(g, c, v, r, s), n.mergePropertyMatch(v)), n.processedProperties.add(String(p));
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (k !== void 0 && p < l.items.length)
|
|
1207
|
+
if (typeof k == "boolean")
|
|
1208
|
+
for (k === !1 && n.problems.push({
|
|
1209
|
+
location: { offset: l.offset, length: l.length },
|
|
1210
|
+
message: b("Array has too many items according to schema. Expected {0} or fewer.", p)
|
|
1211
|
+
}); p < l.items.length; p++)
|
|
1212
|
+
n.processedProperties.add(String(p)), n.propertiesValueMatches++;
|
|
1213
|
+
else
|
|
1214
|
+
for (; p < l.items.length; p++) {
|
|
1215
|
+
const T = new _();
|
|
1216
|
+
j(l.items[p], k, T, r, s), n.mergePropertyMatch(T), n.processedProperties.add(String(p));
|
|
1217
|
+
}
|
|
1218
|
+
const y = B(e.contains);
|
|
1219
|
+
if (y) {
|
|
1220
|
+
let T = 0;
|
|
1221
|
+
for (let N = 0; N < l.items.length; N++) {
|
|
1222
|
+
const c = l.items[N], v = new _();
|
|
1223
|
+
j(c, y, v, ue.instance, s), v.hasProblems() || (T++, s.schemaDraft >= W.v2020_12 && n.processedProperties.add(String(N)));
|
|
1224
|
+
}
|
|
1225
|
+
T === 0 && !D(e.minContains) && n.problems.push({
|
|
1226
|
+
location: { offset: l.offset, length: l.length },
|
|
1227
|
+
message: e.errorMessage || b("Array does not contain required item.")
|
|
1228
|
+
}), D(e.minContains) && T < e.minContains && n.problems.push({
|
|
1229
|
+
location: { offset: l.offset, length: l.length },
|
|
1230
|
+
message: e.errorMessage || b("Array has too few items that match the contains contraint. Expected {0} or more.", e.minContains)
|
|
1231
|
+
}), D(e.maxContains) && T > e.maxContains && n.problems.push({
|
|
1232
|
+
location: { offset: l.offset, length: l.length },
|
|
1233
|
+
message: e.errorMessage || b("Array has too many items that match the contains contraint. Expected {0} or less.", e.maxContains)
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
const d = e.unevaluatedItems;
|
|
1237
|
+
if (d !== void 0)
|
|
1238
|
+
for (let T = 0; T < l.items.length; T++) {
|
|
1239
|
+
if (!n.processedProperties.has(String(T)))
|
|
1240
|
+
if (d === !1)
|
|
1241
|
+
n.problems.push({
|
|
1242
|
+
location: { offset: l.offset, length: l.length },
|
|
1243
|
+
message: b("Item does not match any validation rule from the array.")
|
|
1244
|
+
});
|
|
1245
|
+
else {
|
|
1246
|
+
const N = new _();
|
|
1247
|
+
j(l.items[T], e.unevaluatedItems, N, r, s), n.mergePropertyMatch(N);
|
|
1248
|
+
}
|
|
1249
|
+
n.processedProperties.add(String(T)), n.propertiesValueMatches++;
|
|
1250
|
+
}
|
|
1251
|
+
if (D(e.minItems) && l.items.length < e.minItems && n.problems.push({
|
|
1252
|
+
location: { offset: l.offset, length: l.length },
|
|
1253
|
+
message: b("Array has too few items. Expected {0} or more.", e.minItems)
|
|
1254
|
+
}), D(e.maxItems) && l.items.length > e.maxItems && n.problems.push({
|
|
1255
|
+
location: { offset: l.offset, length: l.length },
|
|
1256
|
+
message: b("Array has too many items. Expected {0} or fewer.", e.maxItems)
|
|
1257
|
+
}), e.uniqueItems === !0) {
|
|
1258
|
+
let N = function() {
|
|
1259
|
+
for (let c = 0; c < T.length - 1; c++) {
|
|
1260
|
+
const v = T[c];
|
|
1261
|
+
for (let g = c + 1; g < T.length; g++)
|
|
1262
|
+
if (ie(v, T[g]))
|
|
1263
|
+
return !0;
|
|
1264
|
+
}
|
|
1265
|
+
return !1;
|
|
1266
|
+
};
|
|
1267
|
+
const T = C(l);
|
|
1268
|
+
N() && n.problems.push({
|
|
1269
|
+
location: { offset: l.offset, length: l.length },
|
|
1270
|
+
message: b("Array has duplicate items.")
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
function h(l) {
|
|
1275
|
+
const u = /* @__PURE__ */ Object.create(null), k = /* @__PURE__ */ new Set();
|
|
1276
|
+
for (const c of l.properties) {
|
|
1277
|
+
const v = c.keyNode.value;
|
|
1278
|
+
u[v] = c.valueNode, k.add(v);
|
|
1279
|
+
}
|
|
1280
|
+
if (Array.isArray(e.required)) {
|
|
1281
|
+
for (const c of e.required)
|
|
1282
|
+
if (!u[c]) {
|
|
1283
|
+
const v = l.parent && l.parent.type === "property" && l.parent.keyNode, g = v ? { offset: v.offset, length: v.length } : { offset: l.offset, length: 1 };
|
|
1284
|
+
n.problems.push({
|
|
1285
|
+
location: g,
|
|
1286
|
+
message: b('Missing property "{0}".', c)
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
const p = (c) => {
|
|
1291
|
+
k.delete(c), n.processedProperties.add(c);
|
|
1292
|
+
};
|
|
1293
|
+
if (e.properties)
|
|
1294
|
+
for (const c of Object.keys(e.properties)) {
|
|
1295
|
+
p(c);
|
|
1296
|
+
const v = e.properties[c], g = u[c];
|
|
1297
|
+
if (g)
|
|
1298
|
+
if (H(v))
|
|
1299
|
+
if (v)
|
|
1300
|
+
n.propertiesMatches++, n.propertiesValueMatches++;
|
|
1301
|
+
else {
|
|
1302
|
+
const S = g.parent;
|
|
1303
|
+
n.problems.push({
|
|
1304
|
+
location: { offset: S.keyNode.offset, length: S.keyNode.length },
|
|
1305
|
+
message: e.errorMessage || b("Property {0} is not allowed.", c)
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
else {
|
|
1309
|
+
const S = new _();
|
|
1310
|
+
j(g, v, S, r, s), n.mergePropertyMatch(S);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (e.patternProperties)
|
|
1314
|
+
for (const c of Object.keys(e.patternProperties)) {
|
|
1315
|
+
const v = be(c);
|
|
1316
|
+
if (v) {
|
|
1317
|
+
const g = [];
|
|
1318
|
+
for (const S of k)
|
|
1319
|
+
if (v.test(S)) {
|
|
1320
|
+
g.push(S);
|
|
1321
|
+
const A = u[S];
|
|
1322
|
+
if (A) {
|
|
1323
|
+
const x = e.patternProperties[c];
|
|
1324
|
+
if (H(x))
|
|
1325
|
+
if (x)
|
|
1326
|
+
n.propertiesMatches++, n.propertiesValueMatches++;
|
|
1327
|
+
else {
|
|
1328
|
+
const w = A.parent;
|
|
1329
|
+
n.problems.push({
|
|
1330
|
+
location: { offset: w.keyNode.offset, length: w.keyNode.length },
|
|
1331
|
+
message: e.errorMessage || b("Property {0} is not allowed.", S)
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
else {
|
|
1335
|
+
const w = new _();
|
|
1336
|
+
j(A, x, w, r, s), n.mergePropertyMatch(w);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
g.forEach(p);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
const y = e.additionalProperties;
|
|
1344
|
+
if (y !== void 0)
|
|
1345
|
+
for (const c of k) {
|
|
1346
|
+
p(c);
|
|
1347
|
+
const v = u[c];
|
|
1348
|
+
if (v) {
|
|
1349
|
+
if (y === !1) {
|
|
1350
|
+
const g = v.parent;
|
|
1351
|
+
n.problems.push({
|
|
1352
|
+
location: { offset: g.keyNode.offset, length: g.keyNode.length },
|
|
1353
|
+
message: e.errorMessage || b("Property {0} is not allowed.", c)
|
|
1354
|
+
});
|
|
1355
|
+
} else if (y !== !0) {
|
|
1356
|
+
const g = new _();
|
|
1357
|
+
j(v, y, g, r, s), n.mergePropertyMatch(g);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
const d = e.unevaluatedProperties;
|
|
1362
|
+
if (d !== void 0) {
|
|
1363
|
+
const c = [];
|
|
1364
|
+
for (const v of k)
|
|
1365
|
+
if (!n.processedProperties.has(v)) {
|
|
1366
|
+
c.push(v);
|
|
1367
|
+
const g = u[v];
|
|
1368
|
+
if (g) {
|
|
1369
|
+
if (d === !1) {
|
|
1370
|
+
const S = g.parent;
|
|
1371
|
+
n.problems.push({
|
|
1372
|
+
location: { offset: S.keyNode.offset, length: S.keyNode.length },
|
|
1373
|
+
message: e.errorMessage || b("Property {0} is not allowed.", v)
|
|
1374
|
+
});
|
|
1375
|
+
} else if (d !== !0) {
|
|
1376
|
+
const S = new _();
|
|
1377
|
+
j(g, d, S, r, s), n.mergePropertyMatch(S);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
c.forEach(p);
|
|
1382
|
+
}
|
|
1383
|
+
if (D(e.maxProperties) && l.properties.length > e.maxProperties && n.problems.push({
|
|
1384
|
+
location: { offset: l.offset, length: l.length },
|
|
1385
|
+
message: b("Object has more properties than limit of {0}.", e.maxProperties)
|
|
1386
|
+
}), D(e.minProperties) && l.properties.length < e.minProperties && n.problems.push({
|
|
1387
|
+
location: { offset: l.offset, length: l.length },
|
|
1388
|
+
message: b("Object has fewer properties than the required number of {0}", e.minProperties)
|
|
1389
|
+
}), e.dependentRequired)
|
|
1390
|
+
for (const c in e.dependentRequired) {
|
|
1391
|
+
const v = u[c], g = e.dependentRequired[c];
|
|
1392
|
+
v && Array.isArray(g) && N(c, g);
|
|
1393
|
+
}
|
|
1394
|
+
if (e.dependentSchemas)
|
|
1395
|
+
for (const c in e.dependentSchemas) {
|
|
1396
|
+
const v = u[c], g = e.dependentSchemas[c];
|
|
1397
|
+
v && Q(g) && N(c, g);
|
|
1398
|
+
}
|
|
1399
|
+
if (e.dependencies)
|
|
1400
|
+
for (const c in e.dependencies)
|
|
1401
|
+
u[c] && N(c, e.dependencies[c]);
|
|
1402
|
+
const T = B(e.propertyNames);
|
|
1403
|
+
if (T)
|
|
1404
|
+
for (const c of l.properties) {
|
|
1405
|
+
const v = c.keyNode;
|
|
1406
|
+
v && j(v, T, n, ue.instance, s);
|
|
1407
|
+
}
|
|
1408
|
+
function N(c, v) {
|
|
1409
|
+
if (Array.isArray(v))
|
|
1410
|
+
for (const g of v)
|
|
1411
|
+
u[g] ? n.propertiesValueMatches++ : n.problems.push({
|
|
1412
|
+
location: { offset: l.offset, length: l.length },
|
|
1413
|
+
message: b("Object is missing property {0} required by property {1}.", g, c)
|
|
1414
|
+
});
|
|
1415
|
+
else {
|
|
1416
|
+
const g = B(v);
|
|
1417
|
+
if (g) {
|
|
1418
|
+
const S = new _();
|
|
1419
|
+
j(l, g, S, r, s), n.mergePropertyMatch(S);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
function Ft(t, e) {
|
|
1426
|
+
const n = [];
|
|
1427
|
+
let r = -1;
|
|
1428
|
+
const s = t.getText(), i = Y(s, !1), a = e && e.collectComments ? [] : void 0;
|
|
1429
|
+
function o() {
|
|
1430
|
+
for (; ; ) {
|
|
1431
|
+
const S = i.scan();
|
|
1432
|
+
switch (h(), S) {
|
|
1433
|
+
case 12:
|
|
1434
|
+
case 13:
|
|
1435
|
+
Array.isArray(a) && a.push($.create(t.positionAt(i.getTokenOffset()), t.positionAt(i.getTokenOffset() + i.getTokenLength())));
|
|
1436
|
+
break;
|
|
1437
|
+
case 15:
|
|
1438
|
+
case 14:
|
|
1439
|
+
break;
|
|
1440
|
+
default:
|
|
1441
|
+
return S;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
function m(S, A, x, w, L = z.Error) {
|
|
1446
|
+
if (n.length === 0 || x !== r) {
|
|
1447
|
+
const I = $.create(t.positionAt(x), t.positionAt(w));
|
|
1448
|
+
n.push(fe.create(I, S, L, A, t.languageId)), r = x;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
function f(S, A, x = void 0, w = [], L = []) {
|
|
1452
|
+
let I = i.getTokenOffset(), P = i.getTokenOffset() + i.getTokenLength();
|
|
1453
|
+
if (I === P && I > 0) {
|
|
1454
|
+
for (I--; I > 0 && /\s/.test(s.charAt(I)); )
|
|
1455
|
+
I--;
|
|
1456
|
+
P = I + 1;
|
|
1457
|
+
}
|
|
1458
|
+
if (m(S, A, I, P), x && l(x, !1), w.length + L.length > 0) {
|
|
1459
|
+
let V = i.getToken();
|
|
1460
|
+
for (; V !== 17; ) {
|
|
1461
|
+
if (w.indexOf(V) !== -1) {
|
|
1462
|
+
o();
|
|
1463
|
+
break;
|
|
1464
|
+
} else if (L.indexOf(V) !== -1)
|
|
1465
|
+
break;
|
|
1466
|
+
V = o();
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
return x;
|
|
1470
|
+
}
|
|
1471
|
+
function h() {
|
|
1472
|
+
switch (i.getTokenError()) {
|
|
1473
|
+
case 4:
|
|
1474
|
+
return f(b("Invalid unicode sequence in string."), O.InvalidUnicode), !0;
|
|
1475
|
+
case 5:
|
|
1476
|
+
return f(b("Invalid escape character in string."), O.InvalidEscapeCharacter), !0;
|
|
1477
|
+
case 3:
|
|
1478
|
+
return f(b("Unexpected end of number."), O.UnexpectedEndOfNumber), !0;
|
|
1479
|
+
case 1:
|
|
1480
|
+
return f(b("Unexpected end of comment."), O.UnexpectedEndOfComment), !0;
|
|
1481
|
+
case 2:
|
|
1482
|
+
return f(b("Unexpected end of string."), O.UnexpectedEndOfString), !0;
|
|
1483
|
+
case 6:
|
|
1484
|
+
return f(b("Invalid characters in string. Control characters must be escaped."), O.InvalidCharacter), !0;
|
|
1485
|
+
}
|
|
1486
|
+
return !1;
|
|
1487
|
+
}
|
|
1488
|
+
function l(S, A) {
|
|
1489
|
+
return S.length = i.getTokenOffset() + i.getTokenLength() - S.offset, A && o(), S;
|
|
1490
|
+
}
|
|
1491
|
+
function u(S) {
|
|
1492
|
+
if (i.getToken() !== 3)
|
|
1493
|
+
return;
|
|
1494
|
+
const A = new Ot(S, i.getTokenOffset());
|
|
1495
|
+
o();
|
|
1496
|
+
let x = !1;
|
|
1497
|
+
for (; i.getToken() !== 4 && i.getToken() !== 17; ) {
|
|
1498
|
+
if (i.getToken() === 5) {
|
|
1499
|
+
x || f(b("Value expected"), O.ValueExpected);
|
|
1500
|
+
const L = i.getTokenOffset();
|
|
1501
|
+
if (o(), i.getToken() === 4) {
|
|
1502
|
+
x && m(b("Trailing comma"), O.TrailingComma, L, L + 1);
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
} else x && f(b("Expected comma"), O.CommaExpected);
|
|
1506
|
+
const w = c(A);
|
|
1507
|
+
w ? A.items.push(w) : f(b("Value expected"), O.ValueExpected, void 0, [], [
|
|
1508
|
+
4,
|
|
1509
|
+
5
|
|
1510
|
+
/* Json.SyntaxKind.CommaToken */
|
|
1511
|
+
]), x = !0;
|
|
1512
|
+
}
|
|
1513
|
+
return i.getToken() !== 4 ? f(b("Expected comma or closing bracket"), O.CommaOrCloseBacketExpected, A) : l(A, !0);
|
|
1514
|
+
}
|
|
1515
|
+
const k = new Te(void 0, 0, 0);
|
|
1516
|
+
function p(S, A) {
|
|
1517
|
+
const x = new It(S, i.getTokenOffset(), k);
|
|
1518
|
+
let w = d(x);
|
|
1519
|
+
if (!w)
|
|
1520
|
+
if (i.getToken() === 16) {
|
|
1521
|
+
f(b("Property keys must be doublequoted"), O.PropertyKeysMustBeDoublequoted);
|
|
1522
|
+
const I = new Te(x, i.getTokenOffset(), i.getTokenLength());
|
|
1523
|
+
I.value = i.getTokenValue(), w = I, o();
|
|
1524
|
+
} else
|
|
1525
|
+
return;
|
|
1526
|
+
if (x.keyNode = w, w.value !== "//") {
|
|
1527
|
+
const I = A[w.value];
|
|
1528
|
+
I ? (m(b("Duplicate object key"), O.DuplicateKey, x.keyNode.offset, x.keyNode.offset + x.keyNode.length, z.Warning), Q(I) && m(b("Duplicate object key"), O.DuplicateKey, I.keyNode.offset, I.keyNode.offset + I.keyNode.length, z.Warning), A[w.value] = !0) : A[w.value] = x;
|
|
1529
|
+
}
|
|
1530
|
+
if (i.getToken() === 6)
|
|
1531
|
+
x.colonOffset = i.getTokenOffset(), o();
|
|
1532
|
+
else if (f(b("Colon expected"), O.ColonExpected), i.getToken() === 10 && t.positionAt(w.offset + w.length).line < t.positionAt(i.getTokenOffset()).line)
|
|
1533
|
+
return x.length = w.length, x;
|
|
1534
|
+
const L = c(x);
|
|
1535
|
+
return L ? (x.valueNode = L, x.length = L.offset + L.length - x.offset, x) : f(b("Value expected"), O.ValueExpected, x, [], [
|
|
1536
|
+
2,
|
|
1537
|
+
5
|
|
1538
|
+
/* Json.SyntaxKind.CommaToken */
|
|
1539
|
+
]);
|
|
1540
|
+
}
|
|
1541
|
+
function y(S) {
|
|
1542
|
+
if (i.getToken() !== 1)
|
|
1543
|
+
return;
|
|
1544
|
+
const A = new Lt(S, i.getTokenOffset()), x = /* @__PURE__ */ Object.create(null);
|
|
1545
|
+
o();
|
|
1546
|
+
let w = !1;
|
|
1547
|
+
for (; i.getToken() !== 2 && i.getToken() !== 17; ) {
|
|
1548
|
+
if (i.getToken() === 5) {
|
|
1549
|
+
w || f(b("Property expected"), O.PropertyExpected);
|
|
1550
|
+
const I = i.getTokenOffset();
|
|
1551
|
+
if (o(), i.getToken() === 2) {
|
|
1552
|
+
w && m(b("Trailing comma"), O.TrailingComma, I, I + 1);
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1555
|
+
} else w && f(b("Expected comma"), O.CommaExpected);
|
|
1556
|
+
const L = p(A, x);
|
|
1557
|
+
L ? A.properties.push(L) : f(b("Property expected"), O.PropertyExpected, void 0, [], [
|
|
1558
|
+
2,
|
|
1559
|
+
5
|
|
1560
|
+
/* Json.SyntaxKind.CommaToken */
|
|
1561
|
+
]), w = !0;
|
|
1562
|
+
}
|
|
1563
|
+
return i.getToken() !== 2 ? f(b("Expected comma or closing brace"), O.CommaOrCloseBraceExpected, A) : l(A, !0);
|
|
1564
|
+
}
|
|
1565
|
+
function d(S) {
|
|
1566
|
+
if (i.getToken() !== 10)
|
|
1567
|
+
return;
|
|
1568
|
+
const A = new Te(S, i.getTokenOffset());
|
|
1569
|
+
return A.value = i.getTokenValue(), l(A, !0);
|
|
1570
|
+
}
|
|
1571
|
+
function T(S) {
|
|
1572
|
+
if (i.getToken() !== 11)
|
|
1573
|
+
return;
|
|
1574
|
+
const A = new Pt(S, i.getTokenOffset());
|
|
1575
|
+
if (i.getTokenError() === 0) {
|
|
1576
|
+
const x = i.getTokenValue();
|
|
1577
|
+
try {
|
|
1578
|
+
const w = JSON.parse(x);
|
|
1579
|
+
if (!D(w))
|
|
1580
|
+
return f(b("Invalid number format."), O.Undefined, A);
|
|
1581
|
+
A.value = w;
|
|
1582
|
+
} catch {
|
|
1583
|
+
return f(b("Invalid number format."), O.Undefined, A);
|
|
1584
|
+
}
|
|
1585
|
+
A.isInteger = x.indexOf(".") === -1;
|
|
1586
|
+
}
|
|
1587
|
+
return l(A, !0);
|
|
1588
|
+
}
|
|
1589
|
+
function N(S) {
|
|
1590
|
+
switch (i.getToken()) {
|
|
1591
|
+
case 7:
|
|
1592
|
+
return l(new wt(S, i.getTokenOffset()), !0);
|
|
1593
|
+
case 8:
|
|
1594
|
+
return l(new We(S, !0, i.getTokenOffset()), !0);
|
|
1595
|
+
case 9:
|
|
1596
|
+
return l(new We(S, !1, i.getTokenOffset()), !0);
|
|
1597
|
+
default:
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
function c(S) {
|
|
1602
|
+
return u(S) || y(S) || d(S) || T(S) || N(S);
|
|
1603
|
+
}
|
|
1604
|
+
let v;
|
|
1605
|
+
return o() !== 17 && (v = c(v), v ? i.getToken() !== 17 && f(b("End of file expected."), O.Undefined) : f(b("Expected a JSON object, array or literal."), O.Undefined)), new nt(v, n, a);
|
|
1606
|
+
}
|
|
1607
|
+
function Pe(t, e, n) {
|
|
1608
|
+
if (t !== null && typeof t == "object") {
|
|
1609
|
+
const r = e + " ";
|
|
1610
|
+
if (Array.isArray(t)) {
|
|
1611
|
+
if (t.length === 0)
|
|
1612
|
+
return "[]";
|
|
1613
|
+
let s = `[
|
|
1614
|
+
`;
|
|
1615
|
+
for (let i = 0; i < t.length; i++)
|
|
1616
|
+
s += r + Pe(t[i], r, n), i < t.length - 1 && (s += ","), s += `
|
|
1617
|
+
`;
|
|
1618
|
+
return s += e + "]", s;
|
|
1619
|
+
} else {
|
|
1620
|
+
const s = Object.keys(t);
|
|
1621
|
+
if (s.length === 0)
|
|
1622
|
+
return "{}";
|
|
1623
|
+
let i = `{
|
|
1624
|
+
`;
|
|
1625
|
+
for (let a = 0; a < s.length; a++) {
|
|
1626
|
+
const o = s[a];
|
|
1627
|
+
i += r + JSON.stringify(o) + ": " + Pe(t[o], r, n), a < s.length - 1 && (i += ","), i += `
|
|
1628
|
+
`;
|
|
1629
|
+
}
|
|
1630
|
+
return i += e + "}", i;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
return n(t);
|
|
1634
|
+
}
|
|
1635
|
+
class $t {
|
|
1636
|
+
constructor(e, n = [], r = Promise, s = {}) {
|
|
1637
|
+
this.schemaService = e, this.contributions = n, this.promiseConstructor = r, this.clientCapabilities = s;
|
|
1638
|
+
}
|
|
1639
|
+
doResolve(e) {
|
|
1640
|
+
for (let n = this.contributions.length - 1; n >= 0; n--) {
|
|
1641
|
+
const r = this.contributions[n].resolveCompletion;
|
|
1642
|
+
if (r) {
|
|
1643
|
+
const s = r(e);
|
|
1644
|
+
if (s)
|
|
1645
|
+
return s;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return this.promiseConstructor.resolve(e);
|
|
1649
|
+
}
|
|
1650
|
+
doComplete(e, n, r) {
|
|
1651
|
+
const s = {
|
|
1652
|
+
items: [],
|
|
1653
|
+
isIncomplete: !1
|
|
1654
|
+
}, i = e.getText(), a = e.offsetAt(n);
|
|
1655
|
+
let o = r.getNodeFromOffset(a, !0);
|
|
1656
|
+
if (this.isInComment(e, o ? o.offset : 0, a))
|
|
1657
|
+
return Promise.resolve(s);
|
|
1658
|
+
if (o && a === o.offset + o.length && a > 0) {
|
|
1659
|
+
const u = i[a - 1];
|
|
1660
|
+
(o.type === "object" && u === "}" || o.type === "array" && u === "]") && (o = o.parent);
|
|
1661
|
+
}
|
|
1662
|
+
const m = this.getCurrentWord(e, a);
|
|
1663
|
+
let f;
|
|
1664
|
+
if (o && (o.type === "string" || o.type === "number" || o.type === "boolean" || o.type === "null"))
|
|
1665
|
+
f = $.create(e.positionAt(o.offset), e.positionAt(o.offset + o.length));
|
|
1666
|
+
else {
|
|
1667
|
+
let u = a - m.length;
|
|
1668
|
+
u > 0 && i[u - 1] === '"' && u--, f = $.create(e.positionAt(u), n);
|
|
1669
|
+
}
|
|
1670
|
+
const h = /* @__PURE__ */ new Map(), l = {
|
|
1671
|
+
add: (u) => {
|
|
1672
|
+
let k = u.label;
|
|
1673
|
+
const p = h.get(k);
|
|
1674
|
+
if (p)
|
|
1675
|
+
p.documentation || (p.documentation = u.documentation), p.detail || (p.detail = u.detail), p.labelDetails || (p.labelDetails = u.labelDetails);
|
|
1676
|
+
else {
|
|
1677
|
+
if (k = k.replace(/[\n]/g, "↵"), k.length > 60) {
|
|
1678
|
+
const y = k.substr(0, 57).trim() + "...";
|
|
1679
|
+
h.has(y) || (k = y);
|
|
1680
|
+
}
|
|
1681
|
+
u.textEdit = ke.replace(f, u.insertText), u.label = k, h.set(k, u), s.items.push(u);
|
|
1682
|
+
}
|
|
1683
|
+
},
|
|
1684
|
+
setAsIncomplete: () => {
|
|
1685
|
+
s.isIncomplete = !0;
|
|
1686
|
+
},
|
|
1687
|
+
error: (u) => {
|
|
1688
|
+
console.error(u);
|
|
1689
|
+
},
|
|
1690
|
+
getNumberOfProposals: () => s.items.length
|
|
1691
|
+
};
|
|
1692
|
+
return this.schemaService.getSchemaForResource(e.uri, r).then((u) => {
|
|
1693
|
+
const k = [];
|
|
1694
|
+
let p = !0, y = "", d;
|
|
1695
|
+
if (o && o.type === "string") {
|
|
1696
|
+
const N = o.parent;
|
|
1697
|
+
N && N.type === "property" && N.keyNode === o && (p = !N.valueNode, d = N, y = i.substr(o.offset + 1, o.length - 2), N && (o = N.parent));
|
|
1698
|
+
}
|
|
1699
|
+
if (o && o.type === "object") {
|
|
1700
|
+
if (o.offset === a)
|
|
1701
|
+
return s;
|
|
1702
|
+
o.properties.forEach((g) => {
|
|
1703
|
+
(!d || d !== g) && h.set(g.keyNode.value, ut.create("__"));
|
|
1704
|
+
});
|
|
1705
|
+
let c = "";
|
|
1706
|
+
p && (c = this.evaluateSeparatorAfter(e, e.offsetAt(f.end))), u ? this.getPropertyCompletions(u, r, o, p, c, l) : this.getSchemaLessPropertyCompletions(r, o, y, l);
|
|
1707
|
+
const v = Oe(o);
|
|
1708
|
+
this.contributions.forEach((g) => {
|
|
1709
|
+
const S = g.collectPropertyCompletions(e.uri, v, m, p, c === "", l);
|
|
1710
|
+
S && k.push(S);
|
|
1711
|
+
}), !u && m.length > 0 && i.charAt(a - m.length - 1) !== '"' && (l.add({
|
|
1712
|
+
kind: J.Property,
|
|
1713
|
+
label: this.getLabelForValue(m),
|
|
1714
|
+
insertText: this.getInsertTextForProperty(m, void 0, !1, c),
|
|
1715
|
+
insertTextFormat: E.Snippet,
|
|
1716
|
+
documentation: ""
|
|
1717
|
+
}), l.setAsIncomplete());
|
|
1718
|
+
}
|
|
1719
|
+
const T = {};
|
|
1720
|
+
return u ? this.getValueCompletions(u, r, o, a, e, l, T) : this.getSchemaLessValueCompletions(r, o, a, e, l), this.contributions.length > 0 && this.getContributedValueCompletions(r, o, a, e, l, k), this.promiseConstructor.all(k).then(() => {
|
|
1721
|
+
if (l.getNumberOfProposals() === 0) {
|
|
1722
|
+
let N = a;
|
|
1723
|
+
o && (o.type === "string" || o.type === "number" || o.type === "boolean" || o.type === "null") && (N = o.offset + o.length);
|
|
1724
|
+
const c = this.evaluateSeparatorAfter(e, N);
|
|
1725
|
+
this.addFillerValueCompletions(T, c, l);
|
|
1726
|
+
}
|
|
1727
|
+
return s;
|
|
1728
|
+
});
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
getPropertyCompletions(e, n, r, s, i, a) {
|
|
1732
|
+
n.getMatchingSchemas(e.schema, r.offset).forEach((m) => {
|
|
1733
|
+
if (m.node === r && !m.inverted) {
|
|
1734
|
+
const f = m.schema.properties;
|
|
1735
|
+
f && Object.keys(f).forEach((l) => {
|
|
1736
|
+
const u = f[l];
|
|
1737
|
+
if (typeof u == "object" && !u.deprecationMessage && !u.doNotSuggest) {
|
|
1738
|
+
const k = {
|
|
1739
|
+
kind: J.Property,
|
|
1740
|
+
label: l,
|
|
1741
|
+
insertText: this.getInsertTextForProperty(l, u, s, i),
|
|
1742
|
+
insertTextFormat: E.Snippet,
|
|
1743
|
+
filterText: this.getFilterTextForValue(l),
|
|
1744
|
+
documentation: this.fromMarkup(u.markdownDescription) || u.description || ""
|
|
1745
|
+
};
|
|
1746
|
+
u.suggestSortText !== void 0 && (k.sortText = u.suggestSortText), k.insertText && ce(k.insertText, `$1${i}`) && (k.command = {
|
|
1747
|
+
title: "Suggest",
|
|
1748
|
+
command: "editor.action.triggerSuggest"
|
|
1749
|
+
}), a.add(k);
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
const h = m.schema.propertyNames;
|
|
1753
|
+
if (typeof h == "object" && !h.deprecationMessage && !h.doNotSuggest) {
|
|
1754
|
+
const l = (u, k = void 0) => {
|
|
1755
|
+
const p = {
|
|
1756
|
+
kind: J.Property,
|
|
1757
|
+
label: u,
|
|
1758
|
+
insertText: this.getInsertTextForProperty(u, void 0, s, i),
|
|
1759
|
+
insertTextFormat: E.Snippet,
|
|
1760
|
+
filterText: this.getFilterTextForValue(u),
|
|
1761
|
+
documentation: k || this.fromMarkup(h.markdownDescription) || h.description || ""
|
|
1762
|
+
};
|
|
1763
|
+
h.suggestSortText !== void 0 && (p.sortText = h.suggestSortText), p.insertText && ce(p.insertText, `$1${i}`) && (p.command = {
|
|
1764
|
+
title: "Suggest",
|
|
1765
|
+
command: "editor.action.triggerSuggest"
|
|
1766
|
+
}), a.add(p);
|
|
1767
|
+
};
|
|
1768
|
+
if (h.enum)
|
|
1769
|
+
for (let u = 0; u < h.enum.length; u++) {
|
|
1770
|
+
let k;
|
|
1771
|
+
h.markdownEnumDescriptions && u < h.markdownEnumDescriptions.length ? k = this.fromMarkup(h.markdownEnumDescriptions[u]) : h.enumDescriptions && u < h.enumDescriptions.length && (k = h.enumDescriptions[u]), l(h.enum[u], k);
|
|
1772
|
+
}
|
|
1773
|
+
h.const && l(h.const);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
getSchemaLessPropertyCompletions(e, n, r, s) {
|
|
1779
|
+
const i = (a) => {
|
|
1780
|
+
a.properties.forEach((o) => {
|
|
1781
|
+
const m = o.keyNode.value;
|
|
1782
|
+
s.add({
|
|
1783
|
+
kind: J.Property,
|
|
1784
|
+
label: m,
|
|
1785
|
+
insertText: this.getInsertTextForValue(m, ""),
|
|
1786
|
+
insertTextFormat: E.Snippet,
|
|
1787
|
+
filterText: this.getFilterTextForValue(m),
|
|
1788
|
+
documentation: ""
|
|
1789
|
+
});
|
|
1790
|
+
});
|
|
1791
|
+
};
|
|
1792
|
+
if (n.parent)
|
|
1793
|
+
if (n.parent.type === "property") {
|
|
1794
|
+
const a = n.parent.keyNode.value;
|
|
1795
|
+
e.visit((o) => (o.type === "property" && o !== n.parent && o.keyNode.value === a && o.valueNode && o.valueNode.type === "object" && i(o.valueNode), !0));
|
|
1796
|
+
} else n.parent.type === "array" && n.parent.items.forEach((a) => {
|
|
1797
|
+
a.type === "object" && a !== n && i(a);
|
|
1798
|
+
});
|
|
1799
|
+
else n.type === "object" && s.add({
|
|
1800
|
+
kind: J.Property,
|
|
1801
|
+
label: "$schema",
|
|
1802
|
+
insertText: this.getInsertTextForProperty("$schema", void 0, !0, ""),
|
|
1803
|
+
insertTextFormat: E.Snippet,
|
|
1804
|
+
documentation: "",
|
|
1805
|
+
filterText: this.getFilterTextForValue("$schema")
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
getSchemaLessValueCompletions(e, n, r, s, i) {
|
|
1809
|
+
let a = r;
|
|
1810
|
+
if (n && (n.type === "string" || n.type === "number" || n.type === "boolean" || n.type === "null") && (a = n.offset + n.length, n = n.parent), !n) {
|
|
1811
|
+
i.add({
|
|
1812
|
+
kind: this.getSuggestionKind("object"),
|
|
1813
|
+
label: "Empty object",
|
|
1814
|
+
insertText: this.getInsertTextForValue({}, ""),
|
|
1815
|
+
insertTextFormat: E.Snippet,
|
|
1816
|
+
documentation: ""
|
|
1817
|
+
}), i.add({
|
|
1818
|
+
kind: this.getSuggestionKind("array"),
|
|
1819
|
+
label: "Empty array",
|
|
1820
|
+
insertText: this.getInsertTextForValue([], ""),
|
|
1821
|
+
insertTextFormat: E.Snippet,
|
|
1822
|
+
documentation: ""
|
|
1823
|
+
});
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
const o = this.evaluateSeparatorAfter(s, a), m = (f) => {
|
|
1827
|
+
f.parent && !tt(f.parent, r, !0) && i.add({
|
|
1828
|
+
kind: this.getSuggestionKind(f.type),
|
|
1829
|
+
label: this.getLabelTextForMatchingNode(f, s),
|
|
1830
|
+
insertText: this.getInsertTextForMatchingNode(f, s, o),
|
|
1831
|
+
insertTextFormat: E.Snippet,
|
|
1832
|
+
documentation: ""
|
|
1833
|
+
}), f.type === "boolean" && this.addBooleanValueCompletion(!f.value, o, i);
|
|
1834
|
+
};
|
|
1835
|
+
if (n.type === "property" && r > (n.colonOffset || 0)) {
|
|
1836
|
+
const f = n.valueNode;
|
|
1837
|
+
if (f && (r > f.offset + f.length || f.type === "object" || f.type === "array"))
|
|
1838
|
+
return;
|
|
1839
|
+
const h = n.keyNode.value;
|
|
1840
|
+
e.visit((l) => (l.type === "property" && l.keyNode.value === h && l.valueNode && m(l.valueNode), !0)), h === "$schema" && n.parent && !n.parent.parent && this.addDollarSchemaCompletions(o, i);
|
|
1841
|
+
}
|
|
1842
|
+
if (n.type === "array")
|
|
1843
|
+
if (n.parent && n.parent.type === "property") {
|
|
1844
|
+
const f = n.parent.keyNode.value;
|
|
1845
|
+
e.visit((h) => (h.type === "property" && h.keyNode.value === f && h.valueNode && h.valueNode.type === "array" && h.valueNode.items.forEach(m), !0));
|
|
1846
|
+
} else
|
|
1847
|
+
n.items.forEach(m);
|
|
1848
|
+
}
|
|
1849
|
+
getValueCompletions(e, n, r, s, i, a, o) {
|
|
1850
|
+
let m = s, f, h;
|
|
1851
|
+
if (r && (r.type === "string" || r.type === "number" || r.type === "boolean" || r.type === "null") && (m = r.offset + r.length, h = r, r = r.parent), !r) {
|
|
1852
|
+
this.addSchemaValueCompletions(e.schema, "", a, o);
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
if (r.type === "property" && s > (r.colonOffset || 0)) {
|
|
1856
|
+
const l = r.valueNode;
|
|
1857
|
+
if (l && s > l.offset + l.length)
|
|
1858
|
+
return;
|
|
1859
|
+
f = r.keyNode.value, r = r.parent;
|
|
1860
|
+
}
|
|
1861
|
+
if (r && (f !== void 0 || r.type === "array")) {
|
|
1862
|
+
const l = this.evaluateSeparatorAfter(i, m), u = n.getMatchingSchemas(e.schema, r.offset, h);
|
|
1863
|
+
for (const k of u)
|
|
1864
|
+
if (k.node === r && !k.inverted && k.schema) {
|
|
1865
|
+
if (r.type === "array" && k.schema.items) {
|
|
1866
|
+
let p = a;
|
|
1867
|
+
if (k.schema.uniqueItems) {
|
|
1868
|
+
const y = /* @__PURE__ */ new Set();
|
|
1869
|
+
r.children.forEach((d) => {
|
|
1870
|
+
d.type !== "array" && d.type !== "object" && y.add(this.getLabelForValue(C(d)));
|
|
1871
|
+
}), p = {
|
|
1872
|
+
...a,
|
|
1873
|
+
add(d) {
|
|
1874
|
+
y.has(d.label) || a.add(d);
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
if (Array.isArray(k.schema.items)) {
|
|
1879
|
+
const y = this.findItemAtOffset(r, i, s);
|
|
1880
|
+
y < k.schema.items.length && this.addSchemaValueCompletions(k.schema.items[y], l, p, o);
|
|
1881
|
+
} else
|
|
1882
|
+
this.addSchemaValueCompletions(k.schema.items, l, p, o);
|
|
1883
|
+
}
|
|
1884
|
+
if (f !== void 0) {
|
|
1885
|
+
let p = !1;
|
|
1886
|
+
if (k.schema.properties) {
|
|
1887
|
+
const y = k.schema.properties[f];
|
|
1888
|
+
y && (p = !0, this.addSchemaValueCompletions(y, l, a, o));
|
|
1889
|
+
}
|
|
1890
|
+
if (k.schema.patternProperties && !p)
|
|
1891
|
+
for (const y of Object.keys(k.schema.patternProperties)) {
|
|
1892
|
+
const d = be(y);
|
|
1893
|
+
if (d != null && d.test(f)) {
|
|
1894
|
+
p = !0;
|
|
1895
|
+
const T = k.schema.patternProperties[y];
|
|
1896
|
+
this.addSchemaValueCompletions(T, l, a, o);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
if (k.schema.additionalProperties && !p) {
|
|
1900
|
+
const y = k.schema.additionalProperties;
|
|
1901
|
+
this.addSchemaValueCompletions(y, l, a, o);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
f === "$schema" && !r.parent && this.addDollarSchemaCompletions(l, a), o.boolean && (this.addBooleanValueCompletion(!0, l, a), this.addBooleanValueCompletion(!1, l, a)), o.null && this.addNullValueCompletion(l, a);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
getContributedValueCompletions(e, n, r, s, i, a) {
|
|
1909
|
+
if (!n)
|
|
1910
|
+
this.contributions.forEach((o) => {
|
|
1911
|
+
const m = o.collectDefaultCompletions(s.uri, i);
|
|
1912
|
+
m && a.push(m);
|
|
1913
|
+
});
|
|
1914
|
+
else if ((n.type === "string" || n.type === "number" || n.type === "boolean" || n.type === "null") && (n = n.parent), n && n.type === "property" && r > (n.colonOffset || 0)) {
|
|
1915
|
+
const o = n.keyNode.value, m = n.valueNode;
|
|
1916
|
+
if ((!m || r <= m.offset + m.length) && n.parent) {
|
|
1917
|
+
const f = Oe(n.parent);
|
|
1918
|
+
this.contributions.forEach((h) => {
|
|
1919
|
+
const l = h.collectValueCompletions(s.uri, f, o, i);
|
|
1920
|
+
l && a.push(l);
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
addSchemaValueCompletions(e, n, r, s) {
|
|
1926
|
+
typeof e == "object" && (this.addEnumValueCompletions(e, n, r), this.addDefaultValueCompletions(e, n, r), this.collectTypes(e, s), Array.isArray(e.allOf) && e.allOf.forEach((i) => this.addSchemaValueCompletions(i, n, r, s)), Array.isArray(e.anyOf) && e.anyOf.forEach((i) => this.addSchemaValueCompletions(i, n, r, s)), Array.isArray(e.oneOf) && e.oneOf.forEach((i) => this.addSchemaValueCompletions(i, n, r, s)));
|
|
1927
|
+
}
|
|
1928
|
+
addDefaultValueCompletions(e, n, r, s = 0) {
|
|
1929
|
+
let i = !1;
|
|
1930
|
+
if (q(e.default)) {
|
|
1931
|
+
let a = e.type, o = e.default;
|
|
1932
|
+
for (let f = s; f > 0; f--)
|
|
1933
|
+
o = [o], a = "array";
|
|
1934
|
+
const m = {
|
|
1935
|
+
kind: this.getSuggestionKind(a),
|
|
1936
|
+
label: this.getLabelForValue(o),
|
|
1937
|
+
insertText: this.getInsertTextForValue(o, n),
|
|
1938
|
+
insertTextFormat: E.Snippet
|
|
1939
|
+
};
|
|
1940
|
+
this.doesSupportsLabelDetails() ? m.labelDetails = { description: b("Default value") } : m.detail = b("Default value"), r.add(m), i = !0;
|
|
1941
|
+
}
|
|
1942
|
+
Array.isArray(e.examples) && e.examples.forEach((a) => {
|
|
1943
|
+
let o = e.type, m = a;
|
|
1944
|
+
for (let f = s; f > 0; f--)
|
|
1945
|
+
m = [m], o = "array";
|
|
1946
|
+
r.add({
|
|
1947
|
+
kind: this.getSuggestionKind(o),
|
|
1948
|
+
label: this.getLabelForValue(m),
|
|
1949
|
+
insertText: this.getInsertTextForValue(m, n),
|
|
1950
|
+
insertTextFormat: E.Snippet
|
|
1951
|
+
}), i = !0;
|
|
1952
|
+
}), Array.isArray(e.defaultSnippets) && e.defaultSnippets.forEach((a) => {
|
|
1953
|
+
let o = e.type, m = a.body, f = a.label, h, l;
|
|
1954
|
+
if (q(m)) {
|
|
1955
|
+
e.type;
|
|
1956
|
+
for (let u = s; u > 0; u--)
|
|
1957
|
+
m = [m];
|
|
1958
|
+
h = this.getInsertTextForSnippetValue(m, n), l = this.getFilterTextForSnippetValue(m), f = f || this.getLabelForSnippetValue(m);
|
|
1959
|
+
} else if (typeof a.bodyText == "string") {
|
|
1960
|
+
let u = "", k = "", p = "";
|
|
1961
|
+
for (let y = s; y > 0; y--)
|
|
1962
|
+
u = u + p + `[
|
|
1963
|
+
`, k = k + `
|
|
1964
|
+
` + p + "]", p += " ", o = "array";
|
|
1965
|
+
h = u + p + a.bodyText.split(`
|
|
1966
|
+
`).join(`
|
|
1967
|
+
` + p) + k + n, f = f || h, l = h.replace(/[\n]/g, "");
|
|
1968
|
+
} else
|
|
1969
|
+
return;
|
|
1970
|
+
r.add({
|
|
1971
|
+
kind: this.getSuggestionKind(o),
|
|
1972
|
+
label: f,
|
|
1973
|
+
documentation: this.fromMarkup(a.markdownDescription) || a.description,
|
|
1974
|
+
insertText: h,
|
|
1975
|
+
insertTextFormat: E.Snippet,
|
|
1976
|
+
filterText: l
|
|
1977
|
+
}), i = !0;
|
|
1978
|
+
}), !i && typeof e.items == "object" && !Array.isArray(e.items) && s < 5 && this.addDefaultValueCompletions(e.items, n, r, s + 1);
|
|
1979
|
+
}
|
|
1980
|
+
addEnumValueCompletions(e, n, r) {
|
|
1981
|
+
if (q(e.const) && r.add({
|
|
1982
|
+
kind: this.getSuggestionKind(e.type),
|
|
1983
|
+
label: this.getLabelForValue(e.const),
|
|
1984
|
+
insertText: this.getInsertTextForValue(e.const, n),
|
|
1985
|
+
insertTextFormat: E.Snippet,
|
|
1986
|
+
documentation: this.fromMarkup(e.markdownDescription) || e.description
|
|
1987
|
+
}), Array.isArray(e.enum))
|
|
1988
|
+
for (let s = 0, i = e.enum.length; s < i; s++) {
|
|
1989
|
+
const a = e.enum[s];
|
|
1990
|
+
let o = this.fromMarkup(e.markdownDescription) || e.description;
|
|
1991
|
+
e.markdownEnumDescriptions && s < e.markdownEnumDescriptions.length && this.doesSupportMarkdown() ? o = this.fromMarkup(e.markdownEnumDescriptions[s]) : e.enumDescriptions && s < e.enumDescriptions.length && (o = e.enumDescriptions[s]), r.add({
|
|
1992
|
+
kind: this.getSuggestionKind(e.type),
|
|
1993
|
+
label: this.getLabelForValue(a),
|
|
1994
|
+
insertText: this.getInsertTextForValue(a, n),
|
|
1995
|
+
insertTextFormat: E.Snippet,
|
|
1996
|
+
documentation: o
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
collectTypes(e, n) {
|
|
2001
|
+
if (Array.isArray(e.enum) || q(e.const))
|
|
2002
|
+
return;
|
|
2003
|
+
const r = e.type;
|
|
2004
|
+
Array.isArray(r) ? r.forEach((s) => n[s] = !0) : r && (n[r] = !0);
|
|
2005
|
+
}
|
|
2006
|
+
addFillerValueCompletions(e, n, r) {
|
|
2007
|
+
e.object && r.add({
|
|
2008
|
+
kind: this.getSuggestionKind("object"),
|
|
2009
|
+
label: "{}",
|
|
2010
|
+
insertText: this.getInsertTextForGuessedValue({}, n),
|
|
2011
|
+
insertTextFormat: E.Snippet,
|
|
2012
|
+
detail: b("New object"),
|
|
2013
|
+
documentation: ""
|
|
2014
|
+
}), e.array && r.add({
|
|
2015
|
+
kind: this.getSuggestionKind("array"),
|
|
2016
|
+
label: "[]",
|
|
2017
|
+
insertText: this.getInsertTextForGuessedValue([], n),
|
|
2018
|
+
insertTextFormat: E.Snippet,
|
|
2019
|
+
detail: b("New array"),
|
|
2020
|
+
documentation: ""
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
addBooleanValueCompletion(e, n, r) {
|
|
2024
|
+
r.add({
|
|
2025
|
+
kind: this.getSuggestionKind("boolean"),
|
|
2026
|
+
label: e ? "true" : "false",
|
|
2027
|
+
insertText: this.getInsertTextForValue(e, n),
|
|
2028
|
+
insertTextFormat: E.Snippet,
|
|
2029
|
+
documentation: ""
|
|
2030
|
+
});
|
|
2031
|
+
}
|
|
2032
|
+
addNullValueCompletion(e, n) {
|
|
2033
|
+
n.add({
|
|
2034
|
+
kind: this.getSuggestionKind("null"),
|
|
2035
|
+
label: "null",
|
|
2036
|
+
insertText: "null" + e,
|
|
2037
|
+
insertTextFormat: E.Snippet,
|
|
2038
|
+
documentation: ""
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
addDollarSchemaCompletions(e, n) {
|
|
2042
|
+
this.schemaService.getRegisteredSchemaIds((s) => s === "http" || s === "https").forEach((s) => {
|
|
2043
|
+
s.startsWith("http://json-schema.org/draft-") && (s = s + "#"), n.add({
|
|
2044
|
+
kind: J.Module,
|
|
2045
|
+
label: this.getLabelForValue(s),
|
|
2046
|
+
filterText: this.getFilterTextForValue(s),
|
|
2047
|
+
insertText: this.getInsertTextForValue(s, e),
|
|
2048
|
+
insertTextFormat: E.Snippet,
|
|
2049
|
+
documentation: ""
|
|
2050
|
+
});
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
getLabelForValue(e) {
|
|
2054
|
+
return JSON.stringify(e);
|
|
2055
|
+
}
|
|
2056
|
+
getValueFromLabel(e) {
|
|
2057
|
+
return JSON.parse(e);
|
|
2058
|
+
}
|
|
2059
|
+
getFilterTextForValue(e) {
|
|
2060
|
+
return JSON.stringify(e);
|
|
2061
|
+
}
|
|
2062
|
+
getFilterTextForSnippetValue(e) {
|
|
2063
|
+
return JSON.stringify(e).replace(/\$\{\d+:([^}]+)\}|\$\d+/g, "$1");
|
|
2064
|
+
}
|
|
2065
|
+
getLabelForSnippetValue(e) {
|
|
2066
|
+
return JSON.stringify(e).replace(/\$\{\d+:([^}]+)\}|\$\d+/g, "$1");
|
|
2067
|
+
}
|
|
2068
|
+
getInsertTextForPlainText(e) {
|
|
2069
|
+
return e.replace(/[\\\$\}]/g, "\\$&");
|
|
2070
|
+
}
|
|
2071
|
+
getInsertTextForValue(e, n) {
|
|
2072
|
+
const r = JSON.stringify(e, null, " ");
|
|
2073
|
+
return r === "{}" ? "{$1}" + n : r === "[]" ? "[$1]" + n : this.getInsertTextForPlainText(r + n);
|
|
2074
|
+
}
|
|
2075
|
+
getInsertTextForSnippetValue(e, n) {
|
|
2076
|
+
return Pe(e, "", (s) => typeof s == "string" && s[0] === "^" ? s.substr(1) : JSON.stringify(s)) + n;
|
|
2077
|
+
}
|
|
2078
|
+
getInsertTextForGuessedValue(e, n) {
|
|
2079
|
+
switch (typeof e) {
|
|
2080
|
+
case "object":
|
|
2081
|
+
return e === null ? "${1:null}" + n : this.getInsertTextForValue(e, n);
|
|
2082
|
+
case "string":
|
|
2083
|
+
let r = JSON.stringify(e);
|
|
2084
|
+
return r = r.substr(1, r.length - 2), r = this.getInsertTextForPlainText(r), '"${1:' + r + '}"' + n;
|
|
2085
|
+
case "number":
|
|
2086
|
+
case "boolean":
|
|
2087
|
+
return "${1:" + JSON.stringify(e) + "}" + n;
|
|
2088
|
+
}
|
|
2089
|
+
return this.getInsertTextForValue(e, n);
|
|
2090
|
+
}
|
|
2091
|
+
getSuggestionKind(e) {
|
|
2092
|
+
if (Array.isArray(e)) {
|
|
2093
|
+
const n = e;
|
|
2094
|
+
e = n.length > 0 ? n[0] : void 0;
|
|
2095
|
+
}
|
|
2096
|
+
if (!e)
|
|
2097
|
+
return J.Value;
|
|
2098
|
+
switch (e) {
|
|
2099
|
+
case "string":
|
|
2100
|
+
return J.Value;
|
|
2101
|
+
case "object":
|
|
2102
|
+
return J.Module;
|
|
2103
|
+
case "property":
|
|
2104
|
+
return J.Property;
|
|
2105
|
+
default:
|
|
2106
|
+
return J.Value;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
getLabelTextForMatchingNode(e, n) {
|
|
2110
|
+
switch (e.type) {
|
|
2111
|
+
case "array":
|
|
2112
|
+
return "[]";
|
|
2113
|
+
case "object":
|
|
2114
|
+
return "{}";
|
|
2115
|
+
default:
|
|
2116
|
+
return n.getText().substr(e.offset, e.length);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
getInsertTextForMatchingNode(e, n, r) {
|
|
2120
|
+
switch (e.type) {
|
|
2121
|
+
case "array":
|
|
2122
|
+
return this.getInsertTextForValue([], r);
|
|
2123
|
+
case "object":
|
|
2124
|
+
return this.getInsertTextForValue({}, r);
|
|
2125
|
+
default:
|
|
2126
|
+
const s = n.getText().substr(e.offset, e.length) + r;
|
|
2127
|
+
return this.getInsertTextForPlainText(s);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
getInsertTextForProperty(e, n, r, s) {
|
|
2131
|
+
const i = this.getInsertTextForValue(e, "");
|
|
2132
|
+
if (!r)
|
|
2133
|
+
return i;
|
|
2134
|
+
const a = i + ": ";
|
|
2135
|
+
let o, m = 0;
|
|
2136
|
+
if (n) {
|
|
2137
|
+
if (Array.isArray(n.defaultSnippets)) {
|
|
2138
|
+
if (n.defaultSnippets.length === 1) {
|
|
2139
|
+
const f = n.defaultSnippets[0].body;
|
|
2140
|
+
q(f) && (o = this.getInsertTextForSnippetValue(f, ""));
|
|
2141
|
+
}
|
|
2142
|
+
m += n.defaultSnippets.length;
|
|
2143
|
+
}
|
|
2144
|
+
if (n.enum && (!o && n.enum.length === 1 && (o = this.getInsertTextForGuessedValue(n.enum[0], "")), m += n.enum.length), q(n.const) && (o || (o = this.getInsertTextForGuessedValue(n.const, "")), m++), q(n.default) && (o || (o = this.getInsertTextForGuessedValue(n.default, "")), m++), Array.isArray(n.examples) && n.examples.length && (o || (o = this.getInsertTextForGuessedValue(n.examples[0], "")), m += n.examples.length), m === 0) {
|
|
2145
|
+
let f = Array.isArray(n.type) ? n.type[0] : n.type;
|
|
2146
|
+
switch (f || (n.properties ? f = "object" : n.items && (f = "array")), f) {
|
|
2147
|
+
case "boolean":
|
|
2148
|
+
o = "$1";
|
|
2149
|
+
break;
|
|
2150
|
+
case "string":
|
|
2151
|
+
o = '"$1"';
|
|
2152
|
+
break;
|
|
2153
|
+
case "object":
|
|
2154
|
+
o = "{$1}";
|
|
2155
|
+
break;
|
|
2156
|
+
case "array":
|
|
2157
|
+
o = "[$1]";
|
|
2158
|
+
break;
|
|
2159
|
+
case "number":
|
|
2160
|
+
case "integer":
|
|
2161
|
+
o = "${1:0}";
|
|
2162
|
+
break;
|
|
2163
|
+
case "null":
|
|
2164
|
+
o = "${1:null}";
|
|
2165
|
+
break;
|
|
2166
|
+
default:
|
|
2167
|
+
return i;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
return (!o || m > 1) && (o = "$1"), a + o + s;
|
|
2172
|
+
}
|
|
2173
|
+
getCurrentWord(e, n) {
|
|
2174
|
+
let r = n - 1;
|
|
2175
|
+
const s = e.getText();
|
|
2176
|
+
for (; r >= 0 && `
|
|
2177
|
+
\r\v":{[,]}`.indexOf(s.charAt(r)) === -1; )
|
|
2178
|
+
r--;
|
|
2179
|
+
return s.substring(r + 1, n);
|
|
2180
|
+
}
|
|
2181
|
+
evaluateSeparatorAfter(e, n) {
|
|
2182
|
+
const r = Y(e.getText(), !0);
|
|
2183
|
+
switch (r.setPosition(n), r.scan()) {
|
|
2184
|
+
case 5:
|
|
2185
|
+
case 2:
|
|
2186
|
+
case 4:
|
|
2187
|
+
case 17:
|
|
2188
|
+
return "";
|
|
2189
|
+
default:
|
|
2190
|
+
return ",";
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
findItemAtOffset(e, n, r) {
|
|
2194
|
+
const s = Y(n.getText(), !0), i = e.items;
|
|
2195
|
+
for (let a = i.length - 1; a >= 0; a--) {
|
|
2196
|
+
const o = i[a];
|
|
2197
|
+
if (r > o.offset + o.length)
|
|
2198
|
+
return s.setPosition(o.offset + o.length), s.scan() === 5 && r >= s.getTokenOffset() + s.getTokenLength() ? a + 1 : a;
|
|
2199
|
+
if (r >= o.offset)
|
|
2200
|
+
return a;
|
|
2201
|
+
}
|
|
2202
|
+
return 0;
|
|
2203
|
+
}
|
|
2204
|
+
isInComment(e, n, r) {
|
|
2205
|
+
const s = Y(e.getText(), !1);
|
|
2206
|
+
s.setPosition(n);
|
|
2207
|
+
let i = s.scan();
|
|
2208
|
+
for (; i !== 17 && s.getTokenOffset() + s.getTokenLength() < r; )
|
|
2209
|
+
i = s.scan();
|
|
2210
|
+
return (i === 12 || i === 13) && s.getTokenOffset() <= r;
|
|
2211
|
+
}
|
|
2212
|
+
fromMarkup(e) {
|
|
2213
|
+
if (e && this.doesSupportMarkdown())
|
|
2214
|
+
return {
|
|
2215
|
+
kind: de.Markdown,
|
|
2216
|
+
value: e
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
doesSupportMarkdown() {
|
|
2220
|
+
var e, n, r;
|
|
2221
|
+
if (!q(this.supportsMarkdown)) {
|
|
2222
|
+
const s = (r = (n = (e = this.clientCapabilities.textDocument) == null ? void 0 : e.completion) == null ? void 0 : n.completionItem) == null ? void 0 : r.documentationFormat;
|
|
2223
|
+
this.supportsMarkdown = Array.isArray(s) && s.indexOf(de.Markdown) !== -1;
|
|
2224
|
+
}
|
|
2225
|
+
return this.supportsMarkdown;
|
|
2226
|
+
}
|
|
2227
|
+
doesSupportsCommitCharacters() {
|
|
2228
|
+
var e, n, r;
|
|
2229
|
+
return q(this.supportsCommitCharacters) || (this.labelDetailsSupport = (r = (n = (e = this.clientCapabilities.textDocument) == null ? void 0 : e.completion) == null ? void 0 : n.completionItem) == null ? void 0 : r.commitCharactersSupport), this.supportsCommitCharacters;
|
|
2230
|
+
}
|
|
2231
|
+
doesSupportsLabelDetails() {
|
|
2232
|
+
var e, n, r;
|
|
2233
|
+
return q(this.labelDetailsSupport) || (this.labelDetailsSupport = (r = (n = (e = this.clientCapabilities.textDocument) == null ? void 0 : e.completion) == null ? void 0 : n.completionItem) == null ? void 0 : r.labelDetailsSupport), this.labelDetailsSupport;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
class Et {
|
|
2237
|
+
constructor(e, n = [], r) {
|
|
2238
|
+
this.schemaService = e, this.contributions = n, this.promise = r || Promise;
|
|
2239
|
+
}
|
|
2240
|
+
doHover(e, n, r) {
|
|
2241
|
+
const s = e.offsetAt(n);
|
|
2242
|
+
let i = r.getNodeFromOffset(s);
|
|
2243
|
+
if (!i || (i.type === "object" || i.type === "array") && s > i.offset + 1 && s < i.offset + i.length - 1)
|
|
2244
|
+
return this.promise.resolve(null);
|
|
2245
|
+
const a = i;
|
|
2246
|
+
if (i.type === "string") {
|
|
2247
|
+
const h = i.parent;
|
|
2248
|
+
if (h && h.type === "property" && h.keyNode === i && (i = h.valueNode, !i))
|
|
2249
|
+
return this.promise.resolve(null);
|
|
2250
|
+
}
|
|
2251
|
+
const o = $.create(e.positionAt(a.offset), e.positionAt(a.offset + a.length)), m = (h) => ({
|
|
2252
|
+
contents: h,
|
|
2253
|
+
range: o
|
|
2254
|
+
}), f = Oe(i);
|
|
2255
|
+
for (let h = this.contributions.length - 1; h >= 0; h--) {
|
|
2256
|
+
const u = this.contributions[h].getInfoContribution(e.uri, f);
|
|
2257
|
+
if (u)
|
|
2258
|
+
return u.then((k) => m(k));
|
|
2259
|
+
}
|
|
2260
|
+
return this.schemaService.getSchemaForResource(e.uri, r).then((h) => {
|
|
2261
|
+
if (h && i) {
|
|
2262
|
+
const l = r.getMatchingSchemas(h.schema, i.offset);
|
|
2263
|
+
let u, k, p, y;
|
|
2264
|
+
l.every((T) => {
|
|
2265
|
+
if (T.node === i && !T.inverted && T.schema && (u = u || T.schema.title, k = k || T.schema.markdownDescription || Ae(T.schema.description), T.schema.enum)) {
|
|
2266
|
+
const N = T.schema.enum.indexOf(C(i));
|
|
2267
|
+
T.schema.markdownEnumDescriptions ? p = T.schema.markdownEnumDescriptions[N] : T.schema.enumDescriptions && (p = Ae(T.schema.enumDescriptions[N])), p && (y = T.schema.enum[N], typeof y != "string" && (y = JSON.stringify(y)));
|
|
2268
|
+
}
|
|
2269
|
+
return !0;
|
|
2270
|
+
});
|
|
2271
|
+
let d = "";
|
|
2272
|
+
return u && (d = Ae(u)), k && (d.length > 0 && (d += `
|
|
2273
|
+
|
|
2274
|
+
`), d += k), p && (d.length > 0 && (d += `
|
|
2275
|
+
|
|
2276
|
+
`), d += `\`${jt(y)}\`: ${p}`), m([d]);
|
|
2277
|
+
}
|
|
2278
|
+
return null;
|
|
2279
|
+
});
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
function Ae(t) {
|
|
2283
|
+
if (t)
|
|
2284
|
+
return t.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, `$1
|
|
2285
|
+
|
|
2286
|
+
$3`).replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
|
|
2287
|
+
}
|
|
2288
|
+
function jt(t) {
|
|
2289
|
+
return t.indexOf("`") !== -1 ? "`` " + t + " ``" : t;
|
|
2290
|
+
}
|
|
2291
|
+
class Dt {
|
|
2292
|
+
constructor(e, n) {
|
|
2293
|
+
this.jsonSchemaService = e, this.promise = n, this.validationEnabled = !0;
|
|
2294
|
+
}
|
|
2295
|
+
configure(e) {
|
|
2296
|
+
e && (this.validationEnabled = e.validate !== !1, this.commentSeverity = e.allowComments ? void 0 : z.Error);
|
|
2297
|
+
}
|
|
2298
|
+
doValidation(e, n, r, s) {
|
|
2299
|
+
if (!this.validationEnabled)
|
|
2300
|
+
return this.promise.resolve([]);
|
|
2301
|
+
const i = [], a = {}, o = (f) => {
|
|
2302
|
+
const h = f.range.start.line + " " + f.range.start.character + " " + f.message;
|
|
2303
|
+
a[h] || (a[h] = !0, i.push(f));
|
|
2304
|
+
}, m = (f) => {
|
|
2305
|
+
let h = r != null && r.trailingCommas ? me(r.trailingCommas) : z.Error, l = r != null && r.comments ? me(r.comments) : this.commentSeverity, u = r != null && r.schemaValidation ? me(r.schemaValidation) : z.Warning, k = r != null && r.schemaRequest ? me(r.schemaRequest) : z.Warning;
|
|
2306
|
+
if (f) {
|
|
2307
|
+
const p = (y, d) => {
|
|
2308
|
+
if (n.root && k) {
|
|
2309
|
+
const T = n.root, N = T.type === "object" ? T.properties[0] : void 0;
|
|
2310
|
+
if (N && N.keyNode.value === "$schema") {
|
|
2311
|
+
const c = N.valueNode || N, v = $.create(e.positionAt(c.offset), e.positionAt(c.offset + c.length));
|
|
2312
|
+
o(fe.create(v, y, k, d));
|
|
2313
|
+
} else {
|
|
2314
|
+
const c = $.create(e.positionAt(T.offset), e.positionAt(T.offset + 1));
|
|
2315
|
+
o(fe.create(c, y, k, d));
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
if (f.errors.length)
|
|
2320
|
+
p(f.errors[0], O.SchemaResolveError);
|
|
2321
|
+
else if (u) {
|
|
2322
|
+
for (const d of f.warnings)
|
|
2323
|
+
p(d, O.SchemaUnsupportedFeature);
|
|
2324
|
+
const y = n.validate(e, f.schema, u, r == null ? void 0 : r.schemaDraft);
|
|
2325
|
+
y && y.forEach(o);
|
|
2326
|
+
}
|
|
2327
|
+
rt(f.schema) && (l = void 0), it(f.schema) && (h = void 0);
|
|
2328
|
+
}
|
|
2329
|
+
for (const p of n.syntaxErrors) {
|
|
2330
|
+
if (p.code === O.TrailingComma) {
|
|
2331
|
+
if (typeof h != "number")
|
|
2332
|
+
continue;
|
|
2333
|
+
p.severity = h;
|
|
2334
|
+
}
|
|
2335
|
+
o(p);
|
|
2336
|
+
}
|
|
2337
|
+
if (typeof l == "number") {
|
|
2338
|
+
const p = b("Comments are not permitted in JSON.");
|
|
2339
|
+
n.comments.forEach((y) => {
|
|
2340
|
+
o(fe.create(y, p, l, O.CommentNotPermitted));
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
return i;
|
|
2344
|
+
};
|
|
2345
|
+
if (s) {
|
|
2346
|
+
const f = s.id || "schemaservice://untitled/" + _t++;
|
|
2347
|
+
return this.jsonSchemaService.registerExternalSchema({ uri: f, schema: s }).getResolvedSchema().then((l) => m(l));
|
|
2348
|
+
}
|
|
2349
|
+
return this.jsonSchemaService.getSchemaForResource(e.uri, n).then((f) => m(f));
|
|
2350
|
+
}
|
|
2351
|
+
getLanguageStatus(e, n) {
|
|
2352
|
+
return { schemas: this.jsonSchemaService.getSchemaURIsForResource(e.uri, n) };
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
let _t = 0;
|
|
2356
|
+
function rt(t) {
|
|
2357
|
+
if (t && typeof t == "object") {
|
|
2358
|
+
if (H(t.allowComments))
|
|
2359
|
+
return t.allowComments;
|
|
2360
|
+
if (t.allOf)
|
|
2361
|
+
for (const e of t.allOf) {
|
|
2362
|
+
const n = rt(e);
|
|
2363
|
+
if (H(n))
|
|
2364
|
+
return n;
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
function it(t) {
|
|
2369
|
+
if (t && typeof t == "object") {
|
|
2370
|
+
if (H(t.allowTrailingCommas))
|
|
2371
|
+
return t.allowTrailingCommas;
|
|
2372
|
+
const e = t;
|
|
2373
|
+
if (H(e.allowsTrailingCommas))
|
|
2374
|
+
return e.allowsTrailingCommas;
|
|
2375
|
+
if (t.allOf)
|
|
2376
|
+
for (const n of t.allOf) {
|
|
2377
|
+
const r = it(n);
|
|
2378
|
+
if (H(r))
|
|
2379
|
+
return r;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
function me(t) {
|
|
2384
|
+
switch (t) {
|
|
2385
|
+
case "error":
|
|
2386
|
+
return z.Error;
|
|
2387
|
+
case "warning":
|
|
2388
|
+
return z.Warning;
|
|
2389
|
+
case "ignore":
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
const Ge = 48, Bt = 57, Ut = 65, he = 97, Rt = 102;
|
|
2394
|
+
function M(t) {
|
|
2395
|
+
return t < Ge ? 0 : t <= Bt ? t - Ge : (t < he && (t += he - Ut), t >= he && t <= Rt ? t - he + 10 : 0);
|
|
2396
|
+
}
|
|
2397
|
+
function Jt(t) {
|
|
2398
|
+
if (t[0] === "#")
|
|
2399
|
+
switch (t.length) {
|
|
2400
|
+
case 4:
|
|
2401
|
+
return {
|
|
2402
|
+
red: M(t.charCodeAt(1)) * 17 / 255,
|
|
2403
|
+
green: M(t.charCodeAt(2)) * 17 / 255,
|
|
2404
|
+
blue: M(t.charCodeAt(3)) * 17 / 255,
|
|
2405
|
+
alpha: 1
|
|
2406
|
+
};
|
|
2407
|
+
case 5:
|
|
2408
|
+
return {
|
|
2409
|
+
red: M(t.charCodeAt(1)) * 17 / 255,
|
|
2410
|
+
green: M(t.charCodeAt(2)) * 17 / 255,
|
|
2411
|
+
blue: M(t.charCodeAt(3)) * 17 / 255,
|
|
2412
|
+
alpha: M(t.charCodeAt(4)) * 17 / 255
|
|
2413
|
+
};
|
|
2414
|
+
case 7:
|
|
2415
|
+
return {
|
|
2416
|
+
red: (M(t.charCodeAt(1)) * 16 + M(t.charCodeAt(2))) / 255,
|
|
2417
|
+
green: (M(t.charCodeAt(3)) * 16 + M(t.charCodeAt(4))) / 255,
|
|
2418
|
+
blue: (M(t.charCodeAt(5)) * 16 + M(t.charCodeAt(6))) / 255,
|
|
2419
|
+
alpha: 1
|
|
2420
|
+
};
|
|
2421
|
+
case 9:
|
|
2422
|
+
return {
|
|
2423
|
+
red: (M(t.charCodeAt(1)) * 16 + M(t.charCodeAt(2))) / 255,
|
|
2424
|
+
green: (M(t.charCodeAt(3)) * 16 + M(t.charCodeAt(4))) / 255,
|
|
2425
|
+
blue: (M(t.charCodeAt(5)) * 16 + M(t.charCodeAt(6))) / 255,
|
|
2426
|
+
alpha: (M(t.charCodeAt(7)) * 16 + M(t.charCodeAt(8))) / 255
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
class qt {
|
|
2431
|
+
constructor(e) {
|
|
2432
|
+
this.schemaService = e;
|
|
2433
|
+
}
|
|
2434
|
+
findDocumentSymbols(e, n, r = { resultLimit: Number.MAX_VALUE }) {
|
|
2435
|
+
const s = n.root;
|
|
2436
|
+
if (!s)
|
|
2437
|
+
return [];
|
|
2438
|
+
let i = r.resultLimit || Number.MAX_VALUE;
|
|
2439
|
+
const a = e.uri;
|
|
2440
|
+
if ((a === "vscode://defaultsettings/keybindings.json" || ce(a.toLowerCase(), "/user/keybindings.json")) && s.type === "array") {
|
|
2441
|
+
const u = [];
|
|
2442
|
+
for (const k of s.items)
|
|
2443
|
+
if (k.type === "object") {
|
|
2444
|
+
for (const p of k.properties)
|
|
2445
|
+
if (p.keyNode.value === "key" && p.valueNode) {
|
|
2446
|
+
const y = Ee.create(e.uri, Z(e, k));
|
|
2447
|
+
if (u.push({ name: Ze(p.valueNode), kind: G.Function, location: y }), i--, i <= 0)
|
|
2448
|
+
return r && r.onResultLimitExceeded && r.onResultLimitExceeded(a), u;
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
return u;
|
|
2452
|
+
}
|
|
2453
|
+
const o = [
|
|
2454
|
+
{ node: s, containerName: "" }
|
|
2455
|
+
];
|
|
2456
|
+
let m = 0, f = !1;
|
|
2457
|
+
const h = [], l = (u, k) => {
|
|
2458
|
+
u.type === "array" ? u.items.forEach((p) => {
|
|
2459
|
+
p && o.push({ node: p, containerName: k });
|
|
2460
|
+
}) : u.type === "object" && u.properties.forEach((p) => {
|
|
2461
|
+
const y = p.valueNode;
|
|
2462
|
+
if (y)
|
|
2463
|
+
if (i > 0) {
|
|
2464
|
+
i--;
|
|
2465
|
+
const d = Ee.create(e.uri, Z(e, p)), T = k ? k + "." + p.keyNode.value : p.keyNode.value;
|
|
2466
|
+
h.push({ name: this.getKeyLabel(p), kind: this.getSymbolKind(y.type), location: d, containerName: k }), o.push({ node: y, containerName: T });
|
|
2467
|
+
} else
|
|
2468
|
+
f = !0;
|
|
2469
|
+
});
|
|
2470
|
+
};
|
|
2471
|
+
for (; m < o.length; ) {
|
|
2472
|
+
const u = o[m++];
|
|
2473
|
+
l(u.node, u.containerName);
|
|
2474
|
+
}
|
|
2475
|
+
return f && r && r.onResultLimitExceeded && r.onResultLimitExceeded(a), h;
|
|
2476
|
+
}
|
|
2477
|
+
findDocumentSymbols2(e, n, r = { resultLimit: Number.MAX_VALUE }) {
|
|
2478
|
+
const s = n.root;
|
|
2479
|
+
if (!s)
|
|
2480
|
+
return [];
|
|
2481
|
+
let i = r.resultLimit || Number.MAX_VALUE;
|
|
2482
|
+
const a = e.uri;
|
|
2483
|
+
if ((a === "vscode://defaultsettings/keybindings.json" || ce(a.toLowerCase(), "/user/keybindings.json")) && s.type === "array") {
|
|
2484
|
+
const u = [];
|
|
2485
|
+
for (const k of s.items)
|
|
2486
|
+
if (k.type === "object") {
|
|
2487
|
+
for (const p of k.properties)
|
|
2488
|
+
if (p.keyNode.value === "key" && p.valueNode) {
|
|
2489
|
+
const y = Z(e, k), d = Z(e, p.keyNode);
|
|
2490
|
+
if (u.push({ name: Ze(p.valueNode), kind: G.Function, range: y, selectionRange: d }), i--, i <= 0)
|
|
2491
|
+
return r && r.onResultLimitExceeded && r.onResultLimitExceeded(a), u;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
return u;
|
|
2495
|
+
}
|
|
2496
|
+
const o = [], m = [
|
|
2497
|
+
{ node: s, result: o }
|
|
2498
|
+
];
|
|
2499
|
+
let f = 0, h = !1;
|
|
2500
|
+
const l = (u, k) => {
|
|
2501
|
+
u.type === "array" ? u.items.forEach((p, y) => {
|
|
2502
|
+
if (p)
|
|
2503
|
+
if (i > 0) {
|
|
2504
|
+
i--;
|
|
2505
|
+
const d = Z(e, p), T = d, c = { name: String(y), kind: this.getSymbolKind(p.type), range: d, selectionRange: T, children: [] };
|
|
2506
|
+
k.push(c), m.push({ result: c.children, node: p });
|
|
2507
|
+
} else
|
|
2508
|
+
h = !0;
|
|
2509
|
+
}) : u.type === "object" && u.properties.forEach((p) => {
|
|
2510
|
+
const y = p.valueNode;
|
|
2511
|
+
if (y)
|
|
2512
|
+
if (i > 0) {
|
|
2513
|
+
i--;
|
|
2514
|
+
const d = Z(e, p), T = Z(e, p.keyNode), N = [], c = { name: this.getKeyLabel(p), kind: this.getSymbolKind(y.type), range: d, selectionRange: T, children: N, detail: this.getDetail(y) };
|
|
2515
|
+
k.push(c), m.push({ result: N, node: y });
|
|
2516
|
+
} else
|
|
2517
|
+
h = !0;
|
|
2518
|
+
});
|
|
2519
|
+
};
|
|
2520
|
+
for (; f < m.length; ) {
|
|
2521
|
+
const u = m[f++];
|
|
2522
|
+
l(u.node, u.result);
|
|
2523
|
+
}
|
|
2524
|
+
return h && r && r.onResultLimitExceeded && r.onResultLimitExceeded(a), o;
|
|
2525
|
+
}
|
|
2526
|
+
getSymbolKind(e) {
|
|
2527
|
+
switch (e) {
|
|
2528
|
+
case "object":
|
|
2529
|
+
return G.Module;
|
|
2530
|
+
case "string":
|
|
2531
|
+
return G.String;
|
|
2532
|
+
case "number":
|
|
2533
|
+
return G.Number;
|
|
2534
|
+
case "array":
|
|
2535
|
+
return G.Array;
|
|
2536
|
+
case "boolean":
|
|
2537
|
+
return G.Boolean;
|
|
2538
|
+
default:
|
|
2539
|
+
return G.Variable;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
getKeyLabel(e) {
|
|
2543
|
+
let n = e.keyNode.value;
|
|
2544
|
+
return n && (n = n.replace(/[\n]/g, "↵")), n && n.trim() ? n : `"${n}"`;
|
|
2545
|
+
}
|
|
2546
|
+
getDetail(e) {
|
|
2547
|
+
if (e) {
|
|
2548
|
+
if (e.type === "boolean" || e.type === "number" || e.type === "null" || e.type === "string")
|
|
2549
|
+
return String(e.value);
|
|
2550
|
+
if (e.type === "array")
|
|
2551
|
+
return e.children.length ? void 0 : "[]";
|
|
2552
|
+
if (e.type === "object")
|
|
2553
|
+
return e.children.length ? void 0 : "{}";
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
findDocumentColors(e, n, r) {
|
|
2557
|
+
return this.schemaService.getSchemaForResource(e.uri, n).then((s) => {
|
|
2558
|
+
const i = [];
|
|
2559
|
+
if (s) {
|
|
2560
|
+
let a = r && typeof r.resultLimit == "number" ? r.resultLimit : Number.MAX_VALUE;
|
|
2561
|
+
const o = n.getMatchingSchemas(s.schema), m = {};
|
|
2562
|
+
for (const f of o)
|
|
2563
|
+
if (!f.inverted && f.schema && (f.schema.format === "color" || f.schema.format === "color-hex") && f.node && f.node.type === "string") {
|
|
2564
|
+
const h = String(f.node.offset);
|
|
2565
|
+
if (!m[h]) {
|
|
2566
|
+
const l = Jt(C(f.node));
|
|
2567
|
+
if (l) {
|
|
2568
|
+
const u = Z(e, f.node);
|
|
2569
|
+
i.push({ color: l, range: u });
|
|
2570
|
+
}
|
|
2571
|
+
if (m[h] = !0, a--, a <= 0)
|
|
2572
|
+
return r && r.onResultLimitExceeded && r.onResultLimitExceeded(e.uri), i;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
return i;
|
|
2577
|
+
});
|
|
2578
|
+
}
|
|
2579
|
+
getColorPresentations(e, n, r, s) {
|
|
2580
|
+
const i = [], a = Math.round(r.red * 255), o = Math.round(r.green * 255), m = Math.round(r.blue * 255);
|
|
2581
|
+
function f(l) {
|
|
2582
|
+
const u = l.toString(16);
|
|
2583
|
+
return u.length !== 2 ? "0" + u : u;
|
|
2584
|
+
}
|
|
2585
|
+
let h;
|
|
2586
|
+
return r.alpha === 1 ? h = `#${f(a)}${f(o)}${f(m)}` : h = `#${f(a)}${f(o)}${f(m)}${f(Math.round(r.alpha * 255))}`, i.push({ label: h, textEdit: ke.replace(s, JSON.stringify(h)) }), i;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
function Z(t, e) {
|
|
2590
|
+
return $.create(t.positionAt(e.offset), t.positionAt(e.offset + e.length));
|
|
2591
|
+
}
|
|
2592
|
+
function Ze(t) {
|
|
2593
|
+
return C(t) || b("<empty>");
|
|
2594
|
+
}
|
|
2595
|
+
const Ie = {
|
|
2596
|
+
schemaAssociations: [],
|
|
2597
|
+
schemas: {
|
|
2598
|
+
// bundle the schema-schema to include (localized) descriptions
|
|
2599
|
+
"http://json-schema.org/draft-04/schema#": {
|
|
2600
|
+
$schema: "http://json-schema.org/draft-04/schema#",
|
|
2601
|
+
definitions: {
|
|
2602
|
+
schemaArray: {
|
|
2603
|
+
type: "array",
|
|
2604
|
+
minItems: 1,
|
|
2605
|
+
items: {
|
|
2606
|
+
$ref: "#"
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
positiveInteger: {
|
|
2610
|
+
type: "integer",
|
|
2611
|
+
minimum: 0
|
|
2612
|
+
},
|
|
2613
|
+
positiveIntegerDefault0: {
|
|
2614
|
+
allOf: [
|
|
2615
|
+
{
|
|
2616
|
+
$ref: "#/definitions/positiveInteger"
|
|
2617
|
+
},
|
|
2618
|
+
{
|
|
2619
|
+
default: 0
|
|
2620
|
+
}
|
|
2621
|
+
]
|
|
2622
|
+
},
|
|
2623
|
+
simpleTypes: {
|
|
2624
|
+
type: "string",
|
|
2625
|
+
enum: [
|
|
2626
|
+
"array",
|
|
2627
|
+
"boolean",
|
|
2628
|
+
"integer",
|
|
2629
|
+
"null",
|
|
2630
|
+
"number",
|
|
2631
|
+
"object",
|
|
2632
|
+
"string"
|
|
2633
|
+
]
|
|
2634
|
+
},
|
|
2635
|
+
stringArray: {
|
|
2636
|
+
type: "array",
|
|
2637
|
+
items: {
|
|
2638
|
+
type: "string"
|
|
2639
|
+
},
|
|
2640
|
+
minItems: 1,
|
|
2641
|
+
uniqueItems: !0
|
|
2642
|
+
}
|
|
2643
|
+
},
|
|
2644
|
+
type: "object",
|
|
2645
|
+
properties: {
|
|
2646
|
+
id: {
|
|
2647
|
+
type: "string",
|
|
2648
|
+
format: "uri"
|
|
2649
|
+
},
|
|
2650
|
+
$schema: {
|
|
2651
|
+
type: "string",
|
|
2652
|
+
format: "uri"
|
|
2653
|
+
},
|
|
2654
|
+
title: {
|
|
2655
|
+
type: "string"
|
|
2656
|
+
},
|
|
2657
|
+
description: {
|
|
2658
|
+
type: "string"
|
|
2659
|
+
},
|
|
2660
|
+
default: {},
|
|
2661
|
+
multipleOf: {
|
|
2662
|
+
type: "number",
|
|
2663
|
+
minimum: 0,
|
|
2664
|
+
exclusiveMinimum: !0
|
|
2665
|
+
},
|
|
2666
|
+
maximum: {
|
|
2667
|
+
type: "number"
|
|
2668
|
+
},
|
|
2669
|
+
exclusiveMaximum: {
|
|
2670
|
+
type: "boolean",
|
|
2671
|
+
default: !1
|
|
2672
|
+
},
|
|
2673
|
+
minimum: {
|
|
2674
|
+
type: "number"
|
|
2675
|
+
},
|
|
2676
|
+
exclusiveMinimum: {
|
|
2677
|
+
type: "boolean",
|
|
2678
|
+
default: !1
|
|
2679
|
+
},
|
|
2680
|
+
maxLength: {
|
|
2681
|
+
allOf: [
|
|
2682
|
+
{
|
|
2683
|
+
$ref: "#/definitions/positiveInteger"
|
|
2684
|
+
}
|
|
2685
|
+
]
|
|
2686
|
+
},
|
|
2687
|
+
minLength: {
|
|
2688
|
+
allOf: [
|
|
2689
|
+
{
|
|
2690
|
+
$ref: "#/definitions/positiveIntegerDefault0"
|
|
2691
|
+
}
|
|
2692
|
+
]
|
|
2693
|
+
},
|
|
2694
|
+
pattern: {
|
|
2695
|
+
type: "string",
|
|
2696
|
+
format: "regex"
|
|
2697
|
+
},
|
|
2698
|
+
additionalItems: {
|
|
2699
|
+
anyOf: [
|
|
2700
|
+
{
|
|
2701
|
+
type: "boolean"
|
|
2702
|
+
},
|
|
2703
|
+
{
|
|
2704
|
+
$ref: "#"
|
|
2705
|
+
}
|
|
2706
|
+
],
|
|
2707
|
+
default: {}
|
|
2708
|
+
},
|
|
2709
|
+
items: {
|
|
2710
|
+
anyOf: [
|
|
2711
|
+
{
|
|
2712
|
+
$ref: "#"
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
$ref: "#/definitions/schemaArray"
|
|
2716
|
+
}
|
|
2717
|
+
],
|
|
2718
|
+
default: {}
|
|
2719
|
+
},
|
|
2720
|
+
maxItems: {
|
|
2721
|
+
allOf: [
|
|
2722
|
+
{
|
|
2723
|
+
$ref: "#/definitions/positiveInteger"
|
|
2724
|
+
}
|
|
2725
|
+
]
|
|
2726
|
+
},
|
|
2727
|
+
minItems: {
|
|
2728
|
+
allOf: [
|
|
2729
|
+
{
|
|
2730
|
+
$ref: "#/definitions/positiveIntegerDefault0"
|
|
2731
|
+
}
|
|
2732
|
+
]
|
|
2733
|
+
},
|
|
2734
|
+
uniqueItems: {
|
|
2735
|
+
type: "boolean",
|
|
2736
|
+
default: !1
|
|
2737
|
+
},
|
|
2738
|
+
maxProperties: {
|
|
2739
|
+
allOf: [
|
|
2740
|
+
{
|
|
2741
|
+
$ref: "#/definitions/positiveInteger"
|
|
2742
|
+
}
|
|
2743
|
+
]
|
|
2744
|
+
},
|
|
2745
|
+
minProperties: {
|
|
2746
|
+
allOf: [
|
|
2747
|
+
{
|
|
2748
|
+
$ref: "#/definitions/positiveIntegerDefault0"
|
|
2749
|
+
}
|
|
2750
|
+
]
|
|
2751
|
+
},
|
|
2752
|
+
required: {
|
|
2753
|
+
allOf: [
|
|
2754
|
+
{
|
|
2755
|
+
$ref: "#/definitions/stringArray"
|
|
2756
|
+
}
|
|
2757
|
+
]
|
|
2758
|
+
},
|
|
2759
|
+
additionalProperties: {
|
|
2760
|
+
anyOf: [
|
|
2761
|
+
{
|
|
2762
|
+
type: "boolean"
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
$ref: "#"
|
|
2766
|
+
}
|
|
2767
|
+
],
|
|
2768
|
+
default: {}
|
|
2769
|
+
},
|
|
2770
|
+
definitions: {
|
|
2771
|
+
type: "object",
|
|
2772
|
+
additionalProperties: {
|
|
2773
|
+
$ref: "#"
|
|
2774
|
+
},
|
|
2775
|
+
default: {}
|
|
2776
|
+
},
|
|
2777
|
+
properties: {
|
|
2778
|
+
type: "object",
|
|
2779
|
+
additionalProperties: {
|
|
2780
|
+
$ref: "#"
|
|
2781
|
+
},
|
|
2782
|
+
default: {}
|
|
2783
|
+
},
|
|
2784
|
+
patternProperties: {
|
|
2785
|
+
type: "object",
|
|
2786
|
+
additionalProperties: {
|
|
2787
|
+
$ref: "#"
|
|
2788
|
+
},
|
|
2789
|
+
default: {}
|
|
2790
|
+
},
|
|
2791
|
+
dependencies: {
|
|
2792
|
+
type: "object",
|
|
2793
|
+
additionalProperties: {
|
|
2794
|
+
anyOf: [
|
|
2795
|
+
{
|
|
2796
|
+
$ref: "#"
|
|
2797
|
+
},
|
|
2798
|
+
{
|
|
2799
|
+
$ref: "#/definitions/stringArray"
|
|
2800
|
+
}
|
|
2801
|
+
]
|
|
2802
|
+
}
|
|
2803
|
+
},
|
|
2804
|
+
enum: {
|
|
2805
|
+
type: "array",
|
|
2806
|
+
minItems: 1,
|
|
2807
|
+
uniqueItems: !0
|
|
2808
|
+
},
|
|
2809
|
+
type: {
|
|
2810
|
+
anyOf: [
|
|
2811
|
+
{
|
|
2812
|
+
$ref: "#/definitions/simpleTypes"
|
|
2813
|
+
},
|
|
2814
|
+
{
|
|
2815
|
+
type: "array",
|
|
2816
|
+
items: {
|
|
2817
|
+
$ref: "#/definitions/simpleTypes"
|
|
2818
|
+
},
|
|
2819
|
+
minItems: 1,
|
|
2820
|
+
uniqueItems: !0
|
|
2821
|
+
}
|
|
2822
|
+
]
|
|
2823
|
+
},
|
|
2824
|
+
format: {
|
|
2825
|
+
anyOf: [
|
|
2826
|
+
{
|
|
2827
|
+
type: "string",
|
|
2828
|
+
enum: [
|
|
2829
|
+
"date-time",
|
|
2830
|
+
"uri",
|
|
2831
|
+
"email",
|
|
2832
|
+
"hostname",
|
|
2833
|
+
"ipv4",
|
|
2834
|
+
"ipv6",
|
|
2835
|
+
"regex"
|
|
2836
|
+
]
|
|
2837
|
+
},
|
|
2838
|
+
{
|
|
2839
|
+
type: "string"
|
|
2840
|
+
}
|
|
2841
|
+
]
|
|
2842
|
+
},
|
|
2843
|
+
allOf: {
|
|
2844
|
+
allOf: [
|
|
2845
|
+
{
|
|
2846
|
+
$ref: "#/definitions/schemaArray"
|
|
2847
|
+
}
|
|
2848
|
+
]
|
|
2849
|
+
},
|
|
2850
|
+
anyOf: {
|
|
2851
|
+
allOf: [
|
|
2852
|
+
{
|
|
2853
|
+
$ref: "#/definitions/schemaArray"
|
|
2854
|
+
}
|
|
2855
|
+
]
|
|
2856
|
+
},
|
|
2857
|
+
oneOf: {
|
|
2858
|
+
allOf: [
|
|
2859
|
+
{
|
|
2860
|
+
$ref: "#/definitions/schemaArray"
|
|
2861
|
+
}
|
|
2862
|
+
]
|
|
2863
|
+
},
|
|
2864
|
+
not: {
|
|
2865
|
+
allOf: [
|
|
2866
|
+
{
|
|
2867
|
+
$ref: "#"
|
|
2868
|
+
}
|
|
2869
|
+
]
|
|
2870
|
+
}
|
|
2871
|
+
},
|
|
2872
|
+
dependencies: {
|
|
2873
|
+
exclusiveMaximum: [
|
|
2874
|
+
"maximum"
|
|
2875
|
+
],
|
|
2876
|
+
exclusiveMinimum: [
|
|
2877
|
+
"minimum"
|
|
2878
|
+
]
|
|
2879
|
+
},
|
|
2880
|
+
default: {}
|
|
2881
|
+
},
|
|
2882
|
+
"http://json-schema.org/draft-07/schema#": {
|
|
2883
|
+
definitions: {
|
|
2884
|
+
schemaArray: {
|
|
2885
|
+
type: "array",
|
|
2886
|
+
minItems: 1,
|
|
2887
|
+
items: { $ref: "#" }
|
|
2888
|
+
},
|
|
2889
|
+
nonNegativeInteger: {
|
|
2890
|
+
type: "integer",
|
|
2891
|
+
minimum: 0
|
|
2892
|
+
},
|
|
2893
|
+
nonNegativeIntegerDefault0: {
|
|
2894
|
+
allOf: [
|
|
2895
|
+
{ $ref: "#/definitions/nonNegativeInteger" },
|
|
2896
|
+
{ default: 0 }
|
|
2897
|
+
]
|
|
2898
|
+
},
|
|
2899
|
+
simpleTypes: {
|
|
2900
|
+
enum: [
|
|
2901
|
+
"array",
|
|
2902
|
+
"boolean",
|
|
2903
|
+
"integer",
|
|
2904
|
+
"null",
|
|
2905
|
+
"number",
|
|
2906
|
+
"object",
|
|
2907
|
+
"string"
|
|
2908
|
+
]
|
|
2909
|
+
},
|
|
2910
|
+
stringArray: {
|
|
2911
|
+
type: "array",
|
|
2912
|
+
items: { type: "string" },
|
|
2913
|
+
uniqueItems: !0,
|
|
2914
|
+
default: []
|
|
2915
|
+
}
|
|
2916
|
+
},
|
|
2917
|
+
type: ["object", "boolean"],
|
|
2918
|
+
properties: {
|
|
2919
|
+
$id: {
|
|
2920
|
+
type: "string",
|
|
2921
|
+
format: "uri-reference"
|
|
2922
|
+
},
|
|
2923
|
+
$schema: {
|
|
2924
|
+
type: "string",
|
|
2925
|
+
format: "uri"
|
|
2926
|
+
},
|
|
2927
|
+
$ref: {
|
|
2928
|
+
type: "string",
|
|
2929
|
+
format: "uri-reference"
|
|
2930
|
+
},
|
|
2931
|
+
$comment: {
|
|
2932
|
+
type: "string"
|
|
2933
|
+
},
|
|
2934
|
+
title: {
|
|
2935
|
+
type: "string"
|
|
2936
|
+
},
|
|
2937
|
+
description: {
|
|
2938
|
+
type: "string"
|
|
2939
|
+
},
|
|
2940
|
+
default: !0,
|
|
2941
|
+
readOnly: {
|
|
2942
|
+
type: "boolean",
|
|
2943
|
+
default: !1
|
|
2944
|
+
},
|
|
2945
|
+
examples: {
|
|
2946
|
+
type: "array",
|
|
2947
|
+
items: !0
|
|
2948
|
+
},
|
|
2949
|
+
multipleOf: {
|
|
2950
|
+
type: "number",
|
|
2951
|
+
exclusiveMinimum: 0
|
|
2952
|
+
},
|
|
2953
|
+
maximum: {
|
|
2954
|
+
type: "number"
|
|
2955
|
+
},
|
|
2956
|
+
exclusiveMaximum: {
|
|
2957
|
+
type: "number"
|
|
2958
|
+
},
|
|
2959
|
+
minimum: {
|
|
2960
|
+
type: "number"
|
|
2961
|
+
},
|
|
2962
|
+
exclusiveMinimum: {
|
|
2963
|
+
type: "number"
|
|
2964
|
+
},
|
|
2965
|
+
maxLength: { $ref: "#/definitions/nonNegativeInteger" },
|
|
2966
|
+
minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
2967
|
+
pattern: {
|
|
2968
|
+
type: "string",
|
|
2969
|
+
format: "regex"
|
|
2970
|
+
},
|
|
2971
|
+
additionalItems: { $ref: "#" },
|
|
2972
|
+
items: {
|
|
2973
|
+
anyOf: [
|
|
2974
|
+
{ $ref: "#" },
|
|
2975
|
+
{ $ref: "#/definitions/schemaArray" }
|
|
2976
|
+
],
|
|
2977
|
+
default: !0
|
|
2978
|
+
},
|
|
2979
|
+
maxItems: { $ref: "#/definitions/nonNegativeInteger" },
|
|
2980
|
+
minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
2981
|
+
uniqueItems: {
|
|
2982
|
+
type: "boolean",
|
|
2983
|
+
default: !1
|
|
2984
|
+
},
|
|
2985
|
+
contains: { $ref: "#" },
|
|
2986
|
+
maxProperties: { $ref: "#/definitions/nonNegativeInteger" },
|
|
2987
|
+
minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
2988
|
+
required: { $ref: "#/definitions/stringArray" },
|
|
2989
|
+
additionalProperties: { $ref: "#" },
|
|
2990
|
+
definitions: {
|
|
2991
|
+
type: "object",
|
|
2992
|
+
additionalProperties: { $ref: "#" },
|
|
2993
|
+
default: {}
|
|
2994
|
+
},
|
|
2995
|
+
properties: {
|
|
2996
|
+
type: "object",
|
|
2997
|
+
additionalProperties: { $ref: "#" },
|
|
2998
|
+
default: {}
|
|
2999
|
+
},
|
|
3000
|
+
patternProperties: {
|
|
3001
|
+
type: "object",
|
|
3002
|
+
additionalProperties: { $ref: "#" },
|
|
3003
|
+
propertyNames: { format: "regex" },
|
|
3004
|
+
default: {}
|
|
3005
|
+
},
|
|
3006
|
+
dependencies: {
|
|
3007
|
+
type: "object",
|
|
3008
|
+
additionalProperties: {
|
|
3009
|
+
anyOf: [
|
|
3010
|
+
{ $ref: "#" },
|
|
3011
|
+
{ $ref: "#/definitions/stringArray" }
|
|
3012
|
+
]
|
|
3013
|
+
}
|
|
3014
|
+
},
|
|
3015
|
+
propertyNames: { $ref: "#" },
|
|
3016
|
+
const: !0,
|
|
3017
|
+
enum: {
|
|
3018
|
+
type: "array",
|
|
3019
|
+
items: !0,
|
|
3020
|
+
minItems: 1,
|
|
3021
|
+
uniqueItems: !0
|
|
3022
|
+
},
|
|
3023
|
+
type: {
|
|
3024
|
+
anyOf: [
|
|
3025
|
+
{ $ref: "#/definitions/simpleTypes" },
|
|
3026
|
+
{
|
|
3027
|
+
type: "array",
|
|
3028
|
+
items: { $ref: "#/definitions/simpleTypes" },
|
|
3029
|
+
minItems: 1,
|
|
3030
|
+
uniqueItems: !0
|
|
3031
|
+
}
|
|
3032
|
+
]
|
|
3033
|
+
},
|
|
3034
|
+
format: { type: "string" },
|
|
3035
|
+
contentMediaType: { type: "string" },
|
|
3036
|
+
contentEncoding: { type: "string" },
|
|
3037
|
+
if: { $ref: "#" },
|
|
3038
|
+
then: { $ref: "#" },
|
|
3039
|
+
else: { $ref: "#" },
|
|
3040
|
+
allOf: { $ref: "#/definitions/schemaArray" },
|
|
3041
|
+
anyOf: { $ref: "#/definitions/schemaArray" },
|
|
3042
|
+
oneOf: { $ref: "#/definitions/schemaArray" },
|
|
3043
|
+
not: { $ref: "#" }
|
|
3044
|
+
},
|
|
3045
|
+
default: !0
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
}, Wt = {
|
|
3049
|
+
id: b("A unique identifier for the schema."),
|
|
3050
|
+
$schema: b("The schema to verify this document against."),
|
|
3051
|
+
title: b("A descriptive title of the element."),
|
|
3052
|
+
description: b("A long description of the element. Used in hover menus and suggestions."),
|
|
3053
|
+
default: b("A default value. Used by suggestions."),
|
|
3054
|
+
multipleOf: b("A number that should cleanly divide the current value (i.e. have no remainder)."),
|
|
3055
|
+
maximum: b("The maximum numerical value, inclusive by default."),
|
|
3056
|
+
exclusiveMaximum: b("Makes the maximum property exclusive."),
|
|
3057
|
+
minimum: b("The minimum numerical value, inclusive by default."),
|
|
3058
|
+
exclusiveMinimum: b("Makes the minimum property exclusive."),
|
|
3059
|
+
maxLength: b("The maximum length of a string."),
|
|
3060
|
+
minLength: b("The minimum length of a string."),
|
|
3061
|
+
pattern: b("A regular expression to match the string against. It is not implicitly anchored."),
|
|
3062
|
+
additionalItems: b("For arrays, only when items is set as an array. If it is a schema, then this schema validates items after the ones specified by the items array. If it is false, then additional items will cause validation to fail."),
|
|
3063
|
+
items: b("For arrays. Can either be a schema to validate every element against or an array of schemas to validate each item against in order (the first schema will validate the first element, the second schema will validate the second element, and so on."),
|
|
3064
|
+
maxItems: b("The maximum number of items that can be inside an array. Inclusive."),
|
|
3065
|
+
minItems: b("The minimum number of items that can be inside an array. Inclusive."),
|
|
3066
|
+
uniqueItems: b("If all of the items in the array must be unique. Defaults to false."),
|
|
3067
|
+
maxProperties: b("The maximum number of properties an object can have. Inclusive."),
|
|
3068
|
+
minProperties: b("The minimum number of properties an object can have. Inclusive."),
|
|
3069
|
+
required: b("An array of strings that lists the names of all properties required on this object."),
|
|
3070
|
+
additionalProperties: b("Either a schema or a boolean. If a schema, then used to validate all properties not matched by 'properties' or 'patternProperties'. If false, then any properties not matched by either will cause this schema to fail."),
|
|
3071
|
+
definitions: b("Not used for validation. Place subschemas here that you wish to reference inline with $ref."),
|
|
3072
|
+
properties: b("A map of property names to schemas for each property."),
|
|
3073
|
+
patternProperties: b("A map of regular expressions on property names to schemas for matching properties."),
|
|
3074
|
+
dependencies: b("A map of property names to either an array of property names or a schema. An array of property names means the property named in the key depends on the properties in the array being present in the object in order to be valid. If the value is a schema, then the schema is only applied to the object if the property in the key exists on the object."),
|
|
3075
|
+
enum: b("The set of literal values that are valid."),
|
|
3076
|
+
type: b("Either a string of one of the basic schema types (number, integer, null, array, object, boolean, string) or an array of strings specifying a subset of those types."),
|
|
3077
|
+
format: b("Describes the format expected for the value."),
|
|
3078
|
+
allOf: b("An array of schemas, all of which must match."),
|
|
3079
|
+
anyOf: b("An array of schemas, where at least one must match."),
|
|
3080
|
+
oneOf: b("An array of schemas, exactly one of which must match."),
|
|
3081
|
+
not: b("A schema which must not match."),
|
|
3082
|
+
$id: b("A unique identifier for the schema."),
|
|
3083
|
+
$ref: b("Reference a definition hosted on any location."),
|
|
3084
|
+
$comment: b("Comments from schema authors to readers or maintainers of the schema."),
|
|
3085
|
+
readOnly: b("Indicates that the value of the instance is managed exclusively by the owning authority."),
|
|
3086
|
+
examples: b("Sample JSON values associated with a particular schema, for the purpose of illustrating usage."),
|
|
3087
|
+
contains: b('An array instance is valid against "contains" if at least one of its elements is valid against the given schema.'),
|
|
3088
|
+
propertyNames: b("If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema."),
|
|
3089
|
+
const: b("An instance validates successfully against this keyword if its value is equal to the value of the keyword."),
|
|
3090
|
+
contentMediaType: b("Describes the media type of a string property."),
|
|
3091
|
+
contentEncoding: b("Describes the content encoding of a string property."),
|
|
3092
|
+
if: b('The validation outcome of the "if" subschema controls which of the "then" or "else" keywords are evaluated.'),
|
|
3093
|
+
then: b('The "if" subschema is used for validation when the "if" subschema succeeds.'),
|
|
3094
|
+
else: b('The "else" subschema is used for validation when the "if" subschema fails.')
|
|
3095
|
+
};
|
|
3096
|
+
for (const t in Ie.schemas) {
|
|
3097
|
+
const e = Ie.schemas[t];
|
|
3098
|
+
for (const n in e.properties) {
|
|
3099
|
+
let r = e.properties[n];
|
|
3100
|
+
typeof r == "boolean" && (r = e.properties[n] = {});
|
|
3101
|
+
const s = Wt[n];
|
|
3102
|
+
s && (r.description = s);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
function zt(t, e) {
|
|
3106
|
+
if (typeof t != "string")
|
|
3107
|
+
throw new TypeError("Expected a string");
|
|
3108
|
+
const n = String(t);
|
|
3109
|
+
let r = "";
|
|
3110
|
+
const s = !!e, i = !!e;
|
|
3111
|
+
let a = !1;
|
|
3112
|
+
const o = e && typeof e.flags == "string" ? e.flags : "";
|
|
3113
|
+
let m;
|
|
3114
|
+
for (let f = 0, h = n.length; f < h; f++)
|
|
3115
|
+
switch (m = n[f], m) {
|
|
3116
|
+
case "/":
|
|
3117
|
+
case "$":
|
|
3118
|
+
case "^":
|
|
3119
|
+
case "+":
|
|
3120
|
+
case ".":
|
|
3121
|
+
case "(":
|
|
3122
|
+
case ")":
|
|
3123
|
+
case "=":
|
|
3124
|
+
case "!":
|
|
3125
|
+
case "|":
|
|
3126
|
+
r += "\\" + m;
|
|
3127
|
+
break;
|
|
3128
|
+
case "?":
|
|
3129
|
+
if (s) {
|
|
3130
|
+
r += ".";
|
|
3131
|
+
break;
|
|
3132
|
+
}
|
|
3133
|
+
case "[":
|
|
3134
|
+
case "]":
|
|
3135
|
+
if (s) {
|
|
3136
|
+
r += m;
|
|
3137
|
+
break;
|
|
3138
|
+
}
|
|
3139
|
+
case "{":
|
|
3140
|
+
if (s) {
|
|
3141
|
+
a = !0, r += "(";
|
|
3142
|
+
break;
|
|
3143
|
+
}
|
|
3144
|
+
case "}":
|
|
3145
|
+
if (s) {
|
|
3146
|
+
a = !1, r += ")";
|
|
3147
|
+
break;
|
|
3148
|
+
}
|
|
3149
|
+
case ",":
|
|
3150
|
+
if (a) {
|
|
3151
|
+
r += "|";
|
|
3152
|
+
break;
|
|
3153
|
+
}
|
|
3154
|
+
r += "\\" + m;
|
|
3155
|
+
break;
|
|
3156
|
+
case "*":
|
|
3157
|
+
const l = n[f - 1];
|
|
3158
|
+
let u = 1;
|
|
3159
|
+
for (; n[f + 1] === "*"; )
|
|
3160
|
+
u++, f++;
|
|
3161
|
+
const k = n[f + 1];
|
|
3162
|
+
i ? u > 1 && (l === "/" || l === void 0 || l === "{" || l === ",") && (k === "/" || k === void 0 || k === "," || k === "}") ? (k === "/" ? f++ : l === "/" && r.endsWith("\\/") && (r = r.substr(0, r.length - 2)), r += "((?:[^/]*(?:/|$))*)") : r += "([^/]*)" : r += ".*";
|
|
3163
|
+
break;
|
|
3164
|
+
default:
|
|
3165
|
+
r += m;
|
|
3166
|
+
}
|
|
3167
|
+
return (!o || !~o.indexOf("g")) && (r = "^" + r + "$"), new RegExp(r, o);
|
|
3168
|
+
}
|
|
3169
|
+
const Ht = "!", Kt = "/";
|
|
3170
|
+
class Gt {
|
|
3171
|
+
constructor(e, n, r) {
|
|
3172
|
+
this.folderUri = n, this.uris = r, this.globWrappers = [];
|
|
3173
|
+
try {
|
|
3174
|
+
for (let s of e) {
|
|
3175
|
+
const i = s[0] !== Ht;
|
|
3176
|
+
i || (s = s.substring(1)), s.length > 0 && (s[0] === Kt && (s = s.substring(1)), this.globWrappers.push({
|
|
3177
|
+
regexp: zt("**/" + s, { extended: !0, globstar: !0 }),
|
|
3178
|
+
include: i
|
|
3179
|
+
}));
|
|
3180
|
+
}
|
|
3181
|
+
n && (n = st(n), n.endsWith("/") || (n = n + "/"), this.folderUri = n);
|
|
3182
|
+
} catch {
|
|
3183
|
+
this.globWrappers.length = 0, this.uris = [];
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
matchesPattern(e) {
|
|
3187
|
+
if (this.folderUri && !e.startsWith(this.folderUri))
|
|
3188
|
+
return !1;
|
|
3189
|
+
let n = !1;
|
|
3190
|
+
for (const { regexp: r, include: s } of this.globWrappers)
|
|
3191
|
+
r.test(e) && (n = s);
|
|
3192
|
+
return n;
|
|
3193
|
+
}
|
|
3194
|
+
getURIs() {
|
|
3195
|
+
return this.uris;
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
class Zt {
|
|
3199
|
+
constructor(e, n, r) {
|
|
3200
|
+
this.service = e, this.uri = n, this.dependencies = /* @__PURE__ */ new Set(), this.anchors = void 0, r && (this.unresolvedSchema = this.service.promise.resolve(new le(r)));
|
|
3201
|
+
}
|
|
3202
|
+
getUnresolvedSchema() {
|
|
3203
|
+
return this.unresolvedSchema || (this.unresolvedSchema = this.service.loadSchema(this.uri)), this.unresolvedSchema;
|
|
3204
|
+
}
|
|
3205
|
+
getResolvedSchema() {
|
|
3206
|
+
return this.resolvedSchema || (this.resolvedSchema = this.getUnresolvedSchema().then((e) => this.service.resolveSchemaContent(e, this))), this.resolvedSchema;
|
|
3207
|
+
}
|
|
3208
|
+
clearSchema() {
|
|
3209
|
+
const e = !!this.unresolvedSchema;
|
|
3210
|
+
return this.resolvedSchema = void 0, this.unresolvedSchema = void 0, this.dependencies.clear(), this.anchors = void 0, e;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
class le {
|
|
3214
|
+
constructor(e, n = []) {
|
|
3215
|
+
this.schema = e, this.errors = n;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
class Xe {
|
|
3219
|
+
constructor(e, n = [], r = [], s) {
|
|
3220
|
+
this.schema = e, this.errors = n, this.warnings = r, this.schemaDraft = s;
|
|
3221
|
+
}
|
|
3222
|
+
getSection(e) {
|
|
3223
|
+
const n = this.getSectionRecursive(e, this.schema);
|
|
3224
|
+
if (n)
|
|
3225
|
+
return B(n);
|
|
3226
|
+
}
|
|
3227
|
+
getSectionRecursive(e, n) {
|
|
3228
|
+
if (!n || typeof n == "boolean" || e.length === 0)
|
|
3229
|
+
return n;
|
|
3230
|
+
const r = e.shift();
|
|
3231
|
+
if (n.properties && typeof n.properties[r])
|
|
3232
|
+
return this.getSectionRecursive(e, n.properties[r]);
|
|
3233
|
+
if (n.patternProperties)
|
|
3234
|
+
for (const s of Object.keys(n.patternProperties)) {
|
|
3235
|
+
const i = be(s);
|
|
3236
|
+
if (i != null && i.test(r))
|
|
3237
|
+
return this.getSectionRecursive(e, n.patternProperties[s]);
|
|
3238
|
+
}
|
|
3239
|
+
else {
|
|
3240
|
+
if (typeof n.additionalProperties == "object")
|
|
3241
|
+
return this.getSectionRecursive(e, n.additionalProperties);
|
|
3242
|
+
if (r.match("[0-9]+")) {
|
|
3243
|
+
if (Array.isArray(n.items)) {
|
|
3244
|
+
const s = parseInt(r, 10);
|
|
3245
|
+
if (!isNaN(s) && n.items[s])
|
|
3246
|
+
return this.getSectionRecursive(e, n.items[s]);
|
|
3247
|
+
} else if (n.items)
|
|
3248
|
+
return this.getSectionRecursive(e, n.items);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
class Xt {
|
|
3254
|
+
constructor(e, n, r) {
|
|
3255
|
+
this.contextService = n, this.requestService = e, this.promiseConstructor = r || Promise, this.callOnDispose = [], this.contributionSchemas = {}, this.contributionAssociations = [], this.schemasById = {}, this.filePatternAssociations = [], this.registeredSchemasIds = {};
|
|
3256
|
+
}
|
|
3257
|
+
getRegisteredSchemaIds(e) {
|
|
3258
|
+
return Object.keys(this.registeredSchemasIds).filter((n) => {
|
|
3259
|
+
const r = se.parse(n).scheme;
|
|
3260
|
+
return r !== "schemaservice" && (!e || e(r));
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
get promise() {
|
|
3264
|
+
return this.promiseConstructor;
|
|
3265
|
+
}
|
|
3266
|
+
dispose() {
|
|
3267
|
+
for (; this.callOnDispose.length > 0; )
|
|
3268
|
+
this.callOnDispose.pop()();
|
|
3269
|
+
}
|
|
3270
|
+
onResourceChange(e) {
|
|
3271
|
+
this.cachedSchemaForResource = void 0;
|
|
3272
|
+
let n = !1;
|
|
3273
|
+
e = X(e);
|
|
3274
|
+
const r = [e], s = Object.keys(this.schemasById).map((i) => this.schemasById[i]);
|
|
3275
|
+
for (; r.length; ) {
|
|
3276
|
+
const i = r.pop();
|
|
3277
|
+
for (let a = 0; a < s.length; a++) {
|
|
3278
|
+
const o = s[a];
|
|
3279
|
+
o && (o.uri === i || o.dependencies.has(i)) && (o.uri !== i && r.push(o.uri), o.clearSchema() && (n = !0), s[a] = void 0);
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
return n;
|
|
3283
|
+
}
|
|
3284
|
+
setSchemaContributions(e) {
|
|
3285
|
+
if (e.schemas) {
|
|
3286
|
+
const n = e.schemas;
|
|
3287
|
+
for (const r in n) {
|
|
3288
|
+
const s = X(r);
|
|
3289
|
+
this.contributionSchemas[s] = this.addSchemaHandle(s, n[r]);
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
if (Array.isArray(e.schemaAssociations)) {
|
|
3293
|
+
const n = e.schemaAssociations;
|
|
3294
|
+
for (let r of n) {
|
|
3295
|
+
const s = r.uris.map(X), i = this.addFilePatternAssociation(r.pattern, r.folderUri, s);
|
|
3296
|
+
this.contributionAssociations.push(i);
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
addSchemaHandle(e, n) {
|
|
3301
|
+
const r = new Zt(this, e, n);
|
|
3302
|
+
return this.schemasById[e] = r, r;
|
|
3303
|
+
}
|
|
3304
|
+
getOrAddSchemaHandle(e, n) {
|
|
3305
|
+
return this.schemasById[e] || this.addSchemaHandle(e, n);
|
|
3306
|
+
}
|
|
3307
|
+
addFilePatternAssociation(e, n, r) {
|
|
3308
|
+
const s = new Gt(e, n, r);
|
|
3309
|
+
return this.filePatternAssociations.push(s), s;
|
|
3310
|
+
}
|
|
3311
|
+
registerExternalSchema(e) {
|
|
3312
|
+
const n = X(e.uri);
|
|
3313
|
+
return this.registeredSchemasIds[n] = !0, this.cachedSchemaForResource = void 0, e.fileMatch && e.fileMatch.length && this.addFilePatternAssociation(e.fileMatch, e.folderUri, [n]), e.schema ? this.addSchemaHandle(n, e.schema) : this.getOrAddSchemaHandle(n);
|
|
3314
|
+
}
|
|
3315
|
+
clearExternalSchemas() {
|
|
3316
|
+
this.schemasById = {}, this.filePatternAssociations = [], this.registeredSchemasIds = {}, this.cachedSchemaForResource = void 0;
|
|
3317
|
+
for (const e in this.contributionSchemas)
|
|
3318
|
+
this.schemasById[e] = this.contributionSchemas[e], this.registeredSchemasIds[e] = !0;
|
|
3319
|
+
for (const e of this.contributionAssociations)
|
|
3320
|
+
this.filePatternAssociations.push(e);
|
|
3321
|
+
}
|
|
3322
|
+
getResolvedSchema(e) {
|
|
3323
|
+
const n = X(e), r = this.schemasById[n];
|
|
3324
|
+
return r ? r.getResolvedSchema() : this.promise.resolve(void 0);
|
|
3325
|
+
}
|
|
3326
|
+
loadSchema(e) {
|
|
3327
|
+
if (!this.requestService) {
|
|
3328
|
+
const n = b("Unable to load schema from '{0}'. No schema request service available", ae(e));
|
|
3329
|
+
return this.promise.resolve(new le({}, [n]));
|
|
3330
|
+
}
|
|
3331
|
+
return e.startsWith("http://json-schema.org/") && (e = "https" + e.substring(4)), this.requestService(e).then((n) => {
|
|
3332
|
+
if (!n) {
|
|
3333
|
+
const a = b("Unable to load schema from '{0}': No content.", ae(e));
|
|
3334
|
+
return new le({}, [a]);
|
|
3335
|
+
}
|
|
3336
|
+
const r = [];
|
|
3337
|
+
n.charCodeAt(0) === 65279 && (r.push(b("Problem reading content from '{0}': UTF-8 with BOM detected, only UTF 8 is allowed.", ae(e))), n = n.trimStart());
|
|
3338
|
+
let s = {};
|
|
3339
|
+
const i = [];
|
|
3340
|
+
return s = kt(n, i), i.length && r.push(b("Unable to parse content from '{0}': Parse error at offset {1}.", ae(e), i[0].offset)), new le(s, r);
|
|
3341
|
+
}, (n) => {
|
|
3342
|
+
let r = n.toString();
|
|
3343
|
+
const s = n.toString().split("Error: ");
|
|
3344
|
+
return s.length > 1 && (r = s[1]), ce(r, ".") && (r = r.substr(0, r.length - 1)), new le({}, [b("Unable to load schema from '{0}': {1}.", ae(e), r)]);
|
|
3345
|
+
});
|
|
3346
|
+
}
|
|
3347
|
+
resolveSchemaContent(e, n) {
|
|
3348
|
+
const r = e.errors.slice(0), s = e.schema;
|
|
3349
|
+
let i = s.$schema ? X(s.$schema) : void 0;
|
|
3350
|
+
if (i === "http://json-schema.org/draft-03/schema")
|
|
3351
|
+
return this.promise.resolve(new Xe({}, [b("Draft-03 schemas are not supported.")], [], i));
|
|
3352
|
+
let a = /* @__PURE__ */ new Set();
|
|
3353
|
+
const o = this.contextService, m = (y, d) => {
|
|
3354
|
+
d = decodeURIComponent(d);
|
|
3355
|
+
let T = y;
|
|
3356
|
+
return d[0] === "/" && (d = d.substring(1)), d.split("/").some((N) => (N = N.replace(/~1/g, "/").replace(/~0/g, "~"), T = T[N], !T)), T;
|
|
3357
|
+
}, f = (y, d, T) => (d.anchors || (d.anchors = p(y)), d.anchors.get(T)), h = (y, d) => {
|
|
3358
|
+
for (const T in d)
|
|
3359
|
+
d.hasOwnProperty(T) && T !== "id" && T !== "$id" && (y[T] = d[T]);
|
|
3360
|
+
}, l = (y, d, T, N) => {
|
|
3361
|
+
let c;
|
|
3362
|
+
N === void 0 || N.length === 0 ? c = d : N.charAt(0) === "/" ? c = m(d, N) : c = f(d, T, N), c ? h(y, c) : r.push(b("$ref '{0}' in '{1}' can not be resolved.", N || "", T.uri));
|
|
3363
|
+
}, u = (y, d, T, N) => {
|
|
3364
|
+
o && !/^[A-Za-z][A-Za-z0-9+\-.+]*:\/\/.*/.test(d) && (d = o.resolveRelativePath(d, N.uri)), d = X(d);
|
|
3365
|
+
const c = this.getOrAddSchemaHandle(d);
|
|
3366
|
+
return c.getUnresolvedSchema().then((v) => {
|
|
3367
|
+
if (N.dependencies.add(d), v.errors.length) {
|
|
3368
|
+
const g = T ? d + "#" + T : d;
|
|
3369
|
+
r.push(b("Problems loading reference '{0}': {1}", g, v.errors[0]));
|
|
3370
|
+
}
|
|
3371
|
+
return l(y, v.schema, c, T), k(y, v.schema, c);
|
|
3372
|
+
});
|
|
3373
|
+
}, k = (y, d, T) => {
|
|
3374
|
+
const N = [];
|
|
3375
|
+
return this.traverseNodes(y, (c) => {
|
|
3376
|
+
const v = /* @__PURE__ */ new Set();
|
|
3377
|
+
for (; c.$ref; ) {
|
|
3378
|
+
const g = c.$ref, S = g.split("#", 2);
|
|
3379
|
+
if (delete c.$ref, S[0].length > 0) {
|
|
3380
|
+
N.push(u(c, S[0], S[1], T));
|
|
3381
|
+
return;
|
|
3382
|
+
} else if (!v.has(g)) {
|
|
3383
|
+
const A = S[1];
|
|
3384
|
+
l(c, d, T, A), v.add(g);
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
c.$recursiveRef && a.add("$recursiveRef"), c.$dynamicRef && a.add("$dynamicRef");
|
|
3388
|
+
}), this.promise.all(N);
|
|
3389
|
+
}, p = (y) => {
|
|
3390
|
+
const d = /* @__PURE__ */ new Map();
|
|
3391
|
+
return this.traverseNodes(y, (T) => {
|
|
3392
|
+
const N = T.$id || T.id, c = et(N) && N.charAt(0) === "#" ? N.substring(1) : T.$anchor;
|
|
3393
|
+
c && (d.has(c) ? r.push(b("Duplicate anchor declaration: '{0}'", c)) : d.set(c, T)), T.$recursiveAnchor && a.add("$recursiveAnchor"), T.$dynamicAnchor && a.add("$dynamicAnchor");
|
|
3394
|
+
}), d;
|
|
3395
|
+
};
|
|
3396
|
+
return k(s, s, n).then((y) => {
|
|
3397
|
+
let d = [];
|
|
3398
|
+
return a.size && d.push(b("The schema uses meta-schema features ({0}) that are not yet supported by the validator.", Array.from(a.keys()).join(", "))), new Xe(s, r, d, i);
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
traverseNodes(e, n) {
|
|
3402
|
+
if (!e || typeof e != "object")
|
|
3403
|
+
return Promise.resolve(null);
|
|
3404
|
+
const r = /* @__PURE__ */ new Set(), s = (...h) => {
|
|
3405
|
+
for (const l of h)
|
|
3406
|
+
Q(l) && m.push(l);
|
|
3407
|
+
}, i = (...h) => {
|
|
3408
|
+
for (const l of h)
|
|
3409
|
+
if (Q(l))
|
|
3410
|
+
for (const u in l) {
|
|
3411
|
+
const p = l[u];
|
|
3412
|
+
Q(p) && m.push(p);
|
|
3413
|
+
}
|
|
3414
|
+
}, a = (...h) => {
|
|
3415
|
+
for (const l of h)
|
|
3416
|
+
if (Array.isArray(l))
|
|
3417
|
+
for (const u of l)
|
|
3418
|
+
Q(u) && m.push(u);
|
|
3419
|
+
}, o = (h) => {
|
|
3420
|
+
if (Array.isArray(h))
|
|
3421
|
+
for (const l of h)
|
|
3422
|
+
Q(l) && m.push(l);
|
|
3423
|
+
else Q(h) && m.push(h);
|
|
3424
|
+
}, m = [e];
|
|
3425
|
+
let f = m.pop();
|
|
3426
|
+
for (; f; )
|
|
3427
|
+
r.has(f) || (r.add(f), n(f), s(f.additionalItems, f.additionalProperties, f.not, f.contains, f.propertyNames, f.if, f.then, f.else, f.unevaluatedItems, f.unevaluatedProperties), i(f.definitions, f.$defs, f.properties, f.patternProperties, f.dependencies, f.dependentSchemas), a(f.anyOf, f.allOf, f.oneOf, f.prefixItems), o(f.items)), f = m.pop();
|
|
3428
|
+
}
|
|
3429
|
+
getSchemaFromProperty(e, n) {
|
|
3430
|
+
var r, s;
|
|
3431
|
+
if (((r = n.root) == null ? void 0 : r.type) === "object") {
|
|
3432
|
+
for (const i of n.root.properties)
|
|
3433
|
+
if (i.keyNode.value === "$schema" && ((s = i.valueNode) == null ? void 0 : s.type) === "string") {
|
|
3434
|
+
let a = i.valueNode.value;
|
|
3435
|
+
return this.contextService && !/^\w[\w\d+.-]*:/.test(a) && (a = this.contextService.resolveRelativePath(a, e)), a;
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
getAssociatedSchemas(e) {
|
|
3440
|
+
const n = /* @__PURE__ */ Object.create(null), r = [], s = st(e);
|
|
3441
|
+
for (const i of this.filePatternAssociations)
|
|
3442
|
+
if (i.matchesPattern(s))
|
|
3443
|
+
for (const a of i.getURIs())
|
|
3444
|
+
n[a] || (r.push(a), n[a] = !0);
|
|
3445
|
+
return r;
|
|
3446
|
+
}
|
|
3447
|
+
getSchemaURIsForResource(e, n) {
|
|
3448
|
+
let r = n && this.getSchemaFromProperty(e, n);
|
|
3449
|
+
return r ? [r] : this.getAssociatedSchemas(e);
|
|
3450
|
+
}
|
|
3451
|
+
getSchemaForResource(e, n) {
|
|
3452
|
+
if (n) {
|
|
3453
|
+
let i = this.getSchemaFromProperty(e, n);
|
|
3454
|
+
if (i) {
|
|
3455
|
+
const a = X(i);
|
|
3456
|
+
return this.getOrAddSchemaHandle(a).getResolvedSchema();
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
if (this.cachedSchemaForResource && this.cachedSchemaForResource.resource === e)
|
|
3460
|
+
return this.cachedSchemaForResource.resolvedSchema;
|
|
3461
|
+
const r = this.getAssociatedSchemas(e), s = r.length > 0 ? this.createCombinedSchema(e, r).getResolvedSchema() : this.promise.resolve(void 0);
|
|
3462
|
+
return this.cachedSchemaForResource = { resource: e, resolvedSchema: s }, s;
|
|
3463
|
+
}
|
|
3464
|
+
createCombinedSchema(e, n) {
|
|
3465
|
+
if (n.length === 1)
|
|
3466
|
+
return this.getOrAddSchemaHandle(n[0]);
|
|
3467
|
+
{
|
|
3468
|
+
const r = "schemaservice://combinedSchema/" + encodeURIComponent(e), s = {
|
|
3469
|
+
allOf: n.map((i) => ({ $ref: i }))
|
|
3470
|
+
};
|
|
3471
|
+
return this.addSchemaHandle(r, s);
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
getMatchingSchemas(e, n, r) {
|
|
3475
|
+
if (r) {
|
|
3476
|
+
const s = r.id || "schemaservice://untitled/matchingSchemas/" + Qt++;
|
|
3477
|
+
return this.addSchemaHandle(s, r).getResolvedSchema().then((a) => n.getMatchingSchemas(a.schema).filter((o) => !o.inverted));
|
|
3478
|
+
}
|
|
3479
|
+
return this.getSchemaForResource(e.uri, n).then((s) => s ? n.getMatchingSchemas(s.schema).filter((i) => !i.inverted) : []);
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
let Qt = 0;
|
|
3483
|
+
function X(t) {
|
|
3484
|
+
try {
|
|
3485
|
+
return se.parse(t).toString(!0);
|
|
3486
|
+
} catch {
|
|
3487
|
+
return t;
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
function st(t) {
|
|
3491
|
+
try {
|
|
3492
|
+
return se.parse(t).with({ fragment: null, query: null }).toString(!0);
|
|
3493
|
+
} catch {
|
|
3494
|
+
return t;
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
function ae(t) {
|
|
3498
|
+
try {
|
|
3499
|
+
const e = se.parse(t);
|
|
3500
|
+
if (e.scheme === "file")
|
|
3501
|
+
return e.fsPath;
|
|
3502
|
+
} catch {
|
|
3503
|
+
}
|
|
3504
|
+
return t;
|
|
3505
|
+
}
|
|
3506
|
+
function Yt(t, e) {
|
|
3507
|
+
const n = [], r = [], s = [];
|
|
3508
|
+
let i = -1;
|
|
3509
|
+
const a = Y(t.getText(), !1);
|
|
3510
|
+
let o = a.scan();
|
|
3511
|
+
function m(p) {
|
|
3512
|
+
n.push(p), r.push(s.length);
|
|
3513
|
+
}
|
|
3514
|
+
for (; o !== 17; ) {
|
|
3515
|
+
switch (o) {
|
|
3516
|
+
case 1:
|
|
3517
|
+
case 3: {
|
|
3518
|
+
const p = t.positionAt(a.getTokenOffset()).line, y = { startLine: p, endLine: p, kind: o === 1 ? "object" : "array" };
|
|
3519
|
+
s.push(y);
|
|
3520
|
+
break;
|
|
3521
|
+
}
|
|
3522
|
+
case 2:
|
|
3523
|
+
case 4: {
|
|
3524
|
+
const p = o === 2 ? "object" : "array";
|
|
3525
|
+
if (s.length > 0 && s[s.length - 1].kind === p) {
|
|
3526
|
+
const y = s.pop(), d = t.positionAt(a.getTokenOffset()).line;
|
|
3527
|
+
y && d > y.startLine + 1 && i !== y.startLine && (y.endLine = d - 1, m(y), i = y.startLine);
|
|
3528
|
+
}
|
|
3529
|
+
break;
|
|
3530
|
+
}
|
|
3531
|
+
case 13: {
|
|
3532
|
+
const p = t.positionAt(a.getTokenOffset()).line, y = t.positionAt(a.getTokenOffset() + a.getTokenLength()).line;
|
|
3533
|
+
a.getTokenError() === 1 && p + 1 < t.lineCount ? a.setPosition(t.offsetAt(R.create(p + 1, 0))) : p < y && (m({ startLine: p, endLine: y, kind: ve.Comment }), i = p);
|
|
3534
|
+
break;
|
|
3535
|
+
}
|
|
3536
|
+
case 12: {
|
|
3537
|
+
const y = t.getText().substr(a.getTokenOffset(), a.getTokenLength()).match(/^\/\/\s*#(region\b)|(endregion\b)/);
|
|
3538
|
+
if (y) {
|
|
3539
|
+
const d = t.positionAt(a.getTokenOffset()).line;
|
|
3540
|
+
if (y[1]) {
|
|
3541
|
+
const T = { startLine: d, endLine: d, kind: ve.Region };
|
|
3542
|
+
s.push(T);
|
|
3543
|
+
} else {
|
|
3544
|
+
let T = s.length - 1;
|
|
3545
|
+
for (; T >= 0 && s[T].kind !== ve.Region; )
|
|
3546
|
+
T--;
|
|
3547
|
+
if (T >= 0) {
|
|
3548
|
+
const N = s[T];
|
|
3549
|
+
s.length = T, d > N.startLine && i !== N.startLine && (N.endLine = d, m(N), i = N.startLine);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
break;
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
o = a.scan();
|
|
3557
|
+
}
|
|
3558
|
+
const f = e && e.rangeLimit;
|
|
3559
|
+
if (typeof f != "number" || n.length <= f)
|
|
3560
|
+
return n;
|
|
3561
|
+
e && e.onRangeLimitExceeded && e.onRangeLimitExceeded(t.uri);
|
|
3562
|
+
const h = [];
|
|
3563
|
+
for (let p of r)
|
|
3564
|
+
p < 30 && (h[p] = (h[p] || 0) + 1);
|
|
3565
|
+
let l = 0, u = 0;
|
|
3566
|
+
for (let p = 0; p < h.length; p++) {
|
|
3567
|
+
const y = h[p];
|
|
3568
|
+
if (y) {
|
|
3569
|
+
if (y + l > f) {
|
|
3570
|
+
u = p;
|
|
3571
|
+
break;
|
|
3572
|
+
}
|
|
3573
|
+
l += y;
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
const k = [];
|
|
3577
|
+
for (let p = 0; p < n.length; p++) {
|
|
3578
|
+
const y = r[p];
|
|
3579
|
+
typeof y == "number" && (y < u || y === u && l++ < f) && k.push(n[p]);
|
|
3580
|
+
}
|
|
3581
|
+
return k;
|
|
3582
|
+
}
|
|
3583
|
+
function Ct(t, e, n) {
|
|
3584
|
+
function r(o) {
|
|
3585
|
+
let m = t.offsetAt(o), f = n.getNodeFromOffset(m, !0);
|
|
3586
|
+
const h = [];
|
|
3587
|
+
for (; f; ) {
|
|
3588
|
+
switch (f.type) {
|
|
3589
|
+
case "string":
|
|
3590
|
+
case "object":
|
|
3591
|
+
case "array":
|
|
3592
|
+
const u = f.offset + 1, k = f.offset + f.length - 1;
|
|
3593
|
+
u < k && m >= u && m <= k && h.push(s(u, k)), h.push(s(f.offset, f.offset + f.length));
|
|
3594
|
+
break;
|
|
3595
|
+
case "number":
|
|
3596
|
+
case "boolean":
|
|
3597
|
+
case "null":
|
|
3598
|
+
case "property":
|
|
3599
|
+
h.push(s(f.offset, f.offset + f.length));
|
|
3600
|
+
break;
|
|
3601
|
+
}
|
|
3602
|
+
if (f.type === "property" || f.parent && f.parent.type === "array") {
|
|
3603
|
+
const u = a(
|
|
3604
|
+
f.offset + f.length,
|
|
3605
|
+
5
|
|
3606
|
+
/* SyntaxKind.CommaToken */
|
|
3607
|
+
);
|
|
3608
|
+
u !== -1 && h.push(s(f.offset, u));
|
|
3609
|
+
}
|
|
3610
|
+
f = f.parent;
|
|
3611
|
+
}
|
|
3612
|
+
let l;
|
|
3613
|
+
for (let u = h.length - 1; u >= 0; u--)
|
|
3614
|
+
l = je.create(h[u], l);
|
|
3615
|
+
return l || (l = je.create($.create(o, o))), l;
|
|
3616
|
+
}
|
|
3617
|
+
function s(o, m) {
|
|
3618
|
+
return $.create(t.positionAt(o), t.positionAt(m));
|
|
3619
|
+
}
|
|
3620
|
+
const i = Y(t.getText(), !0);
|
|
3621
|
+
function a(o, m) {
|
|
3622
|
+
return i.setPosition(o), i.scan() === m ? i.getTokenOffset() + i.getTokenLength() : -1;
|
|
3623
|
+
}
|
|
3624
|
+
return e.map(r);
|
|
3625
|
+
}
|
|
3626
|
+
function Le(t, e, n) {
|
|
3627
|
+
let r;
|
|
3628
|
+
if (n) {
|
|
3629
|
+
const i = t.offsetAt(n.start), a = t.offsetAt(n.end) - i;
|
|
3630
|
+
r = { offset: i, length: a };
|
|
3631
|
+
}
|
|
3632
|
+
const s = {
|
|
3633
|
+
tabSize: e ? e.tabSize : 4,
|
|
3634
|
+
insertSpaces: (e == null ? void 0 : e.insertSpaces) === !0,
|
|
3635
|
+
insertFinalNewline: (e == null ? void 0 : e.insertFinalNewline) === !0,
|
|
3636
|
+
eol: `
|
|
3637
|
+
`,
|
|
3638
|
+
keepLines: (e == null ? void 0 : e.keepLines) === !0
|
|
3639
|
+
};
|
|
3640
|
+
return At(t.getText(), r, s).map((i) => ke.replace($.create(t.positionAt(i.offset), t.positionAt(i.offset + i.length)), i.content));
|
|
3641
|
+
}
|
|
3642
|
+
var F;
|
|
3643
|
+
(function(t) {
|
|
3644
|
+
t[t.Object = 0] = "Object", t[t.Array = 1] = "Array";
|
|
3645
|
+
})(F || (F = {}));
|
|
3646
|
+
class ge {
|
|
3647
|
+
constructor(e, n) {
|
|
3648
|
+
this.propertyName = e ?? "", this.beginningLineNumber = n, this.childrenProperties = [], this.lastProperty = !1, this.noKeyName = !1;
|
|
3649
|
+
}
|
|
3650
|
+
addChildProperty(e) {
|
|
3651
|
+
if (e.parent = this, this.childrenProperties.length > 0) {
|
|
3652
|
+
let n = 0;
|
|
3653
|
+
e.noKeyName ? n = this.childrenProperties.length : n = tn(this.childrenProperties, e, en), n < 0 && (n = n * -1 - 1), this.childrenProperties.splice(n, 0, e);
|
|
3654
|
+
} else
|
|
3655
|
+
this.childrenProperties.push(e);
|
|
3656
|
+
return e;
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
function en(t, e) {
|
|
3660
|
+
const n = t.propertyName.toLowerCase(), r = e.propertyName.toLowerCase();
|
|
3661
|
+
return n < r ? -1 : n > r ? 1 : 0;
|
|
3662
|
+
}
|
|
3663
|
+
function tn(t, e, n) {
|
|
3664
|
+
const r = e.propertyName.toLowerCase(), s = t[0].propertyName.toLowerCase(), i = t[t.length - 1].propertyName.toLowerCase();
|
|
3665
|
+
if (r < s)
|
|
3666
|
+
return 0;
|
|
3667
|
+
if (r > i)
|
|
3668
|
+
return t.length;
|
|
3669
|
+
let a = 0, o = t.length - 1;
|
|
3670
|
+
for (; a <= o; ) {
|
|
3671
|
+
let m = o + a >> 1, f = n(e, t[m]);
|
|
3672
|
+
if (f > 0)
|
|
3673
|
+
a = m + 1;
|
|
3674
|
+
else if (f < 0)
|
|
3675
|
+
o = m - 1;
|
|
3676
|
+
else
|
|
3677
|
+
return m;
|
|
3678
|
+
}
|
|
3679
|
+
return -a - 1;
|
|
3680
|
+
}
|
|
3681
|
+
function nn(t, e) {
|
|
3682
|
+
const n = {
|
|
3683
|
+
...e,
|
|
3684
|
+
keepLines: !1
|
|
3685
|
+
// keepLines must be false so that the properties are on separate lines for the sorting
|
|
3686
|
+
}, r = K.applyEdits(t, Le(t, n, void 0)), s = K.create("test://test.json", "json", 0, r), i = rn(s), a = sn(s, i), o = Le(a, n, void 0), m = K.applyEdits(a, o);
|
|
3687
|
+
return [ke.replace($.create(R.create(0, 0), t.positionAt(t.getText().length)), m)];
|
|
3688
|
+
}
|
|
3689
|
+
function rn(t) {
|
|
3690
|
+
const e = t.getText(), n = Y(e, !1);
|
|
3691
|
+
let r = new ge(), s = r, i = r, a = r, o, m = 0, f = 0, h, l, u = -1, k = -1, p = 0, y = 0, d = [], T = !1, N = !1;
|
|
3692
|
+
for (; (o = n.scan()) !== 17; ) {
|
|
3693
|
+
if (T === !0 && o !== 14 && o !== 15 && o !== 12 && o !== 13 && i.endLineNumber === void 0) {
|
|
3694
|
+
let c = n.getTokenStartLine();
|
|
3695
|
+
l === 2 || l === 4 ? a.endLineNumber = c - 1 : i.endLineNumber = c - 1, p = c, T = !1;
|
|
3696
|
+
}
|
|
3697
|
+
if (N === !0 && o !== 14 && o !== 15 && o !== 12 && o !== 13 && (p = n.getTokenStartLine(), N = !1), n.getTokenStartLine() !== m) {
|
|
3698
|
+
for (let c = m; c < n.getTokenStartLine(); c++) {
|
|
3699
|
+
const v = t.getText($.create(R.create(c, 0), R.create(c + 1, 0))).length;
|
|
3700
|
+
f = f + v;
|
|
3701
|
+
}
|
|
3702
|
+
m = n.getTokenStartLine();
|
|
3703
|
+
}
|
|
3704
|
+
switch (o) {
|
|
3705
|
+
// When a string is found, if it follows an open brace or a comma token and it is within an object, then it corresponds to a key name, not a simple string
|
|
3706
|
+
case 10: {
|
|
3707
|
+
if (h === void 0 || h === 1 || h === 5 && d[d.length - 1] === F.Object) {
|
|
3708
|
+
const c = new ge(n.getTokenValue(), p);
|
|
3709
|
+
a = i, i = s.addChildProperty(c);
|
|
3710
|
+
}
|
|
3711
|
+
break;
|
|
3712
|
+
}
|
|
3713
|
+
// When the token is an open bracket, then we enter into an array
|
|
3714
|
+
case 3: {
|
|
3715
|
+
if (r.beginningLineNumber === void 0 && (r.beginningLineNumber = n.getTokenStartLine()), d[d.length - 1] === F.Object)
|
|
3716
|
+
s = i;
|
|
3717
|
+
else if (d[d.length - 1] === F.Array) {
|
|
3718
|
+
const c = new ge(n.getTokenValue(), p);
|
|
3719
|
+
c.noKeyName = !0, a = i, i = s.addChildProperty(c), s = i;
|
|
3720
|
+
}
|
|
3721
|
+
d.push(F.Array), i.type = F.Array, p = n.getTokenStartLine(), p++;
|
|
3722
|
+
break;
|
|
3723
|
+
}
|
|
3724
|
+
// When the token is an open brace, then we enter into an object
|
|
3725
|
+
case 1: {
|
|
3726
|
+
if (r.beginningLineNumber === void 0)
|
|
3727
|
+
r.beginningLineNumber = n.getTokenStartLine();
|
|
3728
|
+
else if (d[d.length - 1] === F.Array) {
|
|
3729
|
+
const c = new ge(n.getTokenValue(), p);
|
|
3730
|
+
c.noKeyName = !0, a = i, i = s.addChildProperty(c);
|
|
3731
|
+
}
|
|
3732
|
+
i.type = F.Object, d.push(F.Object), s = i, p = n.getTokenStartLine(), p++;
|
|
3733
|
+
break;
|
|
3734
|
+
}
|
|
3735
|
+
case 4: {
|
|
3736
|
+
y = n.getTokenStartLine(), d.pop(), i.endLineNumber === void 0 && (h === 2 || h === 4) && (i.endLineNumber = y - 1, i.lastProperty = !0, i.lineWhereToAddComma = u, i.indexWhereToAddComa = k, a = i, i = i ? i.parent : void 0, s = i), r.endLineNumber = y, p = y + 1;
|
|
3737
|
+
break;
|
|
3738
|
+
}
|
|
3739
|
+
case 2: {
|
|
3740
|
+
y = n.getTokenStartLine(), d.pop(), h !== 1 && (i.endLineNumber === void 0 && (i.endLineNumber = y - 1, i.lastProperty = !0, i.lineWhereToAddComma = u, i.indexWhereToAddComa = k), a = i, i = i ? i.parent : void 0, s = i), r.endLineNumber = n.getTokenStartLine(), p = y + 1;
|
|
3741
|
+
break;
|
|
3742
|
+
}
|
|
3743
|
+
case 5: {
|
|
3744
|
+
y = n.getTokenStartLine(), i.endLineNumber === void 0 && (d[d.length - 1] === F.Object || d[d.length - 1] === F.Array && (h === 2 || h === 4)) && (i.endLineNumber = y, i.commaIndex = n.getTokenOffset() - f, i.commaLine = y), (h === 2 || h === 4) && (a = i, i = i ? i.parent : void 0, s = i), p = y + 1;
|
|
3745
|
+
break;
|
|
3746
|
+
}
|
|
3747
|
+
case 13: {
|
|
3748
|
+
h === 5 && u === n.getTokenStartLine() && (d[d.length - 1] === F.Array && (l === 2 || l === 4) || d[d.length - 1] === F.Object) && (d[d.length - 1] === F.Array && (l === 2 || l === 4) || d[d.length - 1] === F.Object) && (i.endLineNumber = void 0, T = !0), (h === 1 || h === 3) && u === n.getTokenStartLine() && (N = !0);
|
|
3749
|
+
break;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
o !== 14 && o !== 13 && o !== 12 && o !== 15 && (l = h, h = o, u = n.getTokenStartLine(), k = n.getTokenOffset() + n.getTokenLength() - f);
|
|
3753
|
+
}
|
|
3754
|
+
return r;
|
|
3755
|
+
}
|
|
3756
|
+
function sn(t, e) {
|
|
3757
|
+
if (e.childrenProperties.length === 0)
|
|
3758
|
+
return t;
|
|
3759
|
+
const n = K.create("test://test.json", "json", 0, t.getText()), r = [];
|
|
3760
|
+
for (Qe(r, e, e.beginningLineNumber); r.length > 0; ) {
|
|
3761
|
+
const s = r.shift(), i = s.propertyTreeArray;
|
|
3762
|
+
let a = s.beginningLineNumber;
|
|
3763
|
+
for (let o = 0; o < i.length; o++) {
|
|
3764
|
+
const m = i[o], f = $.create(R.create(m.beginningLineNumber, 0), R.create(m.endLineNumber + 1, 0)), h = t.getText(f), l = K.create("test://test.json", "json", 0, h);
|
|
3765
|
+
if (m.lastProperty === !0 && o !== i.length - 1) {
|
|
3766
|
+
const p = m.lineWhereToAddComma - m.beginningLineNumber, y = m.indexWhereToAddComa, d = {
|
|
3767
|
+
range: $.create(R.create(p, y), R.create(p, y)),
|
|
3768
|
+
text: ","
|
|
3769
|
+
};
|
|
3770
|
+
K.update(l, [d], 1);
|
|
3771
|
+
} else if (m.lastProperty === !1 && o === i.length - 1) {
|
|
3772
|
+
const p = m.commaIndex, d = m.commaLine - m.beginningLineNumber, T = {
|
|
3773
|
+
range: $.create(R.create(d, p), R.create(d, p + 1)),
|
|
3774
|
+
text: ""
|
|
3775
|
+
};
|
|
3776
|
+
K.update(l, [T], 1);
|
|
3777
|
+
}
|
|
3778
|
+
const u = m.endLineNumber - m.beginningLineNumber + 1, k = {
|
|
3779
|
+
range: $.create(R.create(a, 0), R.create(a + u, 0)),
|
|
3780
|
+
text: l.getText()
|
|
3781
|
+
};
|
|
3782
|
+
K.update(n, [k], 1), Qe(r, m, a), a = a + u;
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
return n;
|
|
3786
|
+
}
|
|
3787
|
+
function Qe(t, e, n) {
|
|
3788
|
+
if (e.childrenProperties.length !== 0)
|
|
3789
|
+
if (e.type === F.Object) {
|
|
3790
|
+
let r = 1 / 0;
|
|
3791
|
+
for (const i of e.childrenProperties)
|
|
3792
|
+
i.beginningLineNumber < r && (r = i.beginningLineNumber);
|
|
3793
|
+
const s = r - e.beginningLineNumber;
|
|
3794
|
+
n = n + s, t.push(new at(n, e.childrenProperties));
|
|
3795
|
+
} else e.type === F.Array && ot(t, e, n);
|
|
3796
|
+
}
|
|
3797
|
+
function ot(t, e, n) {
|
|
3798
|
+
for (const r of e.childrenProperties) {
|
|
3799
|
+
if (r.type === F.Object) {
|
|
3800
|
+
let s = 1 / 0;
|
|
3801
|
+
for (const a of r.childrenProperties)
|
|
3802
|
+
a.beginningLineNumber < s && (s = a.beginningLineNumber);
|
|
3803
|
+
const i = s - r.beginningLineNumber;
|
|
3804
|
+
t.push(new at(n + r.beginningLineNumber - e.beginningLineNumber + i, r.childrenProperties));
|
|
3805
|
+
}
|
|
3806
|
+
r.type === F.Array && ot(t, r, n + r.beginningLineNumber - e.beginningLineNumber);
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
class at {
|
|
3810
|
+
constructor(e, n) {
|
|
3811
|
+
this.beginningLineNumber = e, this.propertyTreeArray = n;
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
function on(t, e) {
|
|
3815
|
+
const n = [];
|
|
3816
|
+
return e.visit((r) => {
|
|
3817
|
+
var s;
|
|
3818
|
+
if (r.type === "property" && r.keyNode.value === "$ref" && ((s = r.valueNode) == null ? void 0 : s.type) === "string") {
|
|
3819
|
+
const i = r.valueNode.value, a = ln(e, i);
|
|
3820
|
+
if (a) {
|
|
3821
|
+
const o = t.positionAt(a.offset);
|
|
3822
|
+
n.push({
|
|
3823
|
+
target: `${t.uri}#${o.line + 1},${o.character + 1}`,
|
|
3824
|
+
range: an(t, r.valueNode)
|
|
3825
|
+
});
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
return !0;
|
|
3829
|
+
}), Promise.resolve(n);
|
|
3830
|
+
}
|
|
3831
|
+
function an(t, e) {
|
|
3832
|
+
return $.create(t.positionAt(e.offset + 1), t.positionAt(e.offset + e.length - 1));
|
|
3833
|
+
}
|
|
3834
|
+
function ln(t, e) {
|
|
3835
|
+
const n = fn(e);
|
|
3836
|
+
return n ? Ve(n, t.root) : null;
|
|
3837
|
+
}
|
|
3838
|
+
function Ve(t, e) {
|
|
3839
|
+
if (!e)
|
|
3840
|
+
return null;
|
|
3841
|
+
if (t.length === 0)
|
|
3842
|
+
return e;
|
|
3843
|
+
const n = t.shift();
|
|
3844
|
+
if (e && e.type === "object") {
|
|
3845
|
+
const r = e.properties.find((s) => s.keyNode.value === n);
|
|
3846
|
+
return r ? Ve(t, r.valueNode) : null;
|
|
3847
|
+
} else if (e && e.type === "array" && n.match(/^(0|[1-9][0-9]*)$/)) {
|
|
3848
|
+
const r = Number.parseInt(n), s = e.items[r];
|
|
3849
|
+
return s ? Ve(t, s) : null;
|
|
3850
|
+
}
|
|
3851
|
+
return null;
|
|
3852
|
+
}
|
|
3853
|
+
function fn(t) {
|
|
3854
|
+
return t === "#" ? [] : t[0] !== "#" || t[1] !== "/" ? null : t.substring(2).split(/\//).map(cn);
|
|
3855
|
+
}
|
|
3856
|
+
function cn(t) {
|
|
3857
|
+
return t.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
3858
|
+
}
|
|
3859
|
+
function un(t) {
|
|
3860
|
+
const e = t.promiseConstructor || Promise, n = new Xt(t.schemaRequestService, t.workspaceContext, e);
|
|
3861
|
+
n.setSchemaContributions(Ie);
|
|
3862
|
+
const r = new $t(n, t.contributions, e, t.clientCapabilities), s = new Et(n, t.contributions, e), i = new qt(n), a = new Dt(n, e);
|
|
3863
|
+
return {
|
|
3864
|
+
configure: (o) => {
|
|
3865
|
+
var m;
|
|
3866
|
+
n.clearExternalSchemas(), (m = o.schemas) == null || m.forEach(n.registerExternalSchema.bind(n)), a.configure(o);
|
|
3867
|
+
},
|
|
3868
|
+
resetSchema: (o) => n.onResourceChange(o),
|
|
3869
|
+
doValidation: a.doValidation.bind(a),
|
|
3870
|
+
getLanguageStatus: a.getLanguageStatus.bind(a),
|
|
3871
|
+
parseJSONDocument: (o) => Ft(o, { collectComments: !0 }),
|
|
3872
|
+
newJSONDocument: (o, m) => Mt(o, m),
|
|
3873
|
+
getMatchingSchemas: n.getMatchingSchemas.bind(n),
|
|
3874
|
+
doResolve: r.doResolve.bind(r),
|
|
3875
|
+
doComplete: r.doComplete.bind(r),
|
|
3876
|
+
findDocumentSymbols: i.findDocumentSymbols.bind(i),
|
|
3877
|
+
findDocumentSymbols2: i.findDocumentSymbols2.bind(i),
|
|
3878
|
+
findDocumentColors: i.findDocumentColors.bind(i),
|
|
3879
|
+
getColorPresentations: i.getColorPresentations.bind(i),
|
|
3880
|
+
doHover: s.doHover.bind(s),
|
|
3881
|
+
getFoldingRanges: Yt,
|
|
3882
|
+
getSelectionRanges: Ct,
|
|
3883
|
+
findDefinition: () => Promise.resolve([]),
|
|
3884
|
+
findLinks: on,
|
|
3885
|
+
format: (o, m, f) => Le(o, f, m),
|
|
3886
|
+
sort: (o, m) => nn(o, m)
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
let lt;
|
|
3890
|
+
typeof fetch < "u" && (lt = function(t) {
|
|
3891
|
+
return fetch(t).then((e) => e.text());
|
|
3892
|
+
});
|
|
3893
|
+
class pn {
|
|
3894
|
+
constructor(e, n) {
|
|
3895
|
+
this._ctx = e, this._languageSettings = n.languageSettings, this._languageId = n.languageId, this._languageService = un({
|
|
3896
|
+
workspaceContext: {
|
|
3897
|
+
resolveRelativePath: (r, s) => {
|
|
3898
|
+
const i = s.substr(0, s.lastIndexOf("/") + 1);
|
|
3899
|
+
return gn(i, r);
|
|
3900
|
+
}
|
|
3901
|
+
},
|
|
3902
|
+
schemaRequestService: n.enableSchemaRequest ? lt : void 0,
|
|
3903
|
+
clientCapabilities: we.LATEST
|
|
3904
|
+
}), this._languageService.configure(this._languageSettings);
|
|
3905
|
+
}
|
|
3906
|
+
async doValidation(e) {
|
|
3907
|
+
let n = this._getTextDocument(e);
|
|
3908
|
+
if (n) {
|
|
3909
|
+
let r = this._languageService.parseJSONDocument(n);
|
|
3910
|
+
return this._languageService.doValidation(n, r, this._languageSettings);
|
|
3911
|
+
}
|
|
3912
|
+
return Promise.resolve([]);
|
|
3913
|
+
}
|
|
3914
|
+
async doComplete(e, n) {
|
|
3915
|
+
let r = this._getTextDocument(e);
|
|
3916
|
+
if (!r)
|
|
3917
|
+
return null;
|
|
3918
|
+
let s = this._languageService.parseJSONDocument(r);
|
|
3919
|
+
return this._languageService.doComplete(r, n, s);
|
|
3920
|
+
}
|
|
3921
|
+
async doResolve(e) {
|
|
3922
|
+
return this._languageService.doResolve(e);
|
|
3923
|
+
}
|
|
3924
|
+
async doHover(e, n) {
|
|
3925
|
+
let r = this._getTextDocument(e);
|
|
3926
|
+
if (!r)
|
|
3927
|
+
return null;
|
|
3928
|
+
let s = this._languageService.parseJSONDocument(r);
|
|
3929
|
+
return this._languageService.doHover(r, n, s);
|
|
3930
|
+
}
|
|
3931
|
+
async format(e, n, r) {
|
|
3932
|
+
let s = this._getTextDocument(e);
|
|
3933
|
+
if (!s)
|
|
3934
|
+
return [];
|
|
3935
|
+
let i = this._languageService.format(s, n, r);
|
|
3936
|
+
return Promise.resolve(i);
|
|
3937
|
+
}
|
|
3938
|
+
async resetSchema(e) {
|
|
3939
|
+
return Promise.resolve(this._languageService.resetSchema(e));
|
|
3940
|
+
}
|
|
3941
|
+
async findDocumentSymbols(e) {
|
|
3942
|
+
let n = this._getTextDocument(e);
|
|
3943
|
+
if (!n)
|
|
3944
|
+
return [];
|
|
3945
|
+
let r = this._languageService.parseJSONDocument(n), s = this._languageService.findDocumentSymbols2(n, r);
|
|
3946
|
+
return Promise.resolve(s);
|
|
3947
|
+
}
|
|
3948
|
+
async findDocumentColors(e) {
|
|
3949
|
+
let n = this._getTextDocument(e);
|
|
3950
|
+
if (!n)
|
|
3951
|
+
return [];
|
|
3952
|
+
let r = this._languageService.parseJSONDocument(n), s = this._languageService.findDocumentColors(n, r);
|
|
3953
|
+
return Promise.resolve(s);
|
|
3954
|
+
}
|
|
3955
|
+
async getColorPresentations(e, n, r) {
|
|
3956
|
+
let s = this._getTextDocument(e);
|
|
3957
|
+
if (!s)
|
|
3958
|
+
return [];
|
|
3959
|
+
let i = this._languageService.parseJSONDocument(s), a = this._languageService.getColorPresentations(
|
|
3960
|
+
s,
|
|
3961
|
+
i,
|
|
3962
|
+
n,
|
|
3963
|
+
r
|
|
3964
|
+
);
|
|
3965
|
+
return Promise.resolve(a);
|
|
3966
|
+
}
|
|
3967
|
+
async getFoldingRanges(e, n) {
|
|
3968
|
+
let r = this._getTextDocument(e);
|
|
3969
|
+
if (!r)
|
|
3970
|
+
return [];
|
|
3971
|
+
let s = this._languageService.getFoldingRanges(r, n);
|
|
3972
|
+
return Promise.resolve(s);
|
|
3973
|
+
}
|
|
3974
|
+
async getSelectionRanges(e, n) {
|
|
3975
|
+
let r = this._getTextDocument(e);
|
|
3976
|
+
if (!r)
|
|
3977
|
+
return [];
|
|
3978
|
+
let s = this._languageService.parseJSONDocument(r), i = this._languageService.getSelectionRanges(r, n, s);
|
|
3979
|
+
return Promise.resolve(i);
|
|
3980
|
+
}
|
|
3981
|
+
async parseJSONDocument(e) {
|
|
3982
|
+
let n = this._getTextDocument(e);
|
|
3983
|
+
if (!n)
|
|
3984
|
+
return null;
|
|
3985
|
+
let r = this._languageService.parseJSONDocument(n);
|
|
3986
|
+
return Promise.resolve(r);
|
|
3987
|
+
}
|
|
3988
|
+
async getMatchingSchemas(e) {
|
|
3989
|
+
let n = this._getTextDocument(e);
|
|
3990
|
+
if (!n)
|
|
3991
|
+
return [];
|
|
3992
|
+
let r = this._languageService.parseJSONDocument(n);
|
|
3993
|
+
return Promise.resolve(this._languageService.getMatchingSchemas(n, r));
|
|
3994
|
+
}
|
|
3995
|
+
_getTextDocument(e) {
|
|
3996
|
+
let n = this._ctx.getMirrorModels();
|
|
3997
|
+
for (let r of n)
|
|
3998
|
+
if (r.uri.toString() === e)
|
|
3999
|
+
return K.create(
|
|
4000
|
+
e,
|
|
4001
|
+
this._languageId,
|
|
4002
|
+
r.version,
|
|
4003
|
+
r.getValue()
|
|
4004
|
+
);
|
|
4005
|
+
return null;
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
const mn = 47, Ne = 46;
|
|
4009
|
+
function hn(t) {
|
|
4010
|
+
return t.charCodeAt(0) === mn;
|
|
4011
|
+
}
|
|
4012
|
+
function gn(t, e) {
|
|
4013
|
+
if (hn(e)) {
|
|
4014
|
+
const n = se.parse(t), r = e.split("/");
|
|
4015
|
+
return n.with({ path: ft(r) }).toString();
|
|
4016
|
+
}
|
|
4017
|
+
return dn(t, e);
|
|
4018
|
+
}
|
|
4019
|
+
function ft(t) {
|
|
4020
|
+
const e = [];
|
|
4021
|
+
for (const r of t)
|
|
4022
|
+
r.length === 0 || r.length === 1 && r.charCodeAt(0) === Ne || (r.length === 2 && r.charCodeAt(0) === Ne && r.charCodeAt(1) === Ne ? e.pop() : e.push(r));
|
|
4023
|
+
t.length > 1 && t[t.length - 1].length === 0 && e.push("");
|
|
4024
|
+
let n = e.join("/");
|
|
4025
|
+
return t[0].length === 0 && (n = "/" + n), n;
|
|
4026
|
+
}
|
|
4027
|
+
function dn(t, ...e) {
|
|
4028
|
+
const n = se.parse(t), r = n.path.split("/");
|
|
4029
|
+
for (let s of e)
|
|
4030
|
+
r.push(...s.split("/"));
|
|
4031
|
+
return n.with({ path: ft(r) }).toString();
|
|
4032
|
+
}
|
|
4033
|
+
self.onmessage = () => {
|
|
4034
|
+
ct((t, e) => new pn(t, e));
|
|
4035
|
+
};
|
|
4036
|
+
const kn = {};
|
|
4037
|
+
export {
|
|
4038
|
+
kn as default
|
|
4039
|
+
};
|