/* esm.sh - @codemirror/lang-go@6.0.1 */
import{parser as b}from"../../../@lezer/go@^1.0.0?target=es2022";import{syntaxTree as w,LRLanguage as S,indentNodeProp as g,continuedIndent as m,flatIndent as h,delimitedIndent as I,foldNodeProp as C,foldInside as D,LanguageSupport as L}from"../../language@^6.6.0?target=es2022";import{snippetCompletion as l,ifNotIn as B,completeFromList as v}from"../../autocomplete@^6.0.0?target=es2022";import{NodeWeakMap as N,IterMode as F}from"../../../@lezer/common@^1.0.0?target=es2022";var T=[l("func ${name}(${params}) ${type} {\n	${}\n}",{label:"func",detail:"declaration",type:"keyword"}),l("func (${receiver}) ${name}(${params}) ${type} {\n	${}\n}",{label:"func",detail:"method declaration",type:"keyword"}),l("var ${name} = ${value}",{label:"var",detail:"declaration",type:"keyword"}),l("type ${name} ${type}",{label:"type",detail:"declaration",type:"keyword"}),l("const ${name} = ${value}",{label:"const",detail:"declaration",type:"keyword"}),l("type ${name} = ${type}",{label:"type",detail:"alias declaration",type:"keyword"}),l("for ${init}; ${test}; ${update} {\n	${}\n}",{label:"for",detail:"loop",type:"keyword"}),l("for ${i} := range ${value} {\n	${}\n}",{label:"for",detail:"range",type:"keyword"}),l(`select {
	\${}
}`,{label:"select",detail:"statement",type:"keyword"}),l("case ${}:\n${}",{label:"case",type:"keyword"}),l("switch ${} {\n	${}\n}",{label:"switch",detail:"statement",type:"keyword"}),l("switch ${}.(${type}) {\n	${}\n}",{label:"switch",detail:"type statement",type:"keyword"}),l("if ${} {\n	${}\n}",{label:"if",detail:"block",type:"keyword"}),l(`if \${} {
	\${}
} else {
	\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),l('import ${name} "${module}"\n${}',{label:"import",detail:"declaration",type:"keyword"})],f=new N,u=new Set(["SourceFile","Block","FunctionDecl","MethodDecl","FunctionLiteral","ForStatement","SwitchStatement","TypeSwitchStatement","IfStatement"]);function c(e,n){return(r,o)=>{e:for(let t=r.node.firstChild,s=0,a=null;;){for(;!t;){if(!s)break e;s--,t=a.nextSibling,a=a.parent}n&&t.name==n||t.name=="SpecList"?(s++,a=t,t=t.firstChild):(t.name=="DefName"&&o(t,e),t=t.nextSibling)}return!0}}var x={FunctionDecl:c("function"),VarDecl:c("var","VarSpec"),ConstDecl:c("constant","ConstSpec"),TypeDecl:c("type","TypeSpec"),ImportDecl:c("constant","ImportSpec"),Parameter:c("var"),__proto__:null};function y(e,n){let r=f.get(n);if(r)return r;let o=[],t=!0;function s(a,i){let k=e.sliceString(a.from,a.to);o.push({label:k,type:i})}return n.cursor(F.IncludeAnonymous).iterate(a=>{if(t)t=!1;else if(a.name){let i=x[a.name];if(i&&i(a,s)||u.has(a.name))return!1}else if(a.to-a.from>8192){for(let i of y(e,a.node))o.push(i);return!1}}),f.set(n,o),o}var d=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,$=["String","LineComment","BlockComment","DefName","LabelName","FieldName",".","?."],V=e=>{let n=w(e.state).resolveInner(e.pos,-1);if($.indexOf(n.name)>-1)return null;let r=n.name=="VariableName"||n.to-n.from<20&&d.test(e.state.sliceDoc(n.from,n.to));if(!r&&!e.explicit)return null;let o=[];for(let t=n;t;t=t.parent)u.has(t.name)&&(o=o.concat(y(e.state.doc,t)));return{options:o,from:r?n.from:e.pos,validFor:d}},p=S.define({name:"go",parser:b.configure({props:[g.add({IfStatement:m({except:/^\s*({|else\b)/}),LabeledStatement:h,"SwitchBlock SelectBlock":e=>{let n=e.textAfter,r=/^\s*\}/.test(n),o=/^\s*(case|default)\b/.test(n);return e.baseIndent+(r||o?0:e.unit)},Block:I({closing:"}"}),BlockComment:()=>null,Statement:m({except:/^{/})}),C.add({"Block SwitchBlock SelectBlock LiteralValue InterfaceType StructType SpecList":D,BlockComment(e){return{from:e.from+2,to:e.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case\b|default\b|\})$/}}),_=e=>({label:e,type:"keyword"}),M="interface struct chan map package go return break continue goto fallthrough else defer range true false nil".split(" ").map(_);function R(){let e=T.concat(M);return new L(p,[p.data.of({autocomplete:B($,v(e))}),p.data.of({autocomplete:V})])}export{R as go,p as goLanguage,V as localCompletionSource,T as snippets};
//# sourceMappingURL=lang-go.mjs.map