vscode-json-languageservice 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,11 @@
1
- 3.2.0 /
1
+ 3.2.0 / 2018-09-27
2
2
  ==================
3
3
  * New API `LanguageServiceParams.ClientCapabilities` to define what LSP capabilities the client supports.
4
4
  * For the best experiences, clients should always use `LanguageServiceParams.ClientCapabilities.LATEST`, which has all the latest LSP cpabilities enabled.
5
- * `LanguageServiceParams.ClientCapabilities` can allow `MarkupKind.Markdown` as valid documentationFormat (used by completions if schemas use `markdownDescription` or `markdownEnumDescriptions`)
5
+ * `LanguageServiceParams.ClientCapabilities` can allow `MarkupKind.Markdown` as valid documentationFormat (used by completions if schemas use `markdownDescription` or `markdownEnumDescriptions`).
6
6
  * snippets can now provide the description also in markdown format.
7
+ * Bundled draft-07-schema with descriptions.
8
+ * Propose `examples` in code completions.
7
9
 
8
10
  3.1.5 / 2018-08-14
9
11
  ==================
package/README.md CHANGED
@@ -4,6 +4,7 @@ JSON language service extracted from VSCode to be reused, e.g in the Monaco edit
4
4
  [![npm Package](https://img.shields.io/npm/v/vscode-json-languageservice.svg?style=flat-square)](https://www.npmjs.org/package/vscode-json-languageservice)
5
5
  [![NPM Downloads](https://img.shields.io/npm/dm/vscode-json-languageservice.svg)](https://npmjs.org/package/vscode-json-languageservice)
6
6
  [![Build Status](https://travis-ci.org/Microsoft/vscode-json-languageservice.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-json-languageservice)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
8
 
8
9
  Why?
9
10
  ----
@@ -449,16 +449,18 @@ function validate(node, schema, validationResult, matchingSchemas) {
449
449
  var testBranch = function (schema) {
450
450
  var subValidationResult = new ValidationResult();
451
451
  var subMatchingSchemas = matchingSchemas.newSub();
452
- validate(node, schema, subValidationResult, subMatchingSchemas);
452
+ validate(node, asSchema(schema), subValidationResult, subMatchingSchemas);
453
453
  validationResult.merge(subValidationResult);
454
454
  validationResult.propertiesMatches += subValidationResult.propertiesMatches;
455
455
  validationResult.propertiesValueMatches += subValidationResult.propertiesValueMatches;
456
456
  matchingSchemas.merge(subMatchingSchemas);
457
457
  };
458
458
  var testCondition = function (ifSchema, thenSchema, elseSchema) {
459
+ var subSchema = asSchema(ifSchema);
459
460
  var subValidationResult = new ValidationResult();
460
461
  var subMatchingSchemas = matchingSchemas.newSub();
461
- validate(node, ifSchema, subValidationResult, subMatchingSchemas);
462
+ validate(node, subSchema, subValidationResult, subMatchingSchemas);
463
+ matchingSchemas.merge(subMatchingSchemas);
462
464
  if (!subValidationResult.hasProblems()) {
463
465
  if (thenSchema) {
464
466
  testBranch(thenSchema);
@@ -623,10 +623,10 @@ var JSONCompletion = /** @class */ (function () {
623
623
  JSONCompletion.prototype.getInsertTextForValue = function (value, separatorAfter) {
624
624
  var text = JSON.stringify(value, null, '\t');
625
625
  if (text === '{}') {
626
- return '{\n\t$1\n}' + separatorAfter;
626
+ return '{$1}' + separatorAfter;
627
627
  }
628
628
  else if (text === '[]') {
629
- return '[\n\t$1\n]' + separatorAfter;
629
+ return '[$1]' + separatorAfter;
630
630
  }
631
631
  return this.getInsertTextForPlainText(text + separatorAfter);
632
632
  };
@@ -744,10 +744,10 @@ var JSONCompletion = /** @class */ (function () {
744
744
  value = '"$1"';
745
745
  break;
746
746
  case 'object':
747
- value = '{\n\t$1\n}';
747
+ value = '{$1}';
748
748
  break;
749
749
  case 'array':
750
- value = '[\n\t$1\n]';
750
+ value = '[$1]';
751
751
  break;
752
752
  case 'number':
753
753
  case 'integer':
@@ -251,7 +251,12 @@ var JSONSchemaService = /** @class */ (function () {
251
251
  var errors = jsonErrors.length ? [localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': Parse error at offset {1}.', toDisplayString(url), jsonErrors[0].offset)] : [];
252
252
  return new UnresolvedSchema(schemaContent, errors);
253
253
  }, function (error) {
254
- var errorMessage = localize('json.schema.unabletoload', 'Unable to load schema from \'{0}\': {1}', toDisplayString(url), error.toString());
254
+ var errorMessage = error.toString();
255
+ var errorSplit = error.toString().split('Error: ');
256
+ if (errorSplit.length > 1) {
257
+ // more concise error message, URL and context are attached by caller anyways
258
+ errorMessage = errorSplit[1];
259
+ }
255
260
  return new UnresolvedSchema({}, [errorMessage]);
256
261
  });
257
262
  };
@@ -464,16 +464,18 @@ var __extends = (this && this.__extends) || (function () {
464
464
  var testBranch = function (schema) {
465
465
  var subValidationResult = new ValidationResult();
466
466
  var subMatchingSchemas = matchingSchemas.newSub();
467
- validate(node, schema, subValidationResult, subMatchingSchemas);
467
+ validate(node, asSchema(schema), subValidationResult, subMatchingSchemas);
468
468
  validationResult.merge(subValidationResult);
469
469
  validationResult.propertiesMatches += subValidationResult.propertiesMatches;
470
470
  validationResult.propertiesValueMatches += subValidationResult.propertiesValueMatches;
471
471
  matchingSchemas.merge(subMatchingSchemas);
472
472
  };
473
473
  var testCondition = function (ifSchema, thenSchema, elseSchema) {
474
+ var subSchema = asSchema(ifSchema);
474
475
  var subValidationResult = new ValidationResult();
475
476
  var subMatchingSchemas = matchingSchemas.newSub();
476
- validate(node, ifSchema, subValidationResult, subMatchingSchemas);
477
+ validate(node, subSchema, subValidationResult, subMatchingSchemas);
478
+ matchingSchemas.merge(subMatchingSchemas);
477
479
  if (!subValidationResult.hasProblems()) {
478
480
  if (thenSchema) {
479
481
  testBranch(thenSchema);
@@ -633,10 +633,10 @@
633
633
  JSONCompletion.prototype.getInsertTextForValue = function (value, separatorAfter) {
634
634
  var text = JSON.stringify(value, null, '\t');
635
635
  if (text === '{}') {
636
- return '{\n\t$1\n}' + separatorAfter;
636
+ return '{$1}' + separatorAfter;
637
637
  }
638
638
  else if (text === '[]') {
639
- return '[\n\t$1\n]' + separatorAfter;
639
+ return '[$1]' + separatorAfter;
640
640
  }
641
641
  return this.getInsertTextForPlainText(text + separatorAfter);
642
642
  };
@@ -754,10 +754,10 @@
754
754
  value = '"$1"';
755
755
  break;
756
756
  case 'object':
757
- value = '{\n\t$1\n}';
757
+ value = '{$1}';
758
758
  break;
759
759
  case 'array':
760
- value = '[\n\t$1\n]';
760
+ value = '[$1]';
761
761
  break;
762
762
  case 'number':
763
763
  case 'integer':
@@ -261,7 +261,12 @@
261
261
  var errors = jsonErrors.length ? [localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': Parse error at offset {1}.', toDisplayString(url), jsonErrors[0].offset)] : [];
262
262
  return new UnresolvedSchema(schemaContent, errors);
263
263
  }, function (error) {
264
- var errorMessage = localize('json.schema.unabletoload', 'Unable to load schema from \'{0}\': {1}', toDisplayString(url), error.toString());
264
+ var errorMessage = error.toString();
265
+ var errorSplit = error.toString().split('Error: ');
266
+ if (errorSplit.length > 1) {
267
+ // more concise error message, URL and context are attached by caller anyways
268
+ errorMessage = errorSplit[1];
269
+ }
265
270
  return new UnresolvedSchema({}, [errorMessage]);
266
271
  });
267
272
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Language service for JSON",
5
5
  "main": "./lib/umd/jsonLanguageService.js",
6
6
  "typings": "./lib/umd/jsonLanguageService",