vscode-json-languageservice 4.2.1 → 5.0.0
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/CHANGELOG.md +7 -1
- package/SECURITY.md +41 -0
- package/lib/esm/jsonContributions.d.ts +17 -17
- package/lib/esm/jsonContributions.js +1 -1
- package/lib/esm/jsonLanguageService.d.ts +29 -29
- package/lib/esm/jsonLanguageService.js +66 -66
- package/lib/esm/jsonLanguageTypes.d.ts +279 -278
- package/lib/esm/jsonLanguageTypes.js +46 -45
- package/lib/esm/jsonSchema.d.ts +89 -70
- package/lib/esm/jsonSchema.js +1 -1
- package/lib/esm/parser/jsonParser.js +1214 -1218
- package/lib/esm/services/configuration.js +528 -528
- package/lib/esm/services/jsonCompletion.js +918 -934
- package/lib/esm/services/jsonDocumentSymbols.js +267 -278
- package/lib/esm/services/jsonFolding.js +120 -121
- package/lib/esm/services/jsonHover.js +109 -112
- package/lib/esm/services/jsonLinks.js +72 -73
- package/lib/esm/services/jsonSchemaService.js +586 -605
- package/lib/esm/services/jsonSelectionRanges.js +61 -61
- package/lib/esm/services/jsonValidation.js +151 -149
- package/lib/esm/utils/colors.js +68 -69
- package/lib/esm/utils/glob.js +124 -124
- package/lib/esm/utils/json.js +42 -42
- package/lib/esm/utils/objects.js +68 -65
- package/lib/esm/utils/strings.js +64 -64
- package/lib/umd/jsonContributions.d.ts +17 -17
- package/lib/umd/jsonContributions.js +12 -12
- package/lib/umd/jsonLanguageService.d.ts +29 -29
- package/lib/umd/jsonLanguageService.js +90 -90
- package/lib/umd/jsonLanguageTypes.d.ts +279 -278
- package/lib/umd/jsonLanguageTypes.js +93 -92
- package/lib/umd/jsonSchema.d.ts +89 -70
- package/lib/umd/jsonSchema.js +12 -12
- package/lib/umd/parser/jsonParser.js +1243 -1237
- package/lib/umd/services/configuration.js +541 -541
- package/lib/umd/services/jsonCompletion.js +932 -947
- package/lib/umd/services/jsonDocumentSymbols.js +281 -291
- package/lib/umd/services/jsonFolding.js +134 -135
- package/lib/umd/services/jsonHover.js +123 -125
- package/lib/umd/services/jsonLinks.js +86 -87
- package/lib/umd/services/jsonSchemaService.js +602 -618
- package/lib/umd/services/jsonSelectionRanges.js +75 -75
- package/lib/umd/services/jsonValidation.js +165 -162
- package/lib/umd/utils/colors.js +84 -85
- package/lib/umd/utils/glob.js +138 -138
- package/lib/umd/utils/json.js +56 -56
- package/lib/umd/utils/objects.js +87 -83
- package/lib/umd/utils/strings.js +82 -82
- package/package.json +10 -10
|
@@ -1,291 +1,281 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
(function (factory) {
|
|
6
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
-
var v = factory(require, exports);
|
|
8
|
-
if (v !== undefined) module.exports = v;
|
|
9
|
-
}
|
|
10
|
-
else if (typeof define === "function" && define.amd) {
|
|
11
|
-
define(["require", "exports", "../parser/jsonParser", "../utils/strings", "../utils/colors", "../jsonLanguageTypes"], factory);
|
|
12
|
-
}
|
|
13
|
-
})(function (require, exports) {
|
|
14
|
-
"use strict";
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.JSONDocumentSymbols = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.schemaService = schemaService;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
case '
|
|
196
|
-
return jsonLanguageTypes_1.SymbolKind.
|
|
197
|
-
|
|
198
|
-
return jsonLanguageTypes_1.SymbolKind.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
result.push({ label: label, textEdit: jsonLanguageTypes_1.TextEdit.replace(range, JSON.stringify(label)) });
|
|
283
|
-
return result;
|
|
284
|
-
};
|
|
285
|
-
return JSONDocumentSymbols;
|
|
286
|
-
}());
|
|
287
|
-
exports.JSONDocumentSymbols = JSONDocumentSymbols;
|
|
288
|
-
function getRange(document, node) {
|
|
289
|
-
return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
|
290
|
-
}
|
|
291
|
-
});
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
(function (factory) {
|
|
6
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
+
var v = factory(require, exports);
|
|
8
|
+
if (v !== undefined) module.exports = v;
|
|
9
|
+
}
|
|
10
|
+
else if (typeof define === "function" && define.amd) {
|
|
11
|
+
define(["require", "exports", "../parser/jsonParser", "../utils/strings", "../utils/colors", "../jsonLanguageTypes"], factory);
|
|
12
|
+
}
|
|
13
|
+
})(function (require, exports) {
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.JSONDocumentSymbols = void 0;
|
|
17
|
+
const Parser = require("../parser/jsonParser");
|
|
18
|
+
const Strings = require("../utils/strings");
|
|
19
|
+
const colors_1 = require("../utils/colors");
|
|
20
|
+
const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
|
|
21
|
+
class JSONDocumentSymbols {
|
|
22
|
+
constructor(schemaService) {
|
|
23
|
+
this.schemaService = schemaService;
|
|
24
|
+
}
|
|
25
|
+
findDocumentSymbols(document, doc, context = { resultLimit: Number.MAX_VALUE }) {
|
|
26
|
+
const root = doc.root;
|
|
27
|
+
if (!root) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
let limit = context.resultLimit || Number.MAX_VALUE;
|
|
31
|
+
// special handling for key bindings
|
|
32
|
+
const resourceString = document.uri;
|
|
33
|
+
if ((resourceString === 'vscode://defaultsettings/keybindings.json') || Strings.endsWith(resourceString.toLowerCase(), '/user/keybindings.json')) {
|
|
34
|
+
if (root.type === 'array') {
|
|
35
|
+
const result = [];
|
|
36
|
+
for (const item of root.items) {
|
|
37
|
+
if (item.type === 'object') {
|
|
38
|
+
for (const property of item.properties) {
|
|
39
|
+
if (property.keyNode.value === 'key' && property.valueNode) {
|
|
40
|
+
const location = jsonLanguageTypes_1.Location.create(document.uri, getRange(document, item));
|
|
41
|
+
result.push({ name: Parser.getNodeValue(property.valueNode), kind: jsonLanguageTypes_1.SymbolKind.Function, location: location });
|
|
42
|
+
limit--;
|
|
43
|
+
if (limit <= 0) {
|
|
44
|
+
if (context && context.onResultLimitExceeded) {
|
|
45
|
+
context.onResultLimitExceeded(resourceString);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const toVisit = [
|
|
57
|
+
{ node: root, containerName: '' }
|
|
58
|
+
];
|
|
59
|
+
let nextToVisit = 0;
|
|
60
|
+
let limitExceeded = false;
|
|
61
|
+
const result = [];
|
|
62
|
+
const collectOutlineEntries = (node, containerName) => {
|
|
63
|
+
if (node.type === 'array') {
|
|
64
|
+
node.items.forEach(node => {
|
|
65
|
+
if (node) {
|
|
66
|
+
toVisit.push({ node, containerName });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (node.type === 'object') {
|
|
71
|
+
node.properties.forEach((property) => {
|
|
72
|
+
const valueNode = property.valueNode;
|
|
73
|
+
if (valueNode) {
|
|
74
|
+
if (limit > 0) {
|
|
75
|
+
limit--;
|
|
76
|
+
const location = jsonLanguageTypes_1.Location.create(document.uri, getRange(document, property));
|
|
77
|
+
const childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value;
|
|
78
|
+
result.push({ name: this.getKeyLabel(property), kind: this.getSymbolKind(valueNode.type), location: location, containerName: containerName });
|
|
79
|
+
toVisit.push({ node: valueNode, containerName: childContainerName });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
limitExceeded = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
// breath first traversal
|
|
89
|
+
while (nextToVisit < toVisit.length) {
|
|
90
|
+
const next = toVisit[nextToVisit++];
|
|
91
|
+
collectOutlineEntries(next.node, next.containerName);
|
|
92
|
+
}
|
|
93
|
+
if (limitExceeded && context && context.onResultLimitExceeded) {
|
|
94
|
+
context.onResultLimitExceeded(resourceString);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
findDocumentSymbols2(document, doc, context = { resultLimit: Number.MAX_VALUE }) {
|
|
99
|
+
const root = doc.root;
|
|
100
|
+
if (!root) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
let limit = context.resultLimit || Number.MAX_VALUE;
|
|
104
|
+
// special handling for key bindings
|
|
105
|
+
const resourceString = document.uri;
|
|
106
|
+
if ((resourceString === 'vscode://defaultsettings/keybindings.json') || Strings.endsWith(resourceString.toLowerCase(), '/user/keybindings.json')) {
|
|
107
|
+
if (root.type === 'array') {
|
|
108
|
+
const result = [];
|
|
109
|
+
for (const item of root.items) {
|
|
110
|
+
if (item.type === 'object') {
|
|
111
|
+
for (const property of item.properties) {
|
|
112
|
+
if (property.keyNode.value === 'key' && property.valueNode) {
|
|
113
|
+
const range = getRange(document, item);
|
|
114
|
+
const selectionRange = getRange(document, property.keyNode);
|
|
115
|
+
result.push({ name: Parser.getNodeValue(property.valueNode), kind: jsonLanguageTypes_1.SymbolKind.Function, range, selectionRange });
|
|
116
|
+
limit--;
|
|
117
|
+
if (limit <= 0) {
|
|
118
|
+
if (context && context.onResultLimitExceeded) {
|
|
119
|
+
context.onResultLimitExceeded(resourceString);
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const result = [];
|
|
131
|
+
const toVisit = [
|
|
132
|
+
{ node: root, result }
|
|
133
|
+
];
|
|
134
|
+
let nextToVisit = 0;
|
|
135
|
+
let limitExceeded = false;
|
|
136
|
+
const collectOutlineEntries = (node, result) => {
|
|
137
|
+
if (node.type === 'array') {
|
|
138
|
+
node.items.forEach((node, index) => {
|
|
139
|
+
if (node) {
|
|
140
|
+
if (limit > 0) {
|
|
141
|
+
limit--;
|
|
142
|
+
const range = getRange(document, node);
|
|
143
|
+
const selectionRange = range;
|
|
144
|
+
const name = String(index);
|
|
145
|
+
const symbol = { name, kind: this.getSymbolKind(node.type), range, selectionRange, children: [] };
|
|
146
|
+
result.push(symbol);
|
|
147
|
+
toVisit.push({ result: symbol.children, node });
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
limitExceeded = true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else if (node.type === 'object') {
|
|
156
|
+
node.properties.forEach((property) => {
|
|
157
|
+
const valueNode = property.valueNode;
|
|
158
|
+
if (valueNode) {
|
|
159
|
+
if (limit > 0) {
|
|
160
|
+
limit--;
|
|
161
|
+
const range = getRange(document, property);
|
|
162
|
+
const selectionRange = getRange(document, property.keyNode);
|
|
163
|
+
const children = [];
|
|
164
|
+
const symbol = { name: this.getKeyLabel(property), kind: this.getSymbolKind(valueNode.type), range, selectionRange, children, detail: this.getDetail(valueNode) };
|
|
165
|
+
result.push(symbol);
|
|
166
|
+
toVisit.push({ result: children, node: valueNode });
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
limitExceeded = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
// breath first traversal
|
|
176
|
+
while (nextToVisit < toVisit.length) {
|
|
177
|
+
const next = toVisit[nextToVisit++];
|
|
178
|
+
collectOutlineEntries(next.node, next.result);
|
|
179
|
+
}
|
|
180
|
+
if (limitExceeded && context && context.onResultLimitExceeded) {
|
|
181
|
+
context.onResultLimitExceeded(resourceString);
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
getSymbolKind(nodeType) {
|
|
186
|
+
switch (nodeType) {
|
|
187
|
+
case 'object':
|
|
188
|
+
return jsonLanguageTypes_1.SymbolKind.Module;
|
|
189
|
+
case 'string':
|
|
190
|
+
return jsonLanguageTypes_1.SymbolKind.String;
|
|
191
|
+
case 'number':
|
|
192
|
+
return jsonLanguageTypes_1.SymbolKind.Number;
|
|
193
|
+
case 'array':
|
|
194
|
+
return jsonLanguageTypes_1.SymbolKind.Array;
|
|
195
|
+
case 'boolean':
|
|
196
|
+
return jsonLanguageTypes_1.SymbolKind.Boolean;
|
|
197
|
+
default: // 'null'
|
|
198
|
+
return jsonLanguageTypes_1.SymbolKind.Variable;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
getKeyLabel(property) {
|
|
202
|
+
let name = property.keyNode.value;
|
|
203
|
+
if (name) {
|
|
204
|
+
name = name.replace(/[\n]/g, '↵');
|
|
205
|
+
}
|
|
206
|
+
if (name && name.trim()) {
|
|
207
|
+
return name;
|
|
208
|
+
}
|
|
209
|
+
return `"${name}"`;
|
|
210
|
+
}
|
|
211
|
+
getDetail(node) {
|
|
212
|
+
if (!node) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
if (node.type === 'boolean' || node.type === 'number' || node.type === 'null' || node.type === 'string') {
|
|
216
|
+
return String(node.value);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
if (node.type === 'array') {
|
|
220
|
+
return node.children.length ? undefined : '[]';
|
|
221
|
+
}
|
|
222
|
+
else if (node.type === 'object') {
|
|
223
|
+
return node.children.length ? undefined : '{}';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
findDocumentColors(document, doc, context) {
|
|
229
|
+
return this.schemaService.getSchemaForResource(document.uri, doc).then(schema => {
|
|
230
|
+
const result = [];
|
|
231
|
+
if (schema) {
|
|
232
|
+
let limit = context && typeof context.resultLimit === 'number' ? context.resultLimit : Number.MAX_VALUE;
|
|
233
|
+
const matchingSchemas = doc.getMatchingSchemas(schema.schema);
|
|
234
|
+
const visitedNode = {};
|
|
235
|
+
for (const s of matchingSchemas) {
|
|
236
|
+
if (!s.inverted && s.schema && (s.schema.format === 'color' || s.schema.format === 'color-hex') && s.node && s.node.type === 'string') {
|
|
237
|
+
const nodeId = String(s.node.offset);
|
|
238
|
+
if (!visitedNode[nodeId]) {
|
|
239
|
+
const color = (0, colors_1.colorFromHex)(Parser.getNodeValue(s.node));
|
|
240
|
+
if (color) {
|
|
241
|
+
const range = getRange(document, s.node);
|
|
242
|
+
result.push({ color, range });
|
|
243
|
+
}
|
|
244
|
+
visitedNode[nodeId] = true;
|
|
245
|
+
limit--;
|
|
246
|
+
if (limit <= 0) {
|
|
247
|
+
if (context && context.onResultLimitExceeded) {
|
|
248
|
+
context.onResultLimitExceeded(document.uri);
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
getColorPresentations(document, doc, color, range) {
|
|
260
|
+
const result = [];
|
|
261
|
+
const red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
|
|
262
|
+
function toTwoDigitHex(n) {
|
|
263
|
+
const r = n.toString(16);
|
|
264
|
+
return r.length !== 2 ? '0' + r : r;
|
|
265
|
+
}
|
|
266
|
+
let label;
|
|
267
|
+
if (color.alpha === 1) {
|
|
268
|
+
label = `#${toTwoDigitHex(red256)}${toTwoDigitHex(green256)}${toTwoDigitHex(blue256)}`;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
label = `#${toTwoDigitHex(red256)}${toTwoDigitHex(green256)}${toTwoDigitHex(blue256)}${toTwoDigitHex(Math.round(color.alpha * 255))}`;
|
|
272
|
+
}
|
|
273
|
+
result.push({ label: label, textEdit: jsonLanguageTypes_1.TextEdit.replace(range, JSON.stringify(label)) });
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
exports.JSONDocumentSymbols = JSONDocumentSymbols;
|
|
278
|
+
function getRange(document, node) {
|
|
279
|
+
return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
|
280
|
+
}
|
|
281
|
+
});
|