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.
- package/CHANGELOG.md +10 -2
- package/lib/esm/jsonContributions.d.ts +17 -17
- package/lib/esm/jsonContributions.js +1 -1
- package/lib/esm/jsonLanguageService.d.ts +29 -29
- package/lib/esm/jsonLanguageService.js +66 -66
- package/lib/esm/jsonLanguageTypes.d.ts +292 -279
- package/lib/esm/jsonLanguageTypes.js +55 -46
- package/lib/esm/jsonSchema.d.ts +89 -89
- package/lib/esm/jsonSchema.js +1 -1
- package/lib/esm/parser/jsonParser.js +1236 -1214
- package/lib/esm/services/configuration.js +528 -528
- package/lib/esm/services/jsonCompletion.js +924 -918
- package/lib/esm/services/jsonDocumentSymbols.js +267 -267
- package/lib/esm/services/jsonFolding.js +120 -120
- package/lib/esm/services/jsonHover.js +109 -109
- package/lib/esm/services/jsonLinks.js +72 -72
- package/lib/esm/services/jsonSchemaService.js +593 -586
- package/lib/esm/services/jsonSelectionRanges.js +61 -61
- package/lib/esm/services/jsonValidation.js +151 -151
- package/lib/esm/utils/colors.js +68 -68
- package/lib/esm/utils/glob.js +124 -124
- package/lib/esm/utils/json.js +42 -42
- package/lib/esm/utils/objects.js +68 -68
- package/lib/esm/utils/strings.js +79 -64
- package/lib/umd/jsonContributions.d.ts +17 -17
- package/lib/umd/jsonContributions.js +12 -12
- package/lib/umd/jsonLanguageService.d.ts +29 -29
- package/lib/umd/jsonLanguageService.js +94 -90
- package/lib/umd/jsonLanguageTypes.d.ts +292 -279
- package/lib/umd/jsonLanguageTypes.js +103 -93
- package/lib/umd/jsonSchema.d.ts +89 -89
- package/lib/umd/jsonSchema.js +12 -12
- package/lib/umd/parser/jsonParser.js +1265 -1243
- package/lib/umd/services/configuration.js +541 -541
- package/lib/umd/services/jsonCompletion.js +938 -932
- package/lib/umd/services/jsonDocumentSymbols.js +281 -281
- package/lib/umd/services/jsonFolding.js +134 -134
- package/lib/umd/services/jsonHover.js +123 -123
- package/lib/umd/services/jsonLinks.js +86 -86
- package/lib/umd/services/jsonSchemaService.js +609 -602
- package/lib/umd/services/jsonSelectionRanges.js +75 -75
- package/lib/umd/services/jsonValidation.js +165 -165
- package/lib/umd/utils/colors.js +84 -84
- package/lib/umd/utils/glob.js +138 -138
- package/lib/umd/utils/json.js +56 -56
- package/lib/umd/utils/objects.js +87 -87
- package/lib/umd/utils/strings.js +98 -82
- 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.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
});
|