vscode-json-languageservice 5.0.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -2
- 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 +292 -279
- package/lib/esm/jsonLanguageTypes.js +55 -46
- package/lib/esm/jsonSchema.d.ts +89 -89
- package/lib/esm/jsonSchema.js +1 -1
- package/lib/esm/parser/jsonParser.js +1236 -1214
- package/lib/esm/services/configuration.js +528 -528
- package/lib/esm/services/jsonCompletion.js +924 -918
- package/lib/esm/services/jsonDocumentSymbols.js +267 -267
- package/lib/esm/services/jsonFolding.js +120 -120
- package/lib/esm/services/jsonHover.js +109 -109
- package/lib/esm/services/jsonLinks.js +72 -72
- package/lib/esm/services/jsonSchemaService.js +593 -586
- package/lib/esm/services/jsonSelectionRanges.js +61 -61
- package/lib/esm/services/jsonValidation.js +151 -151
- package/lib/esm/utils/colors.js +68 -68
- package/lib/esm/utils/glob.js +124 -124
- package/lib/esm/utils/json.js +42 -42
- package/lib/esm/utils/objects.js +68 -68
- package/lib/esm/utils/strings.js +79 -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 +94 -90
- package/lib/umd/jsonLanguageTypes.d.ts +292 -279
- package/lib/umd/jsonLanguageTypes.js +103 -93
- package/lib/umd/jsonSchema.d.ts +89 -89
- package/lib/umd/jsonSchema.js +12 -12
- package/lib/umd/parser/jsonParser.js +1265 -1243
- package/lib/umd/services/configuration.js +541 -541
- package/lib/umd/services/jsonCompletion.js +938 -932
- package/lib/umd/services/jsonDocumentSymbols.js +281 -281
- package/lib/umd/services/jsonFolding.js +134 -134
- package/lib/umd/services/jsonHover.js +123 -123
- package/lib/umd/services/jsonLinks.js +86 -86
- package/lib/umd/services/jsonSchemaService.js +609 -602
- package/lib/umd/services/jsonSelectionRanges.js +75 -75
- package/lib/umd/services/jsonValidation.js +165 -165
- package/lib/umd/utils/colors.js +84 -84
- package/lib/umd/utils/glob.js +138 -138
- package/lib/umd/utils/json.js +56 -56
- package/lib/umd/utils/objects.js +87 -87
- package/lib/umd/utils/strings.js +98 -82
- package/package.json +11 -10
|
@@ -1,86 +1,86 @@
|
|
|
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", "../jsonLanguageTypes"], factory);
|
|
12
|
-
}
|
|
13
|
-
})(function (require, exports) {
|
|
14
|
-
"use strict";
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.findLinks = void 0;
|
|
17
|
-
const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
|
|
18
|
-
function findLinks(document, doc) {
|
|
19
|
-
const links = [];
|
|
20
|
-
doc.visit(node => {
|
|
21
|
-
if (node.type === "property" && node.keyNode.value === "$ref" && node.valueNode?.type === 'string') {
|
|
22
|
-
const path = node.valueNode.value;
|
|
23
|
-
const targetNode = findTargetNode(doc, path);
|
|
24
|
-
if (targetNode) {
|
|
25
|
-
const targetPos = document.positionAt(targetNode.offset);
|
|
26
|
-
links.push({
|
|
27
|
-
target: `${document.uri}#${targetPos.line + 1},${targetPos.character + 1}`,
|
|
28
|
-
range: createRange(document, node.valueNode)
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
return Promise.resolve(links);
|
|
35
|
-
}
|
|
36
|
-
exports.findLinks = findLinks;
|
|
37
|
-
function createRange(document, node) {
|
|
38
|
-
return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset + 1), document.positionAt(node.offset + node.length - 1));
|
|
39
|
-
}
|
|
40
|
-
function findTargetNode(doc, path) {
|
|
41
|
-
const tokens = parseJSONPointer(path);
|
|
42
|
-
if (!tokens) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return findNode(tokens, doc.root);
|
|
46
|
-
}
|
|
47
|
-
function findNode(pointer, node) {
|
|
48
|
-
if (!node) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
if (pointer.length === 0) {
|
|
52
|
-
return node;
|
|
53
|
-
}
|
|
54
|
-
const token = pointer.shift();
|
|
55
|
-
if (node && node.type === 'object') {
|
|
56
|
-
const propertyNode = node.properties.find((propertyNode) => propertyNode.keyNode.value === token);
|
|
57
|
-
if (!propertyNode) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
return findNode(pointer, propertyNode.valueNode);
|
|
61
|
-
}
|
|
62
|
-
else if (node && node.type === 'array') {
|
|
63
|
-
if (token.match(/^(0|[1-9][0-9]*)$/)) {
|
|
64
|
-
const index = Number.parseInt(token);
|
|
65
|
-
const arrayItem = node.items[index];
|
|
66
|
-
if (!arrayItem) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return findNode(pointer, arrayItem);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
function parseJSONPointer(path) {
|
|
75
|
-
if (path === "#") {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
if (path[0] !== '#' || path[1] !== '/') {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
return path.substring(2).split(/\//).map(unescape);
|
|
82
|
-
}
|
|
83
|
-
function unescape(str) {
|
|
84
|
-
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
85
|
-
}
|
|
86
|
-
});
|
|
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", "../jsonLanguageTypes"], factory);
|
|
12
|
+
}
|
|
13
|
+
})(function (require, exports) {
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.findLinks = void 0;
|
|
17
|
+
const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
|
|
18
|
+
function findLinks(document, doc) {
|
|
19
|
+
const links = [];
|
|
20
|
+
doc.visit(node => {
|
|
21
|
+
if (node.type === "property" && node.keyNode.value === "$ref" && node.valueNode?.type === 'string') {
|
|
22
|
+
const path = node.valueNode.value;
|
|
23
|
+
const targetNode = findTargetNode(doc, path);
|
|
24
|
+
if (targetNode) {
|
|
25
|
+
const targetPos = document.positionAt(targetNode.offset);
|
|
26
|
+
links.push({
|
|
27
|
+
target: `${document.uri}#${targetPos.line + 1},${targetPos.character + 1}`,
|
|
28
|
+
range: createRange(document, node.valueNode)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
return Promise.resolve(links);
|
|
35
|
+
}
|
|
36
|
+
exports.findLinks = findLinks;
|
|
37
|
+
function createRange(document, node) {
|
|
38
|
+
return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset + 1), document.positionAt(node.offset + node.length - 1));
|
|
39
|
+
}
|
|
40
|
+
function findTargetNode(doc, path) {
|
|
41
|
+
const tokens = parseJSONPointer(path);
|
|
42
|
+
if (!tokens) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return findNode(tokens, doc.root);
|
|
46
|
+
}
|
|
47
|
+
function findNode(pointer, node) {
|
|
48
|
+
if (!node) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (pointer.length === 0) {
|
|
52
|
+
return node;
|
|
53
|
+
}
|
|
54
|
+
const token = pointer.shift();
|
|
55
|
+
if (node && node.type === 'object') {
|
|
56
|
+
const propertyNode = node.properties.find((propertyNode) => propertyNode.keyNode.value === token);
|
|
57
|
+
if (!propertyNode) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return findNode(pointer, propertyNode.valueNode);
|
|
61
|
+
}
|
|
62
|
+
else if (node && node.type === 'array') {
|
|
63
|
+
if (token.match(/^(0|[1-9][0-9]*)$/)) {
|
|
64
|
+
const index = Number.parseInt(token);
|
|
65
|
+
const arrayItem = node.items[index];
|
|
66
|
+
if (!arrayItem) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return findNode(pointer, arrayItem);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function parseJSONPointer(path) {
|
|
75
|
+
if (path === "#") {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
if (path[0] !== '#' || path[1] !== '/') {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return path.substring(2).split(/\//).map(unescape);
|
|
82
|
+
}
|
|
83
|
+
function unescape(str) {
|
|
84
|
+
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
85
|
+
}
|
|
86
|
+
});
|