UNPKG

code-server

Version:

Run VS Code on a remote server.

21 lines (20 loc) • 29.7 kB
"use strict";var ce=Object.create;var B=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var me=(e,i)=>{for(var o in i)B(e,o,{get:i[o],enumerable:!0})},z=(e,i,o,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of pe(i))!de.call(e,n)&&n!==o&&B(e,n,{get:()=>i[n],enumerable:!(t=fe(i,n))||t.enumerable});return e};var j=(e,i,o)=>(o=e!=null?ce(ue(e)):{},z(i||!e||!e.__esModule?B(o,"default",{value:e,enumerable:!0}):o,e)),ge=e=>z(B({},"__esModule",{value:!0}),e);var Pe={};me(Pe,{activate:()=>Ae});module.exports=ge(Pe);function V(e,i=!1){let o=e.length,t=0,n="",s=0,r=16,p=0,a=0,u=0,g=0,m=0;function x(c,v){let d=0,k=0;for(;d<c||!v;){let b=e.charCodeAt(t);if(b>=48&&b<=57)k=k*16+b-48;else if(b>=65&&b<=70)k=k*16+b-65+10;else if(b>=97&&b<=102)k=k*16+b-97+10;else break;t++,d++}return d<c&&(k=-1),k}function L(c){t=c,n="",s=0,r=16,m=0}function I(){let c=t;if(e.charCodeAt(t)===48)t++;else for(t++;t<e.length&&O(e.charCodeAt(t));)t++;if(t<e.length&&e.charCodeAt(t)===46)if(t++,t<e.length&&O(e.charCodeAt(t)))for(t++;t<e.length&&O(e.charCodeAt(t));)t++;else return m=3,e.substring(c,t);let v=t;if(t<e.length&&(e.charCodeAt(t)===69||e.charCodeAt(t)===101))if(t++,(t<e.length&&e.charCodeAt(t)===43||e.charCodeAt(t)===45)&&t++,t<e.length&&O(e.charCodeAt(t))){for(t++;t<e.length&&O(e.charCodeAt(t));)t++;v=t}else m=3;return e.substring(c,v)}function N(){let c="",v=t;for(;;){if(t>=o){c+=e.substring(v,t),m=2;break}let d=e.charCodeAt(t);if(d===34){c+=e.substring(v,t),t++;break}if(d===92){if(c+=e.substring(v,t),t++,t>=o){m=2;break}switch(e.charCodeAt(t++)){case 34:c+='"';break;case 92:c+="\\";break;case 47:c+="/";break;case 98:c+="\b";break;case 102:c+="\f";break;case 110:c+=` `;break;case 114:c+="\r";break;case 116:c+=" ";break;case 117:let b=x(4,!0);b>=0?c+=String.fromCharCode(b):m=4;break;default:m=5}v=t;continue}if(d>=0&&d<=31)if(P(d)){c+=e.substring(v,t),m=2;break}else m=6;t++}return c}function F(){if(n="",m=0,s=t,a=p,g=u,t>=o)return s=o,r=17;let c=e.charCodeAt(t);if(q(c)){do t++,n+=String.fromCharCode(c),c=e.charCodeAt(t);while(q(c));return r=15}if(P(c))return t++,n+=String.fromCharCode(c),c===13&&e.charCodeAt(t)===10&&(t++,n+=` `),p++,u=t,r=14;switch(c){case 123:return t++,r=1;case 125:return t++,r=2;case 91:return t++,r=3;case 93:return t++,r=4;case 58:return t++,r=6;case 44:return t++,r=5;case 34:return t++,n=N(),r=10;case 47:let v=t-1;if(e.charCodeAt(t+1)===47){for(t+=2;t<o&&!P(e.charCodeAt(t));)t++;return n=e.substring(v,t),r=12}if(e.charCodeAt(t+1)===42){t+=2;let d=o-1,k=!1;for(;t<d;){let b=e.charCodeAt(t);if(b===42&&e.charCodeAt(t+1)===47){t+=2,k=!0;break}t++,P(b)&&(b===13&&e.charCodeAt(t)===10&&t++,p++,u=t)}return k||(t++,m=1),n=e.substring(v,t),r=13}return n+=String.fromCharCode(c),t++,r=16;case 45:if(n+=String.fromCharCode(c),t++,t===o||!O(e.charCodeAt(t)))return r=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return n+=I(),r=11;default:for(;t<o&&W(c);)t++,c=e.charCodeAt(t);if(s!==t){switch(n=e.substring(s,t),n){case"true":return r=8;case"false":return r=9;case"null":return r=7}return r=16}return n+=String.fromCharCode(c),t++,r=16}}function W(c){if(q(c)||P(c))return!1;switch(c){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function R(){let c;do c=F();while(c>=12&&c<=15);return c}return{setPosition:L,getPosition:()=>t,scan:i?R:F,getToken:()=>r,getTokenValue:()=>n,getTokenOffset:()=>s,getTokenLength:()=>t-s,getTokenStartLine:()=>a,getTokenStartCharacter:()=>s-g,getTokenError:()=>m}}function q(e){return e===32||e===9}function P(e){return e===10||e===13}function O(e){return e>=48&&e<=57}var Q;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Q||(Q={}));var _;(function(e){e.DEFAULT={allowTrailingComma:!1}})(_||(_={}));function X(e,i){let o=[],t=new Object,n,s={value:{},offset:0,length:0,type:"object",parent:void 0},r=!1;function p(a,u,g,m){s.value=a,s.offset=u,s.length=g,s.type=m,s.colonOffset=void 0,n=s}try{D(e,{onObjectBegin:(a,u)=>{if(i<=a)throw t;n=void 0,r=i>a,o.push("")},onObjectProperty:(a,u,g)=>{if(i<u||(p(a,u,g,"property"),o[o.length-1]=a,i<=u+g))throw t},onObjectEnd:(a,u)=>{if(i<=a)throw t;n=void 0,o.pop()},onArrayBegin:(a,u)=>{if(i<=a)throw t;n=void 0,o.push(0)},onArrayEnd:(a,u)=>{if(i<=a)throw t;n=void 0,o.pop()},onLiteralValue:(a,u,g)=>{if(i<u||(p(a,u,g,be(a)),i<=u+g))throw t},onSeparator:(a,u,g)=>{if(i<=u)throw t;if(a===":"&&n&&n.type==="property")n.colonOffset=u,r=!1,n=void 0;else if(a===","){let m=o[o.length-1];typeof m=="number"?o[o.length-1]=m+1:(r=!0,o[o.length-1]=""),n=void 0}}})}catch(a){if(a!==t)throw a}return{path:o,previousNode:n,isAtPropertyKey:r,matches:a=>{let u=0;for(let g=0;u<a.length&&g<o.length;g++)if(a[u]===o[g]||a[u]==="*")u++;else if(a[u]!=="**")return!1;return u===a.length}}}function Z(e,i=[],o=_.DEFAULT){let t=null,n=[],s=[];function r(a){Array.isArray(n)?n.push(a):t!==null&&(n[t]=a)}return D(e,{onObjectBegin:()=>{let a={};r(a),s.push(n),n=a,t=null},onObjectProperty:a=>{t=a},onObjectEnd:()=>{n=s.pop()},onArrayBegin:()=>{let a=[];r(a),s.push(n),n=a,t=null},onArrayEnd:()=>{n=s.pop()},onLiteralValue:r,onError:(a,u,g)=>{i.push({error:a,offset:u,length:g})}},o),n[0]}function D(e,i,o=_.DEFAULT){let t=V(e,!1),n=[];function s(h){return h?()=>h(t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter()):()=>!0}function r(h){return h?()=>h(t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter(),()=>n.slice()):()=>!0}function p(h){return h?w=>h(w,t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter()):()=>!0}function a(h){return h?w=>h(w,t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter(),()=>n.slice()):()=>!0}let u=r(i.onObjectBegin),g=a(i.onObjectProperty),m=s(i.onObjectEnd),x=r(i.onArrayBegin),L=s(i.onArrayEnd),I=a(i.onLiteralValue),N=p(i.onSeparator),F=s(i.onComment),W=p(i.onError),R=o&&o.disallowComments,c=o&&o.allowTrailingComma;function v(){for(;;){let h=t.scan();switch(t.getTokenError()){case 4:d(14);break;case 5:d(15);break;case 3:d(13);break;case 1:R||d(11);break;case 2:d(12);break;case 6:d(16);break}switch(h){case 12:case 13:R?d(10):F();break;case 16:d(1);break;case 15:case 14:break;default:return h}}}function d(h,w=[],G=[]){if(W(h),w.length+G.length>0){let $=t.getToken();for(;$!==17;){if(w.indexOf($)!==-1){v();break}else if(G.indexOf($)!==-1)break;$=v()}}}function k(h){let w=t.getTokenValue();return h?I(w):(g(w),n.push(w)),v(),!0}function b(){switch(t.getToken()){case 11:let h=t.getTokenValue(),w=Number(h);isNaN(w)&&(d(2),w=0),I(w);break;case 7:I(null);break;case 8:I(!0);break;case 9:I(!1);break;default:return!1}return v(),!0}function re(){return t.getToken()!==10?(d(3,[],[2,5]),!1):(k(!1),t.getToken()===6?(N(":"),v(),M()||d(4,[],[2,5])):d(5,[],[2,5]),n.pop(),!0)}function le(){u(),v();let h=!1;for(;t.getToken()!==2&&t.getToken()!==17;){if(t.getToken()===5){if(h||d(4,[],[]),N(","),v(),t.getToken()===2&&c)break}else h&&d(6,[],[]);re()||d(4,[],[2,5]),h=!0}return m(),t.getToken()!==2?d(7,[2],[]):v(),!0}function ae(){x(),v();let h=!0,w=!1;for(;t.getToken()!==4&&t.getToken()!==17;){if(t.getToken()===5){if(w||d(4,[],[]),N(","),v(),t.getToken()===4&&c)break}else w&&d(6,[],[]);h?(n.push(0),h=!1):n[n.length-1]++,M()||d(4,[],[4,5]),w=!0}return L(),h||n.pop(),t.getToken()!==4?d(8,[4],[]):v(),!0}function M(){switch(t.getToken()){case 3:return ae();case 1:return le();case 10:return k(!0);default:return b()}}return v(),t.getToken()===17?o.allowEmptyContent?!0:(d(4,[],[]),!1):M()?(t.getToken()!==17&&d(9,[],[]),!0):(d(4,[],[]),!1)}function be(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}var Y;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Y||(Y={}));var K;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(K||(K={}));var A=X,E=Z;var ee=D;var C;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(C||(C={}));var f=j(require("vscode"));var l=j(require("vscode"));var T=j(require("vscode"));async function S(e,i,o,t){if(Array.isArray(e)){let s=(t?T.extensions.all:T.extensions.all.filter(r=>!(r.id.startsWith("vscode.")||r.id==="Microsoft.vscode-markdown"))).filter(r=>e.indexOf(r.id)===-1);if(s.length)return s.map(r=>{let p=new T.CompletionItem(r.id),a=`"${r.id}"${i}`;return p.kind=T.CompletionItemKind.Value,p.insertText=a,p.range=o,p.filterText=a,p});{let r=new T.CompletionItem(T.l10n.t("Example"));return r.insertText='"vscode.csharp"',r.kind=T.CompletionItemKind.Value,r.range=o,[r]}}return[]}var te=/\[([^\[\]]*)\]/g,U=class{constructor(i){this.document=i}document;async provideCompletionItems(i,o){let t=A(this.document.getText(),this.document.offsetAt(i));if(t.path[0]==="window.title")return this.provideWindowTitleCompletionItems(t,i);if(t.path[0]==="files.associations")return this.provideFilesAssociationsCompletionItems(t,i);if(t.path[0]==="files.exclude"||t.path[0]==="search.exclude"||t.path[0]==="explorer.autoRevealExclude")return this.provideExcludeCompletionItems(t,i);if(t.path[0]==="files.defaultLanguage")return this.provideLanguageCompletionItems(t,i);if(t.path[0]==="workbench.editor.label.patterns")return this.provideEditorLabelCompletionItems(t,i);if(t.path[0]==="settingsSync.ignoredExtensions"){let n=[];try{n=E(this.document.getText())["settingsSync.ignoredExtensions"]}catch{}let s=this.getReplaceRange(t,i);return S(n,"",s,!0)}if(t.path[0]==="remote.extensionKind"&&t.path.length===2&&t.isAtPropertyKey){let n=[];try{n=Object.keys(E(this.document.getText())["remote.extensionKind"])}catch{}let s=this.getReplaceRange(t,i);return S(n,t.previousNode?"":`: [ "ui" ]`,s,!0)}return t.path[0]==="remote.portsAttributes"&&t.path.length===2&&t.isAtPropertyKey?this.providePortsAttributesCompletionItem(this.getReplaceRange(t,i)):this.provideLanguageOverridesCompletionItems(t,i)}getReplaceRange(i,o){let t=i.previousNode;if(t){let n=this.document.positionAt(t.offset),s=this.document.positionAt(t.offset+t.length);if(n.isBeforeOrEqual(o)&&s.isAfterOrEqual(o))return new l.Range(n,s)}return new l.Range(o,o)}isCompletingPropertyValue(i,o){if(i.isAtPropertyKey)return!1;let t=i.previousNode;if(t){let n=this.document.offsetAt(o);return n>=t.offset&&n<=t.offset+t.length}return!0}async provideWindowTitleCompletionItems(i,o){let t=[];if(!this.isCompletingPropertyValue(i,o))return t;let n=this.document.getWordRangeAtPosition(o,/\$\{[^"\}]*\}?/);(!n||n.start.isEqual(o)||n.end.isEqual(o)&&this.document.getText(n).endsWith("}"))&&(n=new l.Range(o,o));let s=r=>{let p="${"+r+"}";return i.previousNode?p:JSON.stringify(p)};return t.push(this.newSimpleCompletionItem(s("activeEditorShort"),n,l.l10n.t("the file name (e.g. myFile.txt)"))),t.push(this.newSimpleCompletionItem(s("activeEditorMedium"),n,l.l10n.t("the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt)"))),t.push(this.newSimpleCompletionItem(s("activeEditorLong"),n,l.l10n.t("the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt)"))),t.push(this.newSimpleCompletionItem(s("activeEditorLanguageId"),n,l.l10n.t("the language identifier of the active editor (e.g. typescript)"))),t.push(this.newSimpleCompletionItem(s("activeFolderShort"),n,l.l10n.t("the name of the folder the file is contained in (e.g. myFileFolder)"))),t.push(this.newSimpleCompletionItem(s("activeFolderMedium"),n,l.l10n.t("the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder)"))),t.push(this.newSimpleCompletionItem(s("activeFolderLong"),n,l.l10n.t("the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder)"))),t.push(this.newSimpleCompletionItem(s("rootName"),n,l.l10n.t("name of the workspace with optional remote name and workspace indicator if applicable (e.g. myFolder, myRemoteFolder [SSH] or myWorkspace (Workspace))"))),t.push(this.newSimpleCompletionItem(s("rootNameShort"),n,l.l10n.t("shortened name of the workspace without suffixes (e.g. myFolder or myWorkspace)"))),t.push(this.newSimpleCompletionItem(s("rootPath"),n,l.l10n.t("file path of the workspace (e.g. /Users/Development/myWorkspace)"))),t.push(this.newSimpleCompletionItem(s("profileName"),n,l.l10n.t("name of the profile in which the workspace is opened (e.g. Data Science (Profile)). Ignored if default profile is used"))),t.push(this.newSimpleCompletionItem(s("folderName"),n,l.l10n.t("name of the workspace folder the file is contained in (e.g. myFolder)"))),t.push(this.newSimpleCompletionItem(s("folderPath"),n,l.l10n.t("file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder)"))),t.push(this.newSimpleCompletionItem(s("appName"),n,l.l10n.t("e.g. VS Code"))),t.push(this.newSimpleCompletionItem(s("remoteName"),n,l.l10n.t("e.g. SSH"))),t.push(this.newSimpleCompletionItem(s("dirty"),n,l.l10n.t("an indicator for when the active editor has unsaved changes"))),t.push(this.newSimpleCompletionItem(s("focusedView"),n,l.l10n.t("the name of the view that is currently focused"))),t.push(this.newSimpleCompletionItem(s("separator"),n,l.l10n.t("a conditional separator (' - ') that only shows when surrounded by variables with values"))),t.push(this.newSimpleCompletionItem(s("activeRepositoryName"),n,l.l10n.t("the name of the active repository (e.g. vscode)"))),t.push(this.newSimpleCompletionItem(s("activeRepositoryBranchName"),n,l.l10n.t("the name of the active branch in the active repository (e.g. main)"))),t.push(this.newSimpleCompletionItem(s("activeEditorState"),n,l.l10n.t("the state of the active editor (e.g. modified)."))),t}async provideEditorLabelCompletionItems(i,o){let t=[];if(!this.isCompletingPropertyValue(i,o))return t;let n=this.document.getWordRangeAtPosition(o,/\$\{[^"\}]*\}?/);(!n||n.start.isEqual(o)||n.end.isEqual(o)&&this.document.getText(n).endsWith("}"))&&(n=new l.Range(o,o));let s=r=>{let p="${"+r+"}";return i.previousNode?p:JSON.stringify(p)};return t.push(this.newSimpleCompletionItem(s("dirname"),n,l.l10n.t("The parent folder name of the editor (e.g. myFileFolder)"))),t.push(this.newSimpleCompletionItem(s("dirname(1)"),n,l.l10n.t("The nth parent folder name of the editor"))),t.push(this.newSimpleCompletionItem(s("filename"),n,l.l10n.t("The file name of the editor without its directory or extension (e.g. myFile)"))),t.push(this.newSimpleCompletionItem(s("extname"),n,l.l10n.t("The file extension of the editor (e.g. txt)"))),t}async provideFilesAssociationsCompletionItems(i,o){let t=[];if(i.path.length===2){if(i.path[1]===""){let n=this.getReplaceRange(i,o);t.push(this.newSnippetCompletionItem({label:l.l10n.t("Files with Extension"),documentation:l.l10n.t("Map all files matching the glob pattern in their filename to the language with the given identifier."),snippet:i.isAtPropertyKey?'"*.${1:extension}": "${2:language}"':'{ "*.${1:extension}": "${2:language}" }',range:n})),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Files with Path"),documentation:l.l10n.t("Map all files matching the absolute path glob pattern in their path to the language with the given identifier."),snippet:i.isAtPropertyKey?'"/${1:path to file}/*.${2:extension}": "${3:language}"':'{ "/${1:path to file}/*.${2:extension}": "${3:language}" }',range:n}))}else if(this.isCompletingPropertyValue(i,o))return this.provideLanguageCompletionItemsForLanguageOverrides(this.getReplaceRange(i,o))}return t}async provideExcludeCompletionItems(i,o){let t=[];if(i.path.length===1||i.path.length===2&&i.path[1]===""){let n=this.getReplaceRange(i,o);t.push(this.newSnippetCompletionItem({label:l.l10n.t("Files by Extension"),documentation:l.l10n.t("Match all files of a specific file extension."),snippet:i.path.length===2?'"**/*.${1:extension}": true':'{ "**/*.${1:extension}": true }',range:n})),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Files with Multiple Extensions"),documentation:l.l10n.t("Match all files with any of the file extensions."),snippet:i.path.length===2?'"**/*.{ext1,ext2,ext3}": true':'{ "**/*.{ext1,ext2,ext3}": true }',range:n})),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Files with Siblings by Name"),documentation:l.l10n.t("Match files that have siblings with the same name but a different extension."),snippet:i.path.length===2?'"**/*.${1:source-extension}": { "when": "$(basename).${2:target-extension}" }':'{ "**/*.${1:source-extension}": { "when": "$(basename).${2:target-extension}" } }',range:n})),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Folder by Name (Top Level)"),documentation:l.l10n.t("Match a top level folder with a specific name."),snippet:i.path.length===2?'"${1:name}": true':'{ "${1:name}": true }',range:n})),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Folders with Multiple Names (Top Level)"),documentation:l.l10n.t("Match multiple top level folders."),snippet:i.path.length===2?'"{folder1,folder2,folder3}": true':'{ "{folder1,folder2,folder3}": true }',range:n})),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Folder by Name (Any Location)"),documentation:l.l10n.t("Match a folder with a specific name in any location."),snippet:i.path.length===2?'"**/${1:name}": true':'{ "**/${1:name}": true }',range:n}))}else if(i.path.length===2&&this.isCompletingPropertyValue(i,o)){let n=this.getReplaceRange(i,o);t.push(this.newSimpleCompletionItem("true",n)),t.push(this.newSnippetCompletionItem({label:l.l10n.t("Files with Siblings by Name"),documentation:l.l10n.t("Match files that have siblings with the same name but a different extension."),snippet:'{ "when": "$(basename).${1:extension}" }',range:n}))}return t}async provideLanguageCompletionItems(i,o){if(i.path.length===1&&this.isCompletingPropertyValue(i,o)){let t=this.getReplaceRange(i,o),n=await l.languages.getLanguages();return[this.newSimpleCompletionItem(JSON.stringify("${activeEditorLanguage}"),t,l.l10n.t("Use the language of the currently active text editor if any")),...n.map(s=>this.newSimpleCompletionItem(JSON.stringify(s),t))]}return[]}async provideLanguageCompletionItemsForLanguageOverrides(i){let o=await l.languages.getLanguages(),t=[];for(let n of o){let s=new l.CompletionItem(JSON.stringify(n));s.kind=l.CompletionItemKind.Property,s.range=i,t.push(s)}return t}async provideLanguageOverridesCompletionItems(i,o){if(i.path.length===1&&i.isAtPropertyKey&&i.previousNode&&typeof i.previousNode.value=="string"&&i.previousNode.value.startsWith("[")){let t=this.document.positionAt(i.previousNode.offset+1),n=t.translate(void 0,i.previousNode.value.length),s=[],r=[],p=te.exec(i.previousNode.value),a;for(;p?.length;)a=new l.Range(this.document.positionAt(i.previousNode.offset+1+p.index),this.document.positionAt(i.previousNode.offset+1+p.index+p[0].length)),r.push(a),a.contains(o)||s.push(p[1].trim()),p=te.exec(i.previousNode.value);let u=a?a.end:t;u.isBefore(n)&&r.push(new l.Range(u,n));let g=r.find(m=>m.contains(o));if(g&&!g.isEqual(r[0])){let m=await l.languages.getLanguages(),x=[];for(let L of m)if(!s.includes(L)){let I=new l.CompletionItem(`[${L}]`);I.kind=l.CompletionItemKind.Property,I.range=g,x.push(I)}return x}}return[]}providePortsAttributesCompletionItem(i){return[this.newSnippetCompletionItem({label:'"3000"',documentation:"Single Port Attribute",range:i,snippet:` "\${1:3000}": { "label": "\${2:Application}", "onAutoForward": "\${3:openPreview}" } `}),this.newSnippetCompletionItem({label:'"5000-6000"',documentation:"Ranged Port Attribute",range:i,snippet:` "\${1:40000-55000}": { "onAutoForward": "\${2:ignore}" } `}),this.newSnippetCompletionItem({label:'".+\\\\/server.js"',documentation:"Command Match Port Attribute",range:i,snippet:` "\${1:.+\\\\/server.js}": { "label": "\${2:Application}", "onAutoForward": "\${3:openPreview}" } `})]}newSimpleCompletionItem(i,o,t,n){let s=new l.CompletionItem(i);return s.kind=l.CompletionItemKind.Value,s.detail=t,s.insertText=n||i,s.range=o,s}newSnippetCompletionItem(i){let o=new l.CompletionItem(i.label);return o.kind=l.CompletionItemKind.Value,o.documentation=i.documentation,o.insertText=new l.SnippetString(i.snippet),o.range=i.range,o}};var y=j(require("vscode")),ne=require("path"),J=class{constructor(i=y.github,o=y.authentication){this.github=i;this.authentication=o}github;authentication;name=y.l10n.t("GitHub");description=y.l10n.t("gist");async saveProfile(i,o,t){this.throwIfCancelled(t);let n=await this.authentication.getSession("github",["gist","user:email"],{createIfNone:!0});this.throwIfCancelled(t);let s=await this.github.getClient(n.id,t);try{this.throwIfCancelled(t);let r=await s.gists.create({public:!1,files:{[i]:{content:o}}},t);return r.id&&r.htmlUrl?{id:r.id,link:r.htmlUrl}:null}finally{s.dispose()}}async readProfile(i,o){this.throwIfCancelled(o);let t=typeof i=="string"?i:(0,ne.basename)(i.path),n;try{n=await this.github.getAnonymousClient(o),this.throwIfCancelled(o);let r=(await n.gists.get(t,o)).files[0];return!r||r.truncated||r.isBinary?null:r.content}catch(s){if(s instanceof y.CancellationError)throw s}finally{n?.dispose()}return null}throwIfCancelled(i){if(i?.isCancellationRequested)throw new y.CancellationError}};function ie(){return y.window.registerProfileContentHandler("github",new J)}function Ae(e){e.subscriptions.push(ie()),e.subscriptions.push(xe()),e.subscriptions.push(...Oe()),e.subscriptions.push(H("**/launch.json")),e.subscriptions.push(H("**/tasks.json")),e.subscriptions.push(H("**/*.code-workspace")),e.subscriptions.push(Ne())}function xe(){return f.languages.registerCompletionItemProvider({language:"jsonc",pattern:"**/settings.json"},{provideCompletionItems(e,i,o){return new U(e).provideCompletionItems(i,o)}})}function H(e){return f.languages.registerCompletionItemProvider({language:"jsonc",pattern:e},{provideCompletionItems(i,o,t){let n=A(i.getText(),i.offsetAt(o));if(oe(i,n,o)){if(i.fileName.endsWith(".code-workspace")&&!Le(n,["launch","tasks"]))return[];let s=i.getWordRangeAtPosition(o,/\$\{[^"\}]*\}?/);return(!s||s.start.isEqual(o)||s.end.isEqual(o)&&i.getText(s).endsWith("}"))&&(s=new f.Range(o,o)),[{label:"workspaceFolder",detail:f.l10n.t("The path of the folder opened in VS Code")},{label:"workspaceFolderBasename",detail:f.l10n.t("The name of the folder opened in VS Code without any slashes (/)")},{label:"fileWorkspaceFolderBasename",detail:f.l10n.t("The current opened file workspace folder name without any slashes (/)")},{label:"relativeFile",detail:f.l10n.t("The current opened file relative to ${workspaceFolder}")},{label:"relativeFileDirname",detail:f.l10n.t("The current opened file's dirname relative to ${workspaceFolder}")},{label:"file",detail:f.l10n.t("The current opened file")},{label:"cwd",detail:f.l10n.t("The task runner's current working directory on startup")},{label:"lineNumber",detail:f.l10n.t("The current selected line number in the active file")},{label:"selectedText",detail:f.l10n.t("The current selected text in the active file")},{label:"fileDirname",detail:f.l10n.t("The current opened file's dirname")},{label:"fileDirnameBasename",detail:f.l10n.t("The current opened file's folder name")},{label:"fileExtname",detail:f.l10n.t("The current opened file's extension")},{label:"fileBasename",detail:f.l10n.t("The current opened file's basename")},{label:"fileBasenameNoExtension",detail:f.l10n.t("The current opened file's basename with no file extension")},{label:"defaultBuildTask",detail:f.l10n.t("The name of the default build task. If there is not a single default build task then a quick pick is shown to choose the build task.")},{label:"pathSeparator",detail:f.l10n.t("The character used by the operating system to separate components in file paths. Is also aliased to '/'.")},{label:"extensionInstallFolder",detail:f.l10n.t("The path where an extension is installed."),param:"publisher.extension"}].map(r=>({label:`\${${r.label}}`,range:s,insertText:r.param?new f.SnippetString(`\${${r.label}:`).appendPlaceholder(r.param).appendText("}"):`\${${r.label}}`,detail:r.detail}))}return[]}})}function oe(e,i,o){if(i.isAtPropertyKey)return!1;let t=i.previousNode;if(t&&t.type==="string"){let n=e.offsetAt(o);return n>t.offset&&n<t.offset+t.length}return!1}function Le(e,i){return i.includes(e.path[0])}function Oe(){return[Ee(),Se()]}function Ee(){return f.languages.registerCompletionItemProvider({pattern:"**/extensions.json"},{provideCompletionItems(e,i,o){let t=A(e.getText(),e.offsetAt(i));if(t.path[0]==="recommendations"){let n=se(e,t,i),s=E(e.getText());return S(s&&s.recommendations||[],"",n,!1)}return[]}})}function Se(){return f.languages.registerCompletionItemProvider({pattern:"**/*.code-workspace"},{provideCompletionItems(e,i,o){let t=A(e.getText(),e.offsetAt(i));if(t.path[0]==="extensions"&&t.path[1]==="recommendations"){let n=se(e,t,i),s=E(e.getText()).extensions;return S(s&&s.recommendations||[],"",n,!1)}return[]}})}function se(e,i,o){let t=i.previousNode;if(t){let n=e.positionAt(t.offset),s=e.positionAt(t.offset+t.length);if(n.isBeforeOrEqual(o)&&s.isAfterOrEqual(o))return new f.Range(n,s)}return new f.Range(o,o)}f.languages.registerDocumentSymbolProvider({pattern:"**/launch.json",language:"jsonc"},{provideDocumentSymbols(e,i){let o=[],t="",n="",s=0,r=0;return ee(e.getText(),{onObjectProperty:(p,a,u)=>{n=p},onLiteralValue:(p,a,u)=>{n==="name"&&(t=p)},onObjectBegin:(p,a)=>{r++,r===2&&(s=p)},onObjectEnd:(p,a)=>{t&&r===2&&o.push(new f.SymbolInformation(t,f.SymbolKind.Object,new f.Range(e.positionAt(s),e.positionAt(p)))),r--}}),o}},{label:"Launch Targets"});function Ne(){let e=new Map([[{language:"jsonc",pattern:"**/keybindings.json"},[["*","when"]]],[{language:"json",pattern:"**/package.json"},[["contributes","menus","*","*","when"],["contributes","views","*","*","when"],["contributes","viewsWelcome","*","when"],["contributes","keybindings","*","when"],["contributes","keybindings","when"]]]]);return f.languages.registerCompletionItemProvider([...e.keys()],{async provideCompletionItems(i,o,t){let n=A(i.getText(),i.offsetAt(o));if(n.isAtPropertyKey)return;let s=!1;for(let[g,m]of e)if(f.languages.match(g,i)&&m.some(n.matches.bind(n))){s=!0;break}if(!s||!oe(i,n,o))return;let r=i.getWordRangeAtPosition(o,/[a-zA-Z.]+/)||new f.Range(o,o),p=r.with(void 0,o),a=await f.commands.executeCommand("getContextKeyInfo");if(t.isCancellationRequested||!a)return;let u=new f.CompletionList;for(let g of a){let m=new f.CompletionItem(g.key,f.CompletionItemKind.Constant);m.detail=g.type,m.range={replacing:r,inserting:p},m.documentation=g.description,u.items.push(m)}return u}})}0&&(module.exports={activate}); //# sourceMappingURL=configurationEditingMain.js.map