vscode-json-languageservice 4.2.0 → 5.1.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 +10 -1
- package/SECURITY.md +41 -0
- package/lib/esm/jsonLanguageService.js +22 -22
- package/lib/esm/jsonLanguageTypes.d.ts +3 -1
- package/lib/esm/jsonLanguageTypes.js +3 -2
- package/lib/esm/jsonSchema.d.ts +21 -2
- package/lib/esm/parser/jsonParser.js +488 -488
- package/lib/esm/services/configuration.js +9 -9
- package/lib/esm/services/jsonCompletion.js +280 -290
- package/lib/esm/services/jsonDocumentSymbols.js +88 -99
- package/lib/esm/services/jsonFolding.js +38 -39
- package/lib/esm/services/jsonHover.js +40 -43
- package/lib/esm/services/jsonLinks.js +12 -13
- package/lib/esm/services/jsonSchemaService.js +234 -253
- package/lib/esm/services/jsonSelectionRanges.js +9 -9
- package/lib/esm/services/jsonValidation.js +53 -51
- package/lib/esm/utils/colors.js +7 -8
- package/lib/esm/utils/glob.js +12 -12
- package/lib/esm/utils/json.js +7 -7
- package/lib/esm/utils/objects.js +3 -0
- package/lib/esm/utils/strings.js +3 -3
- package/lib/umd/jsonLanguageService.js +36 -32
- package/lib/umd/jsonLanguageTypes.d.ts +3 -1
- package/lib/umd/jsonLanguageTypes.js +5 -3
- package/lib/umd/jsonSchema.d.ts +21 -2
- package/lib/umd/parser/jsonParser.js +492 -482
- package/lib/umd/services/configuration.js +9 -9
- package/lib/umd/services/jsonCompletion.js +287 -296
- package/lib/umd/services/jsonDocumentSymbols.js +92 -102
- package/lib/umd/services/jsonFolding.js +40 -41
- package/lib/umd/services/jsonHover.js +42 -44
- package/lib/umd/services/jsonLinks.js +13 -14
- package/lib/umd/services/jsonSchemaService.js +241 -257
- package/lib/umd/services/jsonSelectionRanges.js +11 -11
- package/lib/umd/services/jsonValidation.js +56 -53
- package/lib/umd/utils/colors.js +7 -8
- package/lib/umd/utils/glob.js +12 -12
- package/lib/umd/utils/json.js +7 -7
- package/lib/umd/utils/objects.js +5 -1
- package/lib/umd/utils/strings.js +3 -3
- package/package.json +12 -12
|
@@ -14,18 +14,17 @@
|
|
|
14
14
|
"use strict";
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.findLinks = void 0;
|
|
17
|
-
|
|
17
|
+
const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
|
|
18
18
|
function findLinks(document, doc) {
|
|
19
|
-
|
|
20
|
-
doc.visit(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var targetNode = findTargetNode(doc, path);
|
|
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);
|
|
25
24
|
if (targetNode) {
|
|
26
|
-
|
|
25
|
+
const targetPos = document.positionAt(targetNode.offset);
|
|
27
26
|
links.push({
|
|
28
|
-
target:
|
|
27
|
+
target: `${document.uri}#${targetPos.line + 1},${targetPos.character + 1}`,
|
|
29
28
|
range: createRange(document, node.valueNode)
|
|
30
29
|
});
|
|
31
30
|
}
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset + 1), document.positionAt(node.offset + node.length - 1));
|
|
40
39
|
}
|
|
41
40
|
function findTargetNode(doc, path) {
|
|
42
|
-
|
|
41
|
+
const tokens = parseJSONPointer(path);
|
|
43
42
|
if (!tokens) {
|
|
44
43
|
return null;
|
|
45
44
|
}
|
|
@@ -52,9 +51,9 @@
|
|
|
52
51
|
if (pointer.length === 0) {
|
|
53
52
|
return node;
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
const token = pointer.shift();
|
|
56
55
|
if (node && node.type === 'object') {
|
|
57
|
-
|
|
56
|
+
const propertyNode = node.properties.find((propertyNode) => propertyNode.keyNode.value === token);
|
|
58
57
|
if (!propertyNode) {
|
|
59
58
|
return null;
|
|
60
59
|
}
|
|
@@ -62,8 +61,8 @@
|
|
|
62
61
|
}
|
|
63
62
|
else if (node && node.type === 'array') {
|
|
64
63
|
if (token.match(/^(0|[1-9][0-9]*)$/)) {
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const index = Number.parseInt(token);
|
|
65
|
+
const arrayItem = node.items[index];
|
|
67
66
|
if (!arrayItem) {
|
|
68
67
|
return null;
|
|
69
68
|
}
|