vscode-json-languageservice 3.10.0 → 3.11.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.
- package/CHANGELOG.md +5 -1
- package/README.md +7 -0
- package/lib/esm/jsonLanguageService.js +1 -1
- package/lib/esm/jsonLanguageTypes.d.ts +8 -5
- package/lib/esm/jsonLanguageTypes.js +2 -2
- package/lib/esm/services/jsonCompletion.js +7 -2
- package/lib/esm/services/jsonDocumentSymbols.js +20 -2
- package/lib/esm/services/jsonSchemaService.js +3 -2
- package/lib/esm/services/jsonValidation.js +1 -1
- package/lib/umd/jsonLanguageService.js +1 -1
- package/lib/umd/jsonLanguageTypes.d.ts +8 -5
- package/lib/umd/jsonLanguageTypes.js +1 -2
- package/lib/umd/services/jsonCompletion.js +7 -2
- package/lib/umd/services/jsonDocumentSymbols.js +20 -2
- package/lib/umd/services/jsonSchemaService.js +3 -2
- package/lib/umd/services/jsonValidation.js +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
3.11.0 / 2020-11-30
|
|
2
|
+
================
|
|
3
|
+
* new API `FormattingOptions.insertFinalNewline`
|
|
4
|
+
|
|
1
5
|
3.10.0 / 2020-11-03
|
|
2
|
-
|
|
6
|
+
================
|
|
3
7
|
* new API `findLinks` return links for local `$ref` links. Replaces `findDefinition` which no longer returns results ( kept for API compatibility)
|
|
4
8
|
|
|
5
9
|
3.9.0 / 2020-09-28
|
package/README.md
CHANGED
|
@@ -32,6 +32,12 @@ For the complete API see [jsonLanguageService.ts](./src/jsonLanguageService.ts)
|
|
|
32
32
|
|
|
33
33
|
npm install --save vscode-json-languageservice
|
|
34
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
|
+
|
|
35
41
|
## Development
|
|
36
42
|
|
|
37
43
|
git clone https://github.com/microsoft/vscode-json-languageservice
|
|
@@ -40,6 +46,7 @@ For the complete API see [jsonLanguageService.ts](./src/jsonLanguageService.ts)
|
|
|
40
46
|
|
|
41
47
|
Use `yarn test` to compile and run tests
|
|
42
48
|
|
|
49
|
+
|
|
43
50
|
### How can I run and debug the service?
|
|
44
51
|
|
|
45
52
|
- open the folder in VSCode.
|
|
@@ -57,7 +57,7 @@ export function getLanguageService(params) {
|
|
|
57
57
|
var length = d.offsetAt(r.end) - offset;
|
|
58
58
|
range = { offset: offset, length: length };
|
|
59
59
|
}
|
|
60
|
-
var options = { tabSize: o ? o.tabSize : 4, insertSpaces: o ? o.insertSpaces : true, eol: '\n' };
|
|
60
|
+
var options = { tabSize: o ? o.tabSize : 4, insertSpaces: (o === null || o === void 0 ? void 0 : o.insertSpaces) === true, insertFinalNewline: (o === null || o === void 0 ? void 0 : o.insertFinalNewline) === true, eol: '\n' };
|
|
61
61
|
return formatJSON(d.getText(), range, options).map(function (e) {
|
|
62
62
|
return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
|
|
63
63
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
|
|
2
2
|
import { JSONSchema } from './jsonSchema';
|
|
3
|
-
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
|
|
3
|
+
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
|
|
4
4
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
-
export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString
|
|
5
|
+
export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
|
|
6
6
|
/**
|
|
7
7
|
* Error codes used by diagnostics
|
|
8
8
|
*/
|
|
@@ -129,8 +129,8 @@ export interface WorkspaceContextService {
|
|
|
129
129
|
resolveRelativePath(relativePath: string, resource: string): string;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* The schema request service is used to fetch schemas.
|
|
133
|
-
*
|
|
132
|
+
* The schema request service is used to fetch schemas. If successful, returns a resolved promise with the content of the schema.
|
|
133
|
+
* In case of an error, returns a rejected promise with a displayable error string.
|
|
134
134
|
*/
|
|
135
135
|
export interface SchemaRequestService {
|
|
136
136
|
(uri: string): Thenable<string>;
|
|
@@ -142,7 +142,7 @@ export interface PromiseConstructor {
|
|
|
142
142
|
* a resolve callback used resolve the promise with a value or the result of another promise,
|
|
143
143
|
* and a reject callback used to reject the promise with a provided reason or error.
|
|
144
144
|
*/
|
|
145
|
-
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Thenable<T>;
|
|
145
|
+
new <T>(executor: (resolve: (value?: T | Thenable<T | undefined>) => void, reject: (reason?: any) => void) => void): Thenable<T | undefined>;
|
|
146
146
|
/**
|
|
147
147
|
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
148
148
|
* resolve, or rejected when any Promise is rejected.
|
|
@@ -269,3 +269,6 @@ export interface ColorInformationContext {
|
|
|
269
269
|
*/
|
|
270
270
|
onResultLimitExceeded?: (uri: string) => void;
|
|
271
271
|
}
|
|
272
|
+
export interface FormattingOptions extends LSPFormattingOptions {
|
|
273
|
+
insertFinalNewline?: boolean;
|
|
274
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString
|
|
5
|
+
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString } from 'vscode-languageserver-types';
|
|
6
6
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
7
|
-
export { TextDocument, Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString
|
|
7
|
+
export { TextDocument, Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
|
|
8
8
|
/**
|
|
9
9
|
* Error codes used by diagnostics
|
|
10
10
|
*/
|
|
@@ -89,8 +89,13 @@ var JSONCompletion = /** @class */ (function () {
|
|
|
89
89
|
proposed[label] = suggestion;
|
|
90
90
|
result.items.push(suggestion);
|
|
91
91
|
}
|
|
92
|
-
else
|
|
93
|
-
existing.documentation
|
|
92
|
+
else {
|
|
93
|
+
if (!existing.documentation) {
|
|
94
|
+
existing.documentation = suggestion.documentation;
|
|
95
|
+
}
|
|
96
|
+
if (!existing.detail) {
|
|
97
|
+
existing.detail = suggestion.detail;
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
},
|
|
96
101
|
setAsIncomplete: function () {
|
|
@@ -156,9 +156,10 @@ var JSONDocumentSymbols = /** @class */ (function () {
|
|
|
156
156
|
limit--;
|
|
157
157
|
var range = getRange(document, property);
|
|
158
158
|
var selectionRange = getRange(document, property.keyNode);
|
|
159
|
-
var
|
|
159
|
+
var children = [];
|
|
160
|
+
var symbol = { name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: children, detail: _this.getDetail(valueNode) };
|
|
160
161
|
result.push(symbol);
|
|
161
|
-
toVisit.push({ result:
|
|
162
|
+
toVisit.push({ result: children, node: valueNode });
|
|
162
163
|
}
|
|
163
164
|
else {
|
|
164
165
|
limitExceeded = true;
|
|
@@ -203,6 +204,23 @@ var JSONDocumentSymbols = /** @class */ (function () {
|
|
|
203
204
|
}
|
|
204
205
|
return "\"" + name + "\"";
|
|
205
206
|
};
|
|
207
|
+
JSONDocumentSymbols.prototype.getDetail = function (node) {
|
|
208
|
+
if (!node) {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
if (node.type === 'boolean' || node.type === 'number' || node.type === 'null' || node.type === 'string') {
|
|
212
|
+
return String(node.value);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
if (node.type === 'array') {
|
|
216
|
+
return node.children.length ? undefined : '[]';
|
|
217
|
+
}
|
|
218
|
+
else if (node.type === 'object') {
|
|
219
|
+
return node.children.length ? undefined : '{}';
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return undefined;
|
|
223
|
+
};
|
|
206
224
|
JSONDocumentSymbols.prototype.findDocumentColors = function (document, doc, context) {
|
|
207
225
|
return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
|
|
208
226
|
var result = [];
|
|
@@ -331,6 +331,7 @@ var JSONSchemaService = /** @class */ (function () {
|
|
|
331
331
|
var loc = refSegment ? uri + '#' + refSegment : uri;
|
|
332
332
|
resolveErrors.push(localize('json.schema.problemloadingref', 'Problems loading reference \'{0}\': {1}', loc, unresolvedSchema.errors[0]));
|
|
333
333
|
}
|
|
334
|
+
delete node.$ref;
|
|
334
335
|
merge(node, unresolvedSchema.schema, uri, refSegment);
|
|
335
336
|
return resolveRefs(node, unresolvedSchema.schema, uri, referencedHandle.dependencies);
|
|
336
337
|
});
|
|
@@ -394,14 +395,14 @@ var JSONSchemaService = /** @class */ (function () {
|
|
|
394
395
|
while (next.$ref) {
|
|
395
396
|
var ref = next.$ref;
|
|
396
397
|
var segments = ref.split('#', 2);
|
|
397
|
-
delete next.$ref;
|
|
398
398
|
if (segments[0].length > 0) {
|
|
399
399
|
openPromises.push(resolveExternalLink(next, segments[0], segments[1], parentSchemaURL, parentSchemaDependencies));
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
402
|
else {
|
|
403
|
+
delete next.$ref;
|
|
403
404
|
if (seenRefs.indexOf(ref) === -1) {
|
|
404
|
-
merge(next, parentSchema, parentSchemaURL, segments[1]); // can set next.$ref again, use seenRefs to avoid circle
|
|
405
|
+
merge(next, parentSchema, parentSchemaURL, segments[1]); // will remove $ref, can set next.$ref again, use seenRefs to avoid circle
|
|
405
406
|
seenRefs.push(ref);
|
|
406
407
|
}
|
|
407
408
|
}
|
|
@@ -15,7 +15,7 @@ var JSONValidation = /** @class */ (function () {
|
|
|
15
15
|
}
|
|
16
16
|
JSONValidation.prototype.configure = function (raw) {
|
|
17
17
|
if (raw) {
|
|
18
|
-
this.validationEnabled = raw.validate;
|
|
18
|
+
this.validationEnabled = raw.validate !== false;
|
|
19
19
|
this.commentSeverity = raw.allowComments ? undefined : DiagnosticSeverity.Error;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -79,7 +79,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
79
79
|
var length = d.offsetAt(r.end) - offset;
|
|
80
80
|
range = { offset: offset, length: length };
|
|
81
81
|
}
|
|
82
|
-
var options = { tabSize: o ? o.tabSize : 4, insertSpaces: o ? o.insertSpaces : true, eol: '\n' };
|
|
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
83
|
return jsonc_parser_1.format(d.getText(), range, options).map(function (e) {
|
|
84
84
|
return jsonLanguageTypes_1.TextEdit.replace(jsonLanguageTypes_1.Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
|
|
85
85
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
|
|
2
2
|
import { JSONSchema } from './jsonSchema';
|
|
3
|
-
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
|
|
3
|
+
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
|
|
4
4
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
-
export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString
|
|
5
|
+
export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
|
|
6
6
|
/**
|
|
7
7
|
* Error codes used by diagnostics
|
|
8
8
|
*/
|
|
@@ -129,8 +129,8 @@ export interface WorkspaceContextService {
|
|
|
129
129
|
resolveRelativePath(relativePath: string, resource: string): string;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* The schema request service is used to fetch schemas.
|
|
133
|
-
*
|
|
132
|
+
* The schema request service is used to fetch schemas. If successful, returns a resolved promise with the content of the schema.
|
|
133
|
+
* In case of an error, returns a rejected promise with a displayable error string.
|
|
134
134
|
*/
|
|
135
135
|
export interface SchemaRequestService {
|
|
136
136
|
(uri: string): Thenable<string>;
|
|
@@ -142,7 +142,7 @@ export interface PromiseConstructor {
|
|
|
142
142
|
* a resolve callback used resolve the promise with a value or the result of another promise,
|
|
143
143
|
* and a reject callback used to reject the promise with a provided reason or error.
|
|
144
144
|
*/
|
|
145
|
-
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Thenable<T>;
|
|
145
|
+
new <T>(executor: (resolve: (value?: T | Thenable<T | undefined>) => void, reject: (reason?: any) => void) => void): Thenable<T | undefined>;
|
|
146
146
|
/**
|
|
147
147
|
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
148
148
|
* resolve, or rejected when any Promise is rejected.
|
|
@@ -269,3 +269,6 @@ export interface ColorInformationContext {
|
|
|
269
269
|
*/
|
|
270
270
|
onResultLimitExceeded?: (uri: string) => void;
|
|
271
271
|
}
|
|
272
|
+
export interface FormattingOptions extends LSPFormattingOptions {
|
|
273
|
+
insertFinalNewline?: boolean;
|
|
274
|
+
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
})(function (require, exports) {
|
|
14
14
|
"use strict";
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ClientCapabilities = exports.ErrorCode = exports.
|
|
16
|
+
exports.ClientCapabilities = exports.ErrorCode = exports.MarkedString = exports.Hover = exports.Location = exports.DocumentSymbol = exports.SymbolKind = exports.SymbolInformation = exports.MarkupKind = exports.MarkupContent = exports.InsertTextFormat = exports.Position = exports.CompletionList = exports.CompletionItemKind = exports.CompletionItem = exports.DiagnosticSeverity = exports.Diagnostic = exports.SelectionRange = exports.FoldingRangeKind = exports.FoldingRange = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.TextEdit = exports.Range = exports.TextDocument = void 0;
|
|
17
17
|
var vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
18
18
|
Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return vscode_languageserver_types_1.Range; } });
|
|
19
19
|
Object.defineProperty(exports, "TextEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.TextEdit; } });
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return vscode_languageserver_types_1.Location; } });
|
|
39
39
|
Object.defineProperty(exports, "Hover", { enumerable: true, get: function () { return vscode_languageserver_types_1.Hover; } });
|
|
40
40
|
Object.defineProperty(exports, "MarkedString", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkedString; } });
|
|
41
|
-
Object.defineProperty(exports, "FormattingOptions", { enumerable: true, get: function () { return vscode_languageserver_types_1.FormattingOptions; } });
|
|
42
41
|
var vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
43
42
|
Object.defineProperty(exports, "TextDocument", { enumerable: true, get: function () { return vscode_languageserver_textdocument_1.TextDocument; } });
|
|
44
43
|
/**
|
|
@@ -101,8 +101,13 @@
|
|
|
101
101
|
proposed[label] = suggestion;
|
|
102
102
|
result.items.push(suggestion);
|
|
103
103
|
}
|
|
104
|
-
else
|
|
105
|
-
existing.documentation
|
|
104
|
+
else {
|
|
105
|
+
if (!existing.documentation) {
|
|
106
|
+
existing.documentation = suggestion.documentation;
|
|
107
|
+
}
|
|
108
|
+
if (!existing.detail) {
|
|
109
|
+
existing.detail = suggestion.detail;
|
|
110
|
+
}
|
|
106
111
|
}
|
|
107
112
|
},
|
|
108
113
|
setAsIncomplete: function () {
|
|
@@ -168,9 +168,10 @@
|
|
|
168
168
|
limit--;
|
|
169
169
|
var range = getRange(document, property);
|
|
170
170
|
var selectionRange = getRange(document, property.keyNode);
|
|
171
|
-
var
|
|
171
|
+
var children = [];
|
|
172
|
+
var symbol = { name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: children, detail: _this.getDetail(valueNode) };
|
|
172
173
|
result.push(symbol);
|
|
173
|
-
toVisit.push({ result:
|
|
174
|
+
toVisit.push({ result: children, node: valueNode });
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
176
177
|
limitExceeded = true;
|
|
@@ -215,6 +216,23 @@
|
|
|
215
216
|
}
|
|
216
217
|
return "\"" + name + "\"";
|
|
217
218
|
};
|
|
219
|
+
JSONDocumentSymbols.prototype.getDetail = function (node) {
|
|
220
|
+
if (!node) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
if (node.type === 'boolean' || node.type === 'number' || node.type === 'null' || node.type === 'string') {
|
|
224
|
+
return String(node.value);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
if (node.type === 'array') {
|
|
228
|
+
return node.children.length ? undefined : '[]';
|
|
229
|
+
}
|
|
230
|
+
else if (node.type === 'object') {
|
|
231
|
+
return node.children.length ? undefined : '{}';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
};
|
|
218
236
|
JSONDocumentSymbols.prototype.findDocumentColors = function (document, doc, context) {
|
|
219
237
|
return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
|
|
220
238
|
var result = [];
|
|
@@ -343,6 +343,7 @@
|
|
|
343
343
|
var loc = refSegment ? uri + '#' + refSegment : uri;
|
|
344
344
|
resolveErrors.push(localize('json.schema.problemloadingref', 'Problems loading reference \'{0}\': {1}', loc, unresolvedSchema.errors[0]));
|
|
345
345
|
}
|
|
346
|
+
delete node.$ref;
|
|
346
347
|
merge(node, unresolvedSchema.schema, uri, refSegment);
|
|
347
348
|
return resolveRefs(node, unresolvedSchema.schema, uri, referencedHandle.dependencies);
|
|
348
349
|
});
|
|
@@ -406,14 +407,14 @@
|
|
|
406
407
|
while (next.$ref) {
|
|
407
408
|
var ref = next.$ref;
|
|
408
409
|
var segments = ref.split('#', 2);
|
|
409
|
-
delete next.$ref;
|
|
410
410
|
if (segments[0].length > 0) {
|
|
411
411
|
openPromises.push(resolveExternalLink(next, segments[0], segments[1], parentSchemaURL, parentSchemaDependencies));
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
414
|
else {
|
|
415
|
+
delete next.$ref;
|
|
415
416
|
if (seenRefs.indexOf(ref) === -1) {
|
|
416
|
-
merge(next, parentSchema, parentSchemaURL, segments[1]); // can set next.$ref again, use seenRefs to avoid circle
|
|
417
|
+
merge(next, parentSchema, parentSchemaURL, segments[1]); // will remove $ref, can set next.$ref again, use seenRefs to avoid circle
|
|
417
418
|
seenRefs.push(ref);
|
|
418
419
|
}
|
|
419
420
|
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
JSONValidation.prototype.configure = function (raw) {
|
|
29
29
|
if (raw) {
|
|
30
|
-
this.validationEnabled = raw.validate;
|
|
30
|
+
this.validationEnabled = raw.validate !== false;
|
|
31
31
|
this.commentSeverity = raw.allowComments ? undefined : jsonLanguageTypes_1.DiagnosticSeverity.Error;
|
|
32
32
|
}
|
|
33
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-json-languageservice",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Language service for JSON",
|
|
5
5
|
"main": "./lib/umd/jsonLanguageService.js",
|
|
6
6
|
"typings": "./lib/umd/jsonLanguageService",
|
|
@@ -15,18 +15,17 @@
|
|
|
15
15
|
"url": "https://github.com/Microsoft/vscode-json-languageservice"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@types/mocha": "^8.0.
|
|
18
|
+
"@types/mocha": "^8.0.4",
|
|
19
19
|
"@types/node": "^10.12.21",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
21
|
-
"@typescript-eslint/parser": "^4.
|
|
22
|
-
"eslint": "^7.
|
|
23
|
-
"mocha": "^8.1
|
|
24
|
-
"nyc": "^15.1.0",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^4.8.2",
|
|
21
|
+
"@typescript-eslint/parser": "^4.8.2",
|
|
22
|
+
"eslint": "^7.14.0",
|
|
23
|
+
"mocha": "^8.2.1",
|
|
25
24
|
"rimraf": "^3.0.2",
|
|
26
|
-
"typescript": "^4.
|
|
25
|
+
"typescript": "^4.1.2"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"jsonc-parser": "^
|
|
28
|
+
"jsonc-parser": "^3.0.0",
|
|
30
29
|
"vscode-languageserver-textdocument": "^1.0.1",
|
|
31
30
|
"vscode-languageserver-types": "3.16.0-next.2",
|
|
32
31
|
"vscode-nls": "^5.0.0",
|
|
@@ -43,10 +42,11 @@
|
|
|
43
42
|
"pretest": "npm run compile",
|
|
44
43
|
"test": "mocha",
|
|
45
44
|
"posttest": "npm run lint",
|
|
46
|
-
"coverage": "nyc -r lcov npm run test",
|
|
45
|
+
"coverage": "npx nyc -r lcov npm run test",
|
|
47
46
|
"lint": "eslint src/**/*.ts",
|
|
48
47
|
"install-types-next": "npm install vscode-languageserver-types@next -f -S && npm install vscode-languageserver-textdocument@next -f -S",
|
|
49
48
|
"preversion": "npm test",
|
|
50
|
-
"postversion": "git push && git push --tags"
|
|
49
|
+
"postversion": "git push && git push --tags",
|
|
50
|
+
"sample": "npm run compile && node ./lib/umd/example/sample.js"
|
|
51
51
|
}
|
|
52
52
|
}
|