vscode-json-languageservice 4.1.8

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 (50) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/LICENSE.md +47 -0
  3. package/README.md +65 -0
  4. package/lib/esm/jsonContributions.d.ts +17 -0
  5. package/lib/esm/jsonContributions.js +1 -0
  6. package/lib/esm/jsonLanguageService.d.ts +28 -0
  7. package/lib/esm/jsonLanguageService.js +65 -0
  8. package/lib/esm/jsonLanguageTypes.d.ts +275 -0
  9. package/lib/esm/jsonLanguageTypes.js +45 -0
  10. package/lib/esm/jsonSchema.d.ts +70 -0
  11. package/lib/esm/jsonSchema.js +1 -0
  12. package/lib/esm/parser/jsonParser.js +1212 -0
  13. package/lib/esm/services/configuration.js +528 -0
  14. package/lib/esm/services/jsonCompletion.js +934 -0
  15. package/lib/esm/services/jsonDocumentSymbols.js +278 -0
  16. package/lib/esm/services/jsonFolding.js +121 -0
  17. package/lib/esm/services/jsonHover.js +112 -0
  18. package/lib/esm/services/jsonLinks.js +73 -0
  19. package/lib/esm/services/jsonSchemaService.js +535 -0
  20. package/lib/esm/services/jsonSelectionRanges.js +61 -0
  21. package/lib/esm/services/jsonValidation.js +146 -0
  22. package/lib/esm/utils/colors.js +69 -0
  23. package/lib/esm/utils/glob.js +124 -0
  24. package/lib/esm/utils/json.js +42 -0
  25. package/lib/esm/utils/objects.js +65 -0
  26. package/lib/esm/utils/strings.js +52 -0
  27. package/lib/umd/jsonContributions.d.ts +17 -0
  28. package/lib/umd/jsonContributions.js +12 -0
  29. package/lib/umd/jsonLanguageService.d.ts +28 -0
  30. package/lib/umd/jsonLanguageService.js +89 -0
  31. package/lib/umd/jsonLanguageTypes.d.ts +275 -0
  32. package/lib/umd/jsonLanguageTypes.js +92 -0
  33. package/lib/umd/jsonSchema.d.ts +70 -0
  34. package/lib/umd/jsonSchema.js +12 -0
  35. package/lib/umd/parser/jsonParser.js +1231 -0
  36. package/lib/umd/services/configuration.js +541 -0
  37. package/lib/umd/services/jsonCompletion.js +947 -0
  38. package/lib/umd/services/jsonDocumentSymbols.js +291 -0
  39. package/lib/umd/services/jsonFolding.js +135 -0
  40. package/lib/umd/services/jsonHover.js +125 -0
  41. package/lib/umd/services/jsonLinks.js +87 -0
  42. package/lib/umd/services/jsonSchemaService.js +548 -0
  43. package/lib/umd/services/jsonSelectionRanges.js +75 -0
  44. package/lib/umd/services/jsonValidation.js +159 -0
  45. package/lib/umd/utils/colors.js +85 -0
  46. package/lib/umd/utils/glob.js +138 -0
  47. package/lib/umd/utils/json.js +56 -0
  48. package/lib/umd/utils/objects.js +83 -0
  49. package/lib/umd/utils/strings.js +70 -0
  50. package/package.json +55 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,133 @@
