vscode-json-languageservice 5.0.0 → 5.1.1

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