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.
Files changed (41) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/jsonLanguageService.js +22 -22
  4. package/lib/esm/jsonLanguageTypes.d.ts +3 -1
  5. package/lib/esm/jsonLanguageTypes.js +3 -2
  6. package/lib/esm/jsonSchema.d.ts +21 -2
  7. package/lib/esm/parser/jsonParser.js +488 -488
  8. package/lib/esm/services/configuration.js +9 -9
  9. package/lib/esm/services/jsonCompletion.js +280 -290
  10. package/lib/esm/services/jsonDocumentSymbols.js +88 -99
  11. package/lib/esm/services/jsonFolding.js +38 -39
  12. package/lib/esm/services/jsonHover.js +40 -43
  13. package/lib/esm/services/jsonLinks.js +12 -13
  14. package/lib/esm/services/jsonSchemaService.js +234 -253
  15. package/lib/esm/services/jsonSelectionRanges.js +9 -9
  16. package/lib/esm/services/jsonValidation.js +53 -51
  17. package/lib/esm/utils/colors.js +7 -8
  18. package/lib/esm/utils/glob.js +12 -12
  19. package/lib/esm/utils/json.js +7 -7
  20. package/lib/esm/utils/objects.js +3 -0
  21. package/lib/esm/utils/strings.js +3 -3
  22. package/lib/umd/jsonLanguageService.js +36 -32
  23. package/lib/umd/jsonLanguageTypes.d.ts +3 -1
  24. package/lib/umd/jsonLanguageTypes.js +5 -3
  25. package/lib/umd/jsonSchema.d.ts +21 -2
  26. package/lib/umd/parser/jsonParser.js +492 -482
  27. package/lib/umd/services/configuration.js +9 -9
  28. package/lib/umd/services/jsonCompletion.js +287 -296
  29. package/lib/umd/services/jsonDocumentSymbols.js +92 -102
  30. package/lib/umd/services/jsonFolding.js +40 -41
  31. package/lib/umd/services/jsonHover.js +42 -44
  32. package/lib/umd/services/jsonLinks.js +13 -14
  33. package/lib/umd/services/jsonSchemaService.js +241 -257
  34. package/lib/umd/services/jsonSelectionRanges.js +11 -11
  35. package/lib/umd/services/jsonValidation.js +56 -53
  36. package/lib/umd/utils/colors.js +7 -8
  37. package/lib/umd/utils/glob.js +12 -12
  38. package/lib/umd/utils/json.js +7 -7
  39. package/lib/umd/utils/objects.js +5 -1
  40. package/lib/umd/utils/strings.js +3 -3
  41. package/package.json +12 -12
@@ -4,16 +4,15 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { Range } from '../jsonLanguageTypes';
6
6
  export function findLinks(document, doc) {
7
- var links = [];
8
- doc.visit(function (node) {
9
- var _a;
10
- if (node.type === "property" && node.keyNode.value === "$ref" && ((_a = node.valueNode) === null || _a === void 0 ? void 0 : _a.type) === 'string') {
11
- var path = node.valueNode.value;
12
- var targetNode = findTargetNode(doc, path);
7
+ const links = [];
8
+ doc.visit(node => {
9
+ if (node.type === "property" && node.keyNode.value === "$ref" && node.valueNode?.type === 'string') {
10
+ const path = node.valueNode.value;
11
+ const targetNode = findTargetNode(doc, path);
13
12
  if (targetNode) {
14
- var targetPos = document.positionAt(targetNode.offset);
13
+ const targetPos = document.positionAt(targetNode.offset);
15
14
  links.push({
16
- target: "".concat(document.uri, "#").concat(targetPos.line + 1, ",").concat(targetPos.character + 1),
15
+ target: `${document.uri}#${targetPos.line + 1},${targetPos.character + 1}`,
17
16
  range: createRange(document, node.valueNode)
18
17
  });
19
18
  }
@@ -26,7 +25,7 @@ function createRange(document, node) {
26
25
  return Range.create(document.positionAt(node.offset + 1), document.positionAt(node.offset + node.length - 1));
27
26
  }
28
27
  function findTargetNode(doc, path) {
29
- var tokens = parseJSONPointer(path);
28
+ const tokens = parseJSONPointer(path);
30
29
  if (!tokens) {
31
30
  return null;
32
31
  }
@@ -39,9 +38,9 @@ function findNode(pointer, node) {
39
38
  if (pointer.length === 0) {
40
39
  return node;
41
40
  }
42
- var token = pointer.shift();
41
+ const token = pointer.shift();
43
42
  if (node && node.type === 'object') {
44
- var propertyNode = node.properties.find(function (propertyNode) { return propertyNode.keyNode.value === token; });
43
+ const propertyNode = node.properties.find((propertyNode) => propertyNode.keyNode.value === token);
45
44
  if (!propertyNode) {
46
45
  return null;
47
46
  }
@@ -49,8 +48,8 @@ function findNode(pointer, node) {
49
48
  }
50
49
  else if (node && node.type === 'array') {
51
50
  if (token.match(/^(0|[1-9][0-9]*)$/)) {
52
- var index = Number.parseInt(token);
53
- var arrayItem = node.items[index];
51
+ const index = Number.parseInt(token);
52
+ const arrayItem = node.items[index];
54
53
  if (!arrayItem) {
55
54
  return null;
56
55
  }