pxt-calliope/vs/language/json/jsonWorker.js

9 lines
86 KiB
JavaScript
Raw Normal View History

2017-08-19 17:16:35 +02:00
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* monaco-json version: 1.2.2(5618dbdb4f72c31da0555b463daa3b053decf40a)
* 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){var n;!function(e){function t(e,t){return{line:e,character:t}}function n(e){var t=e;return V.defined(t)&&V.number(t.line)&&V.number(t.character)}e.create=t,e.is=n}(n=t.Position||(t.Position={}));var r;!function(e){function t(e,t,r,i){if(V.number(e)&&V.number(t)&&V.number(r)&&V.number(i))return{start:n.create(e,t),end:n.create(r,i)};if(n.is(e)&&n.is(t))return{start:e,end:t};throw new Error("Range#create called with invalid arguments["+e+", "+t+", "+r+", "+i+"]")}function r(e){var t=e;return V.defined(t)&&n.is(t.start)&&n.is(t.end)}e.create=t,e.is=r}(r=t.Range||(t.Range={}));var i;!function(e){function t(e,t){return{uri:e,range:t}}function n(e){var t=e;return V.defined(t)&&r.is(t.range)&&(V.string(t.uri)||V.undefined(t.uri))}e.create=t,e.is=n}(i=t.Location||(t.Location={}));var o;!function(e){e.Error=1,e.Warning=2,e.Information=3,e.Hint=4}(o=t.DiagnosticSeverity||(t.DiagnosticSeverity={}));var a;!function(e){function t(e,t,n,r,i){var o={range:e,message:t};return V.defined(n)&&(o.severity=n),V.defined(r)&&(o.code=r),V.defined(i)&&(o.source=i),o}function n(e){var t=e;return V.defined(t)&&r.is(t.range)&&V.string(t.message)&&(V.number(t.severity)||V.undefined(t.severity))&&(V.number(t.code)||V.string(t.code)||V.undefined(t.code))&&(V.string(t.source)||V.undefined(t.source))}e.create=t,e.is=n}(a=t.Diagnostic||(t.Diagnostic={}));var s;!function(e){function t(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i={title:e,command:t};return V.defined(n)&&n.length>0&&(i.arguments=n),i}function n(e){var t=e;return V.defined(t)&&V.string(t.title)&&V.string(t.title)}e.create=t,e.is=n}(s=t.Command||(t.Command={}));var c;!function(e){function t(e,t){return{range:e,newText:t}}function n(e,t){return{range:{start:e,end:e},newText:t}}function r(e){return{range:e,newText:""}}e.replace=t,e.insert=n,e.del=r}(c=t.TextEdit||(t.TextEdit={}));var u;!function(e){function t(e,t){return{textDocument:e,edits:t}}function n(e){var t=e;return V.defined(t)&&d.is(t.textDocument)&&Array.isArray(t.edits)}e.create=t,e.is=n}(u=t.TextDocumentEdit||(t.TextDocumentEdit={}));var l=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,t){this.edits.push(c.insert(e,t))},e.prototype.replace=function(e,t){this.edits.push(c.replace(e,t))},e.prototype["delete"]=function(e){this.edits.push(c.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}(),f=function(){function e(e){var t=this;this._textEditChanges=Object.create(null),e?(this._workspaceEdit=e,e.changes.forEach(function(e){var n=new l(e.edits);t._textEditChanges[e.textDocument.uri]=n})):this._workspaceEdit={changes:[]}}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(d.is(e)){var t=e,n=this._textEditChanges[t.uri];if(!n){var r=[],i={textDocument:t,edits:r};this._workspaceEdit.changes.push(i),n=new l(r),this._textEditChanges[t.uri]=n}return n}return this._textEditChanges[e]},e}();t.WorkspaceChange=f;var p;!function(e){function t(e){return{uri:e}}function n(e){var t=e;return V.defined(t)&&V.string(t.uri)}e.create=t,e.is=n}(p=t.TextDocumentIdentifier||(t.TextDocumentIdentifier={}));var d;!function(e){function t(e,t){return{uri:e,version:t}}function n(e){var t=e;return V.defined(t)&&V.string(t.uri)&&V.number(t.version)}e.create=t,e.is=n}(d=t.VersionedTextDocumentIdentifier||(t.VersionedTextDocumentIdentifier={}));var h;!function(e){function t(e,t,n,r){return{uri:e,languageId:t,version:n,text:r}}function n(e){var t=e;return V.defined(t)&&V.string(t.uri)&&V.string(t.languageId)&&V.number(t.version)&&V.string(t.text)}e.create=t,e.is=n}(h=t.TextDocumentItem||(t.TextDocumentItem={}));var m;!function(
label:"[]",insertText:this.getInsertTextForGuessedValue([],t),insertTextFormat:i.InsertTextFormat.Snippet,detail:a("defaults.array","New array"),documentation:""})},e.prototype.addBooleanValueCompletion=function(e,t,n){n.add({kind:this.getSuggestionKind("boolean"),label:e?"true":"false",insertText:this.getInsertTextForValue(e,t),insertTextFormat:i.InsertTextFormat.Snippet,documentation:""})},e.prototype.addNullValueCompletion=function(e,t){t.add({kind:this.getSuggestionKind("null"),label:"null",insertText:"null"+e,insertTextFormat:i.InsertTextFormat.Snippet,documentation:""})},e.prototype.addDollarSchemaCompletions=function(e,t){var n=this,r=this.schemaService.getRegisteredSchemaIds(function(e){return"http"===e||"https"===e});r.forEach(function(r){return t.add({kind:i.CompletionItemKind.Module,label:n.getLabelForValue(r),filterText:JSON.stringify(r),insertText:n.getInsertTextForValue(r,e),insertTextFormat:i.InsertTextFormat.Snippet,documentation:""})})},e.prototype.getLabelForValue=function(e){var t=JSON.stringify(e);return t.length>57?t.substr(0,57).trim()+"...":t},e.prototype.getFilterTextForValue=function(e){return JSON.stringify(e)},e.prototype.getLabelForSnippetValue=function(e){var t=JSON.stringify(e);return t=t.replace(/\$\{\d+:([^}]+)\}|\$\d+/g,"$1"),t.length>57?t.substr(0,57).trim()+"...":t},e.prototype.getInsertTextForPlainText=function(e){return e.replace(/[\\\$\}]/g,"\\$&")},e.prototype.getInsertTextForValue=function(e,t){var n=JSON.stringify(e,null,"\t");return"{}"===n?"{\n\t$1\n}"+t:"[]"===n?"[\n\t$1\n]"+t:this.getInsertTextForPlainText(n+t)},e.prototype.getInsertTextForSnippetValue=function(e,t){var n=function(e){return"string"==typeof e&&"^"===e[0]?e.substr(1):JSON.stringify(e)};return r.stringifyObject(e,"",n)+t},e.prototype.getInsertTextForGuessedValue=function(e,t){switch(typeof e){case"object":return null===e?"${1:null}"+t:this.getInsertTextForValue(e,t);case"string":var n=JSON.stringify(e);return n=n.substr(1,n.length-2),n=this.getInsertTextForPlainText(n),'"${1:'+n+'}"'+t;case"number":case"integer":case"boolean":return"${1:"+JSON.stringify(e)+"}"+t}return this.getInsertTextForValue(e,t)},e.prototype.getSuggestionKind=function(e){if(Array.isArray(e)){var t=e;e=t.length>0?t[0]:null}if(!e)return i.CompletionItemKind.Value;switch(e){case"string":return i.CompletionItemKind.Value;case"object":return i.CompletionItemKind.Module;case"property":return i.CompletionItemKind.Property;default:return i.CompletionItemKind.Value}},e.prototype.getLabelTextForMatchingNode=function(e,t){switch(e.type){case"array":return"[]";case"object":return"{}";default:var n=t.getText().substr(e.start,e.end-e.start);return n}},e.prototype.getInsertTextForMatchingNode=function(e,t,n){switch(e.type){case"array":return this.getInsertTextForValue([],n);case"object":return this.getInsertTextForValue({},n);default:var r=t.getText().substr(e.start,e.end-e.start)+n;return this.getInsertTextForPlainText(r)}},e.prototype.getInsertTextForProperty=function(e,t,n,r){var i=this.getInsertTextForValue(e,"");if(!n)return i;var o=i+": ";if(t){var a=t["default"];if("undefined"!=typeof a)o+=this.getInsertTextForGuessedValue(a,"");else if(t["enum"]&&t["enum"].length>0)o+=this.getInsertTextForGuessedValue(t["enum"][0],"");else{var s=Array.isArray(t.type)?t.type[0]:t.type;switch(s||(t.properties?s="object":t.items&&(s="array")),s){case"boolean":o+="${1:false}";break;case"string":o+='"$1"';break;case"object":o+="{\n\t$1\n}";break;case"array":o+="[\n\t$1\n]";break;case"number":case"integer":o+="${1:0}";break;case"null":o+="${1:null}";break;default:return i}}}else o+="$1";return o+=r},e.prototype.getCurrentWord=function(e,t){for(var n=t-1,r=e.getText();n>=0&&' \t\n\r\x0B":{[,]}'.indexOf(r.charAt(n))===-1;)n--;return r.substring(n+1,t)},e.prototype.evaluateSeparatorAfter=function(e,t){var r=n.createScanner(e.getText(),!0);r.setPosition(t);var i=r.scan();switch(i){case n.SyntaxKind.CommaToken:case n.SyntaxKind.CloseBraceToken:case n.SyntaxKind.CloseBracketToken:case n.SyntaxKind.EOF:return"";default:return","}},e.prototype.isInComment=function(e,t,r){var i=
},uniqueItems:{type:"boolean","default":!1,description:r("schema.json.uniqueItems","If all of the items in the array must be unique. Defaults to false.")},maxProperties:{allOf:[{$ref:"#/definitions/positiveInteger"}],description:r("schema.json.maxProperties","The maximum number of properties an object can have. Inclusive.")},minProperties:{allOf:[{$ref:"#/definitions/positiveIntegerDefault0"}],description:r("schema.json.minProperties","The minimum number of properties an object can have. Inclusive.")},required:{allOf:[{$ref:"#/definitions/stringArray"}],description:r("schema.json.required","An array of strings that lists the names of all properties required on this object.")},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],"default":{},description:r("schema.json.additionalProperties","Either a schema or a boolean. If a schema, then used to validate all properties not matched by 'properties' or 'patternProperties'. If false, then any properties not matched by either will cause this schema to fail.")},definitions:{type:"object",additionalProperties:{$ref:"#"},"default":{},description:r("schema.json.definitions","Not used for validation. Place subschemas here that you wish to reference inline with $ref")},properties:{type:"object",additionalProperties:{$ref:"#"},"default":{},description:r("schema.json.properties","A map of property names to schemas for each property.")},patternProperties:{type:"object",additionalProperties:{$ref:"#"},"default":{},description:r("schema.json.patternProperties","A map of regular expressions on property names to schemas for matching properties.")},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]},description:r("schema.json.dependencies","A map of property names to either an array of property names or a schema. An array of property names means the property named in the key depends on the properties in the array being present in the object in order to be valid. If the value is a schema, then the schema is only applied to the object if the property in the key exists on the object.")},"enum":{type:"array",minItems:1,uniqueItems:!0,description:r("schema.json.enum","The set of literal values that are valid")},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}],description:r("schema.json.type","Either a string of one of the basic schema types (number, integer, null, array, object, boolean, string) or an array of strings specifying a subset of those types.")},format:{anyOf:[{type:"string",description:r("schema.json.format","Describes the format expected for the value."),"enum":["date-time","uri","email","hostname","ipv4","ipv6","regex"]},{type:"string"}]},allOf:{allOf:[{$ref:"#/definitions/schemaArray"}],description:r("schema.json.allOf","An array of schemas, all of which must match.")},anyOf:{allOf:[{$ref:"#/definitions/schemaArray"}],description:r("schema.json.anyOf","An array of schemas, where at least one must match.")},oneOf:{allOf:[{$ref:"#/definitions/schemaArray"}],description:r("schema.json.oneOf","An array of schemas, exactly one of which must match.")},not:{allOf:[{$ref:"#"}],description:r("schema.json.not","A schema which must not match.")}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},"default":{}}}}}),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-uri/index",["require","exports"],e)}(function(e,t){function n(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}function r(e){return encodeURIComponent(e).replace(/[!'()*]/g,n)}function i(e){return e}var o=function(){function e(){this._scheme=e._empty,this._authority=e._empty,this._path=e._empty,this._query=e._empty,this._fragment=e._empty,this._formatted=null,this._fsPath=null}return Object.defineProperty(e.prototype,"scheme",{get:function(){return this._scheme},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aut