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.
Files changed (49) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/jsonContributions.d.ts +17 -17
  4. package/lib/esm/jsonContributions.js +1 -1
  5. package/lib/esm/jsonLanguageService.d.ts +29 -29
  6. package/lib/esm/jsonLanguageService.js +66 -66
  7. package/lib/esm/jsonLanguageTypes.d.ts +279 -278
  8. package/lib/esm/jsonLanguageTypes.js +46 -45
  9. package/lib/esm/jsonSchema.d.ts +89 -70
  10. package/lib/esm/jsonSchema.js +1 -1
  11. package/lib/esm/parser/jsonParser.js +1214 -1218
  12. package/lib/esm/services/configuration.js +528 -528
  13. package/lib/esm/services/jsonCompletion.js +918 -934
  14. package/lib/esm/services/jsonDocumentSymbols.js +267 -278
  15. package/lib/esm/services/jsonFolding.js +120 -121
  16. package/lib/esm/services/jsonHover.js +109 -112
  17. package/lib/esm/services/jsonLinks.js +72 -73
  18. package/lib/esm/services/jsonSchemaService.js +586 -605
  19. package/lib/esm/services/jsonSelectionRanges.js +61 -61
  20. package/lib/esm/services/jsonValidation.js +151 -149
  21. package/lib/esm/utils/colors.js +68 -69
  22. package/lib/esm/utils/glob.js +124 -124
  23. package/lib/esm/utils/json.js +42 -42
  24. package/lib/esm/utils/objects.js +68 -65
  25. package/lib/esm/utils/strings.js +64 -64
  26. package/lib/umd/jsonContributions.d.ts +17 -17
  27. package/lib/umd/jsonContributions.js +12 -12
  28. package/lib/umd/jsonLanguageService.d.ts +29 -29
  29. package/lib/umd/jsonLanguageService.js +90 -90
  30. package/lib/umd/jsonLanguageTypes.d.ts +279 -278
  31. package/lib/umd/jsonLanguageTypes.js +93 -92
  32. package/lib/umd/jsonSchema.d.ts +89 -70
  33. package/lib/umd/jsonSchema.js +12 -12
  34. package/lib/umd/parser/jsonParser.js +1243 -1237
  35. package/lib/umd/services/configuration.js +541 -541
  36. package/lib/umd/services/jsonCompletion.js +932 -947
  37. package/lib/umd/services/jsonDocumentSymbols.js +281 -291
  38. package/lib/umd/services/jsonFolding.js +134 -135
  39. package/lib/umd/services/jsonHover.js +123 -125
  40. package/lib/umd/services/jsonLinks.js +86 -87
  41. package/lib/umd/services/jsonSchemaService.js +602 -618
  42. package/lib/umd/services/jsonSelectionRanges.js +75 -75
  43. package/lib/umd/services/jsonValidation.js +165 -162
  44. package/lib/umd/utils/colors.js +84 -85
  45. package/lib/umd/utils/glob.js +138 -138
  46. package/lib/umd/utils/json.js +56 -56
  47. package/lib/umd/utils/objects.js +87 -83
  48. package/lib/umd/utils/strings.js +82 -82
  49. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
+ 5.0.0 / 2022-05-17
2
+ ================
3
+ * Update to `vscode-languageserver-types@3.16`
4
+ * Add more schema support
5
+ * Schema 2019-09: unevaluatedProperties, unevaluatedItems, minContains, maxContains, deprecated, dependentRequired, dependentSchemas, $defs, $anchor
6
+ * Schema 2020-12: prefixItem
1
7
 
2
8
 
3
- 4.2.0 /
9
+ 4.2.0 / 2022-01-25
4
10
  ================
5
11
  * new API `LanguageService.getLanguageStatus`
6
12
  * 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 -->
