2023-08-22 15:09:45 +08:00
|
|
|
`+t.value+"\n```\n"}}function tt(t){if(t)return Array.isArray(t)?t.map(De):[De(t)]}function nt(t){switch(t){case D.Read:return c.languages.DocumentHighlightKind.Read;case D.Write:return c.languages.DocumentHighlightKind.Write;case D.Text:return c.languages.DocumentHighlightKind.Text}return c.languages.DocumentHighlightKind.Text}function Se(t){return{uri:c.Uri.parse(t.uri),range:_(t.range)}}function st(t){if(!t||!t.changes)return;let n=[];for(let i in t.changes){let r=c.Uri.parse(i);for(let e of t.changes[i])n.push({resource:r,versionId:void 0,textEdit:{range:_(e.range),text:e.newText}})}return{edits:n}}function ct(t){let n=c.languages.SymbolKind;switch(t){case h.File:return n.Array;case h.Module:return n.Module;case h.Namespace:return n.Namespace;case h.Package:return n.Package;case h.Class:return n.Class;case h.Method:return n.Method;case h.Property:return n.Property;case h.Field:return n.Field;case h.Constructor:return n.Constructor;case h.Enum:return n.Enum;case h.Interface:return n.Interface;case h.Function:return n.Function;case h.Variable:return n.Variable;case h.Constant:return n.Constant;case h.String:return n.String;case h.Number:return n.Number;case h.Boolean:return n.Boolean;case h.Array:return n.Array}return n.Function}function Fe(t){return{tabSize:t.tabSize,insertSpaces:t.insertSpaces}}function ht(t){switch(t){case P.Comment:return c.languages.FoldingRangeKind.Comment;case P.Imports:return c.languages.FoldingRangeKind.Imports;case P.Region:return c.languages.FoldingRangeKind.Region}}function wt(t){let n=[],i=[],r=new Xe(t);n.push(r);let e=(...o)=>r.getLanguageServiceWorker(...o);function a(){let{languageId:o,modeConfiguration:u}=t;Le(i),u.completionItems&&i.push(c.languages.registerCompletionItemProvider(o,new Ge(e,["/","-",":"]))),u.hovers&&i.push(c.languages.registerHoverProvider(o,new Ke(e))),u.documentHighlights&&i.push(c.languages.registerDocumentHighlightProvider(o,new rt(e))),u.definitions&&i.push(c.languages.registerDefinitionProvider(o,new it(e))),u.references&&i.push(c.languages.registerReferenceProvider(o,new at(e))),u.documentSymbols&&i.push(c.languages.registerDocumentSymbolProvider(o,new ut(e))),u.rename&&i.push(c.languages.registerRenameProvider(o,new ot(e))),u.colors&&i.push(c.languages.registerColorProvider(o,new gt(e))),u.foldingRanges&&i.push(c.languages.registerFoldingRangeProvider(o,new lt(e))),u.diagnostics&&i.push(new $e(o,e,t.onDidChange)),u.selectionRanges&&i.push(c.languages.registerSelectionRangeProvider(o,new vt(e))),u.documentFormattingEdits&&i.push(c.languages.registerDocumentFormattingEditProvider(o,new dt(e))),u.documentRangeFormattingEdits&&i.push(c.languages.registerDocumentRangeFormattingEditProvider(o,new ft(e)))}return a(),n.push(Me(i)),Me(n)}function Me(t){return{dispose:()=>Le(t)}}function Le(t){for(;t.length;)t.pop().dispose()}var We,Ue,Oe,Ve,Z,He,c,ze,Xe,K,U,b,p,X,ee,B,te,re,P,ne,$,I,ie,ae,O,M,C,R,m,x,V,T,S,F,q,W,oe,mt,se,ue,H,ce,L,Q,l,G,de,fe,ge,le,he,z,ve,pe,me,D,_e,h,we,ke,be,Ee,xe,Ce,Ae,ye,Ie,Re,Pe,Be,s,$e,Ge,Ke,rt,it,at,ot,ut,_t,dt,ft,gt,lt,vt,pt=je(()=>{Ne();We=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyNames,Ve=Object.prototype.hasOwnProperty,Z=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of Oe(n))!Ve.call(t,e)&&e!==i&&We(t,e,{get:()=>n[e],enumerable:!(r=Ue(n,e))||r.enumerable});return t},He=(t,n,i)=>(Z(t,n,"default"),i&&Z(i,n,"default")),c={};He(c,Y);ze=2*60*1e3,Xe=class{constructor(t){k(this,"_defaults");k(this,"_idleCheckInterval");k(this,"_lastUsedTime");k(this,"_configChangeListener");k(this,"_worker");k(this,"_client");this._defaults=t,this._worker=null,this._client=null,this._idleCheckInterval=window.setInterval(()=>this._checkIfIdle(),30*1e3),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(()=>this._stopWorker())}_stopWorker(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null}dispose(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()}_checkIfIdle(){if(!this._worker)return;Date.now()-this._lastUs
|
|
|
|
`&&e++}r&&i.length>0&&n.push(i.length),this._lineOffsets=n}return this._lineOffsets},t.prototype.positionAt=function(n){n=Math.max(Math.min(n,this._content.length),0);var i=this.getLineOffsets(),r=0,e=i.length;if(e===0)return b.create(0,n);for(;r<e;){var a=Math.floor((r+e)/2);i[a]>n?e=a:r=a+1}var o=r-1;return b.create(o,n-i[o])},t.prototype.offsetAt=function(n){var i=this.getLineOffsets();if(n.line>=i.length)return this._content.length;if(n.line<0)return 0;var r=i[n.line],e=n.line+1<i.length?i[n.line+1]:this._content.length;return Math.max(Math.min(r+n.character,e),r)},Object.defineProperty(t.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!1,configurable:!0}),t}();(function(t){var n=Object.prototype.toString;function i(f){return typeof f!="undefined"}t.defined=i;function r(f){return typeof f=="undefined"}t.undefined=r;function e(f){return f===!0||f===!1}t.boolean=e;function a(f){return n.call(f)==="[object String]"}t.string=a;function o(f){return n.call(f)==="[object Number]"}t.number=o;function u(f,y,N){return n.call(f)==="[object Number]"&&y<=f&&f<=N}t.numberRange=u;function g(f){return n.call(f)==="[object Number]"&&-2147483648<=f&&f<=2147483647}t.integer=g;function d(f){return n.call(f)==="[object Number]"&&0<=f&&f<=2147483647}t.uinteger=d;function v(f){return n.call(f)==="[object Function]"}t.func=v;function w(f){return f!==null&&typeof f=="object"}t.objectLiteral=w;function E(f,y){return Array.isArray(f)&&f.every(y)}t.typedArray=E})(s||(s={}));$e=class{constructor(t,n,i){k(this,"_disposables",[]);k(this,"_listener",Object.create(null));this._languageId=t,this._worker=n;let r=a=>{let o=a.getLanguageId();if(o!==this._languageId)return;let u;this._listener[a.uri.toString()]=a.onDidChangeContent(()=>{window.clearTimeout(u),u=window.setTimeout(()=>this._doValidate(a.uri,o),500)}),this._doValidate(a.uri,o)},e=a=>{c.editor.setModelMarkers(a,this._languageId,[]);let o=a.uri.toString(),u=this._listener[o];u&&(u.dispose(),delete this._listener[o])};this._disposables.push(c.editor.onDidCreateModel(r)),this._disposables.push(c.editor.onWillDisposeModel(e)),this._disposables.push(c.editor.onDidChangeModelLanguage(a=>{e(a.model),r(a.model)})),this._disposables.push(i(a=>{c.editor.getModels().forEach(o=>{o.getLanguageId()===this._languageId&&(e(o),r(o))})})),this._disposables.push({dispose:()=>{c.editor.getModels().forEach(e);for(let a in this._listener)this._listener[a].dispose()}}),c.editor.getModels().forEach(r)}dispose(){this._disposables.forEach(t=>t&&t.dispose()),this._disposables.length=0}_doValidate(t,n){this._worker(t).then(i=>i.doValidation(t.toString())).then(i=>{let r=i.map(a=>Qe(t,a)),e=c.editor.getModel(t);e&&e.getLanguageId()===n&&c.editor.setModelMarkers(e,n,r)}).then(void 0,i=>{console.error(i)})}};Ge=class{constructor(t,n){this._worker=t,this._triggerCharacters=n}get triggerCharacters(){return this._triggerCharacters}provideCompletionItems(t,n,i,r){let e=t.uri;return this._worker(e).then(a=>a.doComplete(e.toString(),A(n))).then(a=>{if(!a)return;let o=t.getWordUntilPosition(n),u=new c.Range(n.lineNumber,o.startColumn,n.lineNumber,o.endColumn),g=a.items.map(d=>{let v={label:d.label,insertText:d.insertText||d.label,sortText:d.sortText,filterText:d.filterText,documentation:d.documentation,detail:d.detail,command:Ze(d.command),range:u,kind:Ye(d.kind)};return d.textEdit&&(Je(d.textEdit)?v.range={insert:_(d.textEdit.insert),replace:_(d.textEdit.replace)}:v.range=_(d.textEdit.range),v.insertText=d.textEdit.newText),d.additionalTextEdits&&(v.additionalTextEdits=d.additionalTextEdits.map(j)),d.insertTextFormat===G.Snippet&&(v.insertTextRules=c.languages.CompletionItemInsertTextRule.InsertAsSnippet),v});return{isIncomplete:a.isIncomplete,suggestions:g}})}};Ke=class{constructor(t){this._worker=t}provideHover(t,n,i){let r=t.uri;return this._worker(r).then(e=>e.doHover(r.toString(),A(n))).then(e=>{if(e)return{range:_(e.range),contents:tt(e.contents)}})}};rt=class{constructor(t){this._worker=t}provideDocumentHighlights(t,n,i){let r=t.uri;return this._worker(r).then(e=>e.findDocumentHighl
|