/*!----------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * monaco-json version: 2.1.1(0e6ea95f4f4e093db9201c502e8d401391803233) * Released under the MIT license * https://github.com/Microsoft/monaco-json/blob/master/LICENSE.md *-----------------------------------------------------------------------------*/ !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,r,n,o,i,s,u,c,f,l,p,h,d;Object.defineProperty(t,"__esModule",{value:!0}),(r=a=t.Position||(t.Position={})).create=function(e,t){return{line:e,character:t}},r.is=function(e){var t=e;return N.defined(t)&&N.number(t.line)&&N.number(t.character)},(o=n=t.Range||(t.Range={})).create=function(e,t,r,n){if(N.number(e)&&N.number(t)&&N.number(r)&&N.number(n))return{start:a.create(e,t),end:a.create(r,n)};if(a.is(e)&&a.is(t))return{start:e,end:t};throw new Error("Range#create called with invalid arguments["+e+", "+t+", "+r+", "+n+"]")},o.is=function(e){var t=e;return N.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 N.defined(t)&&n.is(t.range)&&(N.string(t.uri)||N.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,r,n,o){var i={range:e,message:t};return N.defined(r)&&(i.severity=r),N.defined(n)&&(i.code=n),N.defined(o)&&(i.source=o),i},c.is=function(e){var t=e;return N.defined(t)&&n.is(t.range)&&N.string(t.message)&&(N.number(t.severity)||N.undefined(t.severity))&&(N.number(t.code)||N.string(t.code)||N.undefined(t.code))&&(N.string(t.source)||N.undefined(t.source))},(l=f=t.Command||(t.Command={})).create=function(e,t){for(var r=[],n=2;ne?n=o:r=o+1}var i=r-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 r=t[e.line],n=e.line+1=r.children.length)return;r=r.children[f]}}return r}},t.getNodeValue=function e(t){if("array"===t.type)return t.children.map(e);if("object"===t.type){for(var r=Object.create(null),n=0,o=t.children;n()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;(i=b=t.ProblemSeverity||(t.ProblemSeverity={})).Ignore="ignore",i.Error="error",i.Warning="warning";var a=function(){function e(e,t,r){this.offset=t,this.length=r,this.parent=e}return Object.defineProperty(e.prototype,"children",{get:function(){return[]},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"type: "+this.type+" ("+this.offset+"/"+this.length+")"+(this.parent?" parent: {"+this.parent.toString()+"}":"")},e}(),x=function(n){function e(e,t){var r=n.call(this,e,t)||this;return r.type="null",r}return __extends(e,n),e}(t.ASTNodeImpl=a);t.NullASTNodeImpl=x;var S=function(o){function e(e,t,r){var n=o.call(this,e,r)||this;return n.type="boolean",n.value=t,n}return __extends(e,o),e}(a);t.BooleanASTNodeImpl=S;var j=function(n){function e(e,t){var r=n.call(this,e,t)||this;return r.type="array",r.items=[],r}return __extends(e,n),Object.defineProperty(e.prototype,"children",{get:function(){return this.items},enumerable:!0,configurable:!0}),e}(a);t.ArrayASTNodeImpl=j;var O=function(n){function e(e,t){var r=n.call(this,e,t)||this;return r.type="number",r.isInteger=!0,r.value=Number.NaN,r}return __extends(e,n),e}(a);t.NumberASTNodeImpl=O;var T=function(o){function e(e,t,r){var n=o.call(this,e,t,r)||this;return n.type="string",n.value="",n}return __extends(e,o),e}(a);t.StringASTNodeImpl=T;var C=function(n){function e(e,t){var r=n.call(this,e,t)||this;return r.type="property",r.colonOffset=-1,r}return __extends(e,n),Object.defineProperty(e.prototype,"children",{get:function(){return this.valueNode?[this.keyNode,this.valueNode]:[this.keyNode]},enumerable:!0,configurable:!0}),e}(a);t.PropertyASTNodeImpl=C;var f,A=function(n){function e(e,t){var r=n.call(this,e,t)||this;return r.type="object",r.properties=[],r}return __extends(e,n),Object.defineProperty(e.prototype,"children",{get:function(){return this.properties},enumerable:!0,configurable:!0}),e}(a);function m(e){return"boolean"==typeof e?e?{}:{not:{}}:e}t.ObjectASTNodeImpl=A,t.asSchema=m,(f=t.EnumMatch||(t.EnumMatch={}))[f.Key=0]="Key",f[f.Enum=1]="Enum";var l=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=null),this.focusOffset=e,this.exclude=t,this.schemas=[]}return e.prototype.add=function(e){this.schemas.push(e)},e.prototype.merge=function(e){var t;(t=this.schemas).push.apply(t,e.schemas)},e.prototype.include=function(e){return(-1===this.focusOffset||p(e,this.focusOffset))&&e!==this.exclude},e.prototype.newSub=function(){return new e(-1,this.exclude)},e}(),g=function(){function e(){}return Object.defineProperty(e.prototype,"schemas",{get:function(){return[]},enumerable:!0,configurable:!0}),e.prototype.add=function(e){},e.prototype.merge=function(e){},e.prototype.include=function(e){return!0},e.prototype.newSub=function(){return this},e.instance=new e,e}(),k=function(){function e(){this.problems=[],this.propertiesMatches=0,this.propertiesValueMatches=0,this.primaryValueMatches=0,this.enumValueMatch=!1,this.enumValues=null}return e.prototype.hasProblems=function(){return!!this.problems.length},e.prototype.mergeAll=function(e){var t=this;e.forEach(function(e){t.merge(e)})},e.prototype.merge=function(e){this.problems=this.problems.concat(e.problems)},e.prototype.mergeEnumValues=function(e){if(!this.enumValueMatch&&!e.enumValueMatch&&this.enumValues&&e.enumValues){this.enumValues=this.enumValues.concat(e.enumValues);for(var t=0,r=this.problems;t=e.offset&&t=e.offset&&o=e.offset&&o<=e.offset+e.length){for(var t=e.children,r=0;rs.maxProperties&&u.problems.push({location:{offset:i.offset,length:i.length},severity:b.Warning,message:y("MaxPropWarning","Object has more properties than limit of {0}.",s.maxProperties)});s.minProperties&&i.properties.length=u.length&&a.propertiesValueMatches++}),i.items.length>u.length)if("object"==typeof e.additionalItems)for(var t=u.length;te.maxItems&&a.problems.push({location:{offset:i.offset,length:i.length},severity:b.Warning,message:y("maxItemsWarning","Array has too many items. Expected {0} or fewer.",e.minItems)});if(!0===e.uniqueItems){var f=I(i),l=f.some(function(e,t){return t!==f.lastIndexOf(e)});l&&a.problems.push({location:{offset:i.offset,length:i.length},severity:b.Warning,message:y("uniqueItemsWarning","Array has duplicate items.")})}}(f,l,p,h);break;case"string":!function(e,t,r,n){t.minLength&&e.value.lengtht.maxLength&&r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:y("maxLengthWarning","String is longer than the maximum length of {0}.",t.maxLength)});if(t.pattern){var o=new RegExp(t.pattern);o.test(e.value)||r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:t.patternErrorMessage||t.errorMessage||y("patternWarning",'String does not match the pattern of "{0}".',t.pattern)})}if(t.format)switch(t.format){case"uri":case"uri-reference":var i=void 0;if(e.value)try{var a=s.default.parse(e.value);a.scheme||"uri"!==t.format||(i=y("uriSchemeMissing","URI with a scheme is expected."))}catch(e){i=e.message}else i=y("uriEmpty","URI expected.");i&&r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:t.patternErrorMessage||t.errorMessage||y("uriFormatWarning","String is not a URI: {0}",i)});break;case"email":e.value.match(c)||r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:t.patternErrorMessage||t.errorMessage||y("emailFormatWarning","String is not an e-mail address.")});break;case"color-hex":e.value.match(u)||r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:t.patternErrorMessage||t.errorMessage||y("colorHexFormatWarning","Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.")})}}(f,l,p);break;case"number":!function(e,t,r,n){var o=e.value;"number"==typeof t.multipleOf&&o%t.multipleOf!=0&&r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:y("multipleOfWarning","Value is not divisible by {0}.",t.multipleOf)});function i(e,t){return"number"==typeof t?t:"boolean"==typeof t&&t?e:void 0}function a(e,t){if("boolean"!=typeof t||!t)return e}var s=i(t.minimum,t.exclusiveMinimum);"number"==typeof s&&o<=s&&r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:y("exclusiveMinimumWarning","Value is below the exclusive minimum of {0}.",s)});var u=i(t.maximum,t.exclusiveMaximum);"number"==typeof u&&u<=o&&r.problems.push({location:{offset:e.offset,length:e.length},severity:b.Warning,message:y("exclusiveMaximumWarning","Value is above the exclusive maximum of {0}.",u)});var c=a(t.minimum,t.exclusiveMinimum);"number"==typeof c&&o>>=1;return r}}),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-json-languageservice/services/jsonCompletion",["require","exports","../parser/jsonParser","jsonc-parser","../utils/json","../utils/strings","vscode-languageserver-types","vscode-nls"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var b=e("../parser/jsonParser"),s=e("jsonc-parser"),r=e("../utils/json"),u=e("../utils/strings"),x=e("vscode-languageserver-types"),n=e("vscode-nls").loadMessageBundle(),o=function(){function e(e,t,r){void 0===t&&(t=[]),this.templateVarIdCounter=0,this.schemaService=e,this.contributions=t,this.promise=r||Promise}return e.prototype.doResolve=function(e){for(var t=this.contributions.length-1;0<=t;t--)if(this.contributions[t].resolveCompletion){var r=this.contributions[t].resolveCompletion(e);if(r)return r}return this.promise.resolve(e)},e.prototype.doComplete=function(c,e,f){var l=this,p={items:[],isIncomplete:!1},h=c.offsetAt(e),d=f.getNodeFromOffsetEndInclusive(h);if(this.isInComment(c,d?d.offset:0,h))return Promise.resolve(p);var m=this.getCurrentWord(c,h),g=null;if(!d||"string"!==d.type&&"number"!==d.type&&"boolean"!==d.type&&"null"!==d.type){var t=h-m.length;0t.colonOffset){var c=t.valueNode;if(c&&(r>c.offset+c.length||"object"===c.type||"array"===c.type))return;var f=t.keyNode.value;e.visit(function(e){return"property"===e.type&&e.keyNode.value===f&&e.valueNode&&u(e.valueNode),!0}),"$schema"===f&&t.parent&&!t.parent.parent&&this.addDollarSchemaCompletions(s,o)}if("array"===t.type)if(t.parent&&"property"===t.parent.type){var l=t.parent.keyNode.value;e.visit(function(e){var t=e;return"property"===e.type&&t.keyNode.value===l&&t.valueNode&&"array"===t.valueNode.type&&t.valueNode.items.forEach(u),!0})}else t.items.forEach(u)},e.prototype.getValueCompletions=function(e,t,n,o,i,a,s){var u=this,r=o,c=null,f=null;if(!n||"string"!==n.type&&"number"!==n.type&&"boolean"!==n.type&&"null"!==n.type||(r=n.offset+n.length,n=(f=n).parent),n){if("property"===n.type&&o>n.colonOffset){var l=n.valueNode;if(l&&o>l.offset+l.length)return;c=n.keyNode.value,n=n.parent}if(n&&(null!==c||"array"===n.type)){var p=this.evaluateSeparatorAfter(i,r);t.getMatchingSchemas(e.schema,n.offset,f).forEach(function(e){if(e.node===n&&!e.inverted&&e.schema){if("array"===n.type&&e.schema.items)if(Array.isArray(e.schema.items)){var t=u.findItemAtOffset(n,i,o);tt.colonOffset){var a=t.keyNode.value,s=t.valueNode;if(!s||r<=s.offset+s.length){var u=b.getNodePath(t.parent);this.contributions.forEach(function(e){var t=e.collectValueCompletions(n.uri,u,a,o);t&&i.push(t)})}}}else this.contributions.forEach(function(e){var t=e.collectDefaultCompletions(n.uri,o);t&&i.push(t)})},e.prototype.addSchemaValueCompletions=function(e,t,r,n){var o=this;"object"==typeof e&&(this.addEnumValueCompletions(e,t,r),this.addDefaultValueCompletions(e,t,r),this.collectTypes(e,n),Array.isArray(e.allOf)&&e.allOf.forEach(function(e){return o.addSchemaValueCompletions(e,t,r,n)}),Array.isArray(e.anyOf)&&e.anyOf.forEach(function(e){return o.addSchemaValueCompletions(e,t,r,n)}),Array.isArray(e.oneOf)&&e.oneOf.forEach(function(e){return o.addSchemaValueCompletions(e,t,r,n)}))},e.prototype.addDefaultValueCompletions=function(f,l,p,h){var d=this;void 0===h&&(h=0);var m=!1;if(f.default){for(var e=f.type,t=f.default,r=h;0a.offset+a.length)return n.setPosition(a.offset+a.length),5===n.scan()&&r>=n.getTokenOffset()+n.getTokenLength()?i+1:i;if(r>=a.offset)return i}return 0},e.prototype.isInComment=function(e,t,r){var n=s.createScanner(e.getText(),!1);n.setPosition(t);for(var o=n.scan();17!==o&&n.getTokenOffset()+n.getTokenLength()u.offset+1&&r