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
@@ -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,90 +1,90 @@
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
- };
15
- (function (factory) {
16
- if (typeof module === "object" && typeof module.exports === "object") {
17
- var v = factory(require, exports);
18
- if (v !== undefined) module.exports = v;
19
- }
20
- else if (typeof define === "function" && define.amd) {
21
- define(["require", "exports", "./services/jsonCompletion", "./services/jsonHover", "./services/jsonValidation", "./services/jsonDocumentSymbols", "./parser/jsonParser", "./services/configuration", "./services/jsonSchemaService", "./services/jsonFolding", "./services/jsonSelectionRanges", "jsonc-parser", "./jsonLanguageTypes", "./services/jsonLinks", "./jsonLanguageTypes"], factory);
22
- }
23
- })(function (require, exports) {
24
- "use strict";
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getLanguageService = void 0;
27
- var jsonCompletion_1 = require("./services/jsonCompletion");
28
- var jsonHover_1 = require("./services/jsonHover");
29
- var jsonValidation_1 = require("./services/jsonValidation");
30
- var jsonDocumentSymbols_1 = require("./services/jsonDocumentSymbols");
31
- var jsonParser_1 = require("./parser/jsonParser");
32
- var configuration_1 = require("./services/configuration");
33
- var jsonSchemaService_1 = require("./services/jsonSchemaService");
34
- var jsonFolding_1 = require("./services/jsonFolding");
35
- var jsonSelectionRanges_1 = require("./services/jsonSelectionRanges");
36
- var jsonc_parser_1 = require("jsonc-parser");
37
- var jsonLanguageTypes_1 = require("./jsonLanguageTypes");
38
- var jsonLinks_1 = require("./services/jsonLinks");
39
- __exportStar(require("./jsonLanguageTypes"), exports);
40
- function getLanguageService(params) {
41
- var promise = params.promiseConstructor || Promise;
42
- var jsonSchemaService = new jsonSchemaService_1.JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
43
- jsonSchemaService.setSchemaContributions(configuration_1.schemaContributions);
44
- var jsonCompletion = new jsonCompletion_1.JSONCompletion(jsonSchemaService, params.contributions, promise, params.clientCapabilities);
45
- var jsonHover = new jsonHover_1.JSONHover(jsonSchemaService, params.contributions, promise);
46
- var jsonDocumentSymbols = new jsonDocumentSymbols_1.JSONDocumentSymbols(jsonSchemaService);
47
- var jsonValidation = new jsonValidation_1.JSONValidation(jsonSchemaService, promise);
48
- return {
49
- configure: function (settings) {
50
- jsonSchemaService.clearExternalSchemas();
51
- if (settings.schemas) {
52
- settings.schemas.forEach(function (settings) {
53
- jsonSchemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
54
- });
55
- }
56
- jsonValidation.configure(settings);
57
- },
58
- resetSchema: function (uri) { return jsonSchemaService.onResourceChange(uri); },
59
- doValidation: jsonValidation.doValidation.bind(jsonValidation),
60
- getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
61
- parseJSONDocument: function (document) { return (0, jsonParser_1.parse)(document, { collectComments: true }); },
62
- newJSONDocument: function (root, diagnostics) { return (0, jsonParser_1.newJSONDocument)(root, diagnostics); },
63
- getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
64
- doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
65
- doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
66
- findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
67
- findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
68
- findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
69
- getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
70
- doHover: jsonHover.doHover.bind(jsonHover),
71
- getFoldingRanges: jsonFolding_1.getFoldingRanges,
72
- getSelectionRanges: jsonSelectionRanges_1.getSelectionRanges,
73
- findDefinition: function () { return Promise.resolve([]); },
74
- findLinks: jsonLinks_1.findLinks,
75
- format: function (d, r, o) {
76
- var range = undefined;
77
- if (r) {
78
- var offset = d.offsetAt(r.start);
79
- var length = d.offsetAt(r.end) - offset;
80
- range = { offset: offset, length: length };
81
- }
82
- 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' };
83
- return (0, jsonc_parser_1.format)(d.getText(), range, options).map(function (e) {
84
- return jsonLanguageTypes_1.TextEdit.replace(jsonLanguageTypes_1.Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
85
- });
86
- }
87
- };
88
- }
89
- exports.getLanguageService = getLanguageService;
90
- });
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
+ };
15
+ (function (factory) {
16
+ if (typeof module === "object" && typeof module.exports === "object") {
17
+ var v = factory(require, exports);
18
+ if (v !== undefined) module.exports = v;
19
+ }
20
+ else if (typeof define === "function" && define.amd) {
21
+ define(["require", "exports", "./services/jsonCompletion", "./services/jsonHover", "./services/jsonValidation", "./services/jsonDocumentSymbols", "./parser/jsonParser", "./services/configuration", "./services/jsonSchemaService", "./services/jsonFolding", "./services/jsonSelectionRanges", "jsonc-parser", "./jsonLanguageTypes", "./services/jsonLinks", "./jsonLanguageTypes"], factory);
22
+ }
23
+ })(function (require, exports) {
24
+ "use strict";
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getLanguageService = void 0;
27
+ const jsonCompletion_1 = require("./services/jsonCompletion");
28
+ const jsonHover_1 = require("./services/jsonHover");
29
+ const jsonValidation_1 = require("./services/jsonValidation");
30
+ const jsonDocumentSymbols_1 = require("./services/jsonDocumentSymbols");
31
+ const jsonParser_1 = require("./parser/jsonParser");
32
+ const configuration_1 = require("./services/configuration");
33
+ const jsonSchemaService_1 = require("./services/jsonSchemaService");
34
+ const jsonFolding_1 = require("./services/jsonFolding");
35
+ const jsonSelectionRanges_1 = require("./services/jsonSelectionRanges");
36
+ const jsonc_parser_1 = require("jsonc-parser");
37
+ const jsonLanguageTypes_1 = require("./jsonLanguageTypes");
38
+ const jsonLinks_1 = require("./services/jsonLinks");
39
+ __exportStar(require("./jsonLanguageTypes"), exports);
40
+ function getLanguageService(params) {
41
+ const promise = params.promiseConstructor || Promise;
42
+ const jsonSchemaService = new jsonSchemaService_1.JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
43
+ jsonSchemaService.setSchemaContributions(configuration_1.schemaContributions);
44
+ const jsonCompletion = new jsonCompletion_1.JSONCompletion(jsonSchemaService, params.contributions, promise, params.clientCapabilities);
45
+ const jsonHover = new jsonHover_1.JSONHover(jsonSchemaService, params.contributions, promise);
46
+ const jsonDocumentSymbols = new jsonDocumentSymbols_1.JSONDocumentSymbols(jsonSchemaService);
47
+ const jsonValidation = new jsonValidation_1.JSONValidation(jsonSchemaService, promise);
48
+ return {
49
+ configure: (settings) => {
50
+ jsonSchemaService.clearExternalSchemas();
51
+ if (settings.schemas) {
52
+ settings.schemas.forEach(settings => {
53
+ jsonSchemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
54
+ });
55
+ }
56
+ jsonValidation.configure(settings);
57
+ },
58
+ resetSchema: (uri) => jsonSchemaService.onResourceChange(uri),
59
+ doValidation: jsonValidation.doValidation.bind(jsonValidation),
60
+ getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
61
+ parseJSONDocument: (document) => (0, jsonParser_1.parse)(document, { collectComments: true }),
62
+ newJSONDocument: (root, diagnostics) => (0, jsonParser_1.newJSONDocument)(root, diagnostics),
63
+ getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
64
+ doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
65
+ doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
66
+ findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
67
+ findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
68
+ findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
69
+ getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
70
+ doHover: jsonHover.doHover.bind(jsonHover),
71
+ getFoldingRanges: jsonFolding_1.getFoldingRanges,
72
+ getSelectionRanges: jsonSelectionRanges_1.getSelectionRanges,
73
+ findDefinition: () => Promise.resolve([]),
74
+ findLinks: jsonLinks_1.findLinks,
75
+ format: (d, r, o) => {
76
+ let range = undefined;
77
+ if (r) {
78
+ const offset = d.offsetAt(r.start);
79
+ const length = d.offsetAt(r.end) - offset;
80
+ range = { offset, length };
81
+ }
82
+ const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n' };
83
+ return (0, jsonc_parser_1.format)(d.getText(), range, options).map(e => {
84
+ return jsonLanguageTypes_1.TextEdit.replace(jsonLanguageTypes_1.Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
85
+ });
86
+ }
87
+ };
88
+ }
89
+ exports.getLanguageService = getLanguageService;
90
+ });