vscode-json-languageservice 4.2.0-next.3 → 5.0.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 (49) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/jsonContributions.d.ts +17 -17
  4. package/lib/esm/jsonContributions.js +1 -1
  5. package/lib/esm/jsonLanguageService.d.ts +29 -29
  6. package/lib/esm/jsonLanguageService.js +66 -66
  7. package/lib/esm/jsonLanguageTypes.d.ts +279 -278
  8. package/lib/esm/jsonLanguageTypes.js +46 -45
  9. package/lib/esm/jsonSchema.d.ts +89 -70
  10. package/lib/esm/jsonSchema.js +1 -1
  11. package/lib/esm/parser/jsonParser.js +1214 -1218
  12. package/lib/esm/services/configuration.js +528 -528
  13. package/lib/esm/services/jsonCompletion.js +918 -934
  14. package/lib/esm/services/jsonDocumentSymbols.js +267 -278
  15. package/lib/esm/services/jsonFolding.js +120 -121
  16. package/lib/esm/services/jsonHover.js +109 -112
  17. package/lib/esm/services/jsonLinks.js +72 -73
  18. package/lib/esm/services/jsonSchemaService.js +586 -605
  19. package/lib/esm/services/jsonSelectionRanges.js +61 -61
  20. package/lib/esm/services/jsonValidation.js +151 -149
  21. package/lib/esm/utils/colors.js +68 -69
  22. package/lib/esm/utils/glob.js +124 -124
  23. package/lib/esm/utils/json.js +42 -42
  24. package/lib/esm/utils/objects.js +68 -65
  25. package/lib/esm/utils/strings.js +64 -64
  26. package/lib/umd/jsonContributions.d.ts +17 -17
  27. package/lib/umd/jsonContributions.js +12 -12
  28. package/lib/umd/jsonLanguageService.d.ts +29 -29
  29. package/lib/umd/jsonLanguageService.js +90 -90
  30. package/lib/umd/jsonLanguageTypes.d.ts +279 -278
  31. package/lib/umd/jsonLanguageTypes.js +93 -92
  32. package/lib/umd/jsonSchema.d.ts +89 -70
  33. package/lib/umd/jsonSchema.js +12 -12
  34. package/lib/umd/parser/jsonParser.js +1243 -1237
  35. package/lib/umd/services/configuration.js +541 -541
  36. package/lib/umd/services/jsonCompletion.js +932 -947
  37. package/lib/umd/services/jsonDocumentSymbols.js +281 -291
  38. package/lib/umd/services/jsonFolding.js +134 -135
  39. package/lib/umd/services/jsonHover.js +123 -125
  40. package/lib/umd/services/jsonLinks.js +86 -87
  41. package/lib/umd/services/jsonSchemaService.js +602 -618
  42. package/lib/umd/services/jsonSelectionRanges.js +75 -75
  43. package/lib/umd/services/jsonValidation.js +165 -162
  44. package/lib/umd/utils/colors.js +84 -85
  45. package/lib/umd/utils/glob.js +138 -138
  46. package/lib/umd/utils/json.js +56 -56
  47. package/lib/umd/utils/objects.js +87 -83
  48. package/lib/umd/utils/strings.js +82 -82
  49. package/package.json +10 -10
