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
package/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
+ 5.1.0 / 2022-07-11
2
+ ================
3
+ * new API option `FormattingOptions.keepLines` to indicate the formatter should keep the initial line positions
1
4
 
5
+ 5.0.0 / 2022-05-17
6
+ ================
7
+ * Update to `vscode-languageserver-types@3.17`
8
+ * Add more schema support
9
+ * Schema 2019-09: unevaluatedProperties, unevaluatedItems, minContains, maxContains, deprecated, dependentRequired, dependentSchemas, $defs, $anchor
10
+ * Schema 2020-12: prefixItem
2
11
 
3
- 4.2.0 /
12
+ 4.2.0 / 2022-01-25
4
13
  ================
5
14
  * new API `LanguageService.getLanguageStatus`
6
15
  * support for $ref with $id
package/SECURITY.md ADDED
@@ -0,0 +1,41 @@
1
+ <!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
2
+
3
+ ## Security
4
+
5
+ Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6
+
7
+ If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
8
+
9
+ ## Reporting Security Issues
10
+
11
+ **Please do not report security vulnerabilities through public GitHub issues.**
12
+
13
+ Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
14
+
15
+ If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
16
+
17
+ You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
18
+
19
+ Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
+
21
+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
+ * Full paths of source file(s) related to the manifestation of the issue
23
+ * The location of the affected source code (tag/branch/commit or direct URL)
24
+ * Any special configuration required to reproduce the issue
25
+ * Step-by-step instructions to reproduce the issue
26
+ * Proof-of-concept or exploit code (if possible)
27
+ * Impact of the issue, including how an attacker might exploit the issue
28
+
29
+ This information will help us triage your report more quickly.
30
+
31
+ If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
32
+
33
+ ## Preferred Languages
34
+
35
+ We prefer all communications to be in English.
36
+
37
+ ## Policy
38
+
39
+ Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
40
+
41
+ <!-- END MICROSOFT SECURITY.MD BLOCK -->
@@ -16,28 +16,28 @@ import { Range, TextEdit } from './jsonLanguageTypes';
16
16
  import { findLinks } from './services/jsonLinks';
17
17
  export * from './jsonLanguageTypes';
