vscode-json-languageservice 3.3.2 → 3.3.3

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,3 +1,7 @@
1
+ 3.3.3 / 2019-0829
2
+ =================
3
+ Schemas can configure wheter comments and/or trailing are permitted.
4
+
1
5
  3.3.0 / 2019-06-12
2
6
  ==================
3
7
  * New API `LanguageService.getSelectionRanges` to get semantic selection ranges.
@@ -62,6 +62,7 @@ export interface JSONSchema {
62
62
  markdownDescription?: string;
63
63
  doNotSuggest?: boolean;
64
64
  allowComments?: boolean;
65
+ allowsTrailingCommas?: boolean;
65
66
  }
66
67
  export interface JSONSchemaMap {
67
68
  [name: string]: JSONSchemaRef;
@@ -6,6 +6,7 @@ import { UnresolvedSchema } from './jsonSchemaService';
6
6
  import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
7
7
  import { ErrorCode } from '../jsonLanguageTypes';
8
8
  import * as nls from 'vscode-nls';
9
+ import { isBoolean } from '../utils/objects';
9
10
  var localize = nls.loadMessageBundle();
10
11
  var JSONValidation = /** @class */ (function () {
11
12
  function JSONValidation(jsonSchemaService, promiseConstructor) {
@@ -58,7 +59,10 @@ var JSONValidation = /** @class */ (function () {
58
59
  }
59
60
  }
60
61
  if (schemaAllowsComments(schema.schema)) {
61
- trailingCommaSeverity = commentSeverity = void 0;
62
+ commentSeverity = void 0;
63
+ }
64
+ if (schemaAllowsTrailingCommas(schema.schema)) {
65
+ trailingCommaSeverity = void 0;
62
66
  }
63
67
  }
64
68
  for (var _i = 0, _a = jsonDocument.syntaxErrors; _i < _a.length; _i++) {
@@ -95,14 +99,37 @@ export { JSONValidation };
95
99
  var idCounter = 0;
96
100
  function schemaAllowsComments(schemaRef) {
97
101
  if (schemaRef && typeof schemaRef === 'object') {
98
- if (schemaRef.allowComments) {
99
- return true;
102
+ if (isBoolean(schemaRef.allowComments)) {
103
+ return schemaRef.allowComments;
100
104
  }
101
105
  if (schemaRef.allOf) {
102
- return schemaRef.allOf.some(schemaAllowsComments);
106
+ for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
107
+ var schema = _a[_i];
108
+ var allow = schemaAllowsComments(schema);
109
+ if (isBoolean(allow)) {
110
+ return allow;
111
+ }
112
+ }
113
+ }
114
+ }
115
+ return undefined;
116
+ }
117
+ function schemaAllowsTrailingCommas(schemaRef) {
118
+ if (schemaRef && typeof schemaRef === 'object') {
119
+ if (isBoolean(schemaRef.allowsTrailingCommas)) {
120
+ return schemaRef.allowsTrailingCommas;
121
+ }
122
+ if (schemaRef.allOf) {
123
+ for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
124
+ var schema = _a[_i];
125
+ var allow = schemaAllowsTrailingCommas(schema);
126
+ if (isBoolean(allow)) {
127
+ return allow;
128
+ }
129
+ }
103
130
  }
104
131
  }
105
- return false;
132
+ return undefined;
106
133
  }
107
134
  function toDiagnosticSeverity(severityLevel) {
108
135
  switch (severityLevel) {
@@ -62,6 +62,7 @@ export interface JSONSchema {
62
62
  markdownDescription?: string;
63
63
  doNotSuggest?: boolean;
64
64
  allowComments?: boolean;
65
+ allowsTrailingCommas?: boolean;
65
66
  }
66
67
  export interface JSONSchemaMap {
67
68
  [name: string]: JSONSchemaRef;
@@ -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", "./jsonSchemaService", "vscode-languageserver-types", "../jsonLanguageTypes", "vscode-nls"], factory);
11
+ define(["require", "exports", "./jsonSchemaService", "vscode-languageserver-types", "../jsonLanguageTypes", "vscode-nls", "../utils/objects"], factory);
12
12
  }
13
13
  })(function (require, exports) {
14
14
  "use strict";
@@ -17,6 +17,7 @@
17
17
  var vscode_languageserver_types_1 = require("vscode-languageserver-types");
18
18
  var jsonLanguageTypes_1 = require("../jsonLanguageTypes");
19
19
  var nls = require("vscode-nls");
20
+ var objects_1 = require("../utils/objects");
20
21
  var localize = nls.loadMessageBundle();
21
22
  var JSONValidation = /** @class */ (function () {
22
23
  function JSONValidation(jsonSchemaService, promiseConstructor) {
@@ -69,7 +70,10 @@
69
70
  }
70
71
  }
71
72
  if (schemaAllowsComments(schema.schema)) {
72
- trailingCommaSeverity = commentSeverity = void 0;
73
+ commentSeverity = void 0;
74
+ }
75
+ if (schemaAllowsTrailingCommas(schema.schema)) {
76
+ trailingCommaSeverity = void 0;
73
77
  }
74
78
  }
75
79
  for (var _i = 0, _a = jsonDocument.syntaxErrors; _i < _a.length; _i++) {
@@ -106,14 +110,37 @@
106
110
  var idCounter = 0;
107
111
  function schemaAllowsComments(schemaRef) {
108
112
  if (schemaRef && typeof schemaRef === 'object') {
109
- if (schemaRef.allowComments) {
110
- return true;
113
+ if (objects_1.isBoolean(schemaRef.allowComments)) {
114
+ return schemaRef.allowComments;
111
115
  }
112
116
  if (schemaRef.allOf) {
113
- return schemaRef.allOf.some(schemaAllowsComments);
117
+ for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
118
+ var schema = _a[_i];
119
+ var allow = schemaAllowsComments(schema);
120
+ if (objects_1.isBoolean(allow)) {
121
+ return allow;
122
+ }
123
+ }
124
+ }
125
+ }
126
+ return undefined;
127
+ }
128
+ function schemaAllowsTrailingCommas(schemaRef) {
129
+ if (schemaRef && typeof schemaRef === 'object') {
130
+ if (objects_1.isBoolean(schemaRef.allowsTrailingCommas)) {
131
+ return schemaRef.allowsTrailingCommas;
132
+ }
133
+ if (schemaRef.allOf) {
134
+ for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
135
+ var schema = _a[_i];
136
+ var allow = schemaAllowsTrailingCommas(schema);
137
+ if (objects_1.isBoolean(allow)) {
138
+ return allow;
139
+ }
140
+ }
114
141
  }
115
142
  }
116
- return false;
143
+ return undefined;
117
144
  }
118
145
  function toDiagnosticSeverity(severityLevel) {
119
146
  switch (severityLevel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "Language service for JSON",
5
5
  "main": "./lib/umd/jsonLanguageService.js",
6
6
  "typings": "./lib/umd/jsonLanguageService",