@@ -1,75 +1,75 @@
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", "jsonc-parser"], factory);
12
- }
13
- })(function (require, exports) {
14
- "use strict";
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.getSelectionRanges = void 0;
17
- var jsonLanguageTypes_1 = require("../jsonLanguageTypes");
18
- var jsonc_parser_1 = require("jsonc-parser");
19
- function getSelectionRanges(document, positions, doc) {
20
- function getSelectionRange(position) {
21
- var offset = document.offsetAt(position);
22
- var node = doc.getNodeFromOffset(offset, true);
23
- var result = [];
24
- while (node) {
25
- switch (node.type) {
26
- case 'string':
27
- case 'object':
28
- case 'array':
29
- // range without ", [ or {
30
- var cStart = node.offset + 1, cEnd = node.offset + node.length - 1;
31
- if (cStart < cEnd && offset >= cStart && offset <= cEnd) {
32
- result.push(newRange(cStart, cEnd));
33
- }
34
- result.push(newRange(node.offset, node.offset + node.length));
35
- break;
36
- case 'number':
37
- case 'boolean':
38
- case 'null':
39
- case 'property':
40
- result.push(newRange(node.offset, node.offset + node.length));
41
- break;
42
- }
43
- if (node.type === 'property' || node.parent && node.parent.type === 'array') {
44
- var afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* CommaToken */);
45
- if (afterCommaOffset !== -1) {
46
- result.push(newRange(node.offset, afterCommaOffset));
47
- }
48
- }
49
- node = node.parent;
50
- }
51
- var current = undefined;
52
- for (var index = result.length - 1; index >= 0; index--) {
53
- current = jsonLanguageTypes_1.SelectionRange.create(result[index], current);
54
- }
55
- if (!current) {
56
- current = jsonLanguageTypes_1.SelectionRange.create(jsonLanguageTypes_1.Range.create(position, position));
57
- }
58
- return current;
59
- }
60
- function newRange(start, end) {
61
- return jsonLanguageTypes_1.Range.create(document.positionAt(start), document.positionAt(end));
62
- }
63
- var scanner = (0, jsonc_parser_1.createScanner)(document.getText(), true);
64
- function getOffsetAfterNextToken(offset, expectedToken) {
65
- scanner.setPosition(offset);
66
- var token = scanner.scan();
67
- if (token === expectedToken) {
68
- return scanner.getTokenOffset() + scanner.getTokenLength();
69
- }
70
- return -1;
71
- }
72
- return positions.map(getSelectionRange);
73
- }
74
- exports.getSelectionRanges = getSelectionRanges;
75
- });
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", "jsonc-parser"], factory);
12
+ }
13
+ })(function (require, exports) {
14
+ "use strict";
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getSelectionRanges = void 0;
17
+ const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
18
+ const jsonc_parser_1 = require("jsonc-parser");
19
+ function getSelectionRanges(document, positions, doc) {
20
+ function getSelectionRange(position) {
21
+ let offset = document.offsetAt(position);
22
+ let node = doc.getNodeFromOffset(offset, true);
23
+ const result = [];
24
+ while (node) {
25
+ switch (node.type) {
26
+ case 'string':
27
+ case 'object':
28
+ case 'array':
29
+ // range without ", [ or {
30
+ const cStart = node.offset + 1, cEnd = node.offset + node.length - 1;
31
+ if (cStart < cEnd && offset >= cStart && offset <= cEnd) {
32
+ result.push(newRange(cStart, cEnd));
33
+ }
34
+ result.push(newRange(node.offset, node.offset + node.length));
35
+ break;
36
+ case 'number':
37
+ case 'boolean':
38
+ case 'null':
39
+ case 'property':
40
+ result.push(newRange(node.offset, node.offset + node.length));
41
+ break;
42
+ }
43
+ if (node.type === 'property' || node.parent && node.parent.type === 'array') {
44
+ const afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* CommaToken */);
45
+ if (afterCommaOffset !== -1) {
46
+ result.push(newRange(node.offset, afterCommaOffset));
47
+ }
48
+ }
49
+ node = node.parent;
50
+ }
51
+ let current = undefined;
52
+ for (let index = result.length - 1; index >= 0; index--) {
53
+ current = jsonLanguageTypes_1.SelectionRange.create(result[index], current);
54
+ }
55
+ if (!current) {
56
+ current = jsonLanguageTypes_1.SelectionRange.create(jsonLanguageTypes_1.Range.create(position, position));
57
+ }
58
+ return current;
59
+ }
60
+ function newRange(start, end) {
61
+ return jsonLanguageTypes_1.Range.create(document.positionAt(start), document.positionAt(end));
62
+ }
63
+ const scanner = (0, jsonc_parser_1.createScanner)(document.getText(), true);
64
+ function getOffsetAfterNextToken(offset, expectedToken) {
65
+ scanner.setPosition(offset);
66
+ let token = scanner.scan();
67
+ if (token === expectedToken) {
68
+ return scanner.getTokenOffset() + scanner.getTokenLength();
69
+ }
70
+ return -1;
71
+ }
72
+ return positions.map(getSelectionRange);
73
+ }
74
+ exports.getSelectionRanges = getSelectionRanges;
75
+ });
@@ -1,162 +1,165 @@
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", "vscode-nls", "../utils/objects"], factory);
12
- }
13
- })(function (require, exports) {
14
- "use strict";
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.JSONValidation = void 0;
17
- var jsonLanguageTypes_1 = require("../jsonLanguageTypes");
18
- var nls = require("vscode-nls");
19
- var objects_1 = require("../utils/objects");
20
- var localize = nls.loadMessageBundle();
21
- var JSONValidation = /** @class */ (function () {
22
- function JSONValidation(jsonSchemaService, promiseConstructor) {
23
- this.jsonSchemaService = jsonSchemaService;
24
- this.promise = promiseConstructor;
25
- this.validationEnabled = true;
26
- }
27
- JSONValidation.prototype.configure = function (raw) {
28
- if (raw) {
29
- this.validationEnabled = raw.validate !== false;
30
- this.commentSeverity = raw.allowComments ? undefined : jsonLanguageTypes_1.DiagnosticSeverity.Error;
31
- }
32
- };
33
- JSONValidation.prototype.doValidation = function (textDocument, jsonDocument, documentSettings, schema) {
34
- var _this = this;
35
- if (!this.validationEnabled) {
36
- return this.promise.resolve([]);
37
- }
38
- var diagnostics = [];
39
- var added = {};
40
- var addProblem = function (problem) {
41
- // remove duplicated messages
42
- var signature = problem.range.start.line + ' ' + problem.range.start.character + ' ' + problem.message;
43
- if (!added[signature]) {
44
- added[signature] = true;
45
- diagnostics.push(problem);
46
- }
47
- };
48
- var getDiagnostics = function (schema) {
49
- var trailingCommaSeverity = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.trailingCommas) ? toDiagnosticSeverity(documentSettings.trailingCommas) : jsonLanguageTypes_1.DiagnosticSeverity.Error;
50
- var commentSeverity = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.comments) ? toDiagnosticSeverity(documentSettings.comments) : _this.commentSeverity;
51
- var schemaValidation = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.schemaValidation) ? toDiagnosticSeverity(documentSettings.schemaValidation) : jsonLanguageTypes_1.DiagnosticSeverity.Warning;
52
- var schemaRequest = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.schemaRequest) ? toDiagnosticSeverity(documentSettings.schemaRequest) : jsonLanguageTypes_1.DiagnosticSeverity.Warning;
53
- if (schema) {
54
- if (schema.errors.length && jsonDocument.root && schemaRequest) {
55
- var astRoot = jsonDocument.root;
56
- var property = astRoot.type === 'object' ? astRoot.properties[0] : undefined;
57
- if (property && property.keyNode.value === '$schema') {
58
- var node = property.valueNode || property;
59
- var range = jsonLanguageTypes_1.Range.create(textDocument.positionAt(node.offset), textDocument.positionAt(node.offset + node.length));
60
- addProblem(jsonLanguageTypes_1.Diagnostic.create(range, schema.errors[0], schemaRequest, jsonLanguageTypes_1.ErrorCode.SchemaResolveError));
61
- }
62
- else {
63
- var range = jsonLanguageTypes_1.Range.create(textDocument.positionAt(astRoot.offset), textDocument.positionAt(astRoot.offset + 1));
64
- addProblem(jsonLanguageTypes_1.Diagnostic.create(range, schema.errors[0], schemaRequest, jsonLanguageTypes_1.ErrorCode.SchemaResolveError));
65
- }
66
- }
67
- else if (schemaValidation) {
68
- var semanticErrors = jsonDocument.validate(textDocument, schema.schema, schemaValidation);
69
- if (semanticErrors) {
70
- semanticErrors.forEach(addProblem);
71
- }
72
- }
73
- if (schemaAllowsComments(schema.schema)) {
74
- commentSeverity = undefined;
75
- }
76
- if (schemaAllowsTrailingCommas(schema.schema)) {
77
- trailingCommaSeverity = undefined;
78
- }
79
- }
80
- for (var _i = 0, _a = jsonDocument.syntaxErrors; _i < _a.length; _i++) {
81
- var p = _a[_i];
82
- if (p.code === jsonLanguageTypes_1.ErrorCode.TrailingComma) {
83
- if (typeof trailingCommaSeverity !== 'number') {
84
- continue;
85
- }
86
- p.severity = trailingCommaSeverity;
87
- }
88
- addProblem(p);
89
- }
90
- if (typeof commentSeverity === 'number') {
91
- var message_1 = localize('InvalidCommentToken', 'Comments are not permitted in JSON.');
92
- jsonDocument.comments.forEach(function (c) {
93
- addProblem(jsonLanguageTypes_1.Diagnostic.create(c, message_1, commentSeverity, jsonLanguageTypes_1.ErrorCode.CommentNotPermitted));
94
- });
95
- }
96
- return diagnostics;
97
- };
98
- if (schema) {
99
- var id = schema.id || ('schemaservice://untitled/' + idCounter++);
100
- var handle = this.jsonSchemaService.registerExternalSchema(id, [], schema);
101
- return handle.getResolvedSchema().then(function (resolvedSchema) {
102
- return getDiagnostics(resolvedSchema);
103
- });
104
- }
105
- return this.jsonSchemaService.getSchemaForResource(textDocument.uri, jsonDocument).then(function (schema) {
106
- return getDiagnostics(schema);
107
- });
108
- };
109
- JSONValidation.prototype.getLanguageStatus = function (textDocument, jsonDocument) {
110
- return { schemas: this.jsonSchemaService.getSchemaURIsForResource(textDocument.uri, jsonDocument) };
111
- };
112
- return JSONValidation;
113
- }());
114
- exports.JSONValidation = JSONValidation;
115
- var idCounter = 0;
116
- function schemaAllowsComments(schemaRef) {
117
- if (schemaRef && typeof schemaRef === 'object') {
118
- if ((0, objects_1.isBoolean)(schemaRef.allowComments)) {
119
- return schemaRef.allowComments;
120
- }
121
- if (schemaRef.allOf) {
122
- for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
123
- var schema = _a[_i];
124
- var allow = schemaAllowsComments(schema);
125
- if ((0, objects_1.isBoolean)(allow)) {
126
- return allow;
127
- }
128
- }
129
- }
130
- }
131
- return undefined;
132
- }
133
- function schemaAllowsTrailingCommas(schemaRef) {
134
- if (schemaRef && typeof schemaRef === 'object') {
135
- if ((0, objects_1.isBoolean)(schemaRef.allowTrailingCommas)) {
136
- return schemaRef.allowTrailingCommas;
137
- }
138
- var deprSchemaRef = schemaRef;
139
- if ((0, objects_1.isBoolean)(deprSchemaRef['allowsTrailingCommas'])) { // deprecated
140
- return deprSchemaRef['allowsTrailingCommas'];
141
- }
142
- if (schemaRef.allOf) {
143
- for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
144
- var schema = _a[_i];
145
- var allow = schemaAllowsTrailingCommas(schema);
146
- if ((0, objects_1.isBoolean)(allow)) {
147
- return allow;
148
- }
149
- }
150
- }
151
- }
152
- return undefined;
153
- }
154
- function toDiagnosticSeverity(severityLevel) {
155
- switch (severityLevel) {
156
- case 'error': return jsonLanguageTypes_1.DiagnosticSeverity.Error;
157
- case 'warning': return jsonLanguageTypes_1.DiagnosticSeverity.Warning;
158
- case 'ignore': return undefined;
159
- }
160
- return undefined;
161
- }
162
- });
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", "vscode-nls", "../utils/objects"], factory);
12
+ }
13
+ })(function (require, exports) {
14
+ "use strict";
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.JSONValidation = void 0;
17
+ const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
18
+ const nls = require("vscode-nls");
19
+ const objects_1 = require("../utils/objects");
20
+ const localize = nls.loadMessageBundle();
21
+ class JSONValidation {
22
+ constructor(jsonSchemaService, promiseConstructor) {
23
+ this.jsonSchemaService = jsonSchemaService;
24
+ this.promise = promiseConstructor;
25
+ this.validationEnabled = true;
26
+ }
27
+ configure(raw) {
28
+ if (raw) {
29
+ this.validationEnabled = raw.validate !== false;
30
+ this.commentSeverity = raw.allowComments ? undefined : jsonLanguageTypes_1.DiagnosticSeverity.Error;
31
+ }
32
+ }
33
+ doValidation(textDocument, jsonDocument, documentSettings, schema) {
34
+ if (!this.validationEnabled) {
35
+ return this.promise.resolve([]);
36
+ }
37
+ const diagnostics = [];
38
+ const added = {};
39
+ const addProblem = (problem) => {
40
+ // remove duplicated messages
41
+ const signature = problem.range.start.line + ' ' + problem.range.start.character + ' ' + problem.message;
42
+ if (!added[signature]) {
43
+ added[signature] = true;
44
+ diagnostics.push(problem);
45
+ }
46
+ };
47
+ const getDiagnostics = (schema) => {
48
+ let trailingCommaSeverity = documentSettings?.trailingCommas ? toDiagnosticSeverity(documentSettings.trailingCommas) : jsonLanguageTypes_1.DiagnosticSeverity.Error;
49
+ let commentSeverity = documentSettings?.comments ? toDiagnosticSeverity(documentSettings.comments) : this.commentSeverity;
50
+ let schemaValidation = documentSettings?.schemaValidation ? toDiagnosticSeverity(documentSettings.schemaValidation) : jsonLanguageTypes_1.DiagnosticSeverity.Warning;
51
+ let schemaRequest = documentSettings?.schemaRequest ? toDiagnosticSeverity(documentSettings.schemaRequest) : jsonLanguageTypes_1.DiagnosticSeverity.Warning;
52
+ if (schema) {
53
+ const addSchemaProblem = (errorMessage, errorCode) => {
54
+ if (jsonDocument.root && schemaRequest) {
55
+ const astRoot = jsonDocument.root;
56
+ const property = astRoot.type === 'object' ? astRoot.properties[0] : undefined;
57
+ if (property && property.keyNode.value === '$schema') {
58
+ const node = property.valueNode || property;
59
+ const range = jsonLanguageTypes_1.Range.create(textDocument.positionAt(node.offset), textDocument.positionAt(node.offset + node.length));
60
+ addProblem(jsonLanguageTypes_1.Diagnostic.create(range, errorMessage, schemaRequest, errorCode));
61
+ }
62
+ else {
63
+ const range = jsonLanguageTypes_1.Range.create(textDocument.positionAt(astRoot.offset), textDocument.positionAt(astRoot.offset + 1));
64
+ addProblem(jsonLanguageTypes_1.Diagnostic.create(range, errorMessage, schemaRequest, errorCode));
65
+ }
66
+ }
67
+ };
68
+ if (schema.errors.length) {
69
+ addSchemaProblem(schema.errors[0], jsonLanguageTypes_1.ErrorCode.SchemaResolveError);
70
+ }
71
+ else if (schemaValidation) {
72
+ for (const warning of schema.warnings) {
73
+ addSchemaProblem(warning, jsonLanguageTypes_1.ErrorCode.SchemaUnsupportedFeature);
74
+ }
75
+ const semanticErrors = jsonDocument.validate(textDocument, schema.schema, schemaValidation);
76
+ if (semanticErrors) {
77
+ semanticErrors.forEach(addProblem);
78
+ }
79
+ }
80
+ if (schemaAllowsComments(schema.schema)) {
81
+ commentSeverity = undefined;
82
+ }
83
+ if (schemaAllowsTrailingCommas(schema.schema)) {
84
+ trailingCommaSeverity = undefined;
85
+ }
86
+ }
87
+ for (const p of jsonDocument.syntaxErrors) {
88
+ if (p.code === jsonLanguageTypes_1.ErrorCode.TrailingComma) {
89
+ if (typeof trailingCommaSeverity !== 'number') {
90
+ continue;
91
+ }
92
+ p.severity = trailingCommaSeverity;
93
+ }
94
+ addProblem(p);
95
+ }
96
+ if (typeof commentSeverity === 'number') {
97
+ const message = localize('InvalidCommentToken', 'Comments are not permitted in JSON.');
98
+ jsonDocument.comments.forEach(c => {
99
+ addProblem(jsonLanguageTypes_1.Diagnostic.create(c, message, commentSeverity, jsonLanguageTypes_1.ErrorCode.CommentNotPermitted));
100
+ });
101
+ }
102
+ return diagnostics;
103
+ };
104
+ if (schema) {
105
+ const id = schema.id || ('schemaservice://untitled/' + idCounter++);
106
+ const handle = this.jsonSchemaService.registerExternalSchema(id, [], schema);
107
+ return handle.getResolvedSchema().then(resolvedSchema => {
108
+ return getDiagnostics(resolvedSchema);
109
+ });
110
+ }
111
+ return this.jsonSchemaService.getSchemaForResource(textDocument.uri, jsonDocument).then(schema => {
112
+ return getDiagnostics(schema);
113
+ });
114
+ }
115
+ getLanguageStatus(textDocument, jsonDocument) {
116
+ return { schemas: this.jsonSchemaService.getSchemaURIsForResource(textDocument.uri, jsonDocument) };
117
+ }
118
+ }
119
+ exports.JSONValidation = JSONValidation;
120
+ let idCounter = 0;
121
+ function schemaAllowsComments(schemaRef) {
122
+ if (schemaRef && typeof schemaRef === 'object') {
123
+ if ((0, objects_1.isBoolean)(schemaRef.allowComments)) {
124
+ return schemaRef.allowComments;
125
+ }
126
+ if (schemaRef.allOf) {
127
+ for (const schema of schemaRef.allOf) {
128
+ const allow = schemaAllowsComments(schema);
129
+ if ((0, objects_1.isBoolean)(allow)) {
130
+ return allow;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ return undefined;
136
+ }
137
+ function schemaAllowsTrailingCommas(schemaRef) {
138
+ if (schemaRef && typeof schemaRef === 'object') {
139
+ if ((0, objects_1.isBoolean)(schemaRef.allowTrailingCommas)) {
140
+ return schemaRef.allowTrailingCommas;
141
+ }
142
+ const deprSchemaRef = schemaRef;
143
+ if ((0, objects_1.isBoolean)(deprSchemaRef['allowsTrailingCommas'])) { // deprecated
144
+ return deprSchemaRef['allowsTrailingCommas'];
145
+ }
146
+ if (schemaRef.allOf) {
147
+ for (const schema of schemaRef.allOf) {
148
+ const allow = schemaAllowsTrailingCommas(schema);
149
+ if ((0, objects_1.isBoolean)(allow)) {
150
+ return allow;
151
+ }
152
+ }
153
+ }
154
+ }
155
+ return undefined;
156
+ }
157
+ function toDiagnosticSeverity(severityLevel) {
158
+ switch (severityLevel) {
159
+ case 'error': return jsonLanguageTypes_1.DiagnosticSeverity.Error;
160
+ case 'warning': return jsonLanguageTypes_1.DiagnosticSeverity.Warning;
161
+ case 'ignore': return undefined;
162
+ }
163
+ return undefined;
164
+ }
165
+ });