18
18
  export function getLanguageService(params) {
19
- var promise = params.promiseConstructor || Promise;
20
- var jsonSchemaService = new JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
19
+ const promise = params.promiseConstructor || Promise;
20
+ const jsonSchemaService = new JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
21
21
  jsonSchemaService.setSchemaContributions(schemaContributions);
22
- var jsonCompletion = new JSONCompletion(jsonSchemaService, params.contributions, promise, params.clientCapabilities);
23
- var jsonHover = new JSONHover(jsonSchemaService, params.contributions, promise);
24
- var jsonDocumentSymbols = new JSONDocumentSymbols(jsonSchemaService);
25
- var jsonValidation = new JSONValidation(jsonSchemaService, promise);
22
+ const jsonCompletion = new JSONCompletion(jsonSchemaService, params.contributions, promise, params.clientCapabilities);
23
+ const jsonHover = new JSONHover(jsonSchemaService, params.contributions, promise);
24
+ const jsonDocumentSymbols = new JSONDocumentSymbols(jsonSchemaService);
25
+ const jsonValidation = new JSONValidation(jsonSchemaService, promise);
26
26
  return {
27
- configure: function (settings) {
27
+ configure: (settings) => {
28
28
  jsonSchemaService.clearExternalSchemas();
29
29
  if (settings.schemas) {
30
- settings.schemas.forEach(function (settings) {
30
+ settings.schemas.forEach(settings => {
31
31
  jsonSchemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
32
32
  });
33
33
  }
34
34
  jsonValidation.configure(settings);
35
35
  },
36
- resetSchema: function (uri) { return jsonSchemaService.onResourceChange(uri); },
36
+ resetSchema: (uri) => jsonSchemaService.onResourceChange(uri),
37
37
  doValidation: jsonValidation.doValidation.bind(jsonValidation),
38
38
  getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
39
- parseJSONDocument: function (document) { return parseJSON(document, { collectComments: true }); },
40
- newJSONDocument: function (root, diagnostics) { return newJSONDocument(root, diagnostics); },
39
+ parseJSONDocument: (document) => parseJSON(document, { collectComments: true }),
40
+ newJSONDocument: (root, diagnostics) => newJSONDocument(root, diagnostics),
41
41
  getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
42
42
  doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
43
43
  doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
@@ -46,19 +46,19 @@ export function getLanguageService(params) {
46
46
  findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
47
47
  getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
48
48
  doHover: jsonHover.doHover.bind(jsonHover),
49
- getFoldingRanges: getFoldingRanges,
50
- getSelectionRanges: getSelectionRanges,
51
- findDefinition: function () { return Promise.resolve([]); },
52
- findLinks: findLinks,
53
- format: function (d, r, o) {
54
- var range = undefined;
49
+ getFoldingRanges,
50
+ getSelectionRanges,
51
+ findDefinition: () => Promise.resolve([]),
52
+ findLinks,
53
+ format: (d, r, o) => {
54
+ let range = undefined;
55
55
  if (r) {
56
- var offset = d.offsetAt(r.start);
57
- var length = d.offsetAt(r.end) - offset;
58
- range = { offset: offset, length: length };
56
+ const offset = d.offsetAt(r.start);
57
+ const length = d.offsetAt(r.end) - offset;
58
+ range = { offset, length };
59
59
  }
60
- var options = { tabSize: o ? o.tabSize : 4, insertSpaces: (o === null || o === void 0 ? void 0 : o.insertSpaces) === true, insertFinalNewline: (o === null || o === void 0 ? void 0 : o.insertFinalNewline) === true, eol: '\n' };
61
- return formatJSON(d.getText(), range, options).map(function (e) {
60
+ const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n', keepLines: o?.keepLines === true };
61
+ return formatJSON(d.getText(), range, options).map(e => {
62
62
  return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
63
63
  });
64
64
  }
@@ -25,7 +25,8 @@ export declare enum ErrorCode {
25
25
  TrailingComma = 519,
26
26
  DuplicateKey = 520,
27
27
  CommentNotPermitted = 521,
28
- SchemaResolveError = 768
28
+ SchemaResolveError = 768,
29
+ SchemaUnsupportedFeature = 769
29
30
  }
30
31
  export declare type ASTNode = ObjectASTNode | PropertyASTNode | ArrayASTNode | StringASTNode | NumberASTNode | BooleanASTNode | NullASTNode;
31
32
  export interface BaseASTNode {
@@ -275,4 +276,5 @@ export interface ColorInformationContext {
275
276
  }
276
277
  export interface FormattingOptions extends LSPFormattingOptions {
277
278
  insertFinalNewline?: boolean;
279
+ keepLines?: boolean;
278
280
  }
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { Range, Position, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
5
+ import { Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
6
6
  import { TextDocument } from 'vscode-languageserver-textdocument';
7
- export { TextDocument, Range, Position, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
7
+ export { TextDocument, Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
8
8
  /**
9
9
  * Error codes used by diagnostics
10
10
  */
@@ -29,6 +29,7 @@ export var ErrorCode;
29
29
  ErrorCode[ErrorCode["DuplicateKey"] = 520] = "DuplicateKey";
30
30
  ErrorCode[ErrorCode["CommentNotPermitted"] = 521] = "CommentNotPermitted";
31
31
  ErrorCode[ErrorCode["SchemaResolveError"] = 768] = "SchemaResolveError";
32
+ ErrorCode[ErrorCode["SchemaUnsupportedFeature"] = 769] = "SchemaUnsupportedFeature";
32
33
  })(ErrorCode || (ErrorCode = {}));
33
34
  export var ClientCapabilities;
34
35
  (function (ClientCapabilities) {
@@ -12,7 +12,7 @@ export interface JSONSchema {
12
12
  description?: string;
13
13
  properties?: JSONSchemaMap;
14
14
  patternProperties?: JSONSchemaMap;
15
- additionalProperties?: boolean | JSONSchemaRef;
15
+ additionalProperties?: JSONSchemaRef;
16
16
  minProperties?: number;
17
17
  maxProperties?: number;
18
18
  dependencies?: JSONSchemaMap | {
@@ -22,7 +22,7 @@ export interface JSONSchema {
22
22
  minItems?: number;
23
23
  maxItems?: number;
24
24
  uniqueItems?: boolean;
25
- additionalItems?: boolean | JSONSchemaRef;
25
+ additionalItems?: JSONSchemaRef;
26
26
  pattern?: string;
27
27
  minLength?: number;
28
28
  maxLength?: number;
@@ -47,6 +47,25 @@ export interface JSONSchema {
47
47
  if?: JSONSchemaRef;
48
48
  then?: JSONSchemaRef;
49
49
  else?: JSONSchemaRef;
50
+ unevaluatedProperties?: boolean | JSONSchemaRef;
51
+ unevaluatedItems?: boolean | JSONSchemaRef;
52
+ minContains?: number;
53
+ maxContains?: number;
54
+ deprecated?: boolean;
55
+ dependentRequired?: {
56
+ [prop: string]: string[];
57
+ };
58
+ dependentSchemas?: JSONSchemaMap;
59
+ $defs?: {
60
+ [name: string]: JSONSchema;
61
+ };
62
+ $anchor?: string;
63
+ $recursiveRef?: string;
64
+ $recursiveAnchor?: string;
65
+ $vocabulary?: any;
66
+ prefixItems?: JSONSchemaRef[];
67
+ $dynamicRef?: string;
68
+ $dynamicAnchor?: string;
50
69
  defaultSnippets?: {
51
70
  label?: string;
52
71
  description?: string;