1
+
2
+ 4.1.6 / 2021-07-16
3
+ ================
4
+ * Replace minimatch with glob-to-regexp
5
+
6
+ 4.1.0 / 2021-04-24
7
+ ================
8
+ * `SchemaConfiguration.fileMatch` now supports glob patterns (e.g. /foo/**/bar.json')
9
+
10
+ 4.0.0 / 2020-12-14
11
+ ================
12
+ * Update to `vscode-languageserver-types@3.16`
13
+ * Removed deprecated `findColorSymbols`
14
+
15
+ 3.11.0 / 2020-11-30
16
+ ================
17
+ * new API `FormattingOptions.insertFinalNewline`
18
+
19
+ 3.10.0 / 2020-11-03
20
+ ================
21
+ * new API `findLinks` return links for local `$ref` links. Replaces `findDefinition` which no longer returns results ( kept for API compatibility)
22
+
23
+ 3.9.0 / 2020-09-28
24
+ =================
25
+ * new API `DocumentLanguageSettings.schemaValidation`. The severity of problems from schema validation. If set to 'ignore', schema validation will be skipped. If not set, 'warning' is used.
26
+ * new API `DocumentLanguageSettings.schemaRequest`. The severity of problems that occurred while resolving and loading schemas. If set to 'ignore', schema resolving problems are not reported. If not set, 'warning' is used.
27
+
28
+ 3.8.0 / 2020-08-02
29
+ =================
30
+ * new API `LanguageService.getMatchingSchemas`. Matches a document against its schema and list all AST nodes along with the matching sub schemas.
31
+
32
+ 3.7.0 / 2020-06-04
33
+ ==================
34
+ * New API `JSONSchema.suggestSortText` to set the sort order of completion proposals (VS Code specific JSON schema extension)
35
+
36
+ 3.6.0 / 2020-04-27
37
+ ==================
38
+ * New API `findDefinition` to find a definition of a `$ref` link
39
+
40
+ 3.5.0 / 2020-02-20
41
+ ==================
42
+ * Support for exclusive file pattern starting with '!'. A file match consists of an array of patterns. A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'.
43
+
44
+ 3.4.4 / 2019-11-04
45
+ ==================
46
+ * Using `vscode-languageserver-textdocument` for TextDocument
47
+
48
+ 3.4.0 / 2019-10-28
49
+ ==================
50
+ * Added `DocumentSymbolsContext` and `ColorInformationContext` with `resultLimit` and `onResultLimitExceeded`. `onResultLimitExceeded` is called when the result was cropped.
51
+ * Added commit characters for completion proposals (if supported by ClientCapabilities)
52
+ * Warn when using draft-03 or draft-08 schemas
53
+
54
+ 3.3.4 / 2019-09-20
55
+ ==================
56
+ * Renamed `schema.allowsTrailingCommas` -> `schema.allowTrailingCommas`
57
+
58
+ 3.3.3 / 2019-08-29
59
+ ==================
60
+ * Schemas can configure whether comments and/or trailing commas are permitted.
61
+
62
+ 3.3.0 / 2019-06-12
63
+ ==================
64
+ * New API `LanguageService.getSelectionRanges` to get semantic selection ranges.
65
+ * Manage schema dependencies so that `resetSchema` also resets schemas that depend on the schema.
66
+
67
+ 3.2.0 / 2018-09-27
68
+ ==================
69
+ * New API `LanguageServiceParams.ClientCapabilities` to define what LSP capabilities the client supports.
70
+ * For the best experiences, clients should always use `LanguageServiceParams.ClientCapabilities.LATEST`, which has all the latest LSP capabilities enabled.
71
+ * `LanguageServiceParams.ClientCapabilities` can allow `MarkupKind.Markdown` as valid documentationFormat (used by completions if schemas use `markdownDescription` or `markdownEnumDescriptions`).
72
+ * Snippets can now provide the description also in markdown format.
73
+ * Bundled draft-07-schema with descriptions.
74
+ * Propose `examples` in code completions.
75
+
76
+ 3.1.5 / 2018-08-14
77
+ ==================
78
+ * support for JSON schema draft-07
79
+ * New API `LanguageService.findDocumentSymbols2` to get document symbols as `DocumentSymbol[]`
80
+
81
+ 3.1.2 / 2018-07-25
82
+ ==================
83
+ * New API `LanguageService.getFoldingRanges`
84
+ * doValidation can also be used with a given schema
85
+
86
+ 3.1.0 / 2018-04-09
87
+ ==================
88
+ * new APIs: `newJSONDocument` to create a JSON document from a custom AST
89
+ * new API types: ObjectASTNode, PropertyASTNode, ArrayASTNode, StringASTNode, NumberASTNode, BooleanASTNode, NullASTNode that allow creating a custom AST
90
+
91
+ 3.0.9 / 2018-03-07
92
+ ==================
93
+ * Provide ems modules in lib/esm
94
+
95
+ 3.0.2 / 2017-01-27
96
+ ==================
97
+ * Added document specific validation parameters: `DocumentLanguageSettings`
98
+ * API to define the severity of reported comments and trailing commas (`DocumentLanguageSettings.comments`, `DocumentLanguageSettings.trailingCommas`)
99
+
100
+ 3.0.0 / 2017-01-11
101
+ ==================
102
+ * Changed parameters of API `LanguageService.getColorPresentations` to separate color and range
103
+ .
104
+ 2.0.19 / 2017-09-21
105
+ ===================
106
+ * New API `LanguageService.getColorPresentations` returning presentations for a given color.
107
+ * New API type `ColorPresentation` added.
108
+
109
+ 2.0.15 / 2017-08-28
110
+ ===================
111
+ * New API `LanguageService.findDocumentColors` returning the location and value of all colors in a document.
112
+ * New API types `ColorInformation` and `Color` added.
113
+ * Deprecated `LanguageService.findColorSymbols`. Use `LanguageService.findDocumentColors` instead.
114
+
115
+ 2.0.8 / 2017-04-25
116
+ ==================
117
+ * error code for CommentsNotAllowed
118
+
119
+ 2.0.5 / 2017-03-27
120
+ ==================
121
+ * Add new API findColorSymbols that returns all color values in a JSON document. To mark a value as a color, specify `"format": "color"` in the schema.
122
+
123
+ 2.0.4 / 2017-02-27
124
+ ==================
125
+ * Support for custom schema property 'patternErrorMessage'. The message is used as error message if the object is of type string and has a 'pattern' property that does not match the object to validate.
126
+
127
+ 2.0.1 / 2017-02-21
128
+ ==================
129
+ * Fixes for formatting content with errors
130
+
131
+ 2.0.0 / 2017-02-17
132
+ ==================
133
+ * Updating to [language server type 3.0](https://github.com/Microsoft/vscode-languageserver-node/tree/master/types) API
package/LICENSE.md ADDED
@@ -0,0 +1,47 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Microsoft
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Glob matching is based on code from https://github.com/fitzgen/glob-to-regexp
24
+
25
+ Copyright (c) 2013, Nick Fitzgerald
26
+
27
+ All rights reserved.
28
+
29
+ Redistribution and use in source and binary forms, with or without modification,
30
+ are permitted provided that the following conditions are met:
31
+
32
+ Redistributions of source code must retain the above copyright notice, this list
33
+ of conditions and the following disclaimer.
34
+
35
+ Redistributions in binary form must reproduce the above copyright notice, this list
36
+ of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
37
+
38
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
39
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
41
+ SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
42
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
44
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47
+ OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # vscode-json-languageservice
2
+
3
+ JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.
4
+
5
+ [![npm Package](https://img.shields.io/npm/v/vscode-json-languageservice.svg?style=flat-square)](https://www.npmjs.org/package/vscode-json-languageservice)
6
+ [![NPM Downloads](https://img.shields.io/npm/dm/vscode-json-languageservice.svg)](https://npmjs.org/package/vscode-json-languageservice)
7
+ [![Build Status](https://travis-ci.org/Microsoft/vscode-json-languageservice.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-json-languageservice)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ## Why?
11
+
12
+ The _vscode-json-languageservice_ contains the language smarts behind the JSON editing experience of Visual Studio Code
13
+ and the Monaco editor.
14
+
15
+ - _doValidation_ analyses an input string and returns syntax and lint errors.
16
+ - _doComplete_ provides completion proposals for a given location.
17
+ - _doResolve_ resolves a completion proposals.
18
+ - _doHover_ provides a hover text for a given location.
19
+ - _findDocumentSymbols_ provides all symbols in the given document.
20
+ - _findDocumentColors_ provides all color symbols in the given document.
21
+ - _getColorPresentations_ returns available color formats for a color symbol.
22
+ - _format_ formats the code at the given range.
23
+ - _getFoldingRanges_ gets folding ranges for the given document.
24
+ - _getSelectionRanges_ gets selection ranges for a given location.
25
+ - _getMatchingSchemas_ matches a document against its schema and returns all AST nodes along with the matching sub schemas.
26
+ - _parseJSONDocument_ creates a JSON document from source code.
27
+ - _newJSONDocument_ creates a JSON document from an AST.
28
+
29
+ For the complete API see [jsonLanguageService.ts](./src/jsonLanguageService.ts) and [jsonLanguageTypes.ts](./src/jsonLanguageTypes.ts)
30
+
31
+ ## Installation
32
+
33
+ npm install --save vscode-json-languageservice
34
+
35
+ ## Sample usage
36
+
37
+ See [sample.ts](./src/example/sample.ts) for an example on how to use the JSON language service.
38
+
39
+ To run the sample use `yarn sample`
40
+
41
+ ## Development
42
+
43
+ git clone https://github.com/microsoft/vscode-json-languageservice
44
+ cd vscode-json-languageservice
45
+ yarn
46
+
47
+ Use `yarn test` to compile and run tests
48
+
49
+
50
+ ### How can I run and debug the service?
51
+
52
+ - open the folder in VSCode.
53
+ - set breakpoints, e.g. in `jsonCompletion.ts`
54
+ - run the Unit tests from the run viewlet and wait until a breakpoint is hit:
55
+ ![image](https://user-images.githubusercontent.com/6461412/94239202-bdad4e80-ff11-11ea-99c3-cb9dbeb1c0b2.png)
56
+
57
+ ### How can I run and debug the service inside an instance of VSCode?
58
+
59
+ - run VSCode out of sources setup as described here: https://github.com/Microsoft/vscode/wiki/How-to-Contribute
60
+ - use `yarn link vscode-json-languageservice` in `vscode/extensions/json-language-features/server` to run VSCode with the latest changes from `vscode-json-languageservice`
61
+ - run VSCode out of source (`vscode/scripts/code.sh|bat`) and open a `.json` file
62
+ - in VSCode window that is open on the `vscode-json-languageservice` sources, run command `Debug: Attach to Node process` and pick the `code-oss` process with the `json-language-features` path
63
+ ![image](https://user-images.githubusercontent.com/6461412/94242925-061b3b00-ff17-11ea-8c17-8da15268f1a1.png)
64
+ - set breakpoints, e.g. in `jsonCompletion.ts`
65
+ - in the instance run from sources, invoke code completion in the `.json` file
@@ -0,0 +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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
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 } 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
+ doResolve(item: CompletionItem): Thenable<CompletionItem>;
16
+ doComplete(document: TextDocument, position: Position, doc: JSONDocument): Thenable<CompletionList | null>;
17
+ findDocumentSymbols(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): SymbolInformation[];
18
+ findDocumentSymbols2(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
19
+ findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): Thenable<ColorInformation[]>;
20
+ getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[];
21
+ doHover(document: TextDocument, position: Position, doc: JSONDocument): Thenable<Hover | null>;
22
+ format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
23
+ getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
24
+ getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
25
+ findDefinition(document: TextDocument, position: Position, doc: JSONDocument): Thenable<DefinitionLink[]>;
26
+ findLinks(document: TextDocument, doc: JSONDocument): Thenable<DocumentLink[]>;
27
+ }
28
+ export declare function getLanguageService(params: LanguageServiceParams): LanguageService;
@@ -0,0 +1,65 @@
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
+ parseJSONDocument: function (document) { return parseJSON(document, { collectComments: true }); },
39
+ newJSONDocument: function (root, diagnostics) { return newJSONDocument(root, diagnostics); },
40
+ getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
41
+ doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
42
+ doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
43
+ findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
44
+ findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
45
+ findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
46
+ getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
47
+ doHover: jsonHover.doHover.bind(jsonHover),
48
+ getFoldingRanges: getFoldingRanges,
49
+ getSelectionRanges: getSelectionRanges,
50
+ findDefinition: function () { return Promise.resolve([]); },
51
+ findLinks: findLinks,
52
+ format: function (d, r, o) {
53
+ var range = undefined;
54
+ if (r) {
55
+ var offset = d.offsetAt(r.start);
56
+ var length = d.offsetAt(r.end) - offset;
57
+ range = { offset: offset, length: length };
58
+ }
59
+ 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' };
60
+ return formatJSON(d.getText(), range, options).map(function (e) {
61
+ return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
62
+ });
63
+ }
64
+ };
65
+ }
@@ -0,0 +1,275 @@
1
+ import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
2
+ import { JSONSchema } from './jsonSchema';
3
+ 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, FormattingOptions as LSPFormattingOptions, DefinitionLink, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
4
+ import { TextDocument } from 'vscode-languageserver-textdocument';
5
+ export { TextDocument, Range, Position, DocumentUri, MarkupContent, MarkupKind, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
6
+ /**
7
+ * Error codes used by diagnostics
8
+ */
9
+ export declare enum ErrorCode {
10
+ Undefined = 0,
11
+ EnumValueMismatch = 1,
12
+ Deprecated = 2,
13
+ UnexpectedEndOfComment = 257,
14
+ UnexpectedEndOfString = 258,
15
+ UnexpectedEndOfNumber = 259,
16
+ InvalidUnicode = 260,
17
+ InvalidEscapeCharacter = 261,
18
+ InvalidCharacter = 262,
19
+ PropertyExpected = 513,
20
+ CommaExpected = 514,
21
+ ColonExpected = 515,
22
+ ValueExpected = 516,
23
+ CommaOrCloseBacketExpected = 517,
24
+ CommaOrCloseBraceExpected = 518,
25
+ TrailingComma = 519,
26
+ DuplicateKey = 520,
27
+ CommentNotPermitted = 521,
28
+ SchemaResolveError = 768
29
+ }
30
+ export declare type ASTNode = ObjectASTNode | PropertyASTNode | ArrayASTNode | StringASTNode | NumberASTNode | BooleanASTNode | NullASTNode;
31
+ export interface BaseASTNode {
32
+ readonly type: 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
33
+ readonly parent?: ASTNode;
34
+ readonly offset: number;
35
+ readonly length: number;
36
+ readonly children?: ASTNode[];
37
+ readonly value?: string | boolean | number | null;
38
+ }
39
+ export interface ObjectASTNode extends BaseASTNode {
40
+ readonly type: 'object';
41
+ readonly properties: PropertyASTNode[];
42
+ readonly children: ASTNode[];
43
+ }
44
+ export interface PropertyASTNode extends BaseASTNode {
45
+ readonly type: 'property';
46
+ readonly keyNode: StringASTNode;
47
+ readonly valueNode?: ASTNode;
48
+ readonly colonOffset?: number;
49
+ readonly children: ASTNode[];
50
+ }
51
+ export interface ArrayASTNode extends BaseASTNode {
52
+ readonly type: 'array';
53
+ readonly items: ASTNode[];
54
+ readonly children: ASTNode[];
55
+ }
56
+ export interface StringASTNode extends BaseASTNode {
57
+ readonly type: 'string';
58
+ readonly value: string;
59
+ }
60
+ export interface NumberASTNode extends BaseASTNode {
61
+ readonly type: 'number';
62
+ readonly value: number;
63
+ readonly isInteger: boolean;
64
+ }
65
+ export interface BooleanASTNode extends BaseASTNode {
66
+ readonly type: 'boolean';
67
+ readonly value: boolean;
68
+ }
69
+ export interface NullASTNode extends BaseASTNode {
70
+ readonly type: 'null';
71
+ readonly value: null;
72
+ }
73
+ export interface MatchingSchema {
74
+ node: ASTNode;
75
+ schema: JSONSchema;
76
+ }
77
+ export interface LanguageSettings {
78
+ /**
79
+ * If set, the validator will return syntax and semantic errors.
80
+ */
81
+ validate?: boolean;
82
+ /**
83
+ * Defines whether comments are allowed or not. If set to false, comments will be reported as errors.
84
+ * DocumentLanguageSettings.allowComments will override this setting.
85
+ */
86
+ allowComments?: boolean;
87
+ /**
88
+ * A list of known schemas and/or associations of schemas to file names.
89
+ */
90
+ schemas?: SchemaConfiguration[];
91
+ }
92
+ export declare type SeverityLevel = 'error' | 'warning' | 'ignore';
93
+ export interface DocumentLanguageSettings {
94
+ /**
95
+ * The severity of reported comments. If not set, 'LanguageSettings.allowComments' defines whether comments are ignored or reported as errors.
96
+ */
97
+ comments?: SeverityLevel;
98
+ /**
99
+ * The severity of reported trailing commas. If not set, trailing commas will be reported as errors.
100
+ */
101
+ trailingCommas?: SeverityLevel;
102
+ /**
103
+ * The severity of problems from schema validation. If set to 'ignore', schema validation will be skipped. If not set, 'warning' is used.
104
+ */
105
+ schemaValidation?: SeverityLevel;
106
+ /**
107
+ * The severity of problems that occurred when resolving and loading schemas. If set to 'ignore', schema resolving problems are not reported. If not set, 'warning' is used.
108
+ */
109
+ schemaRequest?: SeverityLevel;
110
+ }
111
+ export interface SchemaConfiguration {
112
+ /**
113
+ * The URI of the schema, which is also the identifier of the schema.
114
+ */
115
+ uri: string;
116
+ /**
117
+ * A list of glob patterns that describe for which file URIs the JSON schema will be used.
118
+ * '*' and '**' wildcards are supported. Exclusion patterns start with '!'.
119
+ * For example '*.schema.json', 'package.json', '!foo*.schema.json', 'foo/**\/BADRESP.json'.
120
+ * A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'.
121
+ */
122
+ fileMatch?: string[];
123
+ /**
124
+ * The schema for the given URI.
125
+ * If no schema is provided, the schema will be fetched with the schema request service (if available).
126
+ */
127
+ schema?: JSONSchema;
128
+ }
129
+ export interface WorkspaceContextService {
130
+ resolveRelativePath(relativePath: string, resource: string): string;
131
+ }
132
+ /**
133
+ * The schema request service is used to fetch schemas. If successful, returns a resolved promise with the content of the schema.
134
+ * In case of an error, returns a rejected promise with a displayable error string.
135
+ */
136
+ export interface SchemaRequestService {
137
+ (uri: string): Thenable<string>;
138
+ }
139
+ export interface PromiseConstructor {
140
+ /**
141
+ * Creates a new Promise.
142
+ * @param executor A callback used to initialize the promise. This callback is passed two arguments:
143
+ * a resolve callback used resolve the promise with a value or the result of another promise,
144
+ * and a reject callback used to reject the promise with a provided reason or error.
145
+ */
146
+ new <T>(executor: (resolve: (value?: T | Thenable<T | undefined>) => void, reject: (reason?: any) => void) => void): Thenable<T | undefined>;
147
+ /**
148
+ * Creates a Promise that is resolved with an array of results when all of the provided Promises
149
+ * resolve, or rejected when any Promise is rejected.
150
+ * @param values An array of Promises.
151
+ * @returns A new Promise.
152
+ */
153
+ all<T>(values: Array<T | Thenable<T>>): Thenable<T[]>;
154
+ /**
155
+ * Creates a new rejected promise for the provided reason.
156
+ * @param reason The reason the promise was rejected.
157
+ * @returns A new rejected Promise.
158
+ */
159
+ reject<T>(reason: any): Thenable<T>;
160
+ /**
161
+ * Creates a new resolved promise for the provided value.
162
+ * @param value A promise.
163
+ * @returns A promise whose internal state matches the provided promise.
164
+ */
165
+ resolve<T>(value: T | Thenable<T>): Thenable<T>;
166
+ }
167
+ export interface Thenable<R> {
168
+ /**
169
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
170
+ * @param onfulfilled The callback to execute when the Promise is resolved.
171
+ * @param onrejected The callback to execute when the Promise is rejected.
172
+ * @returns A Promise for the completion of which ever callback is executed.
173
+ */
174
+ then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
175
+ then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
176
+ }
177
+ export interface LanguageServiceParams {
178
+ /**
179
+ * The schema request service is used to fetch schemas from a URI. The provider returns the schema file content, or,
180
+ * in case of an error, a displayable error string
181
+ */
182
+ schemaRequestService?: SchemaRequestService;
183
+ /**
184
+ * The workspace context is used to resolve relative paths for relative schema references.
185
+ */
186
+ workspaceContext?: WorkspaceContextService;
187
+ /**
188
+ * An optional set of completion and hover participants.
189
+ */
190
+ contributions?: JSONWorkerContribution[];
191
+ /**
192
+ * A promise constructor. If not set, the ES5 Promise will be used.
193
+ */
194
+ promiseConstructor?: PromiseConstructor;
195
+ /**
196
+ * Describes the LSP capabilities the client supports.
197
+ */
198
+ clientCapabilities?: ClientCapabilities;
199
+ }
200
+ /**
201
+ * Describes what LSP capabilities the client supports
202
+ */
203
+ export interface ClientCapabilities {
204
+ /**
205
+ * The text document client capabilities
206
+ */
207
+ textDocument?: {
208
+ /**
209
+ * Capabilities specific to completions.
210
+ */
211
+ completion?: {
212
+ /**
213
+ * The client supports the following `CompletionItem` specific
214
+ * capabilities.
215
+ */
216
+ completionItem?: {
217
+ /**
218
+ * Client supports the follow content formats for the documentation
219
+ * property. The order describes the preferred format of the client.
220
+ */
221
+ documentationFormat?: MarkupKind[];
222
+ /**
223
+ * The client supports commit characters on a completion item.
224
+ */
225
+ commitCharactersSupport?: boolean;
226
+ };
227
+ };
228
+ /**
229
+ * Capabilities specific to hovers.
230
+ */
231
+ hover?: {
232
+ /**
233
+ * Client supports the follow content formats for the content
234
+ * property. The order describes the preferred format of the client.
235
+ */
236
+ contentFormat?: MarkupKind[];
237
+ };
238
+ };
239
+ }
240
+ export declare namespace ClientCapabilities {
241
+ const LATEST: ClientCapabilities;
242
+ }
243
+ export interface FoldingRangesContext {
244
+ /**
245
+ * The maximal number of ranges returned.
246
+ */
247
+ rangeLimit?: number;
248
+ /**
249
+ * Called when the result was cropped.
250
+ */
251
+ onRangeLimitExceeded?: (uri: string) => void;
252
+ }
253
+ export interface DocumentSymbolsContext {
254
+ /**
255
+ * The maximal number of document symbols returned.
256
+ */
257
+ resultLimit?: number;
258
+ /**
259
+ * Called when the result was cropped.
260
+ */
261
+ onResultLimitExceeded?: (uri: string) => void;
262
+ }
263
+ export interface ColorInformationContext {
264
+ /**
265
+ * The maximal number of color informations returned.
266
+ */
267
+ resultLimit?: number;
268
+ /**
269
+ * Called when the result was cropped.
270
+ */
271
+ onResultLimitExceeded?: (uri: string) => void;
272
+ }
273
+ export interface FormattingOptions extends LSPFormattingOptions {
274
+ insertFinalNewline?: boolean;
275
+ }