vscode-json-languageservice 3.4.12 → 3.7.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/.nyc_output/0abe3076-16a9-4975-87da-4ecfc24d9226.json +1 -0
- package/.nyc_output/5a0d1463-368f-4136-8a80-4c7fda7ca33b.json +1 -0
- package/.nyc_output/65e3530f-ee58-4bcb-8484-70eb1822427e.json +1 -0
- package/.nyc_output/a37c9066-0aa4-4d91-a56b-17754005a42d.json +1 -0
- package/.nyc_output/b7eb272f-3bf3-48c4-9a42-90600332b363.json +1 -0
- package/.nyc_output/cabc6994-64f7-4258-bb45-9bb5529b388e.json +1 -0
- package/.nyc_output/processinfo/0abe3076-16a9-4975-87da-4ecfc24d9226.json +1 -0
- package/.nyc_output/processinfo/5a0d1463-368f-4136-8a80-4c7fda7ca33b.json +1 -0
- package/.nyc_output/processinfo/65e3530f-ee58-4bcb-8484-70eb1822427e.json +1 -0
- package/.nyc_output/processinfo/a37c9066-0aa4-4d91-a56b-17754005a42d.json +1 -0
- package/.nyc_output/processinfo/b7eb272f-3bf3-48c4-9a42-90600332b363.json +1 -0
- package/.nyc_output/processinfo/cabc6994-64f7-4258-bb45-9bb5529b388e.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/CHANGELOG.md +13 -1
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +156 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/src/index.html +126 -0
- package/coverage/lcov-report/src/jsonLanguageService.ts.html +383 -0
- package/coverage/lcov-report/src/jsonLanguageTypes.ts.html +968 -0
- package/coverage/lcov-report/src/parser/index.html +111 -0
- package/coverage/lcov-report/src/parser/jsonParser.ts.html +3860 -0
- package/coverage/lcov-report/src/services/configuration.ts.html +1679 -0
- package/coverage/lcov-report/src/services/index.html +216 -0
- package/coverage/lcov-report/src/services/jsonCompletion.ts.html +2843 -0
- package/coverage/lcov-report/src/services/jsonDocumentSymbols.ts.html +911 -0
- package/coverage/lcov-report/src/services/jsonFolding.ts.html +455 -0
- package/coverage/lcov-report/src/services/jsonHover.ts.html +461 -0
- package/coverage/lcov-report/src/services/jsonSchemaService.ts.html +1895 -0
- package/coverage/lcov-report/src/services/jsonSelectionRanges.ts.html +311 -0
- package/coverage/lcov-report/src/services/jsonValidation.ts.html +560 -0
- package/coverage/lcov-report/src/utils/colors.ts.html +299 -0
- package/coverage/lcov-report/src/utils/index.html +156 -0
- package/coverage/lcov-report/src/utils/json.ts.html +206 -0
- package/coverage/lcov-report/src/utils/objects.ts.html +296 -0
- package/coverage/lcov-report/src/utils/strings.ts.html +224 -0
- package/coverage/lcov.info +4219 -0
- package/lib/esm/jsonLanguageService.d.ts +2 -1
- package/lib/esm/jsonLanguageService.js +3 -1
- package/lib/esm/jsonLanguageTypes.d.ts +4 -2
- package/lib/esm/jsonSchema.d.ts +1 -0
- package/lib/esm/parser/jsonParser.js +31 -30
- package/lib/esm/services/configuration.js +2 -2
- package/lib/esm/services/jsonCompletion.js +39 -33
- package/lib/esm/services/jsonDefinition.js +83 -0
- package/lib/esm/services/jsonDocumentSymbols.js +4 -4
- package/lib/esm/services/jsonHover.js +5 -5
- package/lib/esm/services/jsonSchemaService.js +90 -79
- package/lib/esm/services/jsonValidation.js +9 -8
- package/lib/esm/utils/colors.js +2 -2
- package/lib/umd/jsonLanguageService.d.ts +2 -1
- package/lib/umd/jsonLanguageService.js +4 -2
- package/lib/umd/jsonLanguageTypes.d.ts +4 -2
- package/lib/umd/jsonSchema.d.ts +1 -0
- package/lib/umd/parser/jsonParser.js +31 -30
- package/lib/umd/services/configuration.js +2 -2
- package/lib/umd/services/jsonCompletion.js +39 -33
- package/lib/umd/services/jsonDefinition.js +96 -0
- package/lib/umd/services/jsonDocumentSymbols.js +4 -4
- package/lib/umd/services/jsonHover.js +5 -5
- package/lib/umd/services/jsonSchemaService.js +90 -79
- package/lib/umd/services/jsonValidation.js +9 -8
- package/lib/umd/utils/colors.js +2 -2
- package/package.json +19 -13
|
@@ -40,6 +40,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
40
40
|
};
|
|
41
41
|
var ASTNodeImpl = /** @class */ (function () {
|
|
42
42
|
function ASTNodeImpl(parent, offset, length) {
|
|
43
|
+
if (length === void 0) { length = 0; }
|
|
43
44
|
this.offset = offset;
|
|
44
45
|
this.length = length;
|
|
45
46
|
this.parent = parent;
|
|
@@ -122,10 +123,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
122
123
|
exports.StringASTNodeImpl = StringASTNodeImpl;
|
|
123
124
|
var PropertyASTNodeImpl = /** @class */ (function (_super) {
|
|
124
125
|
__extends(PropertyASTNodeImpl, _super);
|
|
125
|
-
function PropertyASTNodeImpl(parent, offset) {
|
|
126
|
+
function PropertyASTNodeImpl(parent, offset, keyNode) {
|
|
126
127
|
var _this = _super.call(this, parent, offset) || this;
|
|
127
128
|
_this.type = 'property';
|
|
128
129
|
_this.colonOffset = -1;
|
|
130
|
+
_this.keyNode = keyNode;
|
|
129
131
|
return _this;
|
|
130
132
|
}
|
|
131
133
|
Object.defineProperty(PropertyASTNodeImpl.prototype, "children", {
|
|
@@ -171,7 +173,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
171
173
|
var SchemaCollector = /** @class */ (function () {
|
|
172
174
|
function SchemaCollector(focusOffset, exclude) {
|
|
173
175
|
if (focusOffset === void 0) { focusOffset = -1; }
|
|
174
|
-
if (exclude === void 0) { exclude = null; }
|
|
175
176
|
this.focusOffset = focusOffset;
|
|
176
177
|
this.exclude = exclude;
|
|
177
178
|
this.schemas = [];
|
|
@@ -180,8 +181,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
180
181
|
this.schemas.push(schema);
|
|
181
182
|
};
|
|
182
183
|
SchemaCollector.prototype.merge = function (other) {
|
|
183
|
-
|
|
184
|
-
(_a = this.schemas).push.apply(_a, other.schemas);
|
|
184
|
+
Array.prototype.push.apply(this.schemas, other.schemas);
|
|
185
185
|
};
|
|
186
186
|
SchemaCollector.prototype.include = function (node) {
|
|
187
187
|
return (this.focusOffset === -1 || contains(node, this.focusOffset)) && (node !== this.exclude);
|
|
@@ -213,7 +213,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
213
213
|
this.propertiesValueMatches = 0;
|
|
214
214
|
this.primaryValueMatches = 0;
|
|
215
215
|
this.enumValueMatch = false;
|
|
216
|
-
this.enumValues =
|
|
216
|
+
this.enumValues = undefined;
|
|
217
217
|
}
|
|
218
218
|
ValidationResult.prototype.hasProblems = function () {
|
|
219
219
|
return !!this.problems.length;
|
|
@@ -298,7 +298,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
298
298
|
if (this.root) {
|
|
299
299
|
return Json.findNodeAtOffset(this.root, offset, includeRightBound);
|
|
300
300
|
}
|
|
301
|
-
return
|
|
301
|
+
return undefined;
|
|
302
302
|
};
|
|
303
303
|
JSONDocument.prototype.visit = function (visitor) {
|
|
304
304
|
if (this.root) {
|
|
@@ -324,11 +324,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
324
324
|
return jsonLanguageTypes_1.Diagnostic.create(range, p.message, p.severity, p.code);
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
|
-
return
|
|
327
|
+
return undefined;
|
|
328
328
|
};
|
|
329
329
|
JSONDocument.prototype.getMatchingSchemas = function (schema, focusOffset, exclude) {
|
|
330
330
|
if (focusOffset === void 0) { focusOffset = -1; }
|
|
331
|
-
if (exclude === void 0) { exclude = null; }
|
|
332
331
|
var matchingSchemas = new SchemaCollector(focusOffset, exclude);
|
|
333
332
|
if (this.root && schema) {
|
|
334
333
|
validate(this.root, schema, new ValidationResult(), matchingSchemas);
|
|
@@ -338,10 +337,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
338
337
|
return JSONDocument;
|
|
339
338
|
}());
|
|
340
339
|
exports.JSONDocument = JSONDocument;
|
|
341
|
-
function validate(
|
|
342
|
-
if (!
|
|
340
|
+
function validate(n, schema, validationResult, matchingSchemas) {
|
|
341
|
+
if (!n || !matchingSchemas.include(n)) {
|
|
343
342
|
return;
|
|
344
343
|
}
|
|
344
|
+
var node = n;
|
|
345
345
|
switch (node.type) {
|
|
346
346
|
case 'object':
|
|
347
347
|
_validateObjectNode(node, schema, validationResult, matchingSchemas);
|
|
@@ -409,7 +409,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
409
409
|
var testAlternatives = function (alternatives, maxOneMatch) {
|
|
410
410
|
var matches = [];
|
|
411
411
|
// remember the best match that is used for error messages
|
|
412
|
-
var bestMatch =
|
|
412
|
+
var bestMatch = undefined;
|
|
413
413
|
for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
|
|
414
414
|
var subSchemaRef = alternatives_1[_i];
|
|
415
415
|
var subSchema = asSchema(subSchemaRef);
|
|
@@ -450,7 +450,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
450
450
|
message: localize('oneOfWarning', "Matches multiple schemas when only one must validate.")
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
|
-
if (bestMatch
|
|
453
|
+
if (bestMatch) {
|
|
454
454
|
validationResult.merge(bestMatch.validationResult);
|
|
455
455
|
validationResult.propertiesMatches += bestMatch.validationResult.propertiesMatches;
|
|
456
456
|
validationResult.propertiesValueMatches += bestMatch.validationResult.propertiesValueMatches;
|
|
@@ -555,13 +555,13 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
555
555
|
if (objects_1.isBoolean(exclusive) && exclusive) {
|
|
556
556
|
return limit;
|
|
557
557
|
}
|
|
558
|
-
return
|
|
558
|
+
return undefined;
|
|
559
559
|
}
|
|
560
560
|
function getLimit(limit, exclusive) {
|
|
561
561
|
if (!objects_1.isBoolean(exclusive) || !exclusive) {
|
|
562
562
|
return limit;
|
|
563
563
|
}
|
|
564
|
-
return
|
|
564
|
+
return undefined;
|
|
565
565
|
}
|
|
566
566
|
var exclusiveMinimum = getExclusiveLimit(schema.minimum, schema.exclusiveMinimum);
|
|
567
567
|
if (objects_1.isNumber(exclusiveMinimum) && val <= exclusiveMinimum) {
|
|
@@ -940,7 +940,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
940
940
|
var lastProblemOffset = -1;
|
|
941
941
|
var text = textDocument.getText();
|
|
942
942
|
var scanner = Json.createScanner(text, false);
|
|
943
|
-
var commentRanges = config && config.collectComments ? [] :
|
|
943
|
+
var commentRanges = config && config.collectComments ? [] : undefined;
|
|
944
944
|
function _scanNext() {
|
|
945
945
|
while (true) {
|
|
946
946
|
var token_1 = scanner.scan();
|
|
@@ -976,7 +976,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
978
|
function _error(message, code, node, skipUntilAfter, skipUntil) {
|
|
979
|
-
if (node === void 0) { node =
|
|
979
|
+
if (node === void 0) { node = undefined; }
|
|
980
980
|
if (skipUntilAfter === void 0) { skipUntilAfter = []; }
|
|
981
981
|
if (skipUntil === void 0) { skipUntil = []; }
|
|
982
982
|
var start = scanner.getTokenOffset();
|
|
@@ -1039,7 +1039,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
function _parseArray(parent) {
|
|
1041
1041
|
if (scanner.getToken() !== 3 /* OpenBracketToken */) {
|
|
1042
|
-
return
|
|
1042
|
+
return undefined;
|
|
1043
1043
|
}
|
|
1044
1044
|
var node = new ArrayASTNodeImpl(parent, scanner.getTokenOffset());
|
|
1045
1045
|
_scanNext(); // consume OpenBracketToken
|
|
@@ -1062,9 +1062,9 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1062
1062
|
else if (needsComma) {
|
|
1063
1063
|
_error(localize('ExpectedComma', 'Expected comma'), jsonLanguageTypes_1.ErrorCode.CommaExpected);
|
|
1064
1064
|
}
|
|
1065
|
-
var item = _parseValue(node
|
|
1065
|
+
var item = _parseValue(node);
|
|
1066
1066
|
if (!item) {
|
|
1067
|
-
_error(localize('PropertyExpected', 'Value expected'), jsonLanguageTypes_1.ErrorCode.ValueExpected,
|
|
1067
|
+
_error(localize('PropertyExpected', 'Value expected'), jsonLanguageTypes_1.ErrorCode.ValueExpected, undefined, [], [4 /* CloseBracketToken */, 5 /* CommaToken */]);
|
|
1068
1068
|
}
|
|
1069
1069
|
else {
|
|
1070
1070
|
node.items.push(item);
|
|
@@ -1076,8 +1076,9 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1076
1076
|
}
|
|
1077
1077
|
return _finalize(node, true);
|
|
1078
1078
|
}
|
|
1079
|
+
var keyPlaceholder = new StringASTNodeImpl(undefined, 0, 0);
|
|
1079
1080
|
function _parseProperty(parent, keysSeen) {
|
|
1080
|
-
var node = new PropertyASTNodeImpl(parent, scanner.getTokenOffset());
|
|
1081
|
+
var node = new PropertyASTNodeImpl(parent, scanner.getTokenOffset(), keyPlaceholder);
|
|
1081
1082
|
var key = _parseString(node);
|
|
1082
1083
|
if (!key) {
|
|
1083
1084
|
if (scanner.getToken() === 16 /* Unknown */) {
|
|
@@ -1089,7 +1090,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1089
1090
|
_scanNext(); // consume Unknown
|
|
1090
1091
|
}
|
|
1091
1092
|
else {
|
|
1092
|
-
return
|
|
1093
|
+
return undefined;
|
|
1093
1094
|
}
|
|
1094
1095
|
}
|
|
1095
1096
|
node.keyNode = key;
|
|
@@ -1115,7 +1116,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1115
1116
|
return node;
|
|
1116
1117
|
}
|
|
1117
1118
|
}
|
|
1118
|
-
var value = _parseValue(node
|
|
1119
|
+
var value = _parseValue(node);
|
|
1119
1120
|
if (!value) {
|
|
1120
1121
|
return _error(localize('ValueExpected', 'Value expected'), jsonLanguageTypes_1.ErrorCode.ValueExpected, node, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
|
|
1121
1122
|
}
|
|
@@ -1125,7 +1126,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1125
1126
|
}
|
|
1126
1127
|
function _parseObject(parent) {
|
|
1127
1128
|
if (scanner.getToken() !== 1 /* OpenBraceToken */) {
|
|
1128
|
-
return
|
|
1129
|
+
return undefined;
|
|
1129
1130
|
}
|
|
1130
1131
|
var node = new ObjectASTNodeImpl(parent, scanner.getTokenOffset());
|
|
1131
1132
|
var keysSeen = Object.create(null);
|
|
@@ -1150,7 +1151,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1150
1151
|
}
|
|
1151
1152
|
var property = _parseProperty(node, keysSeen);
|
|
1152
1153
|
if (!property) {
|
|
1153
|
-
_error(localize('PropertyExpected', 'Property expected'), jsonLanguageTypes_1.ErrorCode.PropertyExpected,
|
|
1154
|
+
_error(localize('PropertyExpected', 'Property expected'), jsonLanguageTypes_1.ErrorCode.PropertyExpected, undefined, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
|
|
1154
1155
|
}
|
|
1155
1156
|
else {
|
|
1156
1157
|
node.properties.push(property);
|
|
@@ -1164,7 +1165,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1164
1165
|
}
|
|
1165
1166
|
function _parseString(parent) {
|
|
1166
1167
|
if (scanner.getToken() !== 10 /* StringLiteral */) {
|
|
1167
|
-
return
|
|
1168
|
+
return undefined;
|
|
1168
1169
|
}
|
|
1169
1170
|
var node = new StringASTNodeImpl(parent, scanner.getTokenOffset());
|
|
1170
1171
|
node.value = scanner.getTokenValue();
|
|
@@ -1172,7 +1173,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1172
1173
|
}
|
|
1173
1174
|
function _parseNumber(parent) {
|
|
1174
1175
|
if (scanner.getToken() !== 11 /* NumericLiteral */) {
|
|
1175
|
-
return
|
|
1176
|
+
return undefined;
|
|
1176
1177
|
}
|
|
1177
1178
|
var node = new NumberASTNodeImpl(parent, scanner.getTokenOffset());
|
|
1178
1179
|
if (scanner.getTokenError() === 0 /* None */) {
|
|
@@ -1201,16 +1202,16 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1201
1202
|
case 9 /* FalseKeyword */:
|
|
1202
1203
|
return _finalize(new BooleanASTNodeImpl(parent, false, scanner.getTokenOffset()), true);
|
|
1203
1204
|
default:
|
|
1204
|
-
return
|
|
1205
|
+
return undefined;
|
|
1205
1206
|
}
|
|
1206
1207
|
}
|
|
1207
|
-
function _parseValue(parent
|
|
1208
|
+
function _parseValue(parent) {
|
|
1208
1209
|
return _parseArray(parent) || _parseObject(parent) || _parseString(parent) || _parseNumber(parent) || _parseLiteral(parent);
|
|
1209
1210
|
}
|
|
1210
|
-
var _root =
|
|
1211
|
+
var _root = undefined;
|
|
1211
1212
|
var token = _scanNext();
|
|
1212
1213
|
if (token !== 17 /* EOF */) {
|
|
1213
|
-
_root = _parseValue(
|
|
1214
|
+
_root = _parseValue(_root);
|
|
1214
1215
|
if (!_root) {
|
|
1215
1216
|
_error(localize('Invalid symbol', 'Expected a JSON object, array or literal.'), jsonLanguageTypes_1.ErrorCode.Undefined);
|
|
1216
1217
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
var nls = require("vscode-nls");
|
|
17
17
|
var localize = nls.loadMessageBundle();
|
|
18
18
|
exports.schemaContributions = {
|
|
19
|
-
schemaAssociations:
|
|
19
|
+
schemaAssociations: [],
|
|
20
20
|
schemas: {
|
|
21
21
|
// refer to the latest schema
|
|
22
22
|
'http://json-schema.org/schema#': {
|
|
@@ -527,7 +527,7 @@
|
|
|
527
527
|
var schema = exports.schemaContributions.schemas[schemaName];
|
|
528
528
|
for (var property in schema.properties) {
|
|
529
529
|
var propertyObject = schema.properties[property];
|
|
530
|
-
if (propertyObject ===
|
|
530
|
+
if (typeof propertyObject === 'boolean') {
|
|
531
531
|
propertyObject = schema.properties[property] = {};
|
|
532
532
|
}
|
|
533
533
|
var description = descriptions[property];
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
this.contributions = contributions;
|
|
33
33
|
this.promiseConstructor = promiseConstructor;
|
|
34
34
|
this.clientCapabilities = clientCapabilities;
|
|
35
|
-
this.templateVarIdCounter = 0;
|
|
36
35
|
}
|
|
37
36
|
JSONCompletion.prototype.doResolve = function (item) {
|
|
38
37
|
for (var i = this.contributions.length - 1; i >= 0; i--) {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var resolveCompletion = this.contributions[i].resolveCompletion;
|
|
39
|
+
if (resolveCompletion) {
|
|
40
|
+
var resolver = resolveCompletion(item);
|
|
41
41
|
if (resolver) {
|
|
42
42
|
return resolver;
|
|
43
43
|
}
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
var currentWord = this.getCurrentWord(document, offset);
|
|
68
|
-
var overwriteRange
|
|
68
|
+
var overwriteRange;
|
|
69
69
|
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
|
|
70
70
|
overwriteRange = jsonLanguageTypes_1.Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
|
71
71
|
}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
label = shortendedLabel;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
if (overwriteRange) {
|
|
93
|
+
if (overwriteRange && suggestion.insertText !== undefined) {
|
|
94
94
|
suggestion.textEdit = jsonLanguageTypes_1.TextEdit.replace(overwriteRange, suggestion.insertText);
|
|
95
95
|
}
|
|
96
96
|
if (supportsCommitCharacters) {
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
var collectionPromises = [];
|
|
122
122
|
var addValue = true;
|
|
123
123
|
var currentKey = '';
|
|
124
|
-
var currentProperty =
|
|
124
|
+
var currentProperty = undefined;
|
|
125
125
|
if (node) {
|
|
126
126
|
if (node.type === 'string') {
|
|
127
127
|
var parent = node.parent;
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
collector.add({
|
|
172
172
|
kind: jsonLanguageTypes_1.CompletionItemKind.Property,
|
|
173
173
|
label: _this.getLabelForValue(currentWord),
|
|
174
|
-
insertText: _this.getInsertTextForProperty(currentWord,
|
|
174
|
+
insertText: _this.getInsertTextForProperty(currentWord, undefined, false, separatorAfter_1),
|
|
175
175
|
insertTextFormat: jsonLanguageTypes_1.InsertTextFormat.Snippet, documentation: '',
|
|
176
176
|
});
|
|
177
177
|
collector.setAsIncomplete();
|
|
@@ -221,7 +221,10 @@
|
|
|
221
221
|
filterText: _this.getFilterTextForValue(key),
|
|
222
222
|
documentation: _this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || '',
|
|
223
223
|
};
|
|
224
|
-
if (
|
|
224
|
+
if (propertySchema.suggestSortText !== undefined) {
|
|
225
|
+
proposal.sortText = propertySchema.suggestSortText;
|
|
226
|
+
}
|
|
227
|
+
if (proposal.insertText && strings_1.endsWith(proposal.insertText, "$1" + separatorAfter)) {
|
|
225
228
|
proposal.command = {
|
|
226
229
|
title: 'Suggest',
|
|
227
230
|
command: 'editor.action.triggerSuggest'
|
|
@@ -273,7 +276,7 @@
|
|
|
273
276
|
collector.add({
|
|
274
277
|
kind: jsonLanguageTypes_1.CompletionItemKind.Property,
|
|
275
278
|
label: '$schema',
|
|
276
|
-
insertText: this.getInsertTextForProperty('$schema',
|
|
279
|
+
insertText: this.getInsertTextForProperty('$schema', undefined, true, ''),
|
|
277
280
|
insertTextFormat: jsonLanguageTypes_1.InsertTextFormat.Snippet, documentation: '',
|
|
278
281
|
filterText: this.getFilterTextForValue("$schema")
|
|
279
282
|
});
|
|
@@ -305,7 +308,7 @@
|
|
|
305
308
|
}
|
|
306
309
|
var separatorAfter = this.evaluateSeparatorAfter(document, offsetForSeparator);
|
|
307
310
|
var collectSuggestionsForValues = function (value) {
|
|
308
|
-
if (!Parser.contains(value.parent, offset, true)) {
|
|
311
|
+
if (value.parent && !Parser.contains(value.parent, offset, true)) {
|
|
309
312
|
collector.add({
|
|
310
313
|
kind: _this.getSuggestionKind(value.type),
|
|
311
314
|
label: _this.getLabelTextForMatchingNode(value, document),
|
|
@@ -318,7 +321,7 @@
|
|
|
318
321
|
}
|
|
319
322
|
};
|
|
320
323
|
if (node.type === 'property') {
|
|
321
|
-
if (offset > node.colonOffset) {
|
|
324
|
+
if (offset > (node.colonOffset || 0)) {
|
|
322
325
|
var valueNode = node.valueNode;
|
|
323
326
|
if (valueNode && (offset > (valueNode.offset + valueNode.length) || valueNode.type === 'object' || valueNode.type === 'array')) {
|
|
324
327
|
return;
|
|
@@ -354,10 +357,9 @@
|
|
|
354
357
|
}
|
|
355
358
|
};
|
|
356
359
|
JSONCompletion.prototype.getValueCompletions = function (schema, doc, node, offset, document, collector, types) {
|
|
357
|
-
var _this = this;
|
|
358
360
|
var offsetForSeparator = offset;
|
|
359
|
-
var parentKey =
|
|
360
|
-
var valueNode =
|
|
361
|
+
var parentKey = undefined;
|
|
362
|
+
var valueNode = undefined;
|
|
361
363
|
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
|
|
362
364
|
offsetForSeparator = node.offset + node.length;
|
|
363
365
|
valueNode = node;
|
|
@@ -367,7 +369,7 @@
|
|
|
367
369
|
this.addSchemaValueCompletions(schema.schema, '', collector, types);
|
|
368
370
|
return;
|
|
369
371
|
}
|
|
370
|
-
if ((node.type === 'property') && offset > node.colonOffset) {
|
|
372
|
+
if ((node.type === 'property') && offset > (node.colonOffset || 0)) {
|
|
371
373
|
var valueNode_1 = node.valueNode;
|
|
372
374
|
if (valueNode_1 && offset > (valueNode_1.offset + valueNode_1.length)) {
|
|
373
375
|
return; // we are past the value node
|
|
@@ -375,39 +377,40 @@
|
|
|
375
377
|
parentKey = node.keyNode.value;
|
|
376
378
|
node = node.parent;
|
|
377
379
|
}
|
|
378
|
-
if (node && (parentKey !==
|
|
379
|
-
var
|
|
380
|
+
if (node && (parentKey !== undefined || node.type === 'array')) {
|
|
381
|
+
var separatorAfter = this.evaluateSeparatorAfter(document, offsetForSeparator);
|
|
380
382
|
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset, valueNode);
|
|
381
|
-
matchingSchemas.
|
|
383
|
+
for (var _i = 0, matchingSchemas_1 = matchingSchemas; _i < matchingSchemas_1.length; _i++) {
|
|
384
|
+
var s = matchingSchemas_1[_i];
|
|
382
385
|
if (s.node === node && !s.inverted && s.schema) {
|
|
383
386
|
if (node.type === 'array' && s.schema.items) {
|
|
384
387
|
if (Array.isArray(s.schema.items)) {
|
|
385
|
-
var index =
|
|
388
|
+
var index = this.findItemAtOffset(node, document, offset);
|
|
386
389
|
if (index < s.schema.items.length) {
|
|
387
|
-
|
|
390
|
+
this.addSchemaValueCompletions(s.schema.items[index], separatorAfter, collector, types);
|
|
388
391
|
}
|
|
389
392
|
}
|
|
390
393
|
else {
|
|
391
|
-
|
|
394
|
+
this.addSchemaValueCompletions(s.schema.items, separatorAfter, collector, types);
|
|
392
395
|
}
|
|
393
396
|
}
|
|
394
|
-
if (s.schema.properties) {
|
|
397
|
+
if (s.schema.properties && parentKey !== undefined) {
|
|
395
398
|
var propertySchema = s.schema.properties[parentKey];
|
|
396
399
|
if (propertySchema) {
|
|
397
|
-
|
|
400
|
+
this.addSchemaValueCompletions(propertySchema, separatorAfter, collector, types);
|
|
398
401
|
}
|
|
399
402
|
}
|
|
400
403
|
}
|
|
401
|
-
}
|
|
404
|
+
}
|
|
402
405
|
if (parentKey === '$schema' && !node.parent) {
|
|
403
|
-
this.addDollarSchemaCompletions(
|
|
406
|
+
this.addDollarSchemaCompletions(separatorAfter, collector);
|
|
404
407
|
}
|
|
405
408
|
if (types['boolean']) {
|
|
406
|
-
this.addBooleanValueCompletion(true,
|
|
407
|
-
this.addBooleanValueCompletion(false,
|
|
409
|
+
this.addBooleanValueCompletion(true, separatorAfter, collector);
|
|
410
|
+
this.addBooleanValueCompletion(false, separatorAfter, collector);
|
|
408
411
|
}
|
|
409
412
|
if (types['null']) {
|
|
410
|
-
this.addNullValueCompletion(
|
|
413
|
+
this.addNullValueCompletion(separatorAfter, collector);
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
416
|
};
|
|
@@ -424,10 +427,10 @@
|
|
|
424
427
|
if (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null') {
|
|
425
428
|
node = node.parent;
|
|
426
429
|
}
|
|
427
|
-
if ((node.type === 'property') && offset > node.colonOffset) {
|
|
430
|
+
if (node && (node.type === 'property') && offset > (node.colonOffset || 0)) {
|
|
428
431
|
var parentKey_4 = node.keyNode.value;
|
|
429
432
|
var valueNode = node.valueNode;
|
|
430
|
-
if (!valueNode || offset <= (valueNode.offset + valueNode.length)) {
|
|
433
|
+
if ((!valueNode || offset <= (valueNode.offset + valueNode.length)) && node.parent) {
|
|
431
434
|
var location_2 = Parser.getNodePath(node.parent);
|
|
432
435
|
this.contributions.forEach(function (contribution) {
|
|
433
436
|
var collectPromise = contribution.collectValueCompletions(document.uri, location_2, parentKey_4, collector);
|
|
@@ -522,6 +525,9 @@
|
|
|
522
525
|
label = label || insertText,
|
|
523
526
|
filterText = insertText.replace(/[\n]/g, ''); // remove new lines
|
|
524
527
|
}
|
|
528
|
+
else {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
525
531
|
collector.add({
|
|
526
532
|
kind: _this.getSuggestionKind(type),
|
|
527
533
|
label: label,
|
|
@@ -533,7 +539,7 @@
|
|
|
533
539
|
hasProposals = true;
|
|
534
540
|
});
|
|
535
541
|
}
|
|
536
|
-
if (!hasProposals && typeof schema.items === 'object' && !Array.isArray(schema.items)) {
|
|
542
|
+
if (!hasProposals && typeof schema.items === 'object' && !Array.isArray(schema.items) && arrayDepth < 5 /* beware of recursion */) {
|
|
537
543
|
this.addDefaultValueCompletions(schema.items, separatorAfter, collector, arrayDepth + 1);
|
|
538
544
|
}
|
|
539
545
|
};
|
|
@@ -575,7 +581,7 @@
|
|
|
575
581
|
if (Array.isArray(type)) {
|
|
576
582
|
type.forEach(function (t) { return types[t] = true; });
|
|
577
583
|
}
|
|
578
|
-
else {
|
|
584
|
+
else if (type) {
|
|
579
585
|
types[type] = true;
|
|
580
586
|
}
|
|
581
587
|
};
|
|
@@ -688,7 +694,7 @@
|
|
|
688
694
|
JSONCompletion.prototype.getSuggestionKind = function (type) {
|
|
689
695
|
if (Array.isArray(type)) {
|
|
690
696
|
var array = type;
|
|
691
|
-
type = array.length > 0 ? array[0] :
|
|
697
|
+
type = array.length > 0 ? array[0] : undefined;
|
|
692
698
|
}
|
|
693
699
|
if (!type) {
|
|
694
700
|
return jsonLanguageTypes_1.CompletionItemKind.Value;
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
(function (factory) {
|
|
6
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
+
var v = factory(require, exports);
|
|
8
|
+
if (v !== undefined) module.exports = v;
|
|
9
|
+
}
|
|
10
|
+
else if (typeof define === "function" && define.amd) {
|
|
11
|
+
define(["require", "exports", "../jsonLanguageTypes"], factory);
|
|
12
|
+
}
|
|
13
|
+
})(function (require, exports) {
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
var jsonLanguageTypes_1 = require("../jsonLanguageTypes");
|
|
17
|
+
function findDefinition(document, position, doc) {
|
|
18
|
+
var offset = document.offsetAt(position);
|
|
19
|
+
var node = doc.getNodeFromOffset(offset, true);
|
|
20
|
+
if (!node || !isRef(node)) {
|
|
21
|
+
return Promise.resolve([]);
|
|
22
|
+
}
|
|
23
|
+
var propertyNode = node.parent;
|
|
24
|
+
var valueNode = propertyNode.valueNode;
|
|
25
|
+
var path = valueNode.value;
|
|
26
|
+
var targetNode = findTargetNode(doc, path);
|
|
27
|
+
if (!targetNode) {
|
|
28
|
+
return Promise.resolve([]);
|
|
29
|
+
}
|
|
30
|
+
var definition = {
|
|
31
|
+
targetUri: document.uri,
|
|
32
|
+
originSelectionRange: createRange(document, valueNode),
|
|
33
|
+
targetRange: createRange(document, targetNode),
|
|
34
|
+
targetSelectionRange: createRange(document, targetNode)
|
|
35
|
+
};
|
|
36
|
+
return Promise.resolve([definition]);
|
|
37
|
+
}
|
|
38
|
+
exports.findDefinition = findDefinition;
|
|
39
|
+
function createRange(document, node) {
|
|
40
|
+
return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
|
41
|
+
}
|
|
42
|
+
function isRef(node) {
|
|
43
|
+
return node.type === 'string' &&
|
|
44
|
+
node.parent &&
|
|
45
|
+
node.parent.type === 'property' &&
|
|
46
|
+
node.parent.valueNode === node &&
|
|
47
|
+
node.parent.keyNode.value === "$ref" ||
|
|
48
|
+
false;
|
|
49
|
+
}
|
|
50
|
+
function findTargetNode(doc, path) {
|
|
51
|
+
var tokens = parseJSONPointer(path);
|
|
52
|
+
if (!tokens) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return findNode(tokens, doc.root);
|
|
56
|
+
}
|
|
57
|
+
function findNode(pointer, node) {
|
|
58
|
+
if (!node) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (pointer.length === 0) {
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
var token = pointer.shift();
|
|
65
|
+
if (node && node.type === 'object') {
|
|
66
|
+
var propertyNode = node.properties.find(function (propertyNode) { return propertyNode.keyNode.value === token; });
|
|
67
|
+
if (!propertyNode) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return findNode(pointer, propertyNode.valueNode);
|
|
71
|
+
}
|
|
72
|
+
else if (node && node.type === 'array') {
|
|
73
|
+
if (token.match(/^(0|[1-9][0-9]*)$/)) {
|
|
74
|
+
var index = Number.parseInt(token);
|
|
75
|
+
var arrayItem = node.items[index];
|
|
76
|
+
if (!arrayItem) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return findNode(pointer, arrayItem);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function parseJSONPointer(path) {
|
|
85
|
+
if (path === "#") {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
if (path[0] !== '#' || path[1] !== '/') {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return path.substring(2).split(/\//).map(unescape);
|
|
92
|
+
}
|
|
93
|
+
function unescape(str) {
|
|
94
|
+
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
95
|
+
}
|
|
96
|
+
});
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
if (context === void 0) { context = { resultLimit: Number.MAX_VALUE }; }
|
|
27
27
|
var root = doc.root;
|
|
28
28
|
if (!root) {
|
|
29
|
-
return
|
|
29
|
+
return [];
|
|
30
30
|
}
|
|
31
|
-
var limit = context.resultLimit;
|
|
31
|
+
var limit = context.resultLimit || Number.MAX_VALUE;
|
|
32
32
|
// special handling for key bindings
|
|
33
33
|
var resourceString = document.uri;
|
|
34
34
|
if ((resourceString === 'vscode://defaultsettings/keybindings.json') || Strings.endsWith(resourceString.toLowerCase(), '/user/keybindings.json')) {
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
if (context === void 0) { context = { resultLimit: Number.MAX_VALUE }; }
|
|
104
104
|
var root = doc.root;
|
|
105
105
|
if (!root) {
|
|
106
|
-
return
|
|
106
|
+
return [];
|
|
107
107
|
}
|
|
108
|
-
var limit = context.resultLimit;
|
|
108
|
+
var limit = context.resultLimit || Number.MAX_VALUE;
|
|
109
109
|
// special handling for key bindings
|
|
110
110
|
var resourceString = document.uri;
|
|
111
111
|
if ((resourceString === 'vscode://defaultsettings/keybindings.json') || Strings.endsWith(resourceString.toLowerCase(), '/user/keybindings.json')) {
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
|
|
59
|
-
if (schema) {
|
|
59
|
+
if (schema && node) {
|
|
60
60
|
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
|
|
61
|
-
var title_1 =
|
|
62
|
-
var markdownDescription_1 =
|
|
63
|
-
var markdownEnumValueDescription_1 =
|
|
61
|
+
var title_1 = undefined;
|
|
62
|
+
var markdownDescription_1 = undefined;
|
|
63
|
+
var markdownEnumValueDescription_1 = undefined, enumValue_1 = undefined;
|
|
64
64
|
matchingSchemas.every(function (s) {
|
|
65
65
|
if (s.node === node && !s.inverted && s.schema) {
|
|
66
66
|
title_1 = title_1 || s.schema.title;
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
var res = plain.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, '$1\n\n$3'); // single new lines to \n\n (Markdown paragraph)
|
|
113
113
|
return res.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return undefined;
|
|
116
116
|
}
|
|
117
117
|
function toMarkdownCodeBlock(content) {
|
|
118
118
|
// see https://daringfireball.net/projects/markdown/syntax#precode
|