monaco-json
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "monaco-json", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "JSON plugin for the Monaco Editor", | ||
@@ -29,5 +29,5 @@ "scripts": { | ||
"uglify-js": "^3.3.14", | ||
"vscode-json-languageservice": "3.0.12", | ||
"vscode-json-languageservice": "3.1.0", | ||
"vscode-languageserver-types": "3.6.1" | ||
} | ||
} |
@@ -10,2 +10,3 @@ # Monaco JSON | ||
* Syntax highlighting | ||
* Color decorators for all properties matching a schema containing `format: "color-hex"'` (non-standard schema extension) | ||
@@ -16,3 +17,3 @@ Schemas can be provided by configuration. See [here](https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts) | ||
Internally the JSON plugin uses the [vscode-json-languageservice](https://github.com/Microsoft/vscode-json-languageservice) | ||
node module, providing the implementation of the functionally listed above. The same module is also used | ||
node module, providing the implementation of the features listed above. The same module is also used | ||
in [Visual Studio Code](https://github.com/Microsoft/vscode) to power the JSON editing experience. | ||
@@ -22,3 +23,3 @@ | ||
Please file issues concering `monaco-json` in the [`monaco-editor` repository](https://github.com/Microsoft/monaco-editor/issues). | ||
Please file issues concerning `monaco-json` in the [`monaco-editor` repository](https://github.com/Microsoft/monaco-editor/issues). | ||
@@ -34,3 +35,3 @@ ## Installing | ||
* `npm install .` | ||
* `npm run watch` | ||
* `npm run prepublish` | ||
* open `$/monaco-json/test/index.html` in your favorite browser. | ||
@@ -37,0 +38,0 @@ |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { JSONDocumentSymbols } from './services/jsonDocumentSymbols'; | ||
import { parse as parseJSON } from './parser/jsonParser'; | ||
import { parse as parseJSON, newJSONDocument } from './parser/jsonParser'; | ||
import { schemaContributions } from './services/configuration'; | ||
@@ -38,2 +38,3 @@ import { JSONSchemaService } from './services/jsonSchemaService'; | ||
parseJSONDocument: function (document) { return parseJSON(document, { collectComments: true }); }, | ||
newJSONDocument: function (root, diagnostics) { return newJSONDocument(root, diagnostics); }, | ||
doResolve: jsonCompletion.doResolve.bind(jsonCompletion), | ||
@@ -40,0 +41,0 @@ doComplete: jsonCompletion.doComplete.bind(jsonCompletion), |
@@ -20,2 +20,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import Uri from '../../vscode-uri/index'; | ||
import { DiagnosticSeverity } from '../../vscode-languageserver-types/main'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -48,42 +49,295 @@ export var ErrorCode; | ||
})(ProblemSeverity || (ProblemSeverity = {})); | ||
var ASTNode = /** @class */ (function () { | ||
function ASTNode(parent, type, location, start, end) { | ||
this.type = type; | ||
this.location = location; | ||
this.start = start; | ||
this.end = end; | ||
var ASTNodeImpl = /** @class */ (function () { | ||
function ASTNodeImpl(parent, offset, length) { | ||
this.offset = offset; | ||
this.length = length; | ||
this.parent = parent; | ||
} | ||
ASTNode.prototype.getPath = function () { | ||
var path = this.parent ? this.parent.getPath() : []; | ||
if (this.location !== null) { | ||
path.push(this.location); | ||
} | ||
return path; | ||
Object.defineProperty(ASTNodeImpl.prototype, "children", { | ||
get: function () { | ||
return []; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
ASTNodeImpl.prototype.toString = function () { | ||
return 'type: ' + this.type + ' (' + this.offset + '/' + this.length + ')' + (this.parent ? ' parent: {' + this.parent.toString() + '}' : ''); | ||
}; | ||
ASTNode.prototype.getChildNodes = function () { | ||
return []; | ||
return ASTNodeImpl; | ||
}()); | ||
export { ASTNodeImpl }; | ||
var NullASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(NullASTNodeImpl, _super); | ||
function NullASTNodeImpl(parent, offset) { | ||
var _this = _super.call(this, parent, offset) || this; | ||
_this.type = 'null'; | ||
return _this; | ||
} | ||
return NullASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { NullASTNodeImpl }; | ||
var BooleanASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(BooleanASTNodeImpl, _super); | ||
function BooleanASTNodeImpl(parent, boolValue, offset) { | ||
var _this = _super.call(this, parent, offset) || this; | ||
_this.type = 'boolean'; | ||
_this.value = boolValue; | ||
return _this; | ||
} | ||
return BooleanASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { BooleanASTNodeImpl }; | ||
var ArrayASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(ArrayASTNodeImpl, _super); | ||
function ArrayASTNodeImpl(parent, offset) { | ||
var _this = _super.call(this, parent, offset) || this; | ||
_this.type = 'array'; | ||
_this.items = []; | ||
return _this; | ||
} | ||
Object.defineProperty(ArrayASTNodeImpl.prototype, "children", { | ||
get: function () { | ||
return this.items; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return ArrayASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { ArrayASTNodeImpl }; | ||
var NumberASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(NumberASTNodeImpl, _super); | ||
function NumberASTNodeImpl(parent, offset) { | ||
var _this = _super.call(this, parent, offset) || this; | ||
_this.type = 'number'; | ||
_this.isInteger = true; | ||
_this.value = Number.NaN; | ||
return _this; | ||
} | ||
return NumberASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { NumberASTNodeImpl }; | ||
var StringASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(StringASTNodeImpl, _super); | ||
function StringASTNodeImpl(parent, offset, length) { | ||
var _this = _super.call(this, parent, offset, length) || this; | ||
_this.type = 'string'; | ||
_this.value = ''; | ||
return _this; | ||
} | ||
return StringASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { StringASTNodeImpl }; | ||
var PropertyASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(PropertyASTNodeImpl, _super); | ||
function PropertyASTNodeImpl(parent, offset) { | ||
var _this = _super.call(this, parent, offset) || this; | ||
_this.type = 'property'; | ||
_this.colonOffset = -1; | ||
return _this; | ||
} | ||
Object.defineProperty(PropertyASTNodeImpl.prototype, "children", { | ||
get: function () { | ||
return this.valueNode ? [this.keyNode, this.valueNode] : [this.keyNode]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return PropertyASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { PropertyASTNodeImpl }; | ||
var ObjectASTNodeImpl = /** @class */ (function (_super) { | ||
__extends(ObjectASTNodeImpl, _super); | ||
function ObjectASTNodeImpl(parent, offset) { | ||
var _this = _super.call(this, parent, offset) || this; | ||
_this.type = 'object'; | ||
_this.properties = []; | ||
return _this; | ||
} | ||
Object.defineProperty(ObjectASTNodeImpl.prototype, "children", { | ||
get: function () { | ||
return this.properties; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return ObjectASTNodeImpl; | ||
}(ASTNodeImpl)); | ||
export { ObjectASTNodeImpl }; | ||
export function asSchema(schema) { | ||
if (typeof schema === 'boolean') { | ||
return schema ? {} : { "not": {} }; | ||
} | ||
return schema; | ||
} | ||
export var EnumMatch; | ||
(function (EnumMatch) { | ||
EnumMatch[EnumMatch["Key"] = 0] = "Key"; | ||
EnumMatch[EnumMatch["Enum"] = 1] = "Enum"; | ||
})(EnumMatch || (EnumMatch = {})); | ||
var SchemaCollector = /** @class */ (function () { | ||
function SchemaCollector(focusOffset, exclude) { | ||
if (focusOffset === void 0) { focusOffset = -1; } | ||
if (exclude === void 0) { exclude = null; } | ||
this.focusOffset = focusOffset; | ||
this.exclude = exclude; | ||
this.schemas = []; | ||
} | ||
SchemaCollector.prototype.add = function (schema) { | ||
this.schemas.push(schema); | ||
}; | ||
ASTNode.prototype.getLastChild = function () { | ||
return null; | ||
SchemaCollector.prototype.merge = function (other) { | ||
(_a = this.schemas).push.apply(_a, other.schemas); | ||
var _a; | ||
}; | ||
ASTNode.prototype.getValue = function () { | ||
// override in children | ||
return; | ||
SchemaCollector.prototype.include = function (node) { | ||
return (this.focusOffset === -1 || contains(node, this.focusOffset)) && (node !== this.exclude); | ||
}; | ||
ASTNode.prototype.contains = function (offset, includeRightBound) { | ||
if (includeRightBound === void 0) { includeRightBound = false; } | ||
return offset >= this.start && offset < this.end || includeRightBound && offset === this.end; | ||
SchemaCollector.prototype.newSub = function () { | ||
return new SchemaCollector(-1, this.exclude); | ||
}; | ||
ASTNode.prototype.toString = function () { | ||
return 'type: ' + this.type + ' (' + this.start + '/' + this.end + ')' + (this.parent ? ' parent: {' + this.parent.toString() + '}' : ''); | ||
return SchemaCollector; | ||
}()); | ||
var NoOpSchemaCollector = /** @class */ (function () { | ||
function NoOpSchemaCollector() { | ||
} | ||
Object.defineProperty(NoOpSchemaCollector.prototype, "schemas", { | ||
get: function () { return []; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
NoOpSchemaCollector.prototype.add = function (schema) { }; | ||
NoOpSchemaCollector.prototype.merge = function (other) { }; | ||
NoOpSchemaCollector.prototype.include = function (node) { return true; }; | ||
NoOpSchemaCollector.prototype.newSub = function () { return this; }; | ||
NoOpSchemaCollector.instance = new NoOpSchemaCollector(); | ||
return NoOpSchemaCollector; | ||
}()); | ||
var ValidationResult = /** @class */ (function () { | ||
function ValidationResult() { | ||
this.problems = []; | ||
this.propertiesMatches = 0; | ||
this.propertiesValueMatches = 0; | ||
this.primaryValueMatches = 0; | ||
this.enumValueMatch = false; | ||
this.enumValues = null; | ||
} | ||
ValidationResult.prototype.hasProblems = function () { | ||
return !!this.problems.length; | ||
}; | ||
ASTNode.prototype.visit = function (visitor) { | ||
return visitor(this); | ||
ValidationResult.prototype.mergeAll = function (validationResults) { | ||
var _this = this; | ||
validationResults.forEach(function (validationResult) { | ||
_this.merge(validationResult); | ||
}); | ||
}; | ||
ASTNode.prototype.getNodeFromOffset = function (offset) { | ||
ValidationResult.prototype.merge = function (validationResult) { | ||
this.problems = this.problems.concat(validationResult.problems); | ||
}; | ||
ValidationResult.prototype.mergeEnumValues = function (validationResult) { | ||
if (!this.enumValueMatch && !validationResult.enumValueMatch && this.enumValues && validationResult.enumValues) { | ||
this.enumValues = this.enumValues.concat(validationResult.enumValues); | ||
for (var _i = 0, _a = this.problems; _i < _a.length; _i++) { | ||
var error = _a[_i]; | ||
if (error.code === ErrorCode.EnumValueMismatch) { | ||
error.message = localize('enumWarning', 'Value is not accepted. Valid values: {0}.', this.enumValues.map(function (v) { return JSON.stringify(v); }).join(', ')); | ||
} | ||
} | ||
} | ||
}; | ||
ValidationResult.prototype.mergePropertyMatch = function (propertyValidationResult) { | ||
this.merge(propertyValidationResult); | ||
this.propertiesMatches++; | ||
if (propertyValidationResult.enumValueMatch || !propertyValidationResult.hasProblems() && propertyValidationResult.propertiesMatches) { | ||
this.propertiesValueMatches++; | ||
} | ||
if (propertyValidationResult.enumValueMatch && propertyValidationResult.enumValues && propertyValidationResult.enumValues.length === 1) { | ||
this.primaryValueMatches++; | ||
} | ||
}; | ||
ValidationResult.prototype.compare = function (other) { | ||
var hasProblems = this.hasProblems(); | ||
if (hasProblems !== other.hasProblems()) { | ||
return hasProblems ? -1 : 1; | ||
} | ||
if (this.enumValueMatch !== other.enumValueMatch) { | ||
return other.enumValueMatch ? -1 : 1; | ||
} | ||
if (this.primaryValueMatches !== other.primaryValueMatches) { | ||
return this.primaryValueMatches - other.primaryValueMatches; | ||
} | ||
if (this.propertiesValueMatches !== other.propertiesValueMatches) { | ||
return this.propertiesValueMatches - other.propertiesValueMatches; | ||
} | ||
return this.propertiesMatches - other.propertiesMatches; | ||
}; | ||
return ValidationResult; | ||
}()); | ||
export { ValidationResult }; | ||
function toProblemSeverity(diagnosticsSeverity) { | ||
switch (diagnosticsSeverity) { | ||
case DiagnosticSeverity.Error: return ProblemSeverity.Error; | ||
case DiagnosticSeverity.Warning: return ProblemSeverity.Warning; | ||
case DiagnosticSeverity.Information: return ProblemSeverity.Warning; | ||
} | ||
return ProblemSeverity.Ignore; | ||
} | ||
export function newJSONDocument(root, diagnostics) { | ||
if (diagnostics === void 0) { diagnostics = []; } | ||
return new JSONDocument(root, [], [], diagnostics); | ||
} | ||
export function getNodeValue(node) { | ||
switch (node.type) { | ||
case 'array': | ||
return node.items.map(getNodeValue); | ||
case 'object': | ||
var obj = Object.create(null); | ||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { | ||
var prop = _a[_i]; | ||
obj[prop.keyNode.value] = getNodeValue(prop.valueNode); | ||
} | ||
return obj; | ||
case 'string': | ||
case 'number': | ||
case 'boolean': | ||
return node.value; | ||
} | ||
return null; | ||
} | ||
export function getNodePath(node) { | ||
if (!node.parent) { | ||
return []; | ||
} | ||
var path = getNodePath(node.parent); | ||
if (node.parent.type === 'property') { | ||
var key = node.parent.keyNode.value; | ||
path.push(key); | ||
} | ||
else if (node.parent.type === 'array') { | ||
var index = node.parent.items.indexOf(node); | ||
if (index !== -1) { | ||
path.push(index); | ||
} | ||
} | ||
return path; | ||
} | ||
export function contains(node, offset, includeRightBound) { | ||
if (includeRightBound === void 0) { includeRightBound = false; } | ||
return offset >= node.offset && offset < (node.offset + node.length) || includeRightBound && offset === (node.offset + node.length); | ||
} | ||
var JSONDocument = /** @class */ (function () { | ||
function JSONDocument(root, syntaxErrors, comments, externalDiagnostic) { | ||
if (syntaxErrors === void 0) { syntaxErrors = []; } | ||
if (comments === void 0) { comments = []; } | ||
if (externalDiagnostic === void 0) { externalDiagnostic = []; } | ||
this.root = root; | ||
this.syntaxErrors = syntaxErrors; | ||
this.comments = comments; | ||
this.externalDiagnostic = externalDiagnostic; | ||
} | ||
JSONDocument.prototype.getNodeFromOffset = function (offset) { | ||
var findNode = function (node) { | ||
if (offset >= node.start && offset < node.end) { | ||
var children = node.getChildNodes(); | ||
for (var i = 0; i < children.length && children[i].start <= offset; i++) { | ||
if (offset >= node.offset && offset < (node.offset + node.length)) { | ||
var children = node.children; | ||
for (var i = 0; i < children.length && children[i].offset <= offset; i++) { | ||
var item = findNode(children[i]); | ||
@@ -98,9 +352,9 @@ if (item) { | ||
}; | ||
return findNode(this); | ||
return this.root && findNode(this.root); | ||
}; | ||
ASTNode.prototype.getNodeFromOffsetEndInclusive = function (offset) { | ||
JSONDocument.prototype.getNodeFromOffsetEndInclusive = function (offset) { | ||
var findNode = function (node) { | ||
if (offset >= node.start && offset <= node.end) { | ||
var children = node.getChildNodes(); | ||
for (var i = 0; i < children.length && children[i].start <= offset; i++) { | ||
if (offset >= node.offset && offset <= (node.offset + node.length)) { | ||
var children = node.children; | ||
for (var i = 0; i < children.length && children[i].offset <= offset; i++) { | ||
var item = findNode(children[i]); | ||
@@ -115,13 +369,67 @@ if (item) { | ||
}; | ||
return findNode(this); | ||
return this.root && findNode(this.root); | ||
}; | ||
ASTNode.prototype.validate = function (schema, validationResult, matchingSchemas) { | ||
var _this = this; | ||
if (!matchingSchemas.include(this)) { | ||
return; | ||
JSONDocument.prototype.visit = function (visitor) { | ||
if (this.root) { | ||
var doVisit_1 = function (node) { | ||
var ctn = visitor(node); | ||
var children = node.children; | ||
for (var i = 0; i < children.length && ctn; i++) { | ||
ctn = doVisit_1(children[i]); | ||
} | ||
return ctn; | ||
}; | ||
doVisit_1(this.root); | ||
} | ||
}; | ||
JSONDocument.prototype.validate = function (schema) { | ||
if (this.root && schema) { | ||
var validationResult = new ValidationResult(); | ||
validate(this.root, schema, validationResult, NoOpSchemaCollector.instance); | ||
return validationResult.problems; | ||
} | ||
return null; | ||
}; | ||
JSONDocument.prototype.getMatchingSchemas = function (schema, focusOffset, exclude) { | ||
if (focusOffset === void 0) { focusOffset = -1; } | ||
if (exclude === void 0) { exclude = null; } | ||
var matchingSchemas = new SchemaCollector(focusOffset, exclude); | ||
if (this.root && schema) { | ||
validate(this.root, schema, new ValidationResult(), matchingSchemas); | ||
} | ||
return matchingSchemas.schemas; | ||
}; | ||
return JSONDocument; | ||
}()); | ||
export { JSONDocument }; | ||
function validate(node, schema, validationResult, matchingSchemas) { | ||
if (!node || !matchingSchemas.include(node)) { | ||
return; | ||
} | ||
switch (node.type) { | ||
case 'object': | ||
_validateObjectNode(node, schema, validationResult, matchingSchemas); | ||
break; | ||
case 'array': | ||
_validateArrayNode(node, schema, validationResult, matchingSchemas); | ||
break; | ||
case 'string': | ||
_validateStringNode(node, schema, validationResult, matchingSchemas); | ||
break; | ||
case 'number': | ||
_validateNumberNode(node, schema, validationResult, matchingSchemas); | ||
break; | ||
case 'property': | ||
return validate(node.valueNode, schema, validationResult, matchingSchemas); | ||
} | ||
_validateNode(); | ||
matchingSchemas.add({ node: node, schema: schema }); | ||
function _validateNode() { | ||
function matchesType(type) { | ||
return node.type === type || (type === 'integer' && node.type === 'number' && node.isInteger); | ||
} | ||
if (Array.isArray(schema.type)) { | ||
if (schema.type.indexOf(this.type) === -1) { | ||
if (!schema.type.some(matchesType)) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -133,5 +441,5 @@ message: schema.errorMessage || localize('typeArrayMismatchWarning', 'Incorrect type. Expected one of {0}.', schema.type.join(', ')) | ||
else if (schema.type) { | ||
if (this.type !== schema.type) { | ||
if (!matchesType(schema.type)) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -144,3 +452,3 @@ message: schema.errorMessage || localize('typeMismatchWarning', 'Incorrect type. Expected "{0}".', schema.type) | ||
schema.allOf.forEach(function (subSchemaRef) { | ||
_this.validate(asSchema(subSchemaRef), validationResult, matchingSchemas); | ||
validate(node, asSchema(subSchemaRef), validationResult, matchingSchemas); | ||
}); | ||
@@ -152,6 +460,6 @@ } | ||
var subMatchingSchemas = matchingSchemas.newSub(); | ||
this.validate(notSchema, subValidationResult, subMatchingSchemas); | ||
validate(node, notSchema, subValidationResult, subMatchingSchemas); | ||
if (!subValidationResult.hasProblems()) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -174,3 +482,3 @@ message: localize('notSchemaWarning', "Matches a schema that is not allowed.") | ||
var subMatchingSchemas = matchingSchemas.newSub(); | ||
_this.validate(subSchema, subValidationResult, subMatchingSchemas); | ||
validate(node, subSchema, subValidationResult, subMatchingSchemas); | ||
if (!subValidationResult.hasProblems()) { | ||
@@ -205,3 +513,3 @@ matches.push(subSchema); | ||
validationResult.problems.push({ | ||
location: { start: _this.start, end: _this.start + 1 }, | ||
location: { offset: node.offset, length: 1 }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -226,3 +534,3 @@ message: localize('oneOfWarning', "Matches multiple schemas when only one must validate.") | ||
if (Array.isArray(schema.enum)) { | ||
var val = this.getValue(); | ||
var val = getNodeValue(node); | ||
var enumValueMatch = false; | ||
@@ -240,3 +548,3 @@ for (var _i = 0, _a = schema.enum; _i < _a.length; _i++) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -249,6 +557,6 @@ code: ErrorCode.EnumValueMismatch, | ||
if (schema.const) { | ||
var val = this.getValue(); | ||
var val = getNodeValue(node); | ||
if (!objects.equals(val, schema.const)) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -265,5 +573,5 @@ code: ErrorCode.EnumValueMismatch, | ||
} | ||
if (schema.deprecationMessage && this.parent) { | ||
if (schema.deprecationMessage && node.parent) { | ||
validationResult.problems.push({ | ||
location: { start: this.parent.start, end: this.parent.end }, | ||
location: { offset: node.parent.offset, length: node.parent.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -273,186 +581,9 @@ message: schema.deprecationMessage | ||
} | ||
matchingSchemas.add({ node: this, schema: schema }); | ||
}; | ||
return ASTNode; | ||
}()); | ||
export { ASTNode }; | ||
var NullASTNode = /** @class */ (function (_super) { | ||
__extends(NullASTNode, _super); | ||
function NullASTNode(parent, name, start, end) { | ||
return _super.call(this, parent, 'null', name, start, end) || this; | ||
} | ||
NullASTNode.prototype.getValue = function () { | ||
return null; | ||
}; | ||
return NullASTNode; | ||
}(ASTNode)); | ||
export { NullASTNode }; | ||
var BooleanASTNode = /** @class */ (function (_super) { | ||
__extends(BooleanASTNode, _super); | ||
function BooleanASTNode(parent, name, value, start, end) { | ||
var _this = _super.call(this, parent, 'boolean', name, start, end) || this; | ||
_this.value = value; | ||
return _this; | ||
} | ||
BooleanASTNode.prototype.getValue = function () { | ||
return this.value; | ||
}; | ||
return BooleanASTNode; | ||
}(ASTNode)); | ||
export { BooleanASTNode }; | ||
var ArrayASTNode = /** @class */ (function (_super) { | ||
__extends(ArrayASTNode, _super); | ||
function ArrayASTNode(parent, name, start, end) { | ||
var _this = _super.call(this, parent, 'array', name, start, end) || this; | ||
_this.items = []; | ||
return _this; | ||
} | ||
ArrayASTNode.prototype.getChildNodes = function () { | ||
return this.items; | ||
}; | ||
ArrayASTNode.prototype.getLastChild = function () { | ||
return this.items[this.items.length - 1]; | ||
}; | ||
ArrayASTNode.prototype.getValue = function () { | ||
return this.items.map(function (v) { return v.getValue(); }); | ||
}; | ||
ArrayASTNode.prototype.addItem = function (item) { | ||
if (item) { | ||
this.items.push(item); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
ArrayASTNode.prototype.visit = function (visitor) { | ||
var ctn = visitor(this); | ||
for (var i = 0; i < this.items.length && ctn; i++) { | ||
ctn = this.items[i].visit(visitor); | ||
} | ||
return ctn; | ||
}; | ||
ArrayASTNode.prototype.validate = function (schema, validationResult, matchingSchemas) { | ||
var _this = this; | ||
if (!matchingSchemas.include(this)) { | ||
return; | ||
} | ||
_super.prototype.validate.call(this, schema, validationResult, matchingSchemas); | ||
if (Array.isArray(schema.items)) { | ||
var subSchemas_1 = schema.items; | ||
subSchemas_1.forEach(function (subSchemaRef, index) { | ||
var subSchema = asSchema(subSchemaRef); | ||
var itemValidationResult = new ValidationResult(); | ||
var item = _this.items[index]; | ||
if (item) { | ||
item.validate(subSchema, itemValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(itemValidationResult); | ||
} | ||
else if (_this.items.length >= subSchemas_1.length) { | ||
validationResult.propertiesValueMatches++; | ||
} | ||
}); | ||
if (this.items.length > subSchemas_1.length) { | ||
if (typeof schema.additionalItems === 'object') { | ||
for (var i = subSchemas_1.length; i < this.items.length; i++) { | ||
var itemValidationResult = new ValidationResult(); | ||
this.items[i].validate(schema.additionalItems, itemValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(itemValidationResult); | ||
} | ||
} | ||
else if (schema.additionalItems === false) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('additionalItemsWarning', 'Array has too many items according to schema. Expected {0} or fewer.', subSchemas_1.length) | ||
}); | ||
} | ||
} | ||
} | ||
else { | ||
var itemSchema_1 = asSchema(schema.items); | ||
if (itemSchema_1) { | ||
this.items.forEach(function (item) { | ||
var itemValidationResult = new ValidationResult(); | ||
item.validate(itemSchema_1, itemValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(itemValidationResult); | ||
}); | ||
} | ||
} | ||
var containsSchema = asSchema(schema.contains); | ||
if (containsSchema) { | ||
var doesContain = this.items.some(function (item) { | ||
var itemValidationResult = new ValidationResult(); | ||
item.validate(containsSchema, itemValidationResult, NoOpSchemaCollector.instance); | ||
return !itemValidationResult.hasProblems(); | ||
}); | ||
if (!doesContain) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
severity: ProblemSeverity.Warning, | ||
message: schema.errorMessage || localize('requiredItemMissingWarning', 'Array does not contain required item.', schema.minItems) | ||
}); | ||
} | ||
} | ||
if (schema.minItems && this.items.length < schema.minItems) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('minItemsWarning', 'Array has too few items. Expected {0} or more.', schema.minItems) | ||
}); | ||
} | ||
if (schema.maxItems && this.items.length > schema.maxItems) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('maxItemsWarning', 'Array has too many items. Expected {0} or fewer.', schema.minItems) | ||
}); | ||
} | ||
if (schema.uniqueItems === true) { | ||
var values_1 = this.items.map(function (node) { | ||
return node.getValue(); | ||
}); | ||
var duplicates = values_1.some(function (value, index) { | ||
return index !== values_1.lastIndexOf(value); | ||
}); | ||
if (duplicates) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('uniqueItemsWarning', 'Array has duplicate items.') | ||
}); | ||
} | ||
} | ||
}; | ||
return ArrayASTNode; | ||
}(ASTNode)); | ||
export { ArrayASTNode }; | ||
var NumberASTNode = /** @class */ (function (_super) { | ||
__extends(NumberASTNode, _super); | ||
function NumberASTNode(parent, name, start, end) { | ||
var _this = _super.call(this, parent, 'number', name, start, end) || this; | ||
_this.isInteger = true; | ||
_this.value = Number.NaN; | ||
return _this; | ||
} | ||
NumberASTNode.prototype.getValue = function () { | ||
return this.value; | ||
}; | ||
NumberASTNode.prototype.validate = function (schema, validationResult, matchingSchemas) { | ||
if (!matchingSchemas.include(this)) { | ||
return; | ||
} | ||
// work around type validation in the base class | ||
var typeIsInteger = false; | ||
if (schema.type === 'integer' || (Array.isArray(schema.type) && schema.type.indexOf('integer') !== -1)) { | ||
typeIsInteger = true; | ||
} | ||
if (typeIsInteger && this.isInteger === true) { | ||
this.type = 'integer'; | ||
} | ||
_super.prototype.validate.call(this, schema, validationResult, matchingSchemas); | ||
this.type = 'number'; | ||
var val = this.getValue(); | ||
function _validateNumberNode(node, schema, validationResult, matchingSchemas) { | ||
var val = node.value; | ||
if (typeof schema.multipleOf === 'number') { | ||
if (val % schema.multipleOf !== 0) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -481,3 +612,3 @@ message: localize('multipleOfWarning', 'Value is not divisible by {0}.', schema.multipleOf) | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -490,3 +621,3 @@ message: localize('exclusiveMinimumWarning', 'Value is below the exclusive minimum of {0}.', exclusiveMinimum) | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -499,3 +630,3 @@ message: localize('exclusiveMaximumWarning', 'Value is above the exclusive maximum of {0}.', exclusiveMaximum) | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -508,3 +639,3 @@ message: localize('minimumWarning', 'Value is below the minimum of {0}.', minimum) | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -514,25 +645,7 @@ message: localize('maximumWarning', 'Value is above the maximum of {0}.', maximum) | ||
} | ||
}; | ||
return NumberASTNode; | ||
}(ASTNode)); | ||
export { NumberASTNode }; | ||
var StringASTNode = /** @class */ (function (_super) { | ||
__extends(StringASTNode, _super); | ||
function StringASTNode(parent, name, isKey, start, end) { | ||
var _this = _super.call(this, parent, 'string', name, start, end) || this; | ||
_this.isKey = isKey; | ||
_this.value = ''; | ||
return _this; | ||
} | ||
StringASTNode.prototype.getValue = function () { | ||
return this.value; | ||
}; | ||
StringASTNode.prototype.validate = function (schema, validationResult, matchingSchemas) { | ||
if (!matchingSchemas.include(this)) { | ||
return; | ||
} | ||
_super.prototype.validate.call(this, schema, validationResult, matchingSchemas); | ||
if (schema.minLength && this.value.length < schema.minLength) { | ||
function _validateStringNode(node, schema, validationResult, matchingSchemas) { | ||
if (schema.minLength && node.value.length < schema.minLength) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -542,5 +655,5 @@ message: localize('minLengthWarning', 'String is shorter than the minimum length of {0}.', schema.minLength) | ||
} | ||
if (schema.maxLength && this.value.length > schema.maxLength) { | ||
if (schema.maxLength && node.value.length > schema.maxLength) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -552,5 +665,5 @@ message: localize('maxLengthWarning', 'String is longer than the maximum length of {0}.', schema.maxLength) | ||
var regex = new RegExp(schema.pattern); | ||
if (!regex.test(this.value)) { | ||
if (!regex.test(node.value)) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -567,3 +680,3 @@ message: schema.patternErrorMessage || schema.errorMessage || localize('patternWarning', 'String does not match the pattern of "{0}".', schema.pattern) | ||
var errorMessage = void 0; | ||
if (!this.value) { | ||
if (!node.value) { | ||
errorMessage = localize('uriEmpty', 'URI expected.'); | ||
@@ -573,3 +686,3 @@ } | ||
try { | ||
var uri = Uri.parse(this.value); | ||
var uri = Uri.parse(node.value); | ||
if (!uri.scheme && schema.format === 'uri') { | ||
@@ -585,3 +698,3 @@ errorMessage = localize('uriSchemeMissing', 'URI with a scheme is expected.'); | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -595,5 +708,5 @@ message: schema.patternErrorMessage || schema.errorMessage || localize('uriFormatWarning', 'String is not a URI: {0}', errorMessage) | ||
{ | ||
if (!this.value.match(emailPattern)) { | ||
if (!node.value.match(emailPattern)) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -607,5 +720,5 @@ message: schema.patternErrorMessage || schema.errorMessage || localize('emailFormatWarning', 'String is not an e-mail address.') | ||
{ | ||
if (!this.value.match(colorHexPattern)) { | ||
if (!node.value.match(colorHexPattern)) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -620,99 +733,94 @@ message: schema.patternErrorMessage || schema.errorMessage || localize('colorHexFormatWarning', 'Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.') | ||
} | ||
}; | ||
return StringASTNode; | ||
}(ASTNode)); | ||
export { StringASTNode }; | ||
var PropertyASTNode = /** @class */ (function (_super) { | ||
__extends(PropertyASTNode, _super); | ||
function PropertyASTNode(parent, key) { | ||
var _this = _super.call(this, parent, 'property', null, key.start) || this; | ||
_this.key = key; | ||
key.parent = _this; | ||
key.location = key.value; | ||
_this.colonOffset = -1; | ||
return _this; | ||
} | ||
PropertyASTNode.prototype.getChildNodes = function () { | ||
return this.value ? [this.key, this.value] : [this.key]; | ||
}; | ||
PropertyASTNode.prototype.getLastChild = function () { | ||
return this.value; | ||
}; | ||
PropertyASTNode.prototype.setValue = function (value) { | ||
this.value = value; | ||
return value !== null; | ||
}; | ||
PropertyASTNode.prototype.visit = function (visitor) { | ||
return visitor(this) && this.key.visit(visitor) && this.value && this.value.visit(visitor); | ||
}; | ||
PropertyASTNode.prototype.validate = function (schema, validationResult, matchingSchemas) { | ||
if (!matchingSchemas.include(this)) { | ||
return; | ||
function _validateArrayNode(node, schema, validationResult, matchingSchemas) { | ||
if (Array.isArray(schema.items)) { | ||
var subSchemas_1 = schema.items; | ||
subSchemas_1.forEach(function (subSchemaRef, index) { | ||
var subSchema = asSchema(subSchemaRef); | ||
var itemValidationResult = new ValidationResult(); | ||
var item = node.items[index]; | ||
if (item) { | ||
validate(item, subSchema, itemValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(itemValidationResult); | ||
} | ||
else if (node.items.length >= subSchemas_1.length) { | ||
validationResult.propertiesValueMatches++; | ||
} | ||
}); | ||
if (node.items.length > subSchemas_1.length) { | ||
if (typeof schema.additionalItems === 'object') { | ||
for (var i = subSchemas_1.length; i < node.items.length; i++) { | ||
var itemValidationResult = new ValidationResult(); | ||
validate(node.items[i], schema.additionalItems, itemValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(itemValidationResult); | ||
} | ||
} | ||
else if (schema.additionalItems === false) { | ||
validationResult.problems.push({ | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('additionalItemsWarning', 'Array has too many items according to schema. Expected {0} or fewer.', subSchemas_1.length) | ||
}); | ||
} | ||
} | ||
} | ||
if (this.value) { | ||
this.value.validate(schema, validationResult, matchingSchemas); | ||
else { | ||
var itemSchema_1 = asSchema(schema.items); | ||
if (itemSchema_1) { | ||
node.items.forEach(function (item) { | ||
var itemValidationResult = new ValidationResult(); | ||
validate(item, itemSchema_1, itemValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(itemValidationResult); | ||
}); | ||
} | ||
} | ||
}; | ||
return PropertyASTNode; | ||
}(ASTNode)); | ||
export { PropertyASTNode }; | ||
var ObjectASTNode = /** @class */ (function (_super) { | ||
__extends(ObjectASTNode, _super); | ||
function ObjectASTNode(parent, name, start, end) { | ||
var _this = _super.call(this, parent, 'object', name, start, end) || this; | ||
_this.properties = []; | ||
return _this; | ||
} | ||
ObjectASTNode.prototype.getChildNodes = function () { | ||
return this.properties; | ||
}; | ||
ObjectASTNode.prototype.getLastChild = function () { | ||
return this.properties[this.properties.length - 1]; | ||
}; | ||
ObjectASTNode.prototype.addProperty = function (node) { | ||
if (!node) { | ||
return false; | ||
} | ||
this.properties.push(node); | ||
return true; | ||
}; | ||
ObjectASTNode.prototype.getFirstProperty = function (key) { | ||
for (var i = 0; i < this.properties.length; i++) { | ||
if (this.properties[i].key.value === key) { | ||
return this.properties[i]; | ||
var containsSchema = asSchema(schema.contains); | ||
if (containsSchema) { | ||
var doesContain = node.items.some(function (item) { | ||
var itemValidationResult = new ValidationResult(); | ||
validate(item, containsSchema, itemValidationResult, NoOpSchemaCollector.instance); | ||
return !itemValidationResult.hasProblems(); | ||
}); | ||
if (!doesContain) { | ||
validationResult.problems.push({ | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
message: schema.errorMessage || localize('requiredItemMissingWarning', 'Array does not contain required item.', schema.minItems) | ||
}); | ||
} | ||
} | ||
return null; | ||
}; | ||
ObjectASTNode.prototype.getKeyList = function () { | ||
return this.properties.map(function (p) { return p.key.getValue(); }); | ||
}; | ||
ObjectASTNode.prototype.getValue = function () { | ||
var value = Object.create(null); | ||
this.properties.forEach(function (p) { | ||
var v = p.value && p.value.getValue(); | ||
if (typeof v !== 'undefined') { | ||
value[p.key.getValue()] = v; | ||
if (schema.minItems && node.items.length < schema.minItems) { | ||
validationResult.problems.push({ | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('minItemsWarning', 'Array has too few items. Expected {0} or more.', schema.minItems) | ||
}); | ||
} | ||
if (schema.maxItems && node.items.length > schema.maxItems) { | ||
validationResult.problems.push({ | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('maxItemsWarning', 'Array has too many items. Expected {0} or fewer.', schema.minItems) | ||
}); | ||
} | ||
if (schema.uniqueItems === true) { | ||
var values_1 = getNodeValue(node); | ||
var duplicates = values_1.some(function (value, index) { | ||
return index !== values_1.lastIndexOf(value); | ||
}); | ||
if (duplicates) { | ||
validationResult.problems.push({ | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
message: localize('uniqueItemsWarning', 'Array has duplicate items.') | ||
}); | ||
} | ||
}); | ||
return value; | ||
}; | ||
ObjectASTNode.prototype.visit = function (visitor) { | ||
var ctn = visitor(this); | ||
for (var i = 0; i < this.properties.length && ctn; i++) { | ||
ctn = this.properties[i].visit(visitor); | ||
} | ||
return ctn; | ||
}; | ||
ObjectASTNode.prototype.validate = function (schema, validationResult, matchingSchemas) { | ||
var _this = this; | ||
if (!matchingSchemas.include(this)) { | ||
return; | ||
} | ||
_super.prototype.validate.call(this, schema, validationResult, matchingSchemas); | ||
} | ||
function _validateObjectNode(node, schema, validationResult, matchingSchemas) { | ||
var seenKeys = Object.create(null); | ||
var unprocessedProperties = []; | ||
this.properties.forEach(function (node) { | ||
var key = node.key.value; | ||
seenKeys[key] = node.value; | ||
node.properties.forEach(function (node) { | ||
var key = node.keyNode.value; | ||
seenKeys[key] = node.valueNode; | ||
unprocessedProperties.push(key); | ||
@@ -723,4 +831,4 @@ }); | ||
if (!seenKeys[propertyName]) { | ||
var key = _this.parent && _this.parent && _this.parent.key; | ||
var location = key ? { start: key.start, end: key.end } : { start: _this.start, end: _this.start + 1 }; | ||
var keyNode = node.parent && node.parent.type === 'property' && node.parent.keyNode; | ||
var location = keyNode ? { offset: keyNode.offset, length: keyNode.length } : { offset: node.offset, length: 1 }; | ||
validationResult.problems.push({ | ||
@@ -751,3 +859,3 @@ location: location, | ||
validationResult.problems.push({ | ||
location: { start: propertyNode.key.start, end: propertyNode.key.end }, | ||
location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -764,3 +872,3 @@ message: schema.errorMessage || localize('DisallowedExtraPropWarning', 'Property {0} is not allowed.', propertyName) | ||
var propertyValidationResult = new ValidationResult(); | ||
child.validate(propertySchema, propertyValidationResult, matchingSchemas); | ||
validate(child, propertySchema, propertyValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(propertyValidationResult); | ||
@@ -784,3 +892,3 @@ } | ||
validationResult.problems.push({ | ||
location: { start: propertyNode.key.start, end: propertyNode.key.end }, | ||
location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -797,3 +905,3 @@ message: schema.errorMessage || localize('DisallowedExtraPropWarning', 'Property {0} is not allowed.', propertyName) | ||
var propertyValidationResult = new ValidationResult(); | ||
child.validate(propertySchema, propertyValidationResult, matchingSchemas); | ||
validate(child, propertySchema, propertyValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(propertyValidationResult); | ||
@@ -811,3 +919,3 @@ } | ||
var propertyValidationResult = new ValidationResult(); | ||
child.validate(schema.additionalProperties, propertyValidationResult, matchingSchemas); | ||
validate(child, schema.additionalProperties, propertyValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(propertyValidationResult); | ||
@@ -824,3 +932,3 @@ } | ||
validationResult.problems.push({ | ||
location: { start: propertyNode.key.start, end: propertyNode.key.end }, | ||
location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -834,5 +942,5 @@ message: schema.errorMessage || localize('DisallowedExtraPropWarning', 'Property {0} is not allowed.', propertyName) | ||
if (schema.maxProperties) { | ||
if (this.properties.length > schema.maxProperties) { | ||
if (node.properties.length > schema.maxProperties) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -844,5 +952,5 @@ message: localize('MaxPropWarning', 'Object has more properties than limit of {0}.', schema.maxProperties) | ||
if (schema.minProperties) { | ||
if (this.properties.length < schema.minProperties) { | ||
if (node.properties.length < schema.minProperties) { | ||
validationResult.problems.push({ | ||
location: { start: this.start, end: this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -862,3 +970,3 @@ message: localize('MinPropWarning', 'Object has fewer properties than the required number of {0}', schema.minProperties) | ||
validationResult.problems.push({ | ||
location: { start: _this.start, end: _this.end }, | ||
location: { offset: node.offset, length: node.length }, | ||
severity: ProblemSeverity.Warning, | ||
@@ -877,3 +985,3 @@ message: localize('RequiredDependentPropWarning', 'Object is missing property {0} required by property {1}.', requiredProp, key) | ||
var propertyValidationResult = new ValidationResult(); | ||
_this.validate(propertySchema, propertyValidationResult, matchingSchemas); | ||
validate(node, propertySchema, propertyValidationResult, matchingSchemas); | ||
validationResult.mergePropertyMatch(propertyValidationResult); | ||
@@ -887,163 +995,11 @@ } | ||
if (propertyNames) { | ||
this.properties.forEach(function (f) { | ||
var key = f.key; | ||
node.properties.forEach(function (f) { | ||
var key = f.keyNode; | ||
if (key) { | ||
key.validate(propertyNames, validationResult, NoOpSchemaCollector.instance); | ||
validate(key, propertyNames, validationResult, NoOpSchemaCollector.instance); | ||
} | ||
}); | ||
} | ||
}; | ||
return ObjectASTNode; | ||
}(ASTNode)); | ||
export { ObjectASTNode }; | ||
//region | ||
export function asSchema(schema) { | ||
if (typeof schema === 'boolean') { | ||
return schema ? {} : { "not": {} }; | ||
} | ||
return schema; | ||
} | ||
export var EnumMatch; | ||
(function (EnumMatch) { | ||
EnumMatch[EnumMatch["Key"] = 0] = "Key"; | ||
EnumMatch[EnumMatch["Enum"] = 1] = "Enum"; | ||
})(EnumMatch || (EnumMatch = {})); | ||
var SchemaCollector = /** @class */ (function () { | ||
function SchemaCollector(focusOffset, exclude) { | ||
if (focusOffset === void 0) { focusOffset = -1; } | ||
if (exclude === void 0) { exclude = null; } | ||
this.focusOffset = focusOffset; | ||
this.exclude = exclude; | ||
this.schemas = []; | ||
} | ||
SchemaCollector.prototype.add = function (schema) { | ||
this.schemas.push(schema); | ||
}; | ||
SchemaCollector.prototype.merge = function (other) { | ||
(_a = this.schemas).push.apply(_a, other.schemas); | ||
var _a; | ||
}; | ||
SchemaCollector.prototype.include = function (node) { | ||
return (this.focusOffset === -1 || node.contains(this.focusOffset)) && (node !== this.exclude); | ||
}; | ||
SchemaCollector.prototype.newSub = function () { | ||
return new SchemaCollector(-1, this.exclude); | ||
}; | ||
return SchemaCollector; | ||
}()); | ||
var NoOpSchemaCollector = /** @class */ (function () { | ||
function NoOpSchemaCollector() { | ||
} | ||
Object.defineProperty(NoOpSchemaCollector.prototype, "schemas", { | ||
get: function () { return []; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
NoOpSchemaCollector.prototype.add = function (schema) { }; | ||
NoOpSchemaCollector.prototype.merge = function (other) { }; | ||
NoOpSchemaCollector.prototype.include = function (node) { return true; }; | ||
NoOpSchemaCollector.prototype.newSub = function () { return this; }; | ||
NoOpSchemaCollector.instance = new NoOpSchemaCollector(); | ||
return NoOpSchemaCollector; | ||
}()); | ||
var ValidationResult = /** @class */ (function () { | ||
function ValidationResult() { | ||
this.problems = []; | ||
this.propertiesMatches = 0; | ||
this.propertiesValueMatches = 0; | ||
this.primaryValueMatches = 0; | ||
this.enumValueMatch = false; | ||
this.enumValues = null; | ||
} | ||
ValidationResult.prototype.hasProblems = function () { | ||
return !!this.problems.length; | ||
}; | ||
ValidationResult.prototype.mergeAll = function (validationResults) { | ||
var _this = this; | ||
validationResults.forEach(function (validationResult) { | ||
_this.merge(validationResult); | ||
}); | ||
}; | ||
ValidationResult.prototype.merge = function (validationResult) { | ||
this.problems = this.problems.concat(validationResult.problems); | ||
}; | ||
ValidationResult.prototype.mergeEnumValues = function (validationResult) { | ||
if (!this.enumValueMatch && !validationResult.enumValueMatch && this.enumValues && validationResult.enumValues) { | ||
this.enumValues = this.enumValues.concat(validationResult.enumValues); | ||
for (var _i = 0, _a = this.problems; _i < _a.length; _i++) { | ||
var error = _a[_i]; | ||
if (error.code === ErrorCode.EnumValueMismatch) { | ||
error.message = localize('enumWarning', 'Value is not accepted. Valid values: {0}.', this.enumValues.map(function (v) { return JSON.stringify(v); }).join(', ')); | ||
} | ||
} | ||
} | ||
}; | ||
ValidationResult.prototype.mergePropertyMatch = function (propertyValidationResult) { | ||
this.merge(propertyValidationResult); | ||
this.propertiesMatches++; | ||
if (propertyValidationResult.enumValueMatch || !propertyValidationResult.hasProblems() && propertyValidationResult.propertiesMatches) { | ||
this.propertiesValueMatches++; | ||
} | ||
if (propertyValidationResult.enumValueMatch && propertyValidationResult.enumValues && propertyValidationResult.enumValues.length === 1) { | ||
this.primaryValueMatches++; | ||
} | ||
}; | ||
ValidationResult.prototype.compare = function (other) { | ||
var hasProblems = this.hasProblems(); | ||
if (hasProblems !== other.hasProblems()) { | ||
return hasProblems ? -1 : 1; | ||
} | ||
if (this.enumValueMatch !== other.enumValueMatch) { | ||
return other.enumValueMatch ? -1 : 1; | ||
} | ||
if (this.primaryValueMatches !== other.primaryValueMatches) { | ||
return this.primaryValueMatches - other.primaryValueMatches; | ||
} | ||
if (this.propertiesValueMatches !== other.propertiesValueMatches) { | ||
return this.propertiesValueMatches - other.propertiesValueMatches; | ||
} | ||
return this.propertiesMatches - other.propertiesMatches; | ||
}; | ||
return ValidationResult; | ||
}()); | ||
export { ValidationResult }; | ||
var JSONDocument = /** @class */ (function () { | ||
function JSONDocument(root, syntaxErrors, comments) { | ||
if (syntaxErrors === void 0) { syntaxErrors = []; } | ||
if (comments === void 0) { comments = []; } | ||
this.root = root; | ||
this.syntaxErrors = syntaxErrors; | ||
this.comments = comments; | ||
} | ||
JSONDocument.prototype.getNodeFromOffset = function (offset) { | ||
return this.root && this.root.getNodeFromOffset(offset); | ||
}; | ||
JSONDocument.prototype.getNodeFromOffsetEndInclusive = function (offset) { | ||
return this.root && this.root.getNodeFromOffsetEndInclusive(offset); | ||
}; | ||
JSONDocument.prototype.visit = function (visitor) { | ||
if (this.root) { | ||
this.root.visit(visitor); | ||
} | ||
}; | ||
JSONDocument.prototype.validate = function (schema) { | ||
if (this.root && schema) { | ||
var validationResult = new ValidationResult(); | ||
this.root.validate(schema, validationResult, NoOpSchemaCollector.instance); | ||
return validationResult.problems; | ||
} | ||
return null; | ||
}; | ||
JSONDocument.prototype.getMatchingSchemas = function (schema, focusOffset, exclude) { | ||
if (focusOffset === void 0) { focusOffset = -1; } | ||
if (exclude === void 0) { exclude = null; } | ||
var matchingSchemas = new SchemaCollector(focusOffset, exclude); | ||
if (this.root && schema) { | ||
this.root.validate(schema, new ValidationResult(), matchingSchemas); | ||
} | ||
return matchingSchemas.schemas; | ||
}; | ||
return JSONDocument; | ||
}()); | ||
export { JSONDocument }; | ||
export function parse(textDocument, config) { | ||
@@ -1062,3 +1018,3 @@ var problems = []; | ||
if (Array.isArray(comments)) { | ||
comments.push({ start: scanner.getTokenOffset(), end: scanner.getTokenOffset() + scanner.getTokenLength() }); | ||
comments.push({ offset: scanner.getTokenOffset(), length: scanner.getTokenLength() }); | ||
} | ||
@@ -1082,3 +1038,3 @@ break; | ||
function _errorAtRange(message, code, location) { | ||
if (problems.length === 0 || problems[problems.length - 1].location.start !== location.start) { | ||
if (problems.length === 0 || problems[problems.length - 1].location.offset !== location.offset) { | ||
problems.push({ message: message, location: location, code: code, severity: ProblemSeverity.Error }); | ||
@@ -1100,3 +1056,3 @@ } | ||
} | ||
_errorAtRange(message, code, { start: start, end: end }); | ||
_errorAtRange(message, code, { offset: start, length: end - start }); | ||
if (node) { | ||
@@ -1144,3 +1100,3 @@ _finalize(node, false); | ||
function _finalize(node, scanNext) { | ||
node.end = scanner.getTokenOffset() + scanner.getTokenLength(); | ||
node.length = scanner.getTokenOffset() + scanner.getTokenLength() - node.offset; | ||
if (scanNext) { | ||
@@ -1151,7 +1107,7 @@ _scanNext(); | ||
} | ||
function _parseArray(parent, name) { | ||
function _parseArray(parent) { | ||
if (scanner.getToken() !== 3 /* OpenBracketToken */) { | ||
return null; | ||
} | ||
var node = new ArrayASTNode(parent, name, scanner.getTokenOffset()); | ||
var node = new ArrayASTNodeImpl(parent, scanner.getTokenOffset()); | ||
_scanNext(); // consume OpenBracketToken | ||
@@ -1169,3 +1125,3 @@ var count = 0; | ||
if (needsComma) { | ||
_errorAtRange(localize('TrailingComma', 'Trailing comma'), ErrorCode.TrailingComma, { start: commaOffset, end: commaOffset + 1 }); | ||
_errorAtRange(localize('TrailingComma', 'Trailing comma'), ErrorCode.TrailingComma, { offset: commaOffset, length: 1 }); | ||
} | ||
@@ -1178,5 +1134,9 @@ continue; | ||
} | ||
if (!node.addItem(_parseValue(node, count++))) { | ||
var item = _parseValue(node, count++); | ||
if (!item) { | ||
_error(localize('PropertyExpected', 'Value expected'), ErrorCode.ValueExpected, null, [], [4 /* CloseBracketToken */, 5 /* CommaToken */]); | ||
} | ||
else { | ||
node.items.push(item); | ||
} | ||
needsComma = true; | ||
@@ -1190,3 +1150,4 @@ } | ||
function _parseProperty(parent, keysSeen) { | ||
var key = _parseString(null, null, true); | ||
var node = new PropertyASTNodeImpl(parent, scanner.getTokenOffset()); | ||
var key = _parseString(node); | ||
if (!key) { | ||
@@ -1196,4 +1157,5 @@ if (scanner.getToken() === 16 /* Unknown */) { | ||
_error(localize('DoubleQuotesExpected', 'Property keys must be doublequoted'), ErrorCode.Undefined); | ||
key = new StringASTNode(null, null, true, scanner.getTokenOffset(), scanner.getTokenOffset() + scanner.getTokenLength()); | ||
key.value = scanner.getTokenValue(); | ||
var keyNode = new StringASTNodeImpl(node, scanner.getTokenOffset(), scanner.getTokenLength()); | ||
keyNode.value = scanner.getTokenValue(); | ||
key = keyNode; | ||
_scanNext(); // consume Unknown | ||
@@ -1205,8 +1167,8 @@ } | ||
} | ||
var node = new PropertyASTNode(parent, key); | ||
node.keyNode = key; | ||
var seen = keysSeen[key.value]; | ||
if (seen) { | ||
problems.push({ location: { start: node.key.start, end: node.key.end }, message: localize('DuplicateKeyWarning', "Duplicate object key"), code: ErrorCode.Undefined, severity: ProblemSeverity.Warning }); | ||
if (seen instanceof PropertyASTNode) { | ||
problems.push({ location: { start: seen.key.start, end: seen.key.end }, message: localize('DuplicateKeyWarning', "Duplicate object key"), code: ErrorCode.Undefined, severity: ProblemSeverity.Warning }); | ||
problems.push({ location: { offset: node.keyNode.offset, length: node.keyNode.length }, message: localize('DuplicateKeyWarning', "Duplicate object key"), code: ErrorCode.Undefined, severity: ProblemSeverity.Warning }); | ||
if (typeof seen === 'object') { | ||
problems.push({ location: { offset: seen.keyNode.offset, length: seen.keyNode.length }, message: localize('DuplicateKeyWarning', "Duplicate object key"), code: ErrorCode.Undefined, severity: ProblemSeverity.Warning }); | ||
} | ||
@@ -1224,18 +1186,20 @@ keysSeen[key.value] = true; // if the same key is duplicate again, avoid duplicate error reporting | ||
_error(localize('ColonExpected', 'Colon expected'), ErrorCode.ColonExpected); | ||
if (scanner.getToken() === 10 /* StringLiteral */ && textDocument.positionAt(key.end).line < textDocument.positionAt(scanner.getTokenOffset()).line) { | ||
node.end = key.end; | ||
if (scanner.getToken() === 10 /* StringLiteral */ && textDocument.positionAt(key.offset + key.length).line < textDocument.positionAt(scanner.getTokenOffset()).line) { | ||
node.length = key.length; | ||
return node; | ||
} | ||
} | ||
if (!node.setValue(_parseValue(node, key.value))) { | ||
var value = _parseValue(node, key.value); | ||
if (!value) { | ||
return _error(localize('ValueExpected', 'Value expected'), ErrorCode.ValueExpected, node, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]); | ||
} | ||
node.end = node.value.end; | ||
node.valueNode = value; | ||
node.length = value.offset + value.length - node.offset; | ||
return node; | ||
} | ||
function _parseObject(parent, name) { | ||
function _parseObject(parent) { | ||
if (scanner.getToken() !== 1 /* OpenBraceToken */) { | ||
return null; | ||
} | ||
var node = new ObjectASTNode(parent, name, scanner.getTokenOffset()); | ||
var node = new ObjectASTNodeImpl(parent, scanner.getTokenOffset()); | ||
var keysSeen = Object.create(null); | ||
@@ -1253,3 +1217,3 @@ _scanNext(); // consume OpenBraceToken | ||
if (needsComma) { | ||
_errorAtRange(localize('TrailingComma', 'Trailing comma'), ErrorCode.TrailingComma, { start: commaOffset, end: commaOffset + 1 }); | ||
_errorAtRange(localize('TrailingComma', 'Trailing comma'), ErrorCode.TrailingComma, { offset: commaOffset, length: 1 }); | ||
} | ||
@@ -1262,5 +1226,9 @@ continue; | ||
} | ||
if (!node.addProperty(_parseProperty(node, keysSeen))) { | ||
var property = _parseProperty(node, keysSeen); | ||
if (!property) { | ||
_error(localize('PropertyExpected', 'Property expected'), ErrorCode.PropertyExpected, null, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]); | ||
} | ||
else { | ||
node.properties.push(property); | ||
} | ||
needsComma = true; | ||
@@ -1273,15 +1241,15 @@ } | ||
} | ||
function _parseString(parent, name, isKey) { | ||
function _parseString(parent) { | ||
if (scanner.getToken() !== 10 /* StringLiteral */) { | ||
return null; | ||
} | ||
var node = new StringASTNode(parent, name, isKey, scanner.getTokenOffset()); | ||
var node = new StringASTNodeImpl(parent, scanner.getTokenOffset()); | ||
node.value = scanner.getTokenValue(); | ||
return _finalize(node, true); | ||
} | ||
function _parseNumber(parent, name) { | ||
function _parseNumber(parent) { | ||
if (scanner.getToken() !== 11 /* NumericLiteral */) { | ||
return null; | ||
} | ||
var node = new NumberASTNode(parent, name, scanner.getTokenOffset()); | ||
var node = new NumberASTNodeImpl(parent, scanner.getTokenOffset()); | ||
if (scanner.getTokenError() === 0 /* None */) { | ||
@@ -1303,21 +1271,17 @@ var tokenValue = scanner.getTokenValue(); | ||
} | ||
function _parseLiteral(parent, name) { | ||
function _parseLiteral(parent) { | ||
var node; | ||
switch (scanner.getToken()) { | ||
case 7 /* NullKeyword */: | ||
node = new NullASTNode(parent, name, scanner.getTokenOffset()); | ||
break; | ||
return _finalize(new NullASTNodeImpl(parent, scanner.getTokenOffset()), true); | ||
case 8 /* TrueKeyword */: | ||
node = new BooleanASTNode(parent, name, true, scanner.getTokenOffset()); | ||
break; | ||
return _finalize(new BooleanASTNodeImpl(parent, true, scanner.getTokenOffset()), true); | ||
case 9 /* FalseKeyword */: | ||
node = new BooleanASTNode(parent, name, false, scanner.getTokenOffset()); | ||
break; | ||
return _finalize(new BooleanASTNodeImpl(parent, false, scanner.getTokenOffset()), true); | ||
default: | ||
return null; | ||
} | ||
return _finalize(node, true); | ||
} | ||
function _parseValue(parent, name) { | ||
return _parseArray(parent, name) || _parseObject(parent, name) || _parseString(parent, name, false) || _parseNumber(parent, name) || _parseLiteral(parent, name); | ||
return _parseArray(parent) || _parseObject(parent) || _parseString(parent) || _parseNumber(parent) || _parseLiteral(parent); | ||
} | ||
@@ -1324,0 +1288,0 @@ var _root = null; |
@@ -6,2 +6,3 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import * as Parser from '../parser/jsonParser'; | ||
import * as Json from '../../jsonc-parser/main'; | ||
@@ -40,3 +41,3 @@ import { stringifyObject } from '../utils/json'; | ||
var node = doc.getNodeFromOffsetEndInclusive(offset); | ||
if (this.isInComment(document, node ? node.start : 0, offset)) { | ||
if (this.isInComment(document, node ? node.offset : 0, offset)) { | ||
return Promise.resolve(result); | ||
@@ -47,3 +48,3 @@ } | ||
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) { | ||
overwriteRange = Range.create(document.positionAt(node.start), document.positionAt(node.end)); | ||
overwriteRange = Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length)); | ||
} | ||
@@ -92,9 +93,9 @@ else { | ||
if (node.type === 'string') { | ||
var stringNode = node; | ||
if (stringNode.isKey) { | ||
addValue = !(node.parent && (node.parent.value)); | ||
currentProperty = node.parent ? node.parent : null; | ||
currentKey = document.getText().substring(node.start + 1, node.end - 1); | ||
if (node.parent) { | ||
node = node.parent.parent; | ||
var parent = node.parent; | ||
if (parent && parent.type === 'property' && parent.keyNode === node) { | ||
addValue = !parent.valueNode; | ||
currentProperty = parent; | ||
currentKey = document.getText().substr(node.offset + 1, node.length - 2); | ||
if (parent) { | ||
node = parent.parent; | ||
} | ||
@@ -107,3 +108,3 @@ } | ||
// don't suggest keys when the cursor is just before the opening curly brace | ||
if (node.start === offset) { | ||
if (node.offset === offset) { | ||
return result; | ||
@@ -115,3 +116,3 @@ } | ||
if (!currentProperty || currentProperty !== p) { | ||
proposed[p.key.value] = CompletionItem.create('__'); | ||
proposed[p.keyNode.value] = CompletionItem.create('__'); | ||
} | ||
@@ -131,3 +132,3 @@ }); | ||
} | ||
var location_1 = node.getPath(); | ||
var location_1 = Parser.getNodePath(node); | ||
_this.contributions.forEach(function (contribution) { | ||
@@ -165,3 +166,3 @@ var collectPromise = contribution.collectPropertyCompletions(document.uri, location_1, currentWord, addValue, separatorAfter_1 === '', collector); | ||
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) { | ||
offsetForSeparator = node.end; | ||
offsetForSeparator = node.offset + node.length; | ||
} | ||
@@ -177,3 +178,3 @@ var separatorAfter = _this.evaluateSeparatorAfter(document, offsetForSeparator); | ||
var _this = this; | ||
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.start); | ||
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset); | ||
matchingSchemas.forEach(function (s) { | ||
@@ -211,3 +212,3 @@ if (s.node === node && !s.inverted) { | ||
obj.properties.forEach(function (p) { | ||
var key = p.key.value; | ||
var key = p.keyNode.value; | ||
collector.add({ | ||
@@ -226,7 +227,6 @@ kind: CompletionItemKind.Property, | ||
// if the object is a property value, check the tree for other objects that hang under a property of the same name | ||
var parentKey_1 = node.parent.key.value; | ||
var parentKey_1 = node.parent.keyNode.value; | ||
doc.visit(function (n) { | ||
var p = n; | ||
if (n.type === 'property' && n !== node.parent && p.key.value === parentKey_1 && p.value && p.value.type === 'object') { | ||
collectCompletionsForSimilarObject(p.value); | ||
if (n.type === 'property' && n !== node.parent && n.keyNode.value === parentKey_1 && n.valueNode && n.valueNode.type === 'object') { | ||
collectCompletionsForSimilarObject(n.valueNode); | ||
} | ||
@@ -259,3 +259,3 @@ return true; | ||
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) { | ||
offsetForSeparator = node.end; | ||
offsetForSeparator = node.offset + node.length; | ||
node = node.parent; | ||
@@ -282,3 +282,3 @@ } | ||
var collectSuggestionsForValues = function (value) { | ||
if (!value.parent.contains(offset, true)) { | ||
if (!Parser.contains(value.parent, offset, true)) { | ||
collector.add({ | ||
@@ -292,18 +292,16 @@ kind: _this.getSuggestionKind(value.type), | ||
if (value.type === 'boolean') { | ||
_this.addBooleanValueCompletion(!value.getValue(), separatorAfter, collector); | ||
_this.addBooleanValueCompletion(!value.value, separatorAfter, collector); | ||
} | ||
}; | ||
if (node.type === 'property') { | ||
var propertyNode = node; | ||
if (offset > propertyNode.colonOffset) { | ||
var valueNode = propertyNode.value; | ||
if (valueNode && (offset > valueNode.end || valueNode.type === 'object' || valueNode.type === 'array')) { | ||
if (offset > node.colonOffset) { | ||
var valueNode = node.valueNode; | ||
if (valueNode && (offset > (valueNode.offset + valueNode.length) || valueNode.type === 'object' || valueNode.type === 'array')) { | ||
return; | ||
} | ||
// suggest values at the same key | ||
var parentKey_2 = propertyNode.key.value; | ||
var parentKey_2 = node.keyNode.value; | ||
doc.visit(function (n) { | ||
var p = n; | ||
if (n.type === 'property' && p.key.value === parentKey_2 && p.value) { | ||
collectSuggestionsForValues(p.value); | ||
if (n.type === 'property' && n.keyNode.value === parentKey_2 && n.valueNode) { | ||
collectSuggestionsForValues(n.valueNode); | ||
} | ||
@@ -320,9 +318,7 @@ return true; | ||
// suggest items of an array at the same key | ||
var parentKey_3 = node.parent.key.value; | ||
var parentKey_3 = node.parent.keyNode.value; | ||
doc.visit(function (n) { | ||
var p = n; | ||
if (n.type === 'property' && p.key.value === parentKey_3 && p.value && p.value.type === 'array') { | ||
(p.value.items).forEach(function (n) { | ||
collectSuggestionsForValues(n); | ||
}); | ||
if (n.type === 'property' && p.keyNode.value === parentKey_3 && p.valueNode && p.valueNode.type === 'array') { | ||
p.valueNode.items.forEach(collectSuggestionsForValues); | ||
} | ||
@@ -334,5 +330,3 @@ return true; | ||
// suggest items in the same array | ||
node.items.forEach(function (n) { | ||
collectSuggestionsForValues(n); | ||
}); | ||
node.items.forEach(collectSuggestionsForValues); | ||
} | ||
@@ -347,3 +341,3 @@ } | ||
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) { | ||
offsetForSeparator = node.end; | ||
offsetForSeparator = node.offset + node.length; | ||
valueNode = node; | ||
@@ -357,8 +351,7 @@ node = node.parent; | ||
if ((node.type === 'property') && offset > node.colonOffset) { | ||
var propertyNode = node; | ||
var valueNode_1 = propertyNode.value; | ||
if (valueNode_1 && offset > valueNode_1.end) { | ||
var valueNode_1 = node.valueNode; | ||
if (valueNode_1 && offset > (valueNode_1.offset + valueNode_1.length)) { | ||
return; // we are past the value node | ||
} | ||
parentKey = propertyNode.key.value; | ||
parentKey = node.keyNode.value; | ||
node = node.parent; | ||
@@ -368,6 +361,6 @@ } | ||
var separatorAfter_2 = this.evaluateSeparatorAfter(document, offsetForSeparator); | ||
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.start, valueNode); | ||
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset, valueNode); | ||
matchingSchemas.forEach(function (s) { | ||
if (s.node === node && !s.inverted && s.schema) { | ||
if (s.schema.items) { | ||
if (node.type === 'array' && s.schema.items) { | ||
if (Array.isArray(s.schema.items)) { | ||
@@ -417,6 +410,6 @@ var index = _this.findItemAtOffset(node, document, offset); | ||
if ((node.type === 'property') && offset > node.colonOffset) { | ||
var parentKey_4 = node.key.value; | ||
var valueNode = node.value; | ||
if (!valueNode || offset <= valueNode.end) { | ||
var location_2 = node.parent.getPath(); | ||
var parentKey_4 = node.keyNode.value; | ||
var valueNode = node.valueNode; | ||
if (!valueNode || offset <= (valueNode.offset + valueNode.length)) { | ||
var location_2 = Parser.getNodePath(node.parent); | ||
this.contributions.forEach(function (contribution) { | ||
@@ -435,4 +428,4 @@ var collectPromise = contribution.collectValueCompletions(document.uri, location_2, parentKey_4, collector); | ||
if (typeof schema === 'object') { | ||
this.addEnumValueCompletions(schema, separatorAfter, collector); | ||
this.addDefaultValueCompletions(schema, separatorAfter, collector); | ||
this.addEnumValueCompletions(schema, separatorAfter, collector); | ||
this.collectTypes(schema, types); | ||
@@ -533,2 +526,5 @@ if (Array.isArray(schema.allOf)) { | ||
JSONCompletion.prototype.collectTypes = function (schema, types) { | ||
if (Array.isArray(schema.enum)) { | ||
return; | ||
} | ||
var type = schema.type; | ||
@@ -678,3 +674,3 @@ if (Array.isArray(type)) { | ||
default: | ||
var content = document.getText().substr(node.start, node.end - node.start); | ||
var content = document.getText().substr(node.offset, node.length); | ||
return content; | ||
@@ -690,3 +686,3 @@ } | ||
default: | ||
var content = document.getText().substr(node.start, node.end - node.start) + separatorAfter; | ||
var content = document.getText().substr(node.offset, node.length) + separatorAfter; | ||
return this.getInsertTextForPlainText(content); | ||
@@ -789,7 +785,7 @@ } | ||
var scanner = Json.createScanner(document.getText(), true); | ||
var children = node.getChildNodes(); | ||
var children = node.items; | ||
for (var i = children.length - 1; i >= 0; i--) { | ||
var child = children[i]; | ||
if (offset > child.end) { | ||
scanner.setPosition(child.end); | ||
if (offset > child.offset + child.length) { | ||
scanner.setPosition(child.offset + child.length); | ||
var token = scanner.scan(); | ||
@@ -801,3 +797,3 @@ if (token === 5 /* CommaToken */ && offset >= scanner.getTokenOffset() + scanner.getTokenLength()) { | ||
} | ||
else if (offset >= child.start) { | ||
else if (offset >= child.offset) { | ||
return i; | ||
@@ -804,0 +800,0 @@ } |
@@ -6,2 +6,3 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import * as Parser from '../parser/jsonParser'; | ||
import * as Strings from '../utils/strings'; | ||
@@ -27,6 +28,11 @@ import { colorFromHex } from '../utils/colors'; | ||
if (item.type === 'object') { | ||
var property = item.getFirstProperty('key'); | ||
if (property && property.value) { | ||
var location = Location.create(document.uri, Range.create(document.positionAt(item.start), document.positionAt(item.end))); | ||
result_1.push({ name: property.value.getValue(), kind: SymbolKind.Function, location: location }); | ||
for (var _i = 0, _a = item.properties; _i < _a.length; _i++) { | ||
var property = _a[_i]; | ||
if (property.keyNode.value === 'key') { | ||
if (property.valueNode) { | ||
var location = Location.create(document.uri, Range.create(document.positionAt(item.offset), document.positionAt(item.offset + item.length))); | ||
result_1.push({ name: Parser.getNodeValue(property.valueNode), kind: SymbolKind.Function, location: location }); | ||
} | ||
return; | ||
} | ||
} | ||
@@ -40,14 +46,11 @@ } | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node) { | ||
collectOutlineEntries(result, node, containerName); | ||
}); | ||
node.items.forEach(function (node) { return collectOutlineEntries(result, node, containerName); }); | ||
} | ||
else if (node.type === 'object') { | ||
var objectNode = node; | ||
objectNode.properties.forEach(function (property) { | ||
var location = Location.create(document.uri, Range.create(document.positionAt(property.start), document.positionAt(property.end))); | ||
var valueNode = property.value; | ||
node.properties.forEach(function (property) { | ||
var location = Location.create(document.uri, Range.create(document.positionAt(property.offset), document.positionAt(property.offset + property.length))); | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
var childContainerName = containerName ? containerName + '.' + property.key.value : property.key.value; | ||
result.push({ name: property.key.getValue(), kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName }); | ||
var childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value; | ||
result.push({ name: property.keyNode.value, kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName }); | ||
collectOutlineEntries(result, valueNode, childContainerName); | ||
@@ -87,7 +90,7 @@ } | ||
if (!s.inverted && s.schema && (s.schema.format === 'color' || s.schema.format === 'color-hex') && s.node && s.node.type === 'string') { | ||
var nodeId = String(s.node.start); | ||
var nodeId = String(s.node.offset); | ||
if (!visitedNode[nodeId]) { | ||
var color = colorFromHex(s.node.getValue()); | ||
var color = colorFromHex(Parser.getNodeValue(s.node)); | ||
if (color) { | ||
var range = Range.create(document.positionAt(s.node.start), document.positionAt(s.node.end)); | ||
var range = Range.create(document.positionAt(s.node.offset), document.positionAt(s.node.offset + s.node.length)); | ||
result.push({ color: color, range: range }); | ||
@@ -94,0 +97,0 @@ } |
@@ -6,2 +6,3 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import * as Parser from '../parser/jsonParser'; | ||
import { Range } from '../../vscode-languageserver-types/main'; | ||
@@ -18,3 +19,3 @@ var JSONHover = /** @class */ (function () { | ||
var node = doc.getNodeFromOffset(offset); | ||
if (!node || (node.type === 'object' || node.type === 'array') && offset > node.start + 1 && offset < node.end - 1) { | ||
if (!node || (node.type === 'object' || node.type === 'array') && offset > node.offset + 1 && offset < node.offset + node.length - 1) { | ||
return this.promise.resolve(null); | ||
@@ -25,6 +26,5 @@ } | ||
if (node.type === 'string') { | ||
var stringNode = node; | ||
if (stringNode.isKey) { | ||
var propertyNode = node.parent; | ||
node = propertyNode.value; | ||
var parent = node.parent; | ||
if (parent.type === 'property' && parent.keyNode === node) { | ||
node = parent.valueNode; | ||
if (!node) { | ||
@@ -35,3 +35,3 @@ return this.promise.resolve(null); | ||
} | ||
var hoverRange = Range.create(document.positionAt(hoverRangeNode.start), document.positionAt(hoverRangeNode.end)); | ||
var hoverRange = Range.create(document.positionAt(hoverRangeNode.offset), document.positionAt(hoverRangeNode.offset + hoverRangeNode.length)); | ||
var createHover = function (contents) { | ||
@@ -44,3 +44,3 @@ var result = { | ||
}; | ||
var location = node.getPath(); | ||
var location = Parser.getNodePath(node); | ||
for (var i = this.contributions.length - 1; i >= 0; i--) { | ||
@@ -55,3 +55,3 @@ var contribution = this.contributions[i]; | ||
if (schema) { | ||
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.start); | ||
var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset); | ||
var title_1 = null; | ||
@@ -65,3 +65,3 @@ var markdownDescription_1 = null; | ||
if (s.schema.enum) { | ||
var idx = s.schema.enum.indexOf(node.getValue()); | ||
var idx = s.schema.enum.indexOf(Parser.getNodeValue(node)); | ||
if (s.schema.markdownEnumDescriptions) { | ||
@@ -68,0 +68,0 @@ markdownEnumValueDescription_1 = s.schema.markdownEnumDescriptions[idx]; |
@@ -388,5 +388,5 @@ /*--------------------------------------------------------------------------------------------- | ||
if (document && document.root && document.root.type === 'object') { | ||
var schemaProperties = document.root.properties.filter(function (p) { return (p.key.value === '$schema') && !!p.value; }); | ||
var schemaProperties = document.root.properties.filter(function (p) { return (p.keyNode.value === '$schema') && p.valueNode && p.valueNode.type === 'string'; }); | ||
if (schemaProperties.length > 0) { | ||
var schemeId = schemaProperties[0].value.getValue(); | ||
var schemeId = Parser.getNodeValue(schemaProperties[0].valueNode); | ||
if (schemeId && Strings.startsWith(schemeId, '.') && this.contextService) { | ||
@@ -393,0 +393,0 @@ schemeId = this.contextService.resolveRelativePath(schemeId, resource); |
@@ -34,8 +34,8 @@ /*--------------------------------------------------------------------------------------------- | ||
// remove duplicated messages | ||
var signature = problem.location.start + ' ' + problem.location.end + ' ' + problem.message; | ||
var signature = problem.location.offset + ' ' + problem.location.length + ' ' + problem.message; | ||
if (!added[signature]) { | ||
added[signature] = true; | ||
var range = { | ||
start: textDocument.positionAt(problem.location.start), | ||
end: textDocument.positionAt(problem.location.end) | ||
start: textDocument.positionAt(problem.location.offset), | ||
end: textDocument.positionAt(problem.location.offset + problem.location.length) | ||
}; | ||
@@ -52,9 +52,9 @@ var severity = problem.severity === ProblemSeverity.Error ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning; | ||
var astRoot = jsonDocument.root; | ||
var property = astRoot.type === 'object' ? astRoot.getFirstProperty('$schema') : null; | ||
if (property) { | ||
var node = property.value || property; | ||
addProblem({ location: { start: node.start, end: node.end }, message: schema.errors[0], severity: ProblemSeverity.Warning }); | ||
var property = astRoot.type === 'object' ? astRoot.properties[0] : null; | ||
if (property && property.keyNode.value === '$schema') { | ||
var node = property.valueNode || property; | ||
addProblem({ location: { offset: node.offset, length: node.length }, message: schema.errors[0], severity: ProblemSeverity.Warning }); | ||
} | ||
else { | ||
addProblem({ location: { start: astRoot.start, end: astRoot.start + 1 }, message: schema.errors[0], severity: ProblemSeverity.Warning }); | ||
addProblem({ location: { offset: astRoot.offset, length: 1 }, message: schema.errors[0], severity: ProblemSeverity.Warning }); | ||
} | ||
@@ -78,2 +78,3 @@ } | ||
}); | ||
diagnostics.push.apply(diagnostics, jsonDocument.externalDiagnostic); | ||
if (commentSeverity !== ProblemSeverity.Ignore) { | ||
@@ -80,0 +81,0 @@ var message_1 = localize('InvalidCommentToken', 'Comments are not permitted in JSON.'); |
@@ -26,5 +26,6 @@ /*--------------------------------------------------------------------------------------------- | ||
disposables.push(monaco.languages.registerDocumentRangeFormattingEditProvider(languageId, new languageFeatures.DocumentRangeFormattingEditProvider(worker))); | ||
disposables.push(new languageFeatures.DiagnostcsAdapter(languageId, worker)); | ||
disposables.push(new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults)); | ||
disposables.push(monaco.languages.setTokensProvider(languageId, createTokenizationSupport(true))); | ||
disposables.push(monaco.languages.setLanguageConfiguration(languageId, richEditConfiguration)); | ||
disposables.push(monaco.languages.registerColorProvider(languageId, new languageFeatures.DocumentColorAdapter(worker))); | ||
} | ||
@@ -31,0 +32,0 @@ var richEditConfiguration = { |
@@ -77,2 +77,14 @@ /*--------------------------------------------------------------------------------------------- | ||
}; | ||
JSONWorker.prototype.findDocumentColors = function (uri) { | ||
var document = this._getTextDocument(uri); | ||
var stylesheet = this._languageService.parseJSONDocument(document); | ||
var colorSymbols = this._languageService.findDocumentColors(document, stylesheet); | ||
return Promise.as(colorSymbols); | ||
}; | ||
JSONWorker.prototype.getColorPresentations = function (uri, color, range) { | ||
var document = this._getTextDocument(uri); | ||
var stylesheet = this._languageService.parseJSONDocument(document); | ||
var colorPresentations = this._languageService.getColorPresentations(document, stylesheet, color, range); | ||
return Promise.as(colorPresentations); | ||
}; | ||
JSONWorker.prototype._getTextDocument = function (uri) { | ||
@@ -79,0 +91,0 @@ var models = this._ctx.getMirrorModels(); |
@@ -10,4 +10,4 @@ /*--------------------------------------------------------------------------------------------- | ||
// --- diagnostics --- --- | ||
var DiagnostcsAdapter = /** @class */ (function () { | ||
function DiagnostcsAdapter(_languageId, _worker) { | ||
var DiagnosticsAdapter = /** @class */ (function () { | ||
function DiagnosticsAdapter(_languageId, _worker, defaults) { | ||
var _this = this; | ||
@@ -49,4 +49,13 @@ this._languageId = _languageId; | ||
})); | ||
this._disposables.push(defaults.onDidChange(function (_) { | ||
monaco.editor.getModels().forEach(function (model) { | ||
if (model.getModeId() === _this._languageId) { | ||
onModelRemoved(model); | ||
onModelAdd(model); | ||
} | ||
}); | ||
})); | ||
this._disposables.push({ | ||
dispose: function () { | ||
monaco.editor.getModels().forEach(onModelRemoved); | ||
for (var key in _this._listener) { | ||
@@ -59,7 +68,7 @@ _this._listener[key].dispose(); | ||
} | ||
DiagnostcsAdapter.prototype.dispose = function () { | ||
DiagnosticsAdapter.prototype.dispose = function () { | ||
this._disposables.forEach(function (d) { return d && d.dispose(); }); | ||
this._disposables = []; | ||
}; | ||
DiagnostcsAdapter.prototype._resetSchema = function (resource) { | ||
DiagnosticsAdapter.prototype._resetSchema = function (resource) { | ||
this._worker().then(function (worker) { | ||
@@ -69,3 +78,3 @@ worker.resetSchema(resource.toString()); | ||
}; | ||
DiagnostcsAdapter.prototype._doValidate = function (resource, languageId) { | ||
DiagnosticsAdapter.prototype._doValidate = function (resource, languageId) { | ||
this._worker(resource).then(function (worker) { | ||
@@ -83,5 +92,5 @@ return worker.doValidation(resource.toString()).then(function (diagnostics) { | ||
}; | ||
return DiagnostcsAdapter; | ||
return DiagnosticsAdapter; | ||
}()); | ||
export { DiagnostcsAdapter }; | ||
export { DiagnosticsAdapter }; | ||
function toSeverity(lsSeverity) { | ||
@@ -121,3 +130,3 @@ switch (lsSeverity) { | ||
} | ||
return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) }; | ||
return { start: { line: range.startLineNumber - 1, character: range.startColumn - 1 }, end: { line: range.endLineNumber - 1, character: range.endColumn - 1 } }; | ||
} | ||
@@ -423,2 +432,41 @@ function toRange(range) { | ||
export { DocumentRangeFormattingEditProvider }; | ||
var DocumentColorAdapter = /** @class */ (function () { | ||
function DocumentColorAdapter(_worker) { | ||
this._worker = _worker; | ||
} | ||
DocumentColorAdapter.prototype.provideDocumentColors = function (model, token) { | ||
var resource = model.uri; | ||
return wireCancellationToken(token, this._worker(resource).then(function (worker) { return worker.findDocumentColors(resource.toString()); }).then(function (infos) { | ||
if (!infos) { | ||
return; | ||
} | ||
return infos.map(function (item) { return ({ | ||
color: item.color, | ||
range: toRange(item.range) | ||
}); }); | ||
})); | ||
}; | ||
DocumentColorAdapter.prototype.provideColorPresentations = function (model, info, token) { | ||
var resource = model.uri; | ||
return wireCancellationToken(token, this._worker(resource).then(function (worker) { return worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range)); }).then(function (presentations) { | ||
if (!presentations) { | ||
return; | ||
} | ||
return presentations.map(function (presentation) { | ||
var item = { | ||
label: presentation.label, | ||
}; | ||
if (presentation.textEdit) { | ||
item.textEdit = toTextEdit(presentation.textEdit); | ||
} | ||
if (presentation.additionalTextEdits) { | ||
item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit); | ||
} | ||
return item; | ||
}); | ||
})); | ||
}; | ||
return DocumentColorAdapter; | ||
}()); | ||
export { DocumentColorAdapter }; | ||
/** | ||
@@ -425,0 +473,0 @@ * Hook a cancellation token to a WinJS Promise |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-json version: 2.1.0(427abfc518aba22b38705f2484e3b50662ea3166) | ||
* monaco-json version: 2.1.1(0e6ea95f4f4e093db9201c502e8d401391803233) | ||
* Released under the MIT license | ||
* https://github.com/Microsoft/monaco-json/blob/master/LICENSE.md | ||
*-----------------------------------------------------------------------------*/ | ||
define("vs/language/json/workerManager",["require","exports"],function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var u=monaco.Promise,n=function(){function e(e){var t=this;this._defaults=e,this._worker=null,this._idleCheckInterval=setInterval(function(){return t._checkIfIdle()},3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(function(){return t._stopWorker()})}return e.prototype._stopWorker=function(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null},e.prototype.dispose=function(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()},e.prototype._checkIfIdle=function(){this._worker&&(12e4<Date.now()-this._lastUsedTime&&this._stopWorker())},e.prototype._getClient=function(){return this._lastUsedTime=Date.now(),this._client||(this._worker=monaco.editor.createWebWorker({moduleId:"vs/language/json/jsonWorker",label:this._defaults.languageId,createData:{languageSettings:this._defaults.diagnosticsOptions,languageId:this._defaults.languageId}}),this._client=this._worker.getProxy()),this._client},e.prototype.getLanguageServiceWorker=function(){for(var t,e,n,r,o,i=this,a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];return e=this._getClient().then(function(e){t=e}).then(function(e){return i._worker.withSyncedResources(a)}).then(function(e){return t}),o=new u(function(e,t){n=e,r=t},function(){}),e.then(n,r),o},e}();t.WorkerManager=n}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}(function(e,t){"use strict";var a,n,r,o,i,s,u,c,f,l,d,g,h;Object.defineProperty(t,"__esModule",{value:!0}),(n=a=t.Position||(t.Position={})).create=function(e,t){return{line:e,character:t}},n.is=function(e){var t=e;return K.defined(t)&&K.number(t.line)&&K.number(t.character)},(o=r=t.Range||(t.Range={})).create=function(e,t,n,r){if(K.number(e)&&K.number(t)&&K.number(n)&&K.number(r))return{start:a.create(e,t),end:a.create(n,r)};if(a.is(e)&&a.is(t))return{start:e,end:t};throw new Error("Range#create called with invalid arguments["+e+", "+t+", "+n+", "+r+"]")},o.is=function(e){var t=e;return K.defined(t)&&a.is(t.start)&&a.is(t.end)},(i=t.Location||(t.Location={})).create=function(e,t){return{uri:e,range:t}},i.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&(K.string(t.uri)||K.undefined(t.uri))},(s=t.DiagnosticSeverity||(t.DiagnosticSeverity={})).Error=1,s.Warning=2,s.Information=3,s.Hint=4,(c=u=t.Diagnostic||(t.Diagnostic={})).create=function(e,t,n,r,o){var i={range:e,message:t};return K.defined(n)&&(i.severity=n),K.defined(r)&&(i.code=r),K.defined(o)&&(i.source=o),i},c.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&K.string(t.message)&&(K.number(t.severity)||K.undefined(t.severity))&&(K.number(t.code)||K.string(t.code)||K.undefined(t.code))&&(K.string(t.source)||K.undefined(t.source))},(l=f=t.Command||(t.Command={})).create=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o={title:e,command:t};return K.defined(n)&&0<n.length&&(o.arguments=n),o},l.is=function(e){var t=e;return K.defined(t)&&K.string(t.title)&&K.string(t.title)},(g=d=t.TextEdit||(t.TextEdit={})).replace=function(e,t){return{range:e,newText:t}},g.insert=function(e,t){return{range:{start:e,end:e},newText:t}},g.del=function(e){return{range:e,newText:""}},(h=t.TextDocumentEdit||(t.TextDocumentEdit={})).create=function(e,t){return{textDocument:e,edits:t}},h.is=function(e){var t=e;return K.defined(t)&&m.is(t.textDocument)&&Array.isArray(t.edits)};var p,m,v,y,b,k,_,C,E,T,S,O,w=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,t){this.edits.push(d.insert(e,t))},e.prototype.replace=function(e,t){this.edits.push(d.replace(e,t))},e.prototype.delete=function(e){this.edits.push(d.del(e))},e.prototype.add=function(e){this.edits.push(e)},e.prototype.all=function(){return this.edits},e.prototype.clear=function(){this.edits.splice(0,this.edits.length)},e}(),x=function(){function e(n){var r=this;this._textEditChanges=Object.create(null),n&&((this._workspaceEdit=n).documentChanges?n.documentChanges.forEach(function(e){var t=new w(e.edits);r._textEditChanges[e.textDocument.uri]=t}):n.changes&&Object.keys(n.changes).forEach(function(e){var t=new w(n.changes[e]);r._textEditChanges[e]=t}))}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(m.is(e)){if(this._workspaceEdit||(this._workspaceEdit={documentChanges:[]}),!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for versioned document changes.");var t=e;if(!(r=this._textEditChanges[t.uri])){var n={textDocument:t,edits:o=[]};this._workspaceEdit.documentChanges.push(n),r=new w(o),this._textEditChanges[t.uri]=r}return r}if(this._workspaceEdit||(this._workspaceEdit={changes:Object.create(null)}),!this._workspaceEdit.changes)throw new Error("Workspace edit is not configured for normal text edit changes.");var r;if(!(r=this._textEditChanges[e])){var o=[];this._workspaceEdit.changes[e]=o,r=new w(o),this._textEditChanges[e]=r}return r},e}();t.WorkspaceChange=x,(p=t.TextDocumentIdentifier||(t.TextDocumentIdentifier={})).create=function(e){return{uri:e}},p.is=function(e){var t=e;return K.defined(t)&&K.string(t.uri)},(v=m=t.VersionedTextDocumentIdentifier||(t.VersionedTextDocumentIdentifier={})).create=function(e,t){return{uri:e,version:t}},v.is=function(e){var t=e;return K.defined(t)&&K.string(t.uri)&&K.number(t.version)},(y=t.TextDocumentItem||(t.TextDocumentItem={})).create=function(e,t,n,r){return{uri:e,languageId:t,version:n,text:r}},y.is=function(e){var t=e;return K.defined(t)&&K.string(t.uri)&&K.string(t.languageId)&&K.number(t.version)&&K.string(t.text)},(b=t.MarkupKind||(t.MarkupKind={})).PlainText="plaintext",b.Markdown="markdown",(k=t.CompletionItemKind||(t.CompletionItemKind={})).Text=1,k.Method=2,k.Function=3,k.Constructor=4,k.Field=5,k.Variable=6,k.Class=7,k.Interface=8,k.Module=9,k.Property=10,k.Unit=11,k.Value=12,k.Enum=13,k.Keyword=14,k.Snippet=15,k.Color=16,k.File=17,k.Reference=18,k.Folder=19,k.EnumMember=20,k.Constant=21,k.Struct=22,k.Event=23,k.Operator=24,k.TypeParameter=25,(_=t.InsertTextFormat||(t.InsertTextFormat={})).PlainText=1,_.Snippet=2,(t.CompletionItem||(t.CompletionItem={})).create=function(e){return{label:e}},(t.CompletionList||(t.CompletionList={})).create=function(e,t){return{items:e||[],isIncomplete:!!t}},(t.MarkedString||(t.MarkedString={})).fromPlainText=function(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")},(t.ParameterInformation||(t.ParameterInformation={})).create=function(e,t){return t?{label:e,documentation:t}:{label:e}},(t.SignatureInformation||(t.SignatureInformation={})).create=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o={label:e};return K.defined(t)&&(o.documentation=t),K.defined(n)?o.parameters=n:o.parameters=[],o},(C=t.DocumentHighlightKind||(t.DocumentHighlightKind={})).Text=1,C.Read=2,C.Write=3,(t.DocumentHighlight||(t.DocumentHighlight={})).create=function(e,t){var n={range:e};return K.number(t)&&(n.kind=t),n},(E=t.SymbolKind||(t.SymbolKind={})).File=1,E.Module=2,E.Namespace=3,E.Package=4,E.Class=5,E.Method=6,E.Property=7,E.Field=8,E.Constructor=9,E.Enum=10,E.Interface=11,E.Function=12,E.Variable=13,E.Constant=14,E.String=15,E.Number=16,E.Boolean=17,E.Array=18,E.Object=19,E.Key=20,E.Null=21,E.EnumMember=22,E.Struct=23,E.Event=24,E.Operator=25,E.TypeParameter=26,(t.SymbolInformation||(t.SymbolInformation={})).create=function(e,t,n,r,o){var i={name:e,kind:t,location:{uri:r,range:n}};return o&&(i.containerName=o),i},(T=t.CodeActionContext||(t.CodeActionContext={})).create=function(e){return{diagnostics:e}},T.is=function(e){var t=e;return K.defined(t)&&K.typedArray(t.diagnostics,u.is)},(S=t.CodeLens||(t.CodeLens={})).create=function(e,t){var n={range:e};return K.defined(t)&&(n.data=t),n},S.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&(K.undefined(t.command)||f.is(t.command))},(O=t.FormattingOptions||(t.FormattingOptions={})).create=function(e,t){return{tabSize:e,insertSpaces:t}},O.is=function(e){var t=e;return K.defined(t)&&K.number(t.tabSize)&&K.boolean(t.insertSpaces)};var A,I,M,j=function(){};t.DocumentLink=j,(A=j=t.DocumentLink||(t.DocumentLink={})).create=function(e,t){return{range:e,target:t}},A.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&(K.undefined(t.target)||K.string(t.target))},t.DocumentLink=j,t.EOL=["\n","\r\n","\r"],(I=t.TextDocument||(t.TextDocument={})).create=function(e,t,n,r){return new N(e,t,n,r)},I.is=function(e){var t=e;return!!(K.defined(t)&&K.string(t.uri)&&(K.undefined(t.languageId)||K.string(t.languageId))&&K.number(t.lineCount)&&K.func(t.getText)&&K.func(t.positionAt)&&K.func(t.offsetAt))},I.applyEdits=function(e,t){for(var n=e.getText(),r=function e(t,n){if(t.length<=1)return t;var r=t.length/2|0,o=t.slice(0,r),i=t.slice(r);e(o,n),e(i,n);for(var a=0,s=0,u=0;a<o.length&&s<i.length;){var c=n(o[a],i[s]);t[u++]=c<=0?o[a++]:i[s++]}for(;a<o.length;)t[u++]=o[a++];for(;s<i.length;)t[u++]=i[s++];return t}(t,function(e,t){return 0==e.range.start.line-t.range.start.line?e.range.start.character-t.range.start.character:0}),o=n.length,i=r.length-1;0<=i;i--){var a=r[i],s=e.offsetAt(a.range.start),u=e.offsetAt(a.range.end);if(!(u<=o))throw new Error("Ovelapping edit");n=n.substring(0,s)+a.newText+n.substring(u,n.length),o=s}return n},(M=t.TextDocumentSaveReason||(t.TextDocumentSaveReason={})).Manual=1,M.AfterDelay=2,M.FocusOut=3;var K,L,P,N=function(){function e(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=null}return Object.defineProperty(e.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!0,configurable:!0}),e.prototype.getText=function(e){if(e){var t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content},e.prototype.update=function(e,t){this._content=e.text,this._version=t,this._lineOffsets=null},e.prototype.getLineOffsets=function(){if(null===this._lineOffsets){for(var e=[],t=this._content,n=!0,r=0;r<t.length;r++){n&&(e.push(r),n=!1);var o=t.charAt(r);n="\r"===o||"\n"===o,"\r"===o&&r+1<t.length&&"\n"===t.charAt(r+1)&&r++}n&&0<t.length&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets},e.prototype.positionAt=function(e){e=Math.max(Math.min(e,this._content.length),0);var t=this.getLineOffsets(),n=0,r=t.length;if(0===r)return a.create(0,e);for(;n<r;){var o=Math.floor((n+r)/2);t[o]>e?r=o:n=o+1}var i=n-1;return a.create(i,e-t[i])},e.prototype.offsetAt=function(e){var t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;var n=t[e.line],r=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,r),n)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!0,configurable:!0}),e}();L=K||(K={}),P=Object.prototype.toString,L.defined=function(e){return void 0!==e},L.undefined=function(e){return void 0===e},L.boolean=function(e){return!0===e||!1===e},L.string=function(e){return"[object String]"===P.call(e)},L.number=function(e){return"[object Number]"===P.call(e)},L.func=function(e){return"[object Function]"===P.call(e)},L.typedArray=function(e,t){return Array.isArray(e)&&e.every(t)}}),define("vscode-languageserver-types",["vscode-languageserver-types/main"],function(e){return e}),define("vs/language/json/languageFeatures",["require","exports","vscode-languageserver-types"],function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=monaco.Uri,n=monaco.Range,o=function(){function e(e,t){var r=this;this._languageId=e,this._worker=t,this._disposables=[],this._listener=Object.create(null);var n=function(e){var t,n=e.getModeId();n===r._languageId&&(r._listener[e.uri.toString()]=e.onDidChangeContent(function(){clearTimeout(t),t=setTimeout(function(){return r._doValidate(e.uri,n)},500)}),r._doValidate(e.uri,n))},o=function(e){monaco.editor.setModelMarkers(e,r._languageId,[]);var t=e.uri.toString(),n=r._listener[t];n&&(n.dispose(),delete r._listener[t])};this._disposables.push(monaco.editor.onDidCreateModel(n)),this._disposables.push(monaco.editor.onWillDisposeModel(function(e){o(e),r._resetSchema(e.uri)})),this._disposables.push(monaco.editor.onDidChangeModelLanguage(function(e){o(e.model),n(e.model),r._resetSchema(e.model.uri)})),this._disposables.push({dispose:function(){for(var e in r._listener)r._listener[e].dispose()}}),monaco.editor.getModels().forEach(n)}return e.prototype.dispose=function(){this._disposables.forEach(function(e){return e&&e.dispose()}),this._disposables=[]},e.prototype._resetSchema=function(t){this._worker().then(function(e){e.resetSchema(t.toString())})},e.prototype._doValidate=function(r,o){this._worker(r).then(function(e){return e.doValidation(r.toString()).then(function(e){var t=e.map(function(e){return n="number"==typeof(t=e).code?String(t.code):t.code,{severity:function(e){switch(e){case i.DiagnosticSeverity.Error:return monaco.MarkerSeverity.Error;case i.DiagnosticSeverity.Warning:return monaco.MarkerSeverity.Warning;case i.DiagnosticSeverity.Information:return monaco.MarkerSeverity.Info;case i.DiagnosticSeverity.Hint:return monaco.MarkerSeverity.Hint;default:return monaco.MarkerSeverity.Info}}(t.severity),startLineNumber:t.range.start.line+1,startColumn:t.range.start.character+1,endLineNumber:t.range.end.line+1,endColumn:t.range.end.character+1,message:t.message,code:n,source:t.source};var t,n}),n=monaco.editor.getModel(r);n.getModeId()===o&&monaco.editor.setModelMarkers(n,o,t)})}).then(void 0,function(e){console.error(e)})},e}();function a(e){if(e)return{character:e.column-1,line:e.lineNumber-1}}function s(e){if(e)return{start:a(e.getStartPosition()),end:a(e.getEndPosition())}}function u(e){if(e)return new n(e.start.line+1,e.start.character+1,e.end.line+1,e.end.character+1)}function c(e){var t=monaco.languages.CompletionItemKind;switch(e){case i.CompletionItemKind.Text:return t.Text;case i.CompletionItemKind.Method:return t.Method;case i.CompletionItemKind.Function:return t.Function;case i.CompletionItemKind.Constructor:return t.Constructor;case i.CompletionItemKind.Field:return t.Field;case i.CompletionItemKind.Variable:return t.Variable;case i.CompletionItemKind.Class:return t.Class;case i.CompletionItemKind.Interface:return t.Interface;case i.CompletionItemKind.Module:return t.Module;case i.CompletionItemKind.Property:return t.Property;case i.CompletionItemKind.Unit:return t.Unit;case i.CompletionItemKind.Value:return t.Value;case i.CompletionItemKind.Enum:return t.Enum;case i.CompletionItemKind.Keyword:return t.Keyword;case i.CompletionItemKind.Snippet:return t.Snippet;case i.CompletionItemKind.Color:return t.Color;case i.CompletionItemKind.File:return t.File;case i.CompletionItemKind.Reference:return t.Reference}return t.Property}function f(e){if(e)return{range:u(e.range),text:e.newText}}t.DiagnostcsAdapter=o;var l=function(){function e(e){this._worker=e}return Object.defineProperty(e.prototype,"triggerCharacters",{get:function(){return[" ",":"]},enumerable:!0,configurable:!0}),e.prototype.provideCompletionItems=function(e,t,n){e.getWordUntilPosition(t);var r=e.uri;return y(n,this._worker(r).then(function(e){return e.doComplete(r.toString(),a(t))}).then(function(e){if(e){var t=e.items.map(function(e){var t={label:e.label,insertText:e.insertText,sortText:e.sortText,filterText:e.filterText,documentation:e.documentation,detail:e.detail,kind:c(e.kind)};return e.textEdit&&(t.range=u(e.textEdit.range),t.insertText=e.textEdit.newText),e.insertTextFormat===i.InsertTextFormat.Snippet&&(t.insertText={value:t.insertText}),t});return{isIncomplete:e.isIncomplete,items:t}}}))},e}();function d(e){return"string"==typeof e?{value:e}:(t=e)&&"object"==typeof t&&"string"==typeof t.kind?"plaintext"===e.kind?{value:e.value.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}:{value:e.value}:{value:"```"+e.language+"\n"+e.value+"\n```\n"};var t}t.CompletionAdapter=l;var g=function(){function e(e){this._worker=e}return e.prototype.provideHover=function(e,t,n){var r=e.uri;return y(n,this._worker(r).then(function(e){return e.doHover(r.toString(),a(t))}).then(function(e){if(e)return{range:u(e.range),contents:function(e){if(e)return Array.isArray(e)?e.map(d):[d(e)]}(e.contents)}}))},e}();t.HoverAdapter=g;var h=function(){function e(e){this._worker=e}return e.prototype.provideDocumentSymbols=function(e,t){var n=e.uri;return y(t,this._worker(n).then(function(e){return e.findDocumentSymbols(n.toString())}).then(function(e){if(e)return e.map(function(e){return{name:e.name,containerName:e.containerName,kind:function(e){var t=monaco.languages.SymbolKind;switch(e){case i.SymbolKind.File:return t.Array;case i.SymbolKind.Module:return t.Module;case i.SymbolKind.Namespace:return t.Namespace;case i.SymbolKind.Package:return t.Package;case i.SymbolKind.Class:return t.Class;case i.SymbolKind.Method:return t.Method;case i.SymbolKind.Property:return t.Property;case i.SymbolKind.Field:return t.Field;case i.SymbolKind.Constructor:return t.Constructor;case i.SymbolKind.Enum:return t.Enum;case i.SymbolKind.Interface:return t.Interface;case i.SymbolKind.Function:return t.Function;case i.SymbolKind.Variable:return t.Variable;case i.SymbolKind.Constant:return t.Constant;case i.SymbolKind.String:return t.String;case i.SymbolKind.Number:return t.Number;case i.SymbolKind.Boolean:return t.Boolean;case i.SymbolKind.Array:return t.Array}return t.Function}(e.kind),location:(t=e.location,{uri:r.parse(t.uri),range:u(t.range)})};var t})}))},e}();function p(e){return{tabSize:e.tabSize,insertSpaces:e.insertSpaces}}t.DocumentSymbolAdapter=h;var m=function(){function e(e){this._worker=e}return e.prototype.provideDocumentFormattingEdits=function(e,t,n){var r=e.uri;return y(n,this._worker(r).then(function(e){return e.format(r.toString(),null,p(t)).then(function(e){if(e&&0!==e.length)return e.map(f)})}))},e}();t.DocumentFormattingEditProvider=m;var v=function(){function e(e){this._worker=e}return e.prototype.provideDocumentRangeFormattingEdits=function(e,t,n,r){var o=e.uri;return y(r,this._worker(o).then(function(e){return e.format(o.toString(),s(t),p(n)).then(function(e){if(e&&0!==e.length)return e.map(f)})}))},e}();function y(e,t){return t.cancel&&e.onCancellationRequested(function(){return t.cancel()}),t}t.DocumentRangeFormattingEditProvider=v}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/scanner",["require","exports"],e)}(function(e,t){"use strict";function d(e){return 32===e||9===e||11===e||12===e||160===e||5760===e||8192<=e&&e<=8203||8239===e||8287===e||12288===e||65279===e}function g(e){return 10===e||13===e||8232===e||8233===e}function h(e){return 48<=e&&e<=57}Object.defineProperty(t,"__esModule",{value:!0}),t.createScanner=function(i,e){void 0===e&&(e=!1);var a=0,o=i.length,r="",s=0,u=16,c=0;function f(e,t){for(var n=0,r=0;n<e||!t;){var o=i.charCodeAt(a);if(48<=o&&o<=57)r=16*r+o-48;else if(65<=o&&o<=70)r=16*r+o-65+10;else{if(!(97<=o&&o<=102))break;r=16*r+o-97+10}a++,n++}return n<e&&(r=-1),r}function t(){if(r="",c=0,o<=(s=a))return s=o,u=17;var e=i.charCodeAt(a);if(d(e)){for(;a++,r+=String.fromCharCode(e),d(e=i.charCodeAt(a)););return u=15}if(g(e))return a++,r+=String.fromCharCode(e),13===e&&10===i.charCodeAt(a)&&(a++,r+="\n"),u=14;switch(e){case 123:return a++,u=1;case 125:return a++,u=2;case 91:return a++,u=3;case 93:return a++,u=4;case 58:return a++,u=6;case 44:return a++,u=5;case 34:return a++,r=function(){for(var e="",t=a;;){if(o<=a){e+=i.substring(t,a),c=2;break}var n=i.charCodeAt(a);if(34===n){e+=i.substring(t,a),a++;break}if(92!==n){if(0<=n&&n<=31){if(g(n)){e+=i.substring(t,a),c=2;break}c=6}a++}else{if(e+=i.substring(t,a),o<=++a){c=2;break}switch(n=i.charCodeAt(a++)){case 34:e+='"';break;case 92:e+="\\";break;case 47:e+="/";break;case 98:e+="\b";break;case 102:e+="\f";break;case 110:e+="\n";break;case 114:e+="\r";break;case 116:e+="\t";break;case 117:var r=f(4,!0);0<=r?e+=String.fromCharCode(r):c=4;break;default:c=5}t=a}}return e}(),u=10;case 47:var t=a-1;if(47===i.charCodeAt(a+1)){for(a+=2;a<o&&!g(i.charCodeAt(a));)a++;return r=i.substring(t,a),u=12}if(42===i.charCodeAt(a+1)){a+=2;for(var n=!1;a<o;){if(42===i.charCodeAt(a)&&a+1<o&&47===i.charCodeAt(a+1)){a+=2,n=!0;break}a++}return n||(a++,c=1),r=i.substring(t,a),u=13}return r+=String.fromCharCode(e),a++,u=16;case 45:if(r+=String.fromCharCode(e),++a===o||!h(i.charCodeAt(a)))return u=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=function(){var e=a;if(48===i.charCodeAt(a))a++;else for(a++;a<i.length&&h(i.charCodeAt(a));)a++;if(a<i.length&&46===i.charCodeAt(a)){if(!(++a<i.length&&h(i.charCodeAt(a))))return c=3,i.substring(e,a);for(a++;a<i.length&&h(i.charCodeAt(a));)a++}var t=a;if(a<i.length&&(69===i.charCodeAt(a)||101===i.charCodeAt(a)))if((++a<i.length&&43===i.charCodeAt(a)||45===i.charCodeAt(a))&&a++,a<i.length&&h(i.charCodeAt(a))){for(a++;a<i.length&&h(i.charCodeAt(a));)a++;t=a}else c=3;return i.substring(e,t)}(),u=11;default:for(;a<o&&l(e);)a++,e=i.charCodeAt(a);if(s!==a){switch(r=i.substring(s,a)){case"true":return u=8;case"false":return u=9;case"null":return u=7}return u=16}return r+=String.fromCharCode(e),a++,u=16}}function l(e){if(d(e)||g(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:return!1}return!0}return{setPosition:function(e){a=e,r="",u=16,c=s=0},getPosition:function(){return a},scan:e?function(){for(var e;12<=(e=t())&&e<=15;);return e}:t,getToken:function(){return u},getTokenValue:function(){return r},getTokenOffset:function(){return s},getTokenLength:function(){return a-s},getTokenError:function(){return c}}}}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/format",["require","exports","./scanner"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var T=e("./scanner");function S(e,t){for(var n="",r=0;r<t;r++)n+=e;return n}function O(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}t.format=function(r,e,t){var n,o,i,a,s;if(e){for(a=e.offset,s=a+e.length,i=a;0<i&&!O(r,i-1);)i--;for(var u=s;u<r.length&&!O(r,u);)u++;o=r.substring(i,u),n=function(e,t,n){for(var r=0,o=0,i=n.tabSize||4;r<e.length;){var a=e.charAt(r);if(" "===a)o++;else{if("\t"!==a)break;o+=i}r++}return Math.floor(o/i)}(o,0,t)}else a=i=n=0,s=(o=r).length;var c,f=function(e,t){for(var n=0;n<t.length;n++){var r=t.charAt(n);if("\r"===r)return n+1<t.length&&"\n"===t.charAt(n+1)?"\r\n":"\r";if("\n"===r)return"\n"}return e&&e.eol||"\n"}(t,r),l=!1,d=0;c=t.insertSpaces?S(" ",t.tabSize||4):"\t";var g=T.createScanner(o,!1),h=!1;function p(){return f+S(c,n+d)}function m(){var e=g.scan();for(l=!1;15===e||14===e;)l=l||14===e,e=g.scan();return h=16===e||0!==g.getTokenError(),e}var v=[];function y(e,t,n){!h&&t<s&&a<n&&r.substring(t,n)!==e&&v.push({offset:t,length:n-t,content:e})}var b=m();if(17!==b){var k=g.getTokenOffset()+i;y(S(c,n),i,k)}for(;17!==b;){for(var _=g.getTokenOffset()+g.getTokenLength()+i,C=m(),E="";!l&&(12===C||13===C);)y(" ",_,g.getTokenOffset()+i),_=g.getTokenOffset()+g.getTokenLength()+i,E=12===C?p():"",C=m();if(2===C)1!==b&&(d--,E=p());else if(4===C)3!==b&&(d--,E=p());else{switch(b){case 3:case 1:d++,E=p();break;case 5:case 12:E=p();break;case 13:E=l?p():" ";break;case 6:E=" ";break;case 10:if(6===C){E="";break}case 7:case 8:case 9:case 11:case 2:case 4:12===C||13===C?E=" ":5!==C&&17!==C&&(h=!0);break;case 16:h=!0}!l||12!==C&&13!==C||(E=p())}y(E,_,g.getTokenOffset()+i),b=C}return v},t.isEOL=O}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/parser",["require","exports","./scanner"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var _=e("./scanner");function f(e,t,n){var o=_.createScanner(e,!1);function r(e){return e?function(){return e(o.getTokenOffset(),o.getTokenLength())}:function(){return!0}}function i(t){return t?function(e){return t(e,o.getTokenOffset(),o.getTokenLength())}:function(){return!0}}var a=r(t.onObjectBegin),s=i(t.onObjectProperty),u=r(t.onObjectEnd),c=r(t.onArrayBegin),f=r(t.onArrayEnd),l=i(t.onLiteralValue),d=i(t.onSeparator),g=r(t.onComment),h=i(t.onError),p=n&&n.disallowComments,m=n&&n.allowTrailingComma;function v(){for(;;){var e=o.scan();switch(o.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:p||y(11);break;case 2:y(12);break;case 6:y(16)}switch(e){case 12:case 13:p?y(10):g();break;case 16:y(1);break;case 15:case 14:break;default:return e}}}function y(e,t,n){if(void 0===t&&(t=[]),void 0===n&&(n=[]),h(e),0<t.length+n.length)for(var r=o.getToken();17!==r;){if(-1!==t.indexOf(r)){v();break}if(-1!==n.indexOf(r))break;r=v()}}function b(e){var t=o.getTokenValue();return e?l(t):s(t),v(),!0}function k(){switch(o.getToken()){case 3:return function(){c(),v();for(var e=!1;4!==o.getToken()&&17!==o.getToken();){if(5===o.getToken()){if(e||y(4,[],[]),d(","),v(),4===o.getToken()&&m)break}else e&&y(6,[],[]);k()||y(4,[],[4,5]),e=!0}return f(),4!==o.getToken()?y(8,[4],[]):v(),!0}();case 1:return function(){a(),v();for(var e=!1;2!==o.getToken()&&17!==o.getToken();){if(5===o.getToken()){if(e||y(4,[],[]),d(","),v(),2===o.getToken()&&m)break}else e&&y(6,[],[]);(10!==o.getToken()?(y(3,[],[2,5]),0):(b(!1),6===o.getToken()?(d(":"),v(),k()||y(4,[],[2,5])):y(5,[],[2,5]),1))||y(4,[],[2,5]),e=!0}return u(),2!==o.getToken()?y(7,[2],[]):v(),!0}();case 10:return b(!0);default:return function(){switch(o.getToken()){case 11:var e=0;try{"number"!=typeof(e=JSON.parse(o.getTokenValue()))&&(y(2),e=0)}catch(e){y(2)}l(e);break;case 7:l(null);break;case 8:l(!0);break;case 9:l(!1);break;default:return!1}return v(),!0}()}}return v(),17===o.getToken()||(k()?(17!==o.getToken()&&y(9,[],[]),!0):(y(4,[],[]),!1))}function l(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return"null"}}t.getLocation=function(e,o){var i=[],a=new Object,s=void 0,u={value:{},offset:0,length:0,type:"object"},c=!1;function r(e,t,n,r){u.value=e,u.offset=t,u.length=n,u.type=r,u.columnOffset=void 0,s=u}try{f(e,{onObjectBegin:function(e,t){if(o<=e)throw a;s=void 0,c=e<o,i.push("")},onObjectProperty:function(e,t,n){if(o<t)throw a;if(r(e,t,n,"property"),i[i.length-1]=e,o<=t+n)throw a},onObjectEnd:function(e,t){if(o<=e)throw a;s=void 0,i.pop()},onArrayBegin:function(e,t){if(o<=e)throw a;s=void 0,i.push(0)},onArrayEnd:function(e,t){if(o<=e)throw a;s=void 0,i.pop()},onLiteralValue:function(e,t,n){if(o<t)throw a;if(r(e,t,n,l(e)),o<=t+n)throw a},onSeparator:function(e,t,n){if(o<=t)throw a;if(":"===e&&s&&"property"===s.type)s.columnOffset=t,c=!1,s=void 0;else if(","===e){var r=i[i.length-1];"number"==typeof r?i[i.length-1]=r+1:(c=!0,i[i.length-1]=""),s=void 0}}})}catch(e){if(e!==a)throw e}return{path:i,previousNode:s,isAtPropertyKey:c,matches:function(e){for(var t=0,n=0;t<e.length&&n<i.length;n++)if(e[t]===i[n]||"*"===e[t])t++;else if("**"!==e[t])return!1;return t===e.length}}},t.parse=function(e,r,t){void 0===r&&(r=[]);var n=null,o=[],i=[];function a(e){Array.isArray(o)?o.push(e):n&&(o[n]=e)}return f(e,{onObjectBegin:function(){var e={};a(e),i.push(o),o=e,n=null},onObjectProperty:function(e){n=e},onObjectEnd:function(){o=i.pop()},onArrayBegin:function(){var e=[];a(e),i.push(o),o=e,n=null},onArrayEnd:function(){o=i.pop()},onLiteralValue:a,onError:function(e,t,n){r.push({error:e,offset:t,length:n})}},t),o[0]},t.parseTree=function(e,r,t){void 0===r&&(r=[]);var o={type:"array",offset:-1,length:-1,children:[]};function i(e){"property"===o.type&&(o.length=e-o.offset,o=o.parent)}function a(e){return o.children.push(e),e}f(e,{onObjectBegin:function(e){o=a({type:"object",offset:e,length:-1,parent:o,children:[]})},onObjectProperty:function(e,t,n){(o=a({type:"property",offset:t,length:-1,parent:o,children:[]})).children.push({type:"string",value:e,offset:t,length:n,parent:o})},onObjectEnd:function(e,t){o.length=e+t-o.offset,o=o.parent,i(e+t)},onArrayBegin:function(e,t){o=a({type:"array",offset:e,length:-1,parent:o,children:[]})},onArrayEnd:function(e,t){o.length=e+t-o.offset,o=o.parent,i(e+t)},onLiteralValue:function(e,t,n){a({type:l(e),offset:t,length:n,parent:o,value:e}),i(t+n)},onSeparator:function(e,t,n){"property"===o.type&&(":"===e?o.columnOffset=t:","===e&&i(t))},onError:function(e,t,n){r.push({error:e,offset:t,length:n})}},t);var n=o.children[0];return n&&delete n.parent,n},t.findNodeAtLocation=function(e,t){if(e){for(var n=e,r=0,o=t;r<o.length;r++){var i=o[r];if("string"==typeof i){if("object"!==n.type||!Array.isArray(n.children))return;for(var a=!1,s=0,u=n.children;s<u.length;s++){var c=u[s];if(Array.isArray(c.children)&&c.children[0].value===i){n=c.children[1],a=!0;break}}if(!a)return}else{var f=i;if("array"!==n.type||f<0||!Array.isArray(n.children)||f>=n.children.length)return;n=n.children[f]}}return n}},t.getNodeValue=function e(t){if("array"===t.type)return t.children.map(e);if("object"===t.type){for(var n=Object.create(null),r=0,o=t.children;r<o.length;r++){var i=o[r];n[i.children[0].value]=e(i.children[1])}return n}return t.value},t.visit=f,t.stripComments=function(e,t){var n,r,o=_.createScanner(e),i=[],a=0;do{switch(r=o.getPosition(),n=o.scan()){case 12:case 13:case 17:a!==r&&i.push(e.substring(a,r)),void 0!==t&&i.push(o.getTokenValue().replace(/[^\r\n]/g,t)),a=o.getPosition()}}while(17!==n);return i.join("")}}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/edit",["require","exports","./format","./parser"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var c=e("./format"),k=e("./parser");function r(e,t,n,r,o){for(var i,a=k.parseTree(e,[]),s=void 0,u=void 0;0<t.length&&(u=t.pop(),void 0===(s=k.findNodeAtLocation(a,t))&&void 0!==n);)"string"==typeof u?((i={})[u]=n,n=i):n=[n];if(s){if("object"===s.type&&"string"==typeof u&&Array.isArray(s.children)){var c=k.findNodeAtLocation(s,[u]);if(void 0!==c){if(void 0===n){if(!c.parent)throw new Error("Malformed AST");var f=s.children.indexOf(c.parent),l=void 0,d=c.parent.offset+c.parent.length;if(0<f)l=(y=s.children[f-1]).offset+y.length;else if(l=s.offset+1,1<s.children.length)d=s.children[1].offset;return _(e,{offset:l,length:d-l,content:""},r)}return _(e,{offset:c.offset,length:c.length,content:JSON.stringify(n)},r)}if(void 0===n)return[];var g=JSON.stringify(u)+": "+JSON.stringify(n),h=o?o(s.children.map(function(e){return e.children[0].value})):s.children.length,p=void 0;return _(e,p=0<h?{offset:(y=s.children[h-1]).offset+y.length,length:0,content:","+g}:0===s.children.length?{offset:s.offset+1,length:0,content:g}:{offset:s.offset+1,length:0,content:g+","},r)}if("array"===s.type&&"number"==typeof u&&Array.isArray(s.children)){if(-1===u){g=""+JSON.stringify(n),p=void 0;if(0===s.children.length)p={offset:s.offset+1,length:0,content:g};else p={offset:(y=s.children[s.children.length-1]).offset+y.length,length:0,content:","+g};return _(e,p,r)}if(void 0===n&&0<=s.children.length){var m=u,v=s.children[m];p=void 0;if(1===s.children.length)p={offset:s.offset+1,length:s.length-2,content:""};else if(s.children.length-1===m){var y,b=(y=s.children[m-1]).offset+y.length;p={offset:b,length:s.offset+s.length-2-b,content:""}}else p={offset:v.offset,length:s.children[m+1].offset-v.offset,content:""};return _(e,p,r)}throw new Error("Array modification not supported yet")}throw new Error("Can not add "+("number"!=typeof u?"index":"property")+" to parent of type "+s.type)}if(void 0===n)throw new Error("Can not delete in empty document");return _(e,{offset:a?a.offset:0,length:a?a.length:0,content:JSON.stringify(n)},r)}function _(e,t,n){var r=f(e,t),o=t.offset,i=t.offset+t.content.length;if(0===t.length||0===t.content.length){for(;0<o&&!c.isEOL(r,o-1);)o--;for(;i<r.length&&!c.isEOL(r,i);)i++}for(var a=c.format(r,{offset:o,length:i-o},n),s=a.length-1;0<=s;s--){var u=a[s];r=f(r,u),o=Math.min(o,u.offset),i=Math.max(i,u.offset+u.length),i+=u.content.length-u.length}return[{offset:o,length:e.length-(r.length-i)-o,content:r.substring(o,i)}]}function f(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}t.removeProperty=function(e,t,n){return r(e,t,void 0,n)},t.setProperty=r,t.applyEdit=f,t.isWS=function(e,t){return-1!=="\r\n \t".indexOf(e.charAt(t))}}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/main",["require","exports","./impl/format","./impl/edit","./impl/scanner","./impl/parser"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=e("./impl/format"),o=e("./impl/edit"),n=e("./impl/scanner"),i=e("./impl/parser");t.createScanner=n.createScanner,t.getLocation=i.getLocation,t.parse=i.parse,t.parseTree=i.parseTree,t.findNodeAtLocation=i.findNodeAtLocation,t.getNodeValue=i.getNodeValue,t.visit=i.visit,t.stripComments=i.stripComments,t.format=function(e,t,n){return r.format(e,t,n)},t.modify=function(e,t,n,r){return o.setProperty(e,t,n,r.formattingOptions,r.getInsertionIndex)},t.applyEdits=function(e,t){for(var n=t.length-1;0<=n;n--)e=o.applyEdit(e,t[n]);return e}}),define("jsonc-parser",["jsonc-parser/main"],function(e){return e}),define("vs/language/json/tokenization",["require","exports","jsonc-parser"],function(e,g,h){"use strict";Object.defineProperty(g,"__esModule",{value:!0}),g.createTokenizationSupport=function(o){return{getInitialState:function(){return new p(null,null,!1)},tokenize:function(e,t,n,r){return function(e,t,n,r,o){void 0===r&&(r=0);var i=0,a=!1;switch(n.scanError){case 2:t='"'+t,i=1;break;case 1:t="/*"+t,i=2}var s,u,c=h.createScanner(t),f=n.lastWasColon;for(u={tokens:[],endState:n.clone()};;){var l=r+c.getPosition(),d="";if(17===(s=c.scan()))break;if(l===r+c.getPosition())throw new Error("Scanner did not advance, next 3 characters are: "+t.substr(c.getPosition(),3));switch(a&&(l-=i),a=0<i,s){case 1:case 2:d=g.TOKEN_DELIM_OBJECT,f=!1;break;case 3:case 4:d=g.TOKEN_DELIM_ARRAY,f=!1;break;case 6:d=g.TOKEN_DELIM_COLON,f=!0;break;case 5:d=g.TOKEN_DELIM_COMMA,f=!1;break;case 8:case 9:d=g.TOKEN_VALUE_BOOLEAN,f=!1;break;case 7:d=g.TOKEN_VALUE_NULL,f=!1;break;case 10:d=f?g.TOKEN_VALUE_STRING:g.TOKEN_PROPERTY_NAME,f=!1;break;case 11:d=g.TOKEN_VALUE_NUMBER,f=!1}if(e)switch(s){case 12:d=g.TOKEN_COMMENT_LINE;break;case 13:d=g.TOKEN_COMMENT_BLOCK}u.endState=new p(n.getStateData(),c.getTokenError(),f),u.tokens.push({startIndex:l,scopes:d})}return u}(o,e,t,n)}}},g.TOKEN_DELIM_OBJECT="delimiter.bracket.json",g.TOKEN_DELIM_ARRAY="delimiter.array.json",g.TOKEN_DELIM_COLON="delimiter.colon.json",g.TOKEN_DELIM_COMMA="delimiter.comma.json",g.TOKEN_VALUE_BOOLEAN="keyword.json",g.TOKEN_VALUE_NULL="keyword.json",g.TOKEN_VALUE_STRING="string.value.json",g.TOKEN_VALUE_NUMBER="number.json",g.TOKEN_PROPERTY_NAME="string.key.json",g.TOKEN_COMMENT_BLOCK="comment.block.json",g.TOKEN_COMMENT_LINE="comment.line.json";var p=function(){function t(e,t,n){this._state=e,this.scanError=t,this.lastWasColon=n}return t.prototype.clone=function(){return new t(this._state,this.scanError,this.lastWasColon)},t.prototype.equals=function(e){return e===this||!!(e&&e instanceof t)&&(this.scanError===e.scanError&&this.lastWasColon===e.lastWasColon)},t.prototype.getStateData=function(){return this._state},t.prototype.setStateData=function(e){this._state=e},t}()}),define("vs/language/json/jsonMode",["require","exports","./workerManager","./languageFeatures","./tokenization"],function(e,t,i,a,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupMode=function(e){var t=[],n=new i.WorkerManager(e);t.push(n);var r=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.getLanguageServiceWorker.apply(n,e)},o=e.languageId;t.push(monaco.languages.registerCompletionItemProvider(o,new a.CompletionAdapter(r))),t.push(monaco.languages.registerHoverProvider(o,new a.HoverAdapter(r))),t.push(monaco.languages.registerDocumentSymbolProvider(o,new a.DocumentSymbolAdapter(r))),t.push(monaco.languages.registerDocumentFormattingEditProvider(o,new a.DocumentFormattingEditProvider(r))),t.push(monaco.languages.registerDocumentRangeFormattingEditProvider(o,new a.DocumentRangeFormattingEditProvider(r))),t.push(new a.DiagnostcsAdapter(o,r)),t.push(monaco.languages.setTokensProvider(o,s.createTokenizationSupport(!0))),t.push(monaco.languages.setLanguageConfiguration(o,u))};var u={wordPattern:/(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"]],autoClosingPairs:[{open:"{",close:"}",notIn:["string"]},{open:"[",close:"]",notIn:["string"]},{open:'"',close:'"',notIn:["string"]}]}}); | ||
define("vs/language/json/workerManager",["require","exports"],function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var u=monaco.Promise,n=function(){function e(e){var t=this;this._defaults=e,this._worker=null,this._idleCheckInterval=setInterval(function(){return t._checkIfIdle()},3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(function(){return t._stopWorker()})}return e.prototype._stopWorker=function(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null},e.prototype.dispose=function(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()},e.prototype._checkIfIdle=function(){this._worker&&(12e4<Date.now()-this._lastUsedTime&&this._stopWorker())},e.prototype._getClient=function(){return this._lastUsedTime=Date.now(),this._client||(this._worker=monaco.editor.createWebWorker({moduleId:"vs/language/json/jsonWorker",label:this._defaults.languageId,createData:{languageSettings:this._defaults.diagnosticsOptions,languageId:this._defaults.languageId}}),this._client=this._worker.getProxy()),this._client},e.prototype.getLanguageServiceWorker=function(){for(var t,e,n,r,o,i=this,a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];return e=this._getClient().then(function(e){t=e}).then(function(e){return i._worker.withSyncedResources(a)}).then(function(e){return t}),o=new u(function(e,t){n=e,r=t},function(){}),e.then(n,r),o},e}();t.WorkerManager=n}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}(function(e,t){"use strict";var a,n,r,o,i,s,u,c,f,l,d,g,h;Object.defineProperty(t,"__esModule",{value:!0}),(n=a=t.Position||(t.Position={})).create=function(e,t){return{line:e,character:t}},n.is=function(e){var t=e;return K.defined(t)&&K.number(t.line)&&K.number(t.character)},(o=r=t.Range||(t.Range={})).create=function(e,t,n,r){if(K.number(e)&&K.number(t)&&K.number(n)&&K.number(r))return{start:a.create(e,t),end:a.create(n,r)};if(a.is(e)&&a.is(t))return{start:e,end:t};throw new Error("Range#create called with invalid arguments["+e+", "+t+", "+n+", "+r+"]")},o.is=function(e){var t=e;return K.defined(t)&&a.is(t.start)&&a.is(t.end)},(i=t.Location||(t.Location={})).create=function(e,t){return{uri:e,range:t}},i.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&(K.string(t.uri)||K.undefined(t.uri))},(s=t.DiagnosticSeverity||(t.DiagnosticSeverity={})).Error=1,s.Warning=2,s.Information=3,s.Hint=4,(c=u=t.Diagnostic||(t.Diagnostic={})).create=function(e,t,n,r,o){var i={range:e,message:t};return K.defined(n)&&(i.severity=n),K.defined(r)&&(i.code=r),K.defined(o)&&(i.source=o),i},c.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&K.string(t.message)&&(K.number(t.severity)||K.undefined(t.severity))&&(K.number(t.code)||K.string(t.code)||K.undefined(t.code))&&(K.string(t.source)||K.undefined(t.source))},(l=f=t.Command||(t.Command={})).create=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o={title:e,command:t};return K.defined(n)&&0<n.length&&(o.arguments=n),o},l.is=function(e){var t=e;return K.defined(t)&&K.string(t.title)&&K.string(t.title)},(g=d=t.TextEdit||(t.TextEdit={})).replace=function(e,t){return{range:e,newText:t}},g.insert=function(e,t){return{range:{start:e,end:e},newText:t}},g.del=function(e){return{range:e,newText:""}},(h=t.TextDocumentEdit||(t.TextDocumentEdit={})).create=function(e,t){return{textDocument:e,edits:t}},h.is=function(e){var t=e;return K.defined(t)&&m.is(t.textDocument)&&Array.isArray(t.edits)};var p,m,v,y,b,k,_,C,E,T,S,w,O=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,t){this.edits.push(d.insert(e,t))},e.prototype.replace=function(e,t){this.edits.push(d.replace(e,t))},e.prototype.delete=function(e){this.edits.push(d.del(e))},e.prototype.add=function(e){this.edits.push(e)},e.prototype.all=function(){return this.edits},e.prototype.clear=function(){this.edits.splice(0,this.edits.length)},e}(),x=function(){function e(n){var r=this;this._textEditChanges=Object.create(null),n&&((this._workspaceEdit=n).documentChanges?n.documentChanges.forEach(function(e){var t=new O(e.edits);r._textEditChanges[e.textDocument.uri]=t}):n.changes&&Object.keys(n.changes).forEach(function(e){var t=new O(n.changes[e]);r._textEditChanges[e]=t}))}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(m.is(e)){if(this._workspaceEdit||(this._workspaceEdit={documentChanges:[]}),!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for versioned document changes.");var t=e;if(!(r=this._textEditChanges[t.uri])){var n={textDocument:t,edits:o=[]};this._workspaceEdit.documentChanges.push(n),r=new O(o),this._textEditChanges[t.uri]=r}return r}if(this._workspaceEdit||(this._workspaceEdit={changes:Object.create(null)}),!this._workspaceEdit.changes)throw new Error("Workspace edit is not configured for normal text edit changes.");var r;if(!(r=this._textEditChanges[e])){var o=[];this._workspaceEdit.changes[e]=o,r=new O(o),this._textEditChanges[e]=r}return r},e}();t.WorkspaceChange=x,(p=t.TextDocumentIdentifier||(t.TextDocumentIdentifier={})).create=function(e){return{uri:e}},p.is=function(e){var t=e;return K.defined(t)&&K.string(t.uri)},(v=m=t.VersionedTextDocumentIdentifier||(t.VersionedTextDocumentIdentifier={})).create=function(e,t){return{uri:e,version:t}},v.is=function(e){var t=e;return K.defined(t)&&K.string(t.uri)&&K.number(t.version)},(y=t.TextDocumentItem||(t.TextDocumentItem={})).create=function(e,t,n,r){return{uri:e,languageId:t,version:n,text:r}},y.is=function(e){var t=e;return K.defined(t)&&K.string(t.uri)&&K.string(t.languageId)&&K.number(t.version)&&K.string(t.text)},(b=t.MarkupKind||(t.MarkupKind={})).PlainText="plaintext",b.Markdown="markdown",(k=t.CompletionItemKind||(t.CompletionItemKind={})).Text=1,k.Method=2,k.Function=3,k.Constructor=4,k.Field=5,k.Variable=6,k.Class=7,k.Interface=8,k.Module=9,k.Property=10,k.Unit=11,k.Value=12,k.Enum=13,k.Keyword=14,k.Snippet=15,k.Color=16,k.File=17,k.Reference=18,k.Folder=19,k.EnumMember=20,k.Constant=21,k.Struct=22,k.Event=23,k.Operator=24,k.TypeParameter=25,(_=t.InsertTextFormat||(t.InsertTextFormat={})).PlainText=1,_.Snippet=2,(t.CompletionItem||(t.CompletionItem={})).create=function(e){return{label:e}},(t.CompletionList||(t.CompletionList={})).create=function(e,t){return{items:e||[],isIncomplete:!!t}},(t.MarkedString||(t.MarkedString={})).fromPlainText=function(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")},(t.ParameterInformation||(t.ParameterInformation={})).create=function(e,t){return t?{label:e,documentation:t}:{label:e}},(t.SignatureInformation||(t.SignatureInformation={})).create=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o={label:e};return K.defined(t)&&(o.documentation=t),K.defined(n)?o.parameters=n:o.parameters=[],o},(C=t.DocumentHighlightKind||(t.DocumentHighlightKind={})).Text=1,C.Read=2,C.Write=3,(t.DocumentHighlight||(t.DocumentHighlight={})).create=function(e,t){var n={range:e};return K.number(t)&&(n.kind=t),n},(E=t.SymbolKind||(t.SymbolKind={})).File=1,E.Module=2,E.Namespace=3,E.Package=4,E.Class=5,E.Method=6,E.Property=7,E.Field=8,E.Constructor=9,E.Enum=10,E.Interface=11,E.Function=12,E.Variable=13,E.Constant=14,E.String=15,E.Number=16,E.Boolean=17,E.Array=18,E.Object=19,E.Key=20,E.Null=21,E.EnumMember=22,E.Struct=23,E.Event=24,E.Operator=25,E.TypeParameter=26,(t.SymbolInformation||(t.SymbolInformation={})).create=function(e,t,n,r,o){var i={name:e,kind:t,location:{uri:r,range:n}};return o&&(i.containerName=o),i},(T=t.CodeActionContext||(t.CodeActionContext={})).create=function(e){return{diagnostics:e}},T.is=function(e){var t=e;return K.defined(t)&&K.typedArray(t.diagnostics,u.is)},(S=t.CodeLens||(t.CodeLens={})).create=function(e,t){var n={range:e};return K.defined(t)&&(n.data=t),n},S.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&(K.undefined(t.command)||f.is(t.command))},(w=t.FormattingOptions||(t.FormattingOptions={})).create=function(e,t){return{tabSize:e,insertSpaces:t}},w.is=function(e){var t=e;return K.defined(t)&&K.number(t.tabSize)&&K.boolean(t.insertSpaces)};var A,I,M,j=function(){};t.DocumentLink=j,(A=j=t.DocumentLink||(t.DocumentLink={})).create=function(e,t){return{range:e,target:t}},A.is=function(e){var t=e;return K.defined(t)&&r.is(t.range)&&(K.undefined(t.target)||K.string(t.target))},t.DocumentLink=j,t.EOL=["\n","\r\n","\r"],(I=t.TextDocument||(t.TextDocument={})).create=function(e,t,n,r){return new P(e,t,n,r)},I.is=function(e){var t=e;return!!(K.defined(t)&&K.string(t.uri)&&(K.undefined(t.languageId)||K.string(t.languageId))&&K.number(t.lineCount)&&K.func(t.getText)&&K.func(t.positionAt)&&K.func(t.offsetAt))},I.applyEdits=function(e,t){for(var n=e.getText(),r=function e(t,n){if(t.length<=1)return t;var r=t.length/2|0,o=t.slice(0,r),i=t.slice(r);e(o,n),e(i,n);for(var a=0,s=0,u=0;a<o.length&&s<i.length;){var c=n(o[a],i[s]);t[u++]=c<=0?o[a++]:i[s++]}for(;a<o.length;)t[u++]=o[a++];for(;s<i.length;)t[u++]=i[s++];return t}(t,function(e,t){return 0==e.range.start.line-t.range.start.line?e.range.start.character-t.range.start.character:0}),o=n.length,i=r.length-1;0<=i;i--){var a=r[i],s=e.offsetAt(a.range.start),u=e.offsetAt(a.range.end);if(!(u<=o))throw new Error("Ovelapping edit");n=n.substring(0,s)+a.newText+n.substring(u,n.length),o=s}return n},(M=t.TextDocumentSaveReason||(t.TextDocumentSaveReason={})).Manual=1,M.AfterDelay=2,M.FocusOut=3;var K,L,D,P=function(){function e(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=null}return Object.defineProperty(e.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!0,configurable:!0}),e.prototype.getText=function(e){if(e){var t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content},e.prototype.update=function(e,t){this._content=e.text,this._version=t,this._lineOffsets=null},e.prototype.getLineOffsets=function(){if(null===this._lineOffsets){for(var e=[],t=this._content,n=!0,r=0;r<t.length;r++){n&&(e.push(r),n=!1);var o=t.charAt(r);n="\r"===o||"\n"===o,"\r"===o&&r+1<t.length&&"\n"===t.charAt(r+1)&&r++}n&&0<t.length&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets},e.prototype.positionAt=function(e){e=Math.max(Math.min(e,this._content.length),0);var t=this.getLineOffsets(),n=0,r=t.length;if(0===r)return a.create(0,e);for(;n<r;){var o=Math.floor((n+r)/2);t[o]>e?r=o:n=o+1}var i=n-1;return a.create(i,e-t[i])},e.prototype.offsetAt=function(e){var t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;var n=t[e.line],r=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,r),n)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!0,configurable:!0}),e}();L=K||(K={}),D=Object.prototype.toString,L.defined=function(e){return void 0!==e},L.undefined=function(e){return void 0===e},L.boolean=function(e){return!0===e||!1===e},L.string=function(e){return"[object String]"===D.call(e)},L.number=function(e){return"[object Number]"===D.call(e)},L.func=function(e){return"[object Function]"===D.call(e)},L.typedArray=function(e,t){return Array.isArray(e)&&e.every(t)}}),define("vscode-languageserver-types",["vscode-languageserver-types/main"],function(e){return e}),define("vs/language/json/languageFeatures",["require","exports","vscode-languageserver-types"],function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=monaco.Uri,n=monaco.Range,o=function(){function e(e,t,n){var r=this;this._languageId=e,this._worker=t,this._disposables=[],this._listener=Object.create(null);var o=function(e){var t,n=e.getModeId();n===r._languageId&&(r._listener[e.uri.toString()]=e.onDidChangeContent(function(){clearTimeout(t),t=setTimeout(function(){return r._doValidate(e.uri,n)},500)}),r._doValidate(e.uri,n))},i=function(e){monaco.editor.setModelMarkers(e,r._languageId,[]);var t=e.uri.toString(),n=r._listener[t];n&&(n.dispose(),delete r._listener[t])};this._disposables.push(monaco.editor.onDidCreateModel(o)),this._disposables.push(monaco.editor.onWillDisposeModel(function(e){i(e),r._resetSchema(e.uri)})),this._disposables.push(monaco.editor.onDidChangeModelLanguage(function(e){i(e.model),o(e.model),r._resetSchema(e.model.uri)})),this._disposables.push(n.onDidChange(function(e){monaco.editor.getModels().forEach(function(e){e.getModeId()===r._languageId&&(i(e),o(e))})})),this._disposables.push({dispose:function(){for(var e in monaco.editor.getModels().forEach(i),r._listener)r._listener[e].dispose()}}),monaco.editor.getModels().forEach(o)}return e.prototype.dispose=function(){this._disposables.forEach(function(e){return e&&e.dispose()}),this._disposables=[]},e.prototype._resetSchema=function(t){this._worker().then(function(e){e.resetSchema(t.toString())})},e.prototype._doValidate=function(r,o){this._worker(r).then(function(e){return e.doValidation(r.toString()).then(function(e){var t=e.map(function(e){return n="number"==typeof(t=e).code?String(t.code):t.code,{severity:function(e){switch(e){case i.DiagnosticSeverity.Error:return monaco.MarkerSeverity.Error;case i.DiagnosticSeverity.Warning:return monaco.MarkerSeverity.Warning;case i.DiagnosticSeverity.Information:return monaco.MarkerSeverity.Info;case i.DiagnosticSeverity.Hint:return monaco.MarkerSeverity.Hint;default:return monaco.MarkerSeverity.Info}}(t.severity),startLineNumber:t.range.start.line+1,startColumn:t.range.start.character+1,endLineNumber:t.range.end.line+1,endColumn:t.range.end.character+1,message:t.message,code:n,source:t.source};var t,n}),n=monaco.editor.getModel(r);n.getModeId()===o&&monaco.editor.setModelMarkers(n,o,t)})}).then(void 0,function(e){console.error(e)})},e}();function a(e){if(e)return{character:e.column-1,line:e.lineNumber-1}}function s(e){if(e)return{start:{line:e.startLineNumber-1,character:e.startColumn-1},end:{line:e.endLineNumber-1,character:e.endColumn-1}}}function u(e){if(e)return new n(e.start.line+1,e.start.character+1,e.end.line+1,e.end.character+1)}function c(e){var t=monaco.languages.CompletionItemKind;switch(e){case i.CompletionItemKind.Text:return t.Text;case i.CompletionItemKind.Method:return t.Method;case i.CompletionItemKind.Function:return t.Function;case i.CompletionItemKind.Constructor:return t.Constructor;case i.CompletionItemKind.Field:return t.Field;case i.CompletionItemKind.Variable:return t.Variable;case i.CompletionItemKind.Class:return t.Class;case i.CompletionItemKind.Interface:return t.Interface;case i.CompletionItemKind.Module:return t.Module;case i.CompletionItemKind.Property:return t.Property;case i.CompletionItemKind.Unit:return t.Unit;case i.CompletionItemKind.Value:return t.Value;case i.CompletionItemKind.Enum:return t.Enum;case i.CompletionItemKind.Keyword:return t.Keyword;case i.CompletionItemKind.Snippet:return t.Snippet;case i.CompletionItemKind.Color:return t.Color;case i.CompletionItemKind.File:return t.File;case i.CompletionItemKind.Reference:return t.Reference}return t.Property}function f(e){if(e)return{range:u(e.range),text:e.newText}}t.DiagnosticsAdapter=o;var l=function(){function e(e){this._worker=e}return Object.defineProperty(e.prototype,"triggerCharacters",{get:function(){return[" ",":"]},enumerable:!0,configurable:!0}),e.prototype.provideCompletionItems=function(e,t,n){e.getWordUntilPosition(t);var r=e.uri;return b(n,this._worker(r).then(function(e){return e.doComplete(r.toString(),a(t))}).then(function(e){if(e){var t=e.items.map(function(e){var t={label:e.label,insertText:e.insertText,sortText:e.sortText,filterText:e.filterText,documentation:e.documentation,detail:e.detail,kind:c(e.kind)};return e.textEdit&&(t.range=u(e.textEdit.range),t.insertText=e.textEdit.newText),e.insertTextFormat===i.InsertTextFormat.Snippet&&(t.insertText={value:t.insertText}),t});return{isIncomplete:e.isIncomplete,items:t}}}))},e}();function d(e){return"string"==typeof e?{value:e}:(t=e)&&"object"==typeof t&&"string"==typeof t.kind?"plaintext"===e.kind?{value:e.value.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}:{value:e.value}:{value:"```"+e.language+"\n"+e.value+"\n```\n"};var t}t.CompletionAdapter=l;var g=function(){function e(e){this._worker=e}return e.prototype.provideHover=function(e,t,n){var r=e.uri;return b(n,this._worker(r).then(function(e){return e.doHover(r.toString(),a(t))}).then(function(e){if(e)return{range:u(e.range),contents:function(e){if(e)return Array.isArray(e)?e.map(d):[d(e)]}(e.contents)}}))},e}();t.HoverAdapter=g;var h=function(){function e(e){this._worker=e}return e.prototype.provideDocumentSymbols=function(e,t){var n=e.uri;return b(t,this._worker(n).then(function(e){return e.findDocumentSymbols(n.toString())}).then(function(e){if(e)return e.map(function(e){return{name:e.name,containerName:e.containerName,kind:function(e){var t=monaco.languages.SymbolKind;switch(e){case i.SymbolKind.File:return t.Array;case i.SymbolKind.Module:return t.Module;case i.SymbolKind.Namespace:return t.Namespace;case i.SymbolKind.Package:return t.Package;case i.SymbolKind.Class:return t.Class;case i.SymbolKind.Method:return t.Method;case i.SymbolKind.Property:return t.Property;case i.SymbolKind.Field:return t.Field;case i.SymbolKind.Constructor:return t.Constructor;case i.SymbolKind.Enum:return t.Enum;case i.SymbolKind.Interface:return t.Interface;case i.SymbolKind.Function:return t.Function;case i.SymbolKind.Variable:return t.Variable;case i.SymbolKind.Constant:return t.Constant;case i.SymbolKind.String:return t.String;case i.SymbolKind.Number:return t.Number;case i.SymbolKind.Boolean:return t.Boolean;case i.SymbolKind.Array:return t.Array}return t.Function}(e.kind),location:(t=e.location,{uri:r.parse(t.uri),range:u(t.range)})};var t})}))},e}();function p(e){return{tabSize:e.tabSize,insertSpaces:e.insertSpaces}}t.DocumentSymbolAdapter=h;var m=function(){function e(e){this._worker=e}return e.prototype.provideDocumentFormattingEdits=function(e,t,n){var r=e.uri;return b(n,this._worker(r).then(function(e){return e.format(r.toString(),null,p(t)).then(function(e){if(e&&0!==e.length)return e.map(f)})}))},e}();t.DocumentFormattingEditProvider=m;var v=function(){function e(e){this._worker=e}return e.prototype.provideDocumentRangeFormattingEdits=function(e,t,n,r){var o=e.uri;return b(r,this._worker(o).then(function(e){return e.format(o.toString(),s(t),p(n)).then(function(e){if(e&&0!==e.length)return e.map(f)})}))},e}();t.DocumentRangeFormattingEditProvider=v;var y=function(){function e(e){this._worker=e}return e.prototype.provideDocumentColors=function(e,t){var n=e.uri;return b(t,this._worker(n).then(function(e){return e.findDocumentColors(n.toString())}).then(function(e){if(e)return e.map(function(e){return{color:e.color,range:u(e.range)}})}))},e.prototype.provideColorPresentations=function(e,t,n){var r=e.uri;return b(n,this._worker(r).then(function(e){return e.getColorPresentations(r.toString(),t.color,s(t.range))}).then(function(e){if(e)return e.map(function(e){var t={label:e.label};return e.textEdit&&(t.textEdit=f(e.textEdit)),e.additionalTextEdits&&(t.additionalTextEdits=e.additionalTextEdits.map(f)),t})}))},e}();function b(e,t){return t.cancel&&e.onCancellationRequested(function(){return t.cancel()}),t}t.DocumentColorAdapter=y}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/scanner",["require","exports"],e)}(function(e,t){"use strict";function d(e){return 32===e||9===e||11===e||12===e||160===e||5760===e||8192<=e&&e<=8203||8239===e||8287===e||12288===e||65279===e}function g(e){return 10===e||13===e||8232===e||8233===e}function h(e){return 48<=e&&e<=57}Object.defineProperty(t,"__esModule",{value:!0}),t.createScanner=function(i,e){void 0===e&&(e=!1);var a=0,o=i.length,r="",s=0,u=16,c=0;function f(e,t){for(var n=0,r=0;n<e||!t;){var o=i.charCodeAt(a);if(48<=o&&o<=57)r=16*r+o-48;else if(65<=o&&o<=70)r=16*r+o-65+10;else{if(!(97<=o&&o<=102))break;r=16*r+o-97+10}a++,n++}return n<e&&(r=-1),r}function t(){if(r="",c=0,o<=(s=a))return s=o,u=17;var e=i.charCodeAt(a);if(d(e)){for(;a++,r+=String.fromCharCode(e),d(e=i.charCodeAt(a)););return u=15}if(g(e))return a++,r+=String.fromCharCode(e),13===e&&10===i.charCodeAt(a)&&(a++,r+="\n"),u=14;switch(e){case 123:return a++,u=1;case 125:return a++,u=2;case 91:return a++,u=3;case 93:return a++,u=4;case 58:return a++,u=6;case 44:return a++,u=5;case 34:return a++,r=function(){for(var e="",t=a;;){if(o<=a){e+=i.substring(t,a),c=2;break}var n=i.charCodeAt(a);if(34===n){e+=i.substring(t,a),a++;break}if(92!==n){if(0<=n&&n<=31){if(g(n)){e+=i.substring(t,a),c=2;break}c=6}a++}else{if(e+=i.substring(t,a),o<=++a){c=2;break}switch(n=i.charCodeAt(a++)){case 34:e+='"';break;case 92:e+="\\";break;case 47:e+="/";break;case 98:e+="\b";break;case 102:e+="\f";break;case 110:e+="\n";break;case 114:e+="\r";break;case 116:e+="\t";break;case 117:var r=f(4,!0);0<=r?e+=String.fromCharCode(r):c=4;break;default:c=5}t=a}}return e}(),u=10;case 47:var t=a-1;if(47===i.charCodeAt(a+1)){for(a+=2;a<o&&!g(i.charCodeAt(a));)a++;return r=i.substring(t,a),u=12}if(42===i.charCodeAt(a+1)){a+=2;for(var n=!1;a<o;){if(42===i.charCodeAt(a)&&a+1<o&&47===i.charCodeAt(a+1)){a+=2,n=!0;break}a++}return n||(a++,c=1),r=i.substring(t,a),u=13}return r+=String.fromCharCode(e),a++,u=16;case 45:if(r+=String.fromCharCode(e),++a===o||!h(i.charCodeAt(a)))return u=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=function(){var e=a;if(48===i.charCodeAt(a))a++;else for(a++;a<i.length&&h(i.charCodeAt(a));)a++;if(a<i.length&&46===i.charCodeAt(a)){if(!(++a<i.length&&h(i.charCodeAt(a))))return c=3,i.substring(e,a);for(a++;a<i.length&&h(i.charCodeAt(a));)a++}var t=a;if(a<i.length&&(69===i.charCodeAt(a)||101===i.charCodeAt(a)))if((++a<i.length&&43===i.charCodeAt(a)||45===i.charCodeAt(a))&&a++,a<i.length&&h(i.charCodeAt(a))){for(a++;a<i.length&&h(i.charCodeAt(a));)a++;t=a}else c=3;return i.substring(e,t)}(),u=11;default:for(;a<o&&l(e);)a++,e=i.charCodeAt(a);if(s!==a){switch(r=i.substring(s,a)){case"true":return u=8;case"false":return u=9;case"null":return u=7}return u=16}return r+=String.fromCharCode(e),a++,u=16}}function l(e){if(d(e)||g(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:return!1}return!0}return{setPosition:function(e){a=e,r="",u=16,c=s=0},getPosition:function(){return a},scan:e?function(){for(var e;12<=(e=t())&&e<=15;);return e}:t,getToken:function(){return u},getTokenValue:function(){return r},getTokenOffset:function(){return s},getTokenLength:function(){return a-s},getTokenError:function(){return c}}}}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/format",["require","exports","./scanner"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var T=e("./scanner");function S(e,t){for(var n="",r=0;r<t;r++)n+=e;return n}function w(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}t.format=function(r,e,t){var n,o,i,a,s;if(e){for(a=e.offset,s=a+e.length,i=a;0<i&&!w(r,i-1);)i--;for(var u=s;u<r.length&&!w(r,u);)u++;o=r.substring(i,u),n=function(e,t,n){for(var r=0,o=0,i=n.tabSize||4;r<e.length;){var a=e.charAt(r);if(" "===a)o++;else{if("\t"!==a)break;o+=i}r++}return Math.floor(o/i)}(o,0,t)}else a=i=n=0,s=(o=r).length;var c,f=function(e,t){for(var n=0;n<t.length;n++){var r=t.charAt(n);if("\r"===r)return n+1<t.length&&"\n"===t.charAt(n+1)?"\r\n":"\r";if("\n"===r)return"\n"}return e&&e.eol||"\n"}(t,r),l=!1,d=0;c=t.insertSpaces?S(" ",t.tabSize||4):"\t";var g=T.createScanner(o,!1),h=!1;function p(){return f+S(c,n+d)}function m(){var e=g.scan();for(l=!1;15===e||14===e;)l=l||14===e,e=g.scan();return h=16===e||0!==g.getTokenError(),e}var v=[];function y(e,t,n){!h&&t<s&&a<n&&r.substring(t,n)!==e&&v.push({offset:t,length:n-t,content:e})}var b=m();if(17!==b){var k=g.getTokenOffset()+i;y(S(c,n),i,k)}for(;17!==b;){for(var _=g.getTokenOffset()+g.getTokenLength()+i,C=m(),E="";!l&&(12===C||13===C);)y(" ",_,g.getTokenOffset()+i),_=g.getTokenOffset()+g.getTokenLength()+i,E=12===C?p():"",C=m();if(2===C)1!==b&&(d--,E=p());else if(4===C)3!==b&&(d--,E=p());else{switch(b){case 3:case 1:d++,E=p();break;case 5:case 12:E=p();break;case 13:E=l?p():" ";break;case 6:E=" ";break;case 10:if(6===C){E="";break}case 7:case 8:case 9:case 11:case 2:case 4:12===C||13===C?E=" ":5!==C&&17!==C&&(h=!0);break;case 16:h=!0}!l||12!==C&&13!==C||(E=p())}y(E,_,g.getTokenOffset()+i),b=C}return v},t.isEOL=w}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/parser",["require","exports","./scanner"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var _=e("./scanner");function f(e,t,n){var o=_.createScanner(e,!1);function r(e){return e?function(){return e(o.getTokenOffset(),o.getTokenLength())}:function(){return!0}}function i(t){return t?function(e){return t(e,o.getTokenOffset(),o.getTokenLength())}:function(){return!0}}var a=r(t.onObjectBegin),s=i(t.onObjectProperty),u=r(t.onObjectEnd),c=r(t.onArrayBegin),f=r(t.onArrayEnd),l=i(t.onLiteralValue),d=i(t.onSeparator),g=r(t.onComment),h=i(t.onError),p=n&&n.disallowComments,m=n&&n.allowTrailingComma;function v(){for(;;){var e=o.scan();switch(o.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:p||y(11);break;case 2:y(12);break;case 6:y(16)}switch(e){case 12:case 13:p?y(10):g();break;case 16:y(1);break;case 15:case 14:break;default:return e}}}function y(e,t,n){if(void 0===t&&(t=[]),void 0===n&&(n=[]),h(e),0<t.length+n.length)for(var r=o.getToken();17!==r;){if(-1!==t.indexOf(r)){v();break}if(-1!==n.indexOf(r))break;r=v()}}function b(e){var t=o.getTokenValue();return e?l(t):s(t),v(),!0}function k(){switch(o.getToken()){case 3:return function(){c(),v();for(var e=!1;4!==o.getToken()&&17!==o.getToken();){if(5===o.getToken()){if(e||y(4,[],[]),d(","),v(),4===o.getToken()&&m)break}else e&&y(6,[],[]);k()||y(4,[],[4,5]),e=!0}return f(),4!==o.getToken()?y(8,[4],[]):v(),!0}();case 1:return function(){a(),v();for(var e=!1;2!==o.getToken()&&17!==o.getToken();){if(5===o.getToken()){if(e||y(4,[],[]),d(","),v(),2===o.getToken()&&m)break}else e&&y(6,[],[]);(10!==o.getToken()?(y(3,[],[2,5]),0):(b(!1),6===o.getToken()?(d(":"),v(),k()||y(4,[],[2,5])):y(5,[],[2,5]),1))||y(4,[],[2,5]),e=!0}return u(),2!==o.getToken()?y(7,[2],[]):v(),!0}();case 10:return b(!0);default:return function(){switch(o.getToken()){case 11:var e=0;try{"number"!=typeof(e=JSON.parse(o.getTokenValue()))&&(y(2),e=0)}catch(e){y(2)}l(e);break;case 7:l(null);break;case 8:l(!0);break;case 9:l(!1);break;default:return!1}return v(),!0}()}}return v(),17===o.getToken()||(k()?(17!==o.getToken()&&y(9,[],[]),!0):(y(4,[],[]),!1))}function l(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return"null"}}t.getLocation=function(e,o){var i=[],a=new Object,s=void 0,u={value:{},offset:0,length:0,type:"object"},c=!1;function r(e,t,n,r){u.value=e,u.offset=t,u.length=n,u.type=r,u.columnOffset=void 0,s=u}try{f(e,{onObjectBegin:function(e,t){if(o<=e)throw a;s=void 0,c=e<o,i.push("")},onObjectProperty:function(e,t,n){if(o<t)throw a;if(r(e,t,n,"property"),i[i.length-1]=e,o<=t+n)throw a},onObjectEnd:function(e,t){if(o<=e)throw a;s=void 0,i.pop()},onArrayBegin:function(e,t){if(o<=e)throw a;s=void 0,i.push(0)},onArrayEnd:function(e,t){if(o<=e)throw a;s=void 0,i.pop()},onLiteralValue:function(e,t,n){if(o<t)throw a;if(r(e,t,n,l(e)),o<=t+n)throw a},onSeparator:function(e,t,n){if(o<=t)throw a;if(":"===e&&s&&"property"===s.type)s.columnOffset=t,c=!1,s=void 0;else if(","===e){var r=i[i.length-1];"number"==typeof r?i[i.length-1]=r+1:(c=!0,i[i.length-1]=""),s=void 0}}})}catch(e){if(e!==a)throw e}return{path:i,previousNode:s,isAtPropertyKey:c,matches:function(e){for(var t=0,n=0;t<e.length&&n<i.length;n++)if(e[t]===i[n]||"*"===e[t])t++;else if("**"!==e[t])return!1;return t===e.length}}},t.parse=function(e,r,t){void 0===r&&(r=[]);var n=null,o=[],i=[];function a(e){Array.isArray(o)?o.push(e):n&&(o[n]=e)}return f(e,{onObjectBegin:function(){var e={};a(e),i.push(o),o=e,n=null},onObjectProperty:function(e){n=e},onObjectEnd:function(){o=i.pop()},onArrayBegin:function(){var e=[];a(e),i.push(o),o=e,n=null},onArrayEnd:function(){o=i.pop()},onLiteralValue:a,onError:function(e,t,n){r.push({error:e,offset:t,length:n})}},t),o[0]},t.parseTree=function(e,r,t){void 0===r&&(r=[]);var o={type:"array",offset:-1,length:-1,children:[]};function i(e){"property"===o.type&&(o.length=e-o.offset,o=o.parent)}function a(e){return o.children.push(e),e}f(e,{onObjectBegin:function(e){o=a({type:"object",offset:e,length:-1,parent:o,children:[]})},onObjectProperty:function(e,t,n){(o=a({type:"property",offset:t,length:-1,parent:o,children:[]})).children.push({type:"string",value:e,offset:t,length:n,parent:o})},onObjectEnd:function(e,t){o.length=e+t-o.offset,o=o.parent,i(e+t)},onArrayBegin:function(e,t){o=a({type:"array",offset:e,length:-1,parent:o,children:[]})},onArrayEnd:function(e,t){o.length=e+t-o.offset,o=o.parent,i(e+t)},onLiteralValue:function(e,t,n){a({type:l(e),offset:t,length:n,parent:o,value:e}),i(t+n)},onSeparator:function(e,t,n){"property"===o.type&&(":"===e?o.columnOffset=t:","===e&&i(t))},onError:function(e,t,n){r.push({error:e,offset:t,length:n})}},t);var n=o.children[0];return n&&delete n.parent,n},t.findNodeAtLocation=function(e,t){if(e){for(var n=e,r=0,o=t;r<o.length;r++){var i=o[r];if("string"==typeof i){if("object"!==n.type||!Array.isArray(n.children))return;for(var a=!1,s=0,u=n.children;s<u.length;s++){var c=u[s];if(Array.isArray(c.children)&&c.children[0].value===i){n=c.children[1],a=!0;break}}if(!a)return}else{var f=i;if("array"!==n.type||f<0||!Array.isArray(n.children)||f>=n.children.length)return;n=n.children[f]}}return n}},t.getNodeValue=function e(t){if("array"===t.type)return t.children.map(e);if("object"===t.type){for(var n=Object.create(null),r=0,o=t.children;r<o.length;r++){var i=o[r];n[i.children[0].value]=e(i.children[1])}return n}return t.value},t.visit=f,t.stripComments=function(e,t){var n,r,o=_.createScanner(e),i=[],a=0;do{switch(r=o.getPosition(),n=o.scan()){case 12:case 13:case 17:a!==r&&i.push(e.substring(a,r)),void 0!==t&&i.push(o.getTokenValue().replace(/[^\r\n]/g,t)),a=o.getPosition()}}while(17!==n);return i.join("")}}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/impl/edit",["require","exports","./format","./parser"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var c=e("./format"),k=e("./parser");function r(e,t,n,r,o){for(var i,a=k.parseTree(e,[]),s=void 0,u=void 0;0<t.length&&(u=t.pop(),void 0===(s=k.findNodeAtLocation(a,t))&&void 0!==n);)"string"==typeof u?((i={})[u]=n,n=i):n=[n];if(s){if("object"===s.type&&"string"==typeof u&&Array.isArray(s.children)){var c=k.findNodeAtLocation(s,[u]);if(void 0!==c){if(void 0===n){if(!c.parent)throw new Error("Malformed AST");var f=s.children.indexOf(c.parent),l=void 0,d=c.parent.offset+c.parent.length;if(0<f)l=(y=s.children[f-1]).offset+y.length;else if(l=s.offset+1,1<s.children.length)d=s.children[1].offset;return _(e,{offset:l,length:d-l,content:""},r)}return _(e,{offset:c.offset,length:c.length,content:JSON.stringify(n)},r)}if(void 0===n)return[];var g=JSON.stringify(u)+": "+JSON.stringify(n),h=o?o(s.children.map(function(e){return e.children[0].value})):s.children.length,p=void 0;return _(e,p=0<h?{offset:(y=s.children[h-1]).offset+y.length,length:0,content:","+g}:0===s.children.length?{offset:s.offset+1,length:0,content:g}:{offset:s.offset+1,length:0,content:g+","},r)}if("array"===s.type&&"number"==typeof u&&Array.isArray(s.children)){if(-1===u){g=""+JSON.stringify(n),p=void 0;if(0===s.children.length)p={offset:s.offset+1,length:0,content:g};else p={offset:(y=s.children[s.children.length-1]).offset+y.length,length:0,content:","+g};return _(e,p,r)}if(void 0===n&&0<=s.children.length){var m=u,v=s.children[m];p=void 0;if(1===s.children.length)p={offset:s.offset+1,length:s.length-2,content:""};else if(s.children.length-1===m){var y,b=(y=s.children[m-1]).offset+y.length;p={offset:b,length:s.offset+s.length-2-b,content:""}}else p={offset:v.offset,length:s.children[m+1].offset-v.offset,content:""};return _(e,p,r)}throw new Error("Array modification not supported yet")}throw new Error("Can not add "+("number"!=typeof u?"index":"property")+" to parent of type "+s.type)}if(void 0===n)throw new Error("Can not delete in empty document");return _(e,{offset:a?a.offset:0,length:a?a.length:0,content:JSON.stringify(n)},r)}function _(e,t,n){var r=f(e,t),o=t.offset,i=t.offset+t.content.length;if(0===t.length||0===t.content.length){for(;0<o&&!c.isEOL(r,o-1);)o--;for(;i<r.length&&!c.isEOL(r,i);)i++}for(var a=c.format(r,{offset:o,length:i-o},n),s=a.length-1;0<=s;s--){var u=a[s];r=f(r,u),o=Math.min(o,u.offset),i=Math.max(i,u.offset+u.length),i+=u.content.length-u.length}return[{offset:o,length:e.length-(r.length-i)-o,content:r.substring(o,i)}]}function f(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}t.removeProperty=function(e,t,n){return r(e,t,void 0,n)},t.setProperty=r,t.applyEdit=f,t.isWS=function(e,t){return-1!=="\r\n \t".indexOf(e.charAt(t))}}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define("jsonc-parser/main",["require","exports","./impl/format","./impl/edit","./impl/scanner","./impl/parser"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=e("./impl/format"),o=e("./impl/edit"),n=e("./impl/scanner"),i=e("./impl/parser");t.createScanner=n.createScanner,t.getLocation=i.getLocation,t.parse=i.parse,t.parseTree=i.parseTree,t.findNodeAtLocation=i.findNodeAtLocation,t.getNodeValue=i.getNodeValue,t.visit=i.visit,t.stripComments=i.stripComments,t.format=function(e,t,n){return r.format(e,t,n)},t.modify=function(e,t,n,r){return o.setProperty(e,t,n,r.formattingOptions,r.getInsertionIndex)},t.applyEdits=function(e,t){for(var n=t.length-1;0<=n;n--)e=o.applyEdit(e,t[n]);return e}}),define("jsonc-parser",["jsonc-parser/main"],function(e){return e}),define("vs/language/json/tokenization",["require","exports","jsonc-parser"],function(e,g,h){"use strict";Object.defineProperty(g,"__esModule",{value:!0}),g.createTokenizationSupport=function(o){return{getInitialState:function(){return new p(null,null,!1)},tokenize:function(e,t,n,r){return function(e,t,n,r,o){void 0===r&&(r=0);var i=0,a=!1;switch(n.scanError){case 2:t='"'+t,i=1;break;case 1:t="/*"+t,i=2}var s,u,c=h.createScanner(t),f=n.lastWasColon;for(u={tokens:[],endState:n.clone()};;){var l=r+c.getPosition(),d="";if(17===(s=c.scan()))break;if(l===r+c.getPosition())throw new Error("Scanner did not advance, next 3 characters are: "+t.substr(c.getPosition(),3));switch(a&&(l-=i),a=0<i,s){case 1:case 2:d=g.TOKEN_DELIM_OBJECT,f=!1;break;case 3:case 4:d=g.TOKEN_DELIM_ARRAY,f=!1;break;case 6:d=g.TOKEN_DELIM_COLON,f=!0;break;case 5:d=g.TOKEN_DELIM_COMMA,f=!1;break;case 8:case 9:d=g.TOKEN_VALUE_BOOLEAN,f=!1;break;case 7:d=g.TOKEN_VALUE_NULL,f=!1;break;case 10:d=f?g.TOKEN_VALUE_STRING:g.TOKEN_PROPERTY_NAME,f=!1;break;case 11:d=g.TOKEN_VALUE_NUMBER,f=!1}if(e)switch(s){case 12:d=g.TOKEN_COMMENT_LINE;break;case 13:d=g.TOKEN_COMMENT_BLOCK}u.endState=new p(n.getStateData(),c.getTokenError(),f),u.tokens.push({startIndex:l,scopes:d})}return u}(o,e,t,n)}}},g.TOKEN_DELIM_OBJECT="delimiter.bracket.json",g.TOKEN_DELIM_ARRAY="delimiter.array.json",g.TOKEN_DELIM_COLON="delimiter.colon.json",g.TOKEN_DELIM_COMMA="delimiter.comma.json",g.TOKEN_VALUE_BOOLEAN="keyword.json",g.TOKEN_VALUE_NULL="keyword.json",g.TOKEN_VALUE_STRING="string.value.json",g.TOKEN_VALUE_NUMBER="number.json",g.TOKEN_PROPERTY_NAME="string.key.json",g.TOKEN_COMMENT_BLOCK="comment.block.json",g.TOKEN_COMMENT_LINE="comment.line.json";var p=function(){function t(e,t,n){this._state=e,this.scanError=t,this.lastWasColon=n}return t.prototype.clone=function(){return new t(this._state,this.scanError,this.lastWasColon)},t.prototype.equals=function(e){return e===this||!!(e&&e instanceof t)&&(this.scanError===e.scanError&&this.lastWasColon===e.lastWasColon)},t.prototype.getStateData=function(){return this._state},t.prototype.setStateData=function(e){this._state=e},t}()}),define("vs/language/json/jsonMode",["require","exports","./workerManager","./languageFeatures","./tokenization"],function(e,t,i,a,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupMode=function(e){var t=[],n=new i.WorkerManager(e);t.push(n);var r=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.getLanguageServiceWorker.apply(n,e)},o=e.languageId;t.push(monaco.languages.registerCompletionItemProvider(o,new a.CompletionAdapter(r))),t.push(monaco.languages.registerHoverProvider(o,new a.HoverAdapter(r))),t.push(monaco.languages.registerDocumentSymbolProvider(o,new a.DocumentSymbolAdapter(r))),t.push(monaco.languages.registerDocumentFormattingEditProvider(o,new a.DocumentFormattingEditProvider(r))),t.push(monaco.languages.registerDocumentRangeFormattingEditProvider(o,new a.DocumentRangeFormattingEditProvider(r))),t.push(new a.DiagnosticsAdapter(o,r,e)),t.push(monaco.languages.setTokensProvider(o,s.createTokenizationSupport(!0))),t.push(monaco.languages.setLanguageConfiguration(o,u)),t.push(monaco.languages.registerColorProvider(o,new a.DocumentColorAdapter(r)))};var u={wordPattern:/(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"]],autoClosingPairs:[{open:"{",close:"}",notIn:["string"]},{open:"[",close:"]",notIn:["string"]},{open:'"',close:'"',notIn:["string"]}]}}); |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-json version: 2.1.0(427abfc518aba22b38705f2484e3b50662ea3166) | ||
* monaco-json version: 2.1.1(0e6ea95f4f4e093db9201c502e8d401391803233) | ||
* Released under the MIT license | ||
@@ -5,0 +5,0 @@ * https://github.com/Microsoft/monaco-json/blob/master/LICENSE.md |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
882036
16832
37