@@ -1,17 +1,17 @@
1
- import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService';
2
- export interface JSONWorkerContribution {
3
- getInfoContribution(uri: string, location: JSONPath): Thenable<MarkedString[]>;
4
- collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any>;
5
- collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): Thenable<any>;
6
- collectDefaultCompletions(uri: string, result: CompletionsCollector): Thenable<any>;
7
- resolveCompletion?(item: CompletionItem): Thenable<CompletionItem>;
8
- }
9
- export declare type Segment = string | number;
10
- export declare type JSONPath = Segment[];
11
- export interface CompletionsCollector {
12
- add(suggestion: CompletionItem): void;
13
- error(message: string): void;
14
- log(message: string): void;
15
- setAsIncomplete(): void;
16
- getNumberOfProposals(): number;
17
- }
1
+ import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService';
2
+ export interface JSONWorkerContribution {
3
+ getInfoContribution(uri: string, location: JSONPath): Thenable<MarkedString[]>;
4
+ collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any>;
5
+ collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): Thenable<any>;
6
+ collectDefaultCompletions(uri: string, result: CompletionsCollector): Thenable<any>;
7
+ resolveCompletion?(item: CompletionItem): Thenable<CompletionItem>;
8
+ }
9
+ export declare type Segment = string | number;
10
+ export declare type JSONPath = Segment[];
11
+ export interface CompletionsCollector {
12
+ add(suggestion: CompletionItem): void;
13
+ error(message: string): void;
14
+ log(message: string): void;
15
+ setAsIncomplete(): void;
16
+ getNumberOfProposals(): number;
17
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,29 +1,29 @@
1
- import { Thenable, ASTNode, Color, ColorInformation, ColorPresentation, LanguageServiceParams, LanguageSettings, DocumentLanguageSettings, FoldingRange, JSONSchema, SelectionRange, FoldingRangesContext, DocumentSymbolsContext, ColorInformationContext as DocumentColorsContext, TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, FormattingOptions, DocumentSymbol, DefinitionLink, MatchingSchema, JSONLanguageStatus } from './jsonLanguageTypes';
2
- import { DocumentLink } from 'vscode-languageserver-types';
3
- export declare type JSONDocument = {
4
- root: ASTNode | undefined;
5
- getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
6
- };
7
- export * from './jsonLanguageTypes';
8
- export interface LanguageService {
9
- configure(settings: LanguageSettings): void;
10
- doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): Thenable<Diagnostic[]>;
11
- parseJSONDocument(document: TextDocument): JSONDocument;
12
- newJSONDocument(rootNode: ASTNode, syntaxDiagnostics?: Diagnostic[]): JSONDocument;
13
- resetSchema(uri: string): boolean;
14
- getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): Thenable<MatchingSchema[]>;
15
- getLanguageStatus(document: TextDocument, jsonDocument: JSONDocument): JSONLanguageStatus;
16
- doResolve(item: CompletionItem): Thenable<CompletionItem>;
17
- doComplete(document: TextDocument, position: Position, doc: JSONDocument): Thenable<CompletionList | null>;
18
- findDocumentSymbols(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): SymbolInformation[];
19
- findDocumentSymbols2(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
20
- findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): Thenable<ColorInformation[]>;
21
- getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[];
22
- doHover(document: TextDocument, position: Position, doc: JSONDocument): Thenable<Hover | null>;
23
- format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
24
- getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
25
- getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
26
- findDefinition(document: TextDocument, position: Position, doc: JSONDocument): Thenable<DefinitionLink[]>;
27
- findLinks(document: TextDocument, doc: JSONDocument): Thenable<DocumentLink[]>;
28
- }
29
- export declare function getLanguageService(params: LanguageServiceParams): LanguageService;
1
+ import { Thenable, ASTNode, Color, ColorInformation, ColorPresentation, LanguageServiceParams, LanguageSettings, DocumentLanguageSettings, FoldingRange, JSONSchema, SelectionRange, FoldingRangesContext, DocumentSymbolsContext, ColorInformationContext as DocumentColorsContext, TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, FormattingOptions, DocumentSymbol, DefinitionLink, MatchingSchema, JSONLanguageStatus } from './jsonLanguageTypes';
2
+ import { DocumentLink } from 'vscode-languageserver-types';
3
+ export declare type JSONDocument = {
4
+ root: ASTNode | undefined;
5
+ getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
6
+ };
7
+ export * from './jsonLanguageTypes';
8
+ export interface LanguageService {
9
+ configure(settings: LanguageSettings): void;
10
+ doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): Thenable<Diagnostic[]>;
11
+ parseJSONDocument(document: TextDocument): JSONDocument;
12
+ newJSONDocument(rootNode: ASTNode, syntaxDiagnostics?: Diagnostic[]): JSONDocument;
13
+ resetSchema(uri: string): boolean;
14
+ getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): Thenable<MatchingSchema[]>;
15
+ getLanguageStatus(document: TextDocument, jsonDocument: JSONDocument): JSONLanguageStatus;
16
+ doResolve(item: CompletionItem): Thenable<CompletionItem>;
17
+ doComplete(document: TextDocument, position: Position, doc: JSONDocument): Thenable<CompletionList | null>;
18
+ findDocumentSymbols(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): SymbolInformation[];
19
+ findDocumentSymbols2(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
20
+ findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): Thenable<ColorInformation[]>;
21
+ getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[];
22
+ doHover(document: TextDocument, position: Position, doc: JSONDocument): Thenable<Hover | null>;
23
+ format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
24
+ getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
25
+ getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
26
+ findDefinition(document: TextDocument, position: Position, doc: JSONDocument): Thenable<DefinitionLink[]>;
27
+ findLinks(document: TextDocument, doc: JSONDocument): Thenable<DocumentLink[]>;
28
+ }
29
+ export declare function getLanguageService(params: LanguageServiceParams): LanguageService;
@@ -1,66 +1,66 @@
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
- import { JSONCompletion } from './services/jsonCompletion';
6
- import { JSONHover } from './services/jsonHover';
7
- import { JSONValidation } from './services/jsonValidation';
8
- import { JSONDocumentSymbols } from './services/jsonDocumentSymbols';
9
- import { parse as parseJSON, newJSONDocument } from './parser/jsonParser';
10
- import { schemaContributions } from './services/configuration';
11
- import { JSONSchemaService } from './services/jsonSchemaService';
12
- import { getFoldingRanges } from './services/jsonFolding';
13
- import { getSelectionRanges } from './services/jsonSelectionRanges';
14
- import { format as formatJSON } from 'jsonc-parser';
15
- import { Range, TextEdit } from './jsonLanguageTypes';
16
- import { findLinks } from './services/jsonLinks';
17
- export * from './jsonLanguageTypes';
18
- export function getLanguageService(params) {
19
- var promise = params.promiseConstructor || Promise;
20
- var jsonSchemaService = new JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
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);
26
- return {
27
- configure: function (settings) {
28
- jsonSchemaService.clearExternalSchemas();
29
- if (settings.schemas) {
30
- settings.schemas.forEach(function (settings) {
31
- jsonSchemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
32
- });
33
- }
34
- jsonValidation.configure(settings);
35
- },
36
- resetSchema: function (uri) { return jsonSchemaService.onResourceChange(uri); },
37
- doValidation: jsonValidation.doValidation.bind(jsonValidation),
38
- getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
39
- parseJSONDocument: function (document) { return parseJSON(document, { collectComments: true }); },
40
- newJSONDocument: function (root, diagnostics) { return newJSONDocument(root, diagnostics); },
41
- getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
42
- doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
43
- doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
44
- findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
45
- findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
46
- findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
47
- getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
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;
55
- if (r) {
56
- var offset = d.offsetAt(r.start);
57
- var length = d.offsetAt(r.end) - offset;
58
- range = { offset: offset, length: length };
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) {
62
- return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
63
- });
64
- }
65
- };
66
- }
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
+ import { JSONCompletion } from './services/jsonCompletion';
6
+ import { JSONHover } from './services/jsonHover';
7
+ import { JSONValidation } from './services/jsonValidation';
8
+ import { JSONDocumentSymbols } from './services/jsonDocumentSymbols';
9
+ import { parse as parseJSON, newJSONDocument } from './parser/jsonParser';
10
+ import { schemaContributions } from './services/configuration';
11
+ import { JSONSchemaService } from './services/jsonSchemaService';
12
+ import { getFoldingRanges } from './services/jsonFolding';
13
+ import { getSelectionRanges } from './services/jsonSelectionRanges';
14
+ import { format as formatJSON } from 'jsonc-parser';
15
+ import { Range, TextEdit } from './jsonLanguageTypes';
16
+ import { findLinks } from './services/jsonLinks';
17
+ export * from './jsonLanguageTypes';
18
+ export function getLanguageService(params) {
19
+ const promise = params.promiseConstructor || Promise;
20
+ const jsonSchemaService = new JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
21
+ jsonSchemaService.setSchemaContributions(schemaContributions);
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
+ return {
27
+ configure: (settings) => {
28
+ jsonSchemaService.clearExternalSchemas();
29
+ if (settings.schemas) {
30
+ settings.schemas.forEach(settings => {
31
+ jsonSchemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
32
+ });
33
+ }
34
+ jsonValidation.configure(settings);
35
+ },
36
+ resetSchema: (uri) => jsonSchemaService.onResourceChange(uri),
37
+ doValidation: jsonValidation.doValidation.bind(jsonValidation),
38
+ getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
39
+ parseJSONDocument: (document) => parseJSON(document, { collectComments: true }),
40
+ newJSONDocument: (root, diagnostics) => newJSONDocument(root, diagnostics),
41
+ getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
42
+ doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
43
+ doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
44
+ findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
45
+ findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
46
+ findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
47
+ getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
48
+ doHover: jsonHover.doHover.bind(jsonHover),
49
+ getFoldingRanges,
50
+ getSelectionRanges,
51
+ findDefinition: () => Promise.resolve([]),
52
+ findLinks,
53
+ format: (d, r, o) => {
54
+ let range = undefined;
55
+ if (r) {
56
+ const offset = d.offsetAt(r.start);
57
+ const length = d.offsetAt(r.end) - offset;
58
+ range = { offset, length };
59
+ }
60
+ const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n' };
61
+ return formatJSON(d.getText(), range, options).map(e => {
62
+ return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
63
+ });
64
+ }
65
+ };
66
+ }