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.
Files changed (69) hide show
  1. package/.nyc_output/0abe3076-16a9-4975-87da-4ecfc24d9226.json +1 -0
  2. package/.nyc_output/5a0d1463-368f-4136-8a80-4c7fda7ca33b.json +1 -0
  3. package/.nyc_output/65e3530f-ee58-4bcb-8484-70eb1822427e.json +1 -0
  4. package/.nyc_output/a37c9066-0aa4-4d91-a56b-17754005a42d.json +1 -0
  5. package/.nyc_output/b7eb272f-3bf3-48c4-9a42-90600332b363.json +1 -0
  6. package/.nyc_output/cabc6994-64f7-4258-bb45-9bb5529b388e.json +1 -0
  7. package/.nyc_output/processinfo/0abe3076-16a9-4975-87da-4ecfc24d9226.json +1 -0
  8. package/.nyc_output/processinfo/5a0d1463-368f-4136-8a80-4c7fda7ca33b.json +1 -0
  9. package/.nyc_output/processinfo/65e3530f-ee58-4bcb-8484-70eb1822427e.json +1 -0
  10. package/.nyc_output/processinfo/a37c9066-0aa4-4d91-a56b-17754005a42d.json +1 -0
  11. package/.nyc_output/processinfo/b7eb272f-3bf3-48c4-9a42-90600332b363.json +1 -0
  12. package/.nyc_output/processinfo/cabc6994-64f7-4258-bb45-9bb5529b388e.json +1 -0
  13. package/.nyc_output/processinfo/index.json +1 -0
  14. package/CHANGELOG.md +13 -1
  15. package/coverage/lcov-report/base.css +224 -0
  16. package/coverage/lcov-report/block-navigation.js +79 -0
  17. package/coverage/lcov-report/favicon.png +0 -0
  18. package/coverage/lcov-report/index.html +156 -0
  19. package/coverage/lcov-report/prettify.css +1 -0
  20. package/coverage/lcov-report/prettify.js +2 -0
  21. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  22. package/coverage/lcov-report/sorter.js +170 -0
  23. package/coverage/lcov-report/src/index.html +126 -0
  24. package/coverage/lcov-report/src/jsonLanguageService.ts.html +383 -0
  25. package/coverage/lcov-report/src/jsonLanguageTypes.ts.html +968 -0
  26. package/coverage/lcov-report/src/parser/index.html +111 -0
  27. package/coverage/lcov-report/src/parser/jsonParser.ts.html +3860 -0
  28. package/coverage/lcov-report/src/services/configuration.ts.html +1679 -0
  29. package/coverage/lcov-report/src/services/index.html +216 -0
  30. package/coverage/lcov-report/src/services/jsonCompletion.ts.html +2843 -0
  31. package/coverage/lcov-report/src/services/jsonDocumentSymbols.ts.html +911 -0
  32. package/coverage/lcov-report/src/services/jsonFolding.ts.html +455 -0
  33. package/coverage/lcov-report/src/services/jsonHover.ts.html +461 -0
  34. package/coverage/lcov-report/src/services/jsonSchemaService.ts.html +1895 -0
  35. package/coverage/lcov-report/src/services/jsonSelectionRanges.ts.html +311 -0
  36. package/coverage/lcov-report/src/services/jsonValidation.ts.html +560 -0
  37. package/coverage/lcov-report/src/utils/colors.ts.html +299 -0
  38. package/coverage/lcov-report/src/utils/index.html +156 -0
  39. package/coverage/lcov-report/src/utils/json.ts.html +206 -0
  40. package/coverage/lcov-report/src/utils/objects.ts.html +296 -0
  41. package/coverage/lcov-report/src/utils/strings.ts.html +224 -0
  42. package/coverage/lcov.info +4219 -0
  43. package/lib/esm/jsonLanguageService.d.ts +2 -1
  44. package/lib/esm/jsonLanguageService.js +3 -1
  45. package/lib/esm/jsonLanguageTypes.d.ts +4 -2
  46. package/lib/esm/jsonSchema.d.ts +1 -0
  47. package/lib/esm/parser/jsonParser.js +31 -30
  48. package/lib/esm/services/configuration.js +2 -2
  49. package/lib/esm/services/jsonCompletion.js +39 -33
  50. package/lib/esm/services/jsonDefinition.js +83 -0
  51. package/lib/esm/services/jsonDocumentSymbols.js +4 -4
  52. package/lib/esm/services/jsonHover.js +5 -5
  53. package/lib/esm/services/jsonSchemaService.js +90 -79
  54. package/lib/esm/services/jsonValidation.js +9 -8
  55. package/lib/esm/utils/colors.js +2 -2
  56. package/lib/umd/jsonLanguageService.d.ts +2 -1
  57. package/lib/umd/jsonLanguageService.js +4 -2
  58. package/lib/umd/jsonLanguageTypes.d.ts +4 -2
  59. package/lib/umd/jsonSchema.d.ts +1 -0
  60. package/lib/umd/parser/jsonParser.js +31 -30
  61. package/lib/umd/services/configuration.js +2 -2
  62. package/lib/umd/services/jsonCompletion.js +39 -33
  63. package/lib/umd/services/jsonDefinition.js +96 -0
  64. package/lib/umd/services/jsonDocumentSymbols.js +4 -4
  65. package/lib/umd/services/jsonHover.js +5 -5
  66. package/lib/umd/services/jsonSchemaService.js +90 -79
  67. package/lib/umd/services/jsonValidation.js +9 -8
  68. package/lib/umd/utils/colors.js +2 -2
  69. package/package.json +19 -13
@@ -45,11 +45,11 @@ var JSONHover = /** @class */ (function () {
45
45
  }
46
46
  }
47
47
  return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
48
- if (schema) {
48
+ if (schema && node) {
49
49
  var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
50
- var title_1 = null;
51
- var markdownDescription_1 = null;
52
- var markdownEnumValueDescription_1 = null, enumValue_1 = null;
50
+ var title_1 = undefined;
51
+ var markdownDescription_1 = undefined;
52
+ var markdownEnumValueDescription_1 = undefined, enumValue_1 = undefined;
53
53
  matchingSchemas.every(function (s) {
54
54
  if (s.node === node && !s.inverted && s.schema) {
55
55
  title_1 = title_1 || s.schema.title;
@@ -101,7 +101,7 @@ function toMarkdown(plain) {
101
101
  var res = plain.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, '$1\n\n$3'); // single new lines to \n\n (Markdown paragraph)
102
102
  return res.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
103
103
  }
104
- return void 0;
104
+ return undefined;
105
105
  }
106
106
  function toMarkdownCodeBlock(content) {
107
107
  // see https://daringfireball.net/projects/markdown/syntax#precode
@@ -9,24 +9,40 @@ import * as Parser from '../parser/jsonParser';
9
9
  import * as nls from 'vscode-nls';
10
10
  var localize = nls.loadMessageBundle();
11
11
  var FilePatternAssociation = /** @class */ (function () {
12
- function FilePatternAssociation(pattern) {
12
+ function FilePatternAssociation(pattern, uris) {
13
+ this.patternRegExps = [];
14
+ this.isInclude = [];
13
15
  try {
14
- this.patternRegExp = new RegExp(Strings.convertSimple2RegExpPattern(pattern) + '$');
16
+ for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
17
+ var p = pattern_1[_i];
18
+ var include = p[0] !== '!';
19
+ if (!include) {
20
+ p = p.substring(1);
21
+ }
22
+ this.patternRegExps.push(new RegExp(Strings.convertSimple2RegExpPattern(p) + '$'));
23
+ this.isInclude.push(include);
24
+ }
25
+ this.uris = uris;
15
26
  }
16
27
  catch (e) {
17
28
  // invalid pattern
18
- this.patternRegExp = null;
29
+ this.patternRegExps.length = 0;
30
+ this.isInclude.length = 0;
31
+ this.uris = [];
19
32
  }
20
- this.schemas = [];
21
33
  }
22
- FilePatternAssociation.prototype.addSchema = function (id) {
23
- this.schemas.push(id);
24
- };
25
34
  FilePatternAssociation.prototype.matchesPattern = function (fileName) {
26
- return this.patternRegExp && this.patternRegExp.test(fileName);
35
+ var match = false;
36
+ for (var i = 0; i < this.patternRegExps.length; i++) {
37
+ var regExp = this.patternRegExps[i];
38
+ if (regExp.test(fileName)) {
39
+ match = this.isInclude[i];
40
+ }
41
+ }
42
+ return match;
27
43
  };
28
- FilePatternAssociation.prototype.getSchemas = function () {
29
- return this.schemas;
44
+ FilePatternAssociation.prototype.getURIs = function () {
45
+ return this.uris;
30
46
  };
31
47
  return FilePatternAssociation;
32
48
  }());
@@ -55,8 +71,8 @@ var SchemaHandle = /** @class */ (function () {
55
71
  return this.resolvedSchema;
56
72
  };
57
73
  SchemaHandle.prototype.clearSchema = function () {
58
- this.resolvedSchema = null;
59
- this.unresolvedSchema = null;
74
+ this.resolvedSchema = undefined;
75
+ this.unresolvedSchema = undefined;
60
76
  this.dependencies = {};
61
77
  };
62
78
  return SchemaHandle;
@@ -77,7 +93,11 @@ var ResolvedSchema = /** @class */ (function () {
77
93
  this.errors = errors;
78
94
  }
79
95
  ResolvedSchema.prototype.getSection = function (path) {
80
- return Parser.asSchema(this.getSectionRecursive(path, this.schema));
96
+ var schemaRef = this.getSectionRecursive(path, this.schema);
97
+ if (schemaRef) {
98
+ return Parser.asSchema(schemaRef);
99
+ }
100
+ return undefined;
81
101
  };
82
102
  ResolvedSchema.prototype.getSectionRecursive = function (path, schema) {
83
103
  if (!schema || typeof schema === 'boolean' || path.length === 0) {
@@ -110,7 +130,7 @@ var ResolvedSchema = /** @class */ (function () {
110
130
  return this.getSectionRecursive(path, schema.items);
111
131
  }
112
132
  }
113
- return null;
133
+ return undefined;
114
134
  };
115
135
  return ResolvedSchema;
116
136
  }());
@@ -122,10 +142,9 @@ var JSONSchemaService = /** @class */ (function () {
122
142
  this.promiseConstructor = promiseConstructor || Promise;
123
143
  this.callOnDispose = [];
124
144
  this.contributionSchemas = {};
125
- this.contributionAssociations = {};
145
+ this.contributionAssociations = [];
126
146
  this.schemasById = {};
127
147
  this.filePatternAssociations = [];
128
- this.filePatternAssociationById = {};
129
148
  this.registeredSchemasIds = {};
130
149
  }
131
150
  JSONSchemaService.prototype.getRegisteredSchemaIds = function (filter) {
@@ -149,7 +168,7 @@ var JSONSchemaService = /** @class */ (function () {
149
168
  JSONSchemaService.prototype.onResourceChange = function (uri) {
150
169
  var _this = this;
151
170
  var hasChanges = false;
152
- uri = this.normalizeId(uri);
171
+ uri = normalizeId(uri);
153
172
  var toWalk = [uri];
154
173
  var all = Object.keys(this.schemasById).map(function (key) { return _this.schemasById[key]; });
155
174
  while (toWalk.length) {
@@ -168,34 +187,21 @@ var JSONSchemaService = /** @class */ (function () {
168
187
  }
169
188
  return hasChanges;
170
189
  };
171
- JSONSchemaService.prototype.normalizeId = function (id) {
172
- // remove trailing '#', normalize drive capitalization
173
- try {
174
- return URI.parse(id).toString();
175
- }
176
- catch (e) {
177
- return id;
178
- }
179
- };
180
190
  JSONSchemaService.prototype.setSchemaContributions = function (schemaContributions) {
181
191
  if (schemaContributions.schemas) {
182
192
  var schemas = schemaContributions.schemas;
183
193
  for (var id in schemas) {
184
- var normalizedId = this.normalizeId(id);
194
+ var normalizedId = normalizeId(id);
185
195
  this.contributionSchemas[normalizedId] = this.addSchemaHandle(normalizedId, schemas[id]);
186
196
  }
187
197
  }
188
- if (schemaContributions.schemaAssociations) {
198
+ if (Array.isArray(schemaContributions.schemaAssociations)) {
189
199
  var schemaAssociations = schemaContributions.schemaAssociations;
190
- for (var pattern in schemaAssociations) {
191
- var associations = schemaAssociations[pattern];
192
- this.contributionAssociations[pattern] = associations;
193
- var fpa = this.getOrAddFilePatternAssociation(pattern);
194
- for (var _i = 0, associations_1 = associations; _i < associations_1.length; _i++) {
195
- var schemaId = associations_1[_i];
196
- var id = this.normalizeId(schemaId);
197
- fpa.addSchema(id);
198
- }
200
+ for (var _i = 0, schemaAssociations_1 = schemaAssociations; _i < schemaAssociations_1.length; _i++) {
201
+ var schemaAssociation = schemaAssociations_1[_i];
202
+ var uris = schemaAssociation.uris.map(normalizeId);
203
+ var association = this.addFilePatternAssociation(schemaAssociation.pattern, uris);
204
+ this.contributionAssociations.push(association);
199
205
  }
200
206
  }
201
207
  };
@@ -207,52 +213,41 @@ var JSONSchemaService = /** @class */ (function () {
207
213
  JSONSchemaService.prototype.getOrAddSchemaHandle = function (id, unresolvedSchemaContent) {
208
214
  return this.schemasById[id] || this.addSchemaHandle(id, unresolvedSchemaContent);
209
215
  };
210
- JSONSchemaService.prototype.getOrAddFilePatternAssociation = function (pattern) {
211
- var fpa = this.filePatternAssociationById[pattern];
212
- if (!fpa) {
213
- fpa = new FilePatternAssociation(pattern);
214
- this.filePatternAssociationById[pattern] = fpa;
215
- this.filePatternAssociations.push(fpa);
216
- }
216
+ JSONSchemaService.prototype.addFilePatternAssociation = function (pattern, uris) {
217
+ var fpa = new FilePatternAssociation(pattern, uris);
218
+ this.filePatternAssociations.push(fpa);
217
219
  return fpa;
218
220
  };
219
221
  JSONSchemaService.prototype.registerExternalSchema = function (uri, filePatterns, unresolvedSchemaContent) {
220
- if (filePatterns === void 0) { filePatterns = null; }
221
- var id = this.normalizeId(uri);
222
+ var id = normalizeId(uri);
222
223
  this.registeredSchemasIds[id] = true;
224
+ this.cachedSchemaForResource = undefined;
223
225
  if (filePatterns) {
224
- for (var _i = 0, filePatterns_1 = filePatterns; _i < filePatterns_1.length; _i++) {
225
- var pattern = filePatterns_1[_i];
226
- this.getOrAddFilePatternAssociation(pattern).addSchema(id);
227
- }
226
+ this.addFilePatternAssociation(filePatterns, [uri]);
228
227
  }
229
228
  return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
230
229
  };
231
230
  JSONSchemaService.prototype.clearExternalSchemas = function () {
232
231
  this.schemasById = {};
233
232
  this.filePatternAssociations = [];
234
- this.filePatternAssociationById = {};
235
233
  this.registeredSchemasIds = {};
234
+ this.cachedSchemaForResource = undefined;
236
235
  for (var id in this.contributionSchemas) {
237
236
  this.schemasById[id] = this.contributionSchemas[id];
238
237
  this.registeredSchemasIds[id] = true;
239
238
  }
240
- for (var pattern in this.contributionAssociations) {
241
- var fpa = this.getOrAddFilePatternAssociation(pattern);
242
- for (var _i = 0, _a = this.contributionAssociations[pattern]; _i < _a.length; _i++) {
243
- var schemaId = _a[_i];
244
- var id = this.normalizeId(schemaId);
245
- fpa.addSchema(id);
246
- }
239
+ for (var _i = 0, _a = this.contributionAssociations; _i < _a.length; _i++) {
240
+ var contributionAssociation = _a[_i];
241
+ this.filePatternAssociations.push(contributionAssociation);
247
242
  }
248
243
  };
249
244
  JSONSchemaService.prototype.getResolvedSchema = function (schemaId) {
250
- var id = this.normalizeId(schemaId);
245
+ var id = normalizeId(schemaId);
251
246
  var schemaHandle = this.schemasById[id];
252
247
  if (schemaHandle) {
253
248
  return schemaHandle.getResolvedSchema();
254
249
  }
255
- return this.promise.resolve(null);
250
+ return this.promise.resolve(undefined);
256
251
  };
257
252
  JSONSchemaService.prototype.loadSchema = function (url) {
258
253
  if (!this.requestService) {
@@ -287,7 +282,7 @@ var JSONSchemaService = /** @class */ (function () {
287
282
  var resolveErrors = schemaToResolve.errors.slice(0);
288
283
  var schema = schemaToResolve.schema;
289
284
  if (schema.$schema) {
290
- var id = this.normalizeId(schema.$schema);
285
+ var id = normalizeId(schema.$schema);
291
286
  if (id === 'http://json-schema.org/draft-03/schema') {
292
287
  return this.promise.resolve(new ResolvedSchema({}, [localize('json.schema.draft03.notsupported', "Draft-03 schemas are not supported.")]));
293
288
  }
@@ -310,7 +305,8 @@ var JSONSchemaService = /** @class */ (function () {
310
305
  });
311
306
  return current;
312
307
  };
313
- var merge = function (target, sourceRoot, sourceURI, path) {
308
+ var merge = function (target, sourceRoot, sourceURI, refSegment) {
309
+ var path = refSegment ? decodeURIComponent(refSegment) : undefined;
314
310
  var section = findSection(sourceRoot, path);
315
311
  if (section) {
316
312
  for (var key in section) {
@@ -323,19 +319,19 @@ var JSONSchemaService = /** @class */ (function () {
323
319
  resolveErrors.push(localize('json.schema.invalidref', '$ref \'{0}\' in \'{1}\' can not be resolved.', path, sourceURI));
324
320
  }
325
321
  };
326
- var resolveExternalLink = function (node, uri, linkPath, parentSchemaURL, parentSchemaDependencies) {
322
+ var resolveExternalLink = function (node, uri, refSegment, parentSchemaURL, parentSchemaDependencies) {
327
323
  if (contextService && !/^\w+:\/\/.*/.test(uri)) {
328
324
  uri = contextService.resolveRelativePath(uri, parentSchemaURL);
329
325
  }
330
- uri = _this.normalizeId(uri);
326
+ uri = normalizeId(uri);
331
327
  var referencedHandle = _this.getOrAddSchemaHandle(uri);
332
328
  return referencedHandle.getUnresolvedSchema().then(function (unresolvedSchema) {
333
329
  parentSchemaDependencies[uri] = true;
334
330
  if (unresolvedSchema.errors.length) {
335
- var loc = linkPath ? uri + '#' + linkPath : uri;
331
+ var loc = refSegment ? uri + '#' + refSegment : uri;
336
332
  resolveErrors.push(localize('json.schema.problemloadingref', 'Problems loading reference \'{0}\': {1}', loc, unresolvedSchema.errors[0]));
337
333
  }
338
- merge(node, unresolvedSchema.schema, uri, linkPath);
334
+ merge(node, unresolvedSchema.schema, uri, refSegment);
339
335
  return resolveRefs(node, unresolvedSchema.schema, uri, referencedHandle.dependencies);
340
336
  });
341
337
  };
@@ -366,7 +362,8 @@ var JSONSchemaService = /** @class */ (function () {
366
362
  for (var _a = 0, maps_1 = maps; _a < maps_1.length; _a++) {
367
363
  var map = maps_1[_a];
368
364
  if (typeof map === 'object') {
369
- for (var key in map) {
365
+ for (var k in map) {
366
+ var key = k;
370
367
  var entry = map[key];
371
368
  if (typeof entry === 'object') {
372
369
  toWalk.push(entry);
@@ -430,22 +427,28 @@ var JSONSchemaService = /** @class */ (function () {
430
427
  if (document && document.root && document.root.type === 'object') {
431
428
  var schemaProperties = document.root.properties.filter(function (p) { return (p.keyNode.value === '$schema') && p.valueNode && p.valueNode.type === 'string'; });
432
429
  if (schemaProperties.length > 0) {
433
- var schemeId = Parser.getNodeValue(schemaProperties[0].valueNode);
434
- if (schemeId && Strings.startsWith(schemeId, '.') && this.contextService) {
435
- schemeId = this.contextService.resolveRelativePath(schemeId, resource);
436
- }
437
- if (schemeId) {
438
- var id = this.normalizeId(schemeId);
439
- return this.getOrAddSchemaHandle(id).getResolvedSchema();
430
+ var valueNode = schemaProperties[0].valueNode;
431
+ if (valueNode && valueNode.type === 'string') {
432
+ var schemeId = Parser.getNodeValue(valueNode);
433
+ if (schemeId && Strings.startsWith(schemeId, '.') && this.contextService) {
434
+ schemeId = this.contextService.resolveRelativePath(schemeId, resource);
435
+ }
436
+ if (schemeId) {
437
+ var id = normalizeId(schemeId);
438
+ return this.getOrAddSchemaHandle(id).getResolvedSchema();
439
+ }
440
440
  }
441
441
  }
442
442
  }
443
+ if (this.cachedSchemaForResource && this.cachedSchemaForResource.resource === resource) {
444
+ return this.cachedSchemaForResource.resolvedSchema;
445
+ }
443
446
  var seen = Object.create(null);
444
447
  var schemas = [];
445
448
  for (var _i = 0, _a = this.filePatternAssociations; _i < _a.length; _i++) {
446
449
  var entry = _a[_i];
447
450
  if (entry.matchesPattern(resource)) {
448
- for (var _b = 0, _c = entry.getSchemas(); _b < _c.length; _b++) {
451
+ for (var _b = 0, _c = entry.getURIs(); _b < _c.length; _b++) {
449
452
  var schemaId = _c[_b];
450
453
  if (!seen[schemaId]) {
451
454
  schemas.push(schemaId);
@@ -454,10 +457,9 @@ var JSONSchemaService = /** @class */ (function () {
454
457
  }
455
458
  }
456
459
  }
457
- if (schemas.length > 0) {
458
- return this.createCombinedSchema(resource, schemas).getResolvedSchema();
459
- }
460
- return this.promise.resolve(null);
460
+ var resolvedSchema = schemas.length > 0 ? this.createCombinedSchema(resource, schemas).getResolvedSchema() : this.promise.resolve(undefined);
461
+ this.cachedSchemaForResource = { resource: resource, resolvedSchema: resolvedSchema };
462
+ return resolvedSchema;
461
463
  };
462
464
  JSONSchemaService.prototype.createCombinedSchema = function (resource, schemaIds) {
463
465
  if (schemaIds.length === 1) {
@@ -474,6 +476,15 @@ var JSONSchemaService = /** @class */ (function () {
474
476
  return JSONSchemaService;
475
477
  }());
476
478
  export { JSONSchemaService };
479
+ function normalizeId(id) {
480
+ // remove trailing '#', normalize drive capitalization
481
+ try {
482
+ return URI.parse(id).toString();
483
+ }
484
+ catch (e) {
485
+ return id;
486
+ }
487
+ }
477
488
  function toDisplayString(url) {
478
489
  try {
479
490
  var uri = URI.parse(url);
@@ -16,7 +16,7 @@ var JSONValidation = /** @class */ (function () {
16
16
  JSONValidation.prototype.configure = function (raw) {
17
17
  if (raw) {
18
18
  this.validationEnabled = raw.validate;
19
- this.commentSeverity = raw.allowComments ? void 0 : DiagnosticSeverity.Error;
19
+ this.commentSeverity = raw.allowComments ? undefined : DiagnosticSeverity.Error;
20
20
  }
21
21
  };
22
22
  JSONValidation.prototype.doValidation = function (textDocument, jsonDocument, documentSettings, schema) {
@@ -40,7 +40,7 @@ var JSONValidation = /** @class */ (function () {
40
40
  if (schema) {
41
41
  if (schema.errors.length && jsonDocument.root) {
42
42
  var astRoot = jsonDocument.root;
43
- var property = astRoot.type === 'object' ? astRoot.properties[0] : null;
43
+ var property = astRoot.type === 'object' ? astRoot.properties[0] : undefined;
44
44
  if (property && property.keyNode.value === '$schema') {
45
45
  var node = property.valueNode || property;
46
46
  var range = Range.create(textDocument.positionAt(node.offset), textDocument.positionAt(node.offset + node.length));
@@ -58,10 +58,10 @@ var JSONValidation = /** @class */ (function () {
58
58
  }
59
59
  }
60
60
  if (schemaAllowsComments(schema.schema)) {
61
- commentSeverity = void 0;
61
+ commentSeverity = undefined;
62
62
  }
63
63
  if (schemaAllowsTrailingCommas(schema.schema)) {
64
- trailingCommaSeverity = void 0;
64
+ trailingCommaSeverity = undefined;
65
65
  }
66
66
  }
67
67
  for (var _i = 0, _a = jsonDocument.syntaxErrors; _i < _a.length; _i++) {
@@ -118,8 +118,9 @@ function schemaAllowsTrailingCommas(schemaRef) {
118
118
  if (isBoolean(schemaRef.allowTrailingCommas)) {
119
119
  return schemaRef.allowTrailingCommas;
120
120
  }
121
- if (isBoolean(schemaRef['allowsTrailingCommas'])) { // deprecated
122
- return schemaRef['allowsTrailingCommas'];
121
+ var deprSchemaRef = schemaRef;
122
+ if (isBoolean(deprSchemaRef['allowsTrailingCommas'])) { // deprecated
123
+ return deprSchemaRef['allowsTrailingCommas'];
123
124
  }
124
125
  if (schemaRef.allOf) {
125
126
  for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
@@ -137,7 +138,7 @@ function toDiagnosticSeverity(severityLevel) {
137
138
  switch (severityLevel) {
138
139
  case 'error': return DiagnosticSeverity.Error;
139
140
  case 'warning': return DiagnosticSeverity.Warning;
140
- case 'ignore': return void 0;
141
+ case 'ignore': return undefined;
141
142
  }
142
- return void 0;
143
+ return undefined;
143
144
  }
@@ -24,7 +24,7 @@ export function hexDigit(charCode) {
24
24
  }
25
25
  export function colorFromHex(text) {
26
26
  if (text[0] !== '#') {
27
- return null;
27
+ return undefined;
28
28
  }
29
29
  switch (text.length) {
30
30
  case 4:
@@ -56,7 +56,7 @@ export function colorFromHex(text) {
56
56
  alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0
57
57
  };
58
58
  }
59
- return null;
59
+ return undefined;
60
60
  }
61
61
  export function colorFrom256RGB(red, green, blue, alpha) {
62
62
  if (alpha === void 0) { alpha = 1.0; }
@@ -1,4 +1,4 @@
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 } from './jsonLanguageTypes';
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 } from './jsonLanguageTypes';
2
2
  export declare type JSONDocument = {};
3
3
  export * from './jsonLanguageTypes';
4
4
  export interface LanguageService {
@@ -19,5 +19,6 @@ export interface LanguageService {
19
19
  format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
20
20
  getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
21
21
  getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
22
+ findDefinition(document: TextDocument, position: Position, doc: JSONDocument): Thenable<DefinitionLink[]>;
22
23
  }
23
24
  export declare function getLanguageService(params: LanguageServiceParams): LanguageService;
@@ -8,7 +8,7 @@
8
8
  if (v !== undefined) module.exports = v;
9
9
  }
10
10
  else if (typeof define === "function" && define.amd) {
11
- define(["require", "exports", "./services/jsonCompletion", "./services/jsonHover", "./services/jsonValidation", "./services/jsonDocumentSymbols", "./parser/jsonParser", "./services/configuration", "./services/jsonSchemaService", "./services/jsonFolding", "./services/jsonSelectionRanges", "jsonc-parser", "./jsonLanguageTypes", "./jsonLanguageTypes"], factory);
11
+ define(["require", "exports", "./services/jsonCompletion", "./services/jsonHover", "./services/jsonValidation", "./services/jsonDocumentSymbols", "./parser/jsonParser", "./services/configuration", "./services/jsonSchemaService", "./services/jsonFolding", "./services/jsonSelectionRanges", "jsonc-parser", "./jsonLanguageTypes", "./services/jsonDefinition", "./jsonLanguageTypes"], factory);
12
12
  }
13
13
  })(function (require, exports) {
14
14
  "use strict";
@@ -27,6 +27,7 @@
27
27
  var jsonSelectionRanges_1 = require("./services/jsonSelectionRanges");
28
28
  var jsonc_parser_1 = require("jsonc-parser");
29
29
  var jsonLanguageTypes_1 = require("./jsonLanguageTypes");
30
+ var jsonDefinition_1 = require("./services/jsonDefinition");
30
31
  __export(require("./jsonLanguageTypes"));
31
32
  function getLanguageService(params) {
32
33
  var promise = params.promiseConstructor || Promise;
@@ -60,8 +61,9 @@
60
61
  doHover: jsonHover.doHover.bind(jsonHover),
61
62
  getFoldingRanges: jsonFolding_1.getFoldingRanges,
62
63
  getSelectionRanges: jsonSelectionRanges_1.getSelectionRanges,
64
+ findDefinition: jsonDefinition_1.findDefinition,
63
65
  format: function (d, r, o) {
64
- var range = void 0;
66
+ var range = undefined;
65
67
  if (r) {
66
68
  var offset = d.offsetAt(r.start);
67
69
  var length = d.offsetAt(r.end) - offset;
@@ -88,7 +88,7 @@ export interface LanguageSettings {
88
88
  export declare type SeverityLevel = 'error' | 'warning' | 'ignore';
89
89
  export interface DocumentLanguageSettings {
90
90
  /**
91
- * The severity of reported comments. If not set, 'LanguageSettings.allowComments' defines wheter comments are ignored or reported as errors.
91
+ * The severity of reported comments. If not set, 'LanguageSettings.allowComments' defines whether comments are ignored or reported as errors.
92
92
  */
93
93
  comments?: SeverityLevel;
94
94
  /**
@@ -102,7 +102,9 @@ export interface SchemaConfiguration {
102
102
  */
103
103
  uri: string;
104
104
  /**
105
- * A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
105
+ * A list of file path patterns that are associated to the schema. The '*' wildcard can be used. Exclusion patterns starting with '!'.
106
+ * For example '*.schema.json', 'package.json', '!foo*.schema.json'.
107
+ * A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'.
106
108
  */
107
109
  fileMatch?: string[];
108
110
  /**
@@ -61,6 +61,7 @@ export interface JSONSchema {
61
61
  markdownEnumDescriptions?: string[];
62
62
  markdownDescription?: string;
63
63
  doNotSuggest?: boolean;
64
+ suggestSortText?: string;
64
65
  allowComments?: boolean;
65
66
  allowTrailingCommas?: boolean;
66
67
  }