devicetree-language-server 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_LICENSES.txt +1 -1
- package/dist/server.js +3 -3
- package/package.json +1 -1
|
@@ -108,7 +108,7 @@ Repository: https://github.com/moxystudio/node-cross-spawn
|
|
|
108
108
|
|
|
109
109
|
----------------------------------------------------------------------
|
|
110
110
|
|
|
111
|
-
devicetree-language-server@0.10.
|
|
111
|
+
devicetree-language-server@0.10.2
|
|
112
112
|
License: Apache-2.0
|
|
113
113
|
Repository: https://github.com/kylebonnici/dts-lsp
|
|
114
114
|
|
package/dist/server.js
CHANGED
|
@@ -180,7 +180,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
180
180
|
missingProperty: ${r},
|
|
181
181
|
depsCount: ${e},
|
|
182
182
|
deps: ${n}}`};var pJ={keyword:"dependencies",type:"object",schemaType:"object",error:xi.error,code(t){let[e,n]=hJ(t);F$(t,e),B$(t,n)}};function hJ({schema:t}){let e={},n={};for(let r in t){if(r==="__proto__")continue;let i=Array.isArray(t[r])?e:n;i[r]=t[r]}return[e,n]}function F$(t,e=t.schema){let{gen:n,data:r,it:i}=t;if(Object.keys(e).length===0)return;let s=n.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Hu.propertyInData)(n,r,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?n.if(c,()=>{for(let l of a)(0,Hu.checkReportMissingProp)(t,l)}):(n.if((0,I_._)`${c} && (${(0,Hu.checkMissingProp)(t,a,s)})`),(0,Hu.reportMissingProp)(t,s),n.else())}}xi.validatePropertyDeps=F$;function B$(t,e=t.schema){let{gen:n,data:r,keyword:i,it:s}=t,o=n.name("valid");for(let a in e)(0,fJ.alwaysValidSchema)(s,e[a])||(n.if((0,Hu.propertyInData)(n,r,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>n.var(o,!0)),t.ok(o))}xi.validateSchemaDeps=B$;xi.default=pJ});var U$=N(O_=>{"use strict";Object.defineProperty(O_,"__esModule",{value:!0});var j$=be(),mJ=De(),gJ={message:"property name must be valid",params:({params:t})=>(0,j$._)`{propertyName: ${t.propertyName}}`},yJ={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:gJ,code(t){let{gen:e,schema:n,data:r,it:i}=t;if((0,mJ.alwaysValidSchema)(i,n))return;let s=e.name("valid");e.forIn("key",r,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,j$.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};O_.default=yJ});var x_=N(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var tg=$r(),pi=be(),TJ=qr(),ng=De(),vJ={message:"must NOT have additional properties",params:({params:t})=>(0,pi._)`{additionalProperty: ${t.additionalProperty}}`},bJ={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:vJ,code(t){let{gen:e,schema:n,parentSchema:r,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,ng.alwaysValidSchema)(o,n))return;let l=(0,tg.allSchemaProperties)(r.properties),u=(0,tg.allSchemaProperties)(r.patternProperties);d(),t.ok((0,pi._)`${s} === ${TJ.default.errors}`);function d(){e.forIn("key",i,y=>{!l.length&&!u.length?m(y):e.if(f(y),()=>m(y))})}function f(y){let S;if(l.length>8){let b=(0,ng.schemaRefOrVal)(o,r.properties,"properties");S=(0,tg.isOwnProperty)(e,b,y)}else l.length?S=(0,pi.or)(...l.map(b=>(0,pi._)`${y} === ${b}`)):S=pi.nil;return u.length&&(S=(0,pi.or)(S,...u.map(b=>(0,pi._)`${(0,tg.usePattern)(t,b)}.test(${y})`))),(0,pi.not)(S)}function p(y){e.code((0,pi._)`delete ${i}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&n===!1){p(y);return}if(n===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof n=="object"&&!(0,ng.alwaysValidSchema)(o,n)){let S=e.name("valid");c.removeAdditional==="failing"?(h(y,S,!1),e.if((0,pi.not)(S),()=>{t.reset(),p(y)})):(h(y,S),a||e.if((0,pi.not)(S),()=>e.break()))}}function h(y,S,b){let v={keyword:"additionalProperties",dataProp:y,dataPropType:ng.Type.Str};b===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,S)}}};M_.default=bJ});var W$=N(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var SJ=Eu(),H$=$r(),L_=De(),V$=x_(),_J={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:n,parentSchema:r,data:i,it:s}=t;s.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&V$.default.code(new SJ.KeywordCxt(s,V$.default,"additionalProperties"));let o=(0,H$.allSchemaProperties)(n);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=L_.mergeEvaluated.props(e,(0,L_.toHash)(o),s.props));let a=o.filter(d=>!(0,L_.alwaysValidSchema)(s,n[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,H$.propertyInData)(e,i,d,s.opts.ownProperties)),u(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return s.opts.useDefaults&&!s.compositeRule&&n[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};q_.default=_J});var K$=N($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var z$=$r(),rg=be(),G$=De(),Y$=De(),PJ={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:n,data:r,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,z$.allSchemaProperties)(n),c=a.filter(h=>(0,G$.alwaysValidSchema)(s,n[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof rg.Name)&&(s.props=(0,Y$.evaluatedPropsToName)(e,s.props));let{props:d}=s;f();function f(){for(let h of a)l&&p(h),s.allErrors?m(h):(e.var(u,!0),m(h),e.if(u))}function p(h){for(let y in l)new RegExp(h).test(y)&&(0,G$.checkStrictMode)(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",r,y=>{e.if((0,rg._)`${(0,z$.usePattern)(t,h)}.test(${y})`,()=>{let S=c.includes(h);S||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:y,dataPropType:Y$.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,rg._)`${d}[${y}]`,!0):!S&&!s.allErrors&&e.if((0,rg.not)(u),()=>e.break())})})}}};$_.default=PJ});var X$=N(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});var kJ=De(),NJ={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:n,it:r}=t;if((0,kJ.alwaysValidSchema)(r,n)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};F_.default=NJ});var J$=N(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var RJ=$r(),wJ={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:RJ.validateUnion,error:{message:"must match a schema in anyOf"}};B_.default=wJ});var Q$=N(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var ig=be(),EJ=De(),CJ={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,ig._)`{passingSchemas: ${t.passing}}`},DJ={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:CJ,code(t){let{gen:e,schema:n,parentSchema:r,it:i}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;let s=n,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(o,()=>t.reset(),()=>t.error(!0));function l(){s.forEach((u,d)=>{let f;(0,EJ.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,ig._)`${c} && ${o}`).assign(o,!1).assign(a,(0,ig._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,ig.Name)})})}}};j_.default=DJ});var Z$=N(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var AJ=De(),IJ={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:n,it:r}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");let i=e.name("valid");n.forEach((s,o)=>{if((0,AJ.alwaysValidSchema)(r,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};U_.default=IJ});var nF=N(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});var sg=be(),tF=De(),OJ={message:({params:t})=>(0,sg.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,sg._)`{failingKeyword: ${t.ifClause}}`},MJ={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:OJ,code(t){let{gen:e,parentSchema:n,it:r}=t;n.then===void 0&&n.else===void 0&&(0,tF.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=eF(r,"then"),s=eF(r,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else i?e.if(a,l("then")):e.if((0,sg.not)(a),l("else"));t.pass(o,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,sg._)`${u}`):t.setParams({ifClause:u})}}}};function eF(t,e){let n=t.schema[e];return n!==void 0&&!(0,tF.alwaysValidSchema)(t,n)}H_.default=MJ});var rF=N(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var xJ=De(),LJ={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){e.if===void 0&&(0,xJ.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};V_.default=LJ});var iF=N(W_=>{"use strict";Object.defineProperty(W_,"__esModule",{value:!0});var qJ=w_(),$J=x$(),FJ=E_(),BJ=q$(),jJ=$$(),UJ=eg(),HJ=U$(),VJ=x_(),WJ=W$(),zJ=K$(),GJ=X$(),YJ=J$(),KJ=Q$(),XJ=Z$(),JJ=nF(),QJ=rF();function ZJ(t=!1){let e=[GJ.default,YJ.default,KJ.default,XJ.default,JJ.default,QJ.default,HJ.default,VJ.default,UJ.default,WJ.default,zJ.default];return t?e.push($J.default,BJ.default):e.push(qJ.default,FJ.default),e.push(jJ.default),e}W_.default=ZJ});var sF=N(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});var jt=be(),e6={message:({schemaCode:t})=>(0,jt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,jt._)`{format: ${t}}`},t6={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:e6,code(t,e){let{gen:n,data:r,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;i?f():p();function f(){let m=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=n.const("fDef",(0,jt._)`${m}[${o}]`),y=n.let("fType"),S=n.let("format");n.if((0,jt._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(y,(0,jt._)`${h}.type || "string"`).assign(S,(0,jt._)`${h}.validate`),()=>n.assign(y,(0,jt._)`"string"`).assign(S,h)),t.fail$data((0,jt.or)(b(),v()));function b(){return c.strictSchema===!1?jt.nil:(0,jt._)`${o} && !${S}`}function v(){let k=u.$async?(0,jt._)`(${h}.async ? await ${S}(${r}) : ${S}(${r}))`:(0,jt._)`${S}(${r})`,R=(0,jt._)`(typeof ${S} == "function" ? ${k} : ${S}.test(${r}))`;return(0,jt._)`${S} && ${S} !== true && ${y} === ${e} && !${R}`}}function p(){let m=d.formats[s];if(!m){b();return}if(m===!0)return;let[h,y,S]=v(m);h===e&&t.pass(k());function b(){if(c.strictSchema===!1){d.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function v(R){let q=R instanceof RegExp?(0,jt.regexpCode)(R):c.code.formats?(0,jt._)`${c.code.formats}${(0,jt.getProperty)(s)}`:void 0,O=n.scopeValue("formats",{key:s,ref:R,code:q});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,jt._)`${O}.validate`]:["string",R,O]}function k(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,jt._)`await ${S}(${r})`}return typeof y=="function"?(0,jt._)`${S}(${r})`:(0,jt._)`${S}.test(${r})`}}}};z_.default=t6});var oF=N(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});var n6=sF(),r6=[n6.default];G_.default=r6});var aF=N(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.contentVocabulary=hc.metadataVocabulary=void 0;hc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];hc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var lF=N(Y_=>{"use strict";Object.defineProperty(Y_,"__esModule",{value:!0});var i6=y$(),s6=A$(),o6=iF(),a6=oF(),cF=aF(),c6=[i6.default,s6.default,(0,o6.default)(),a6.default,cF.metadataVocabulary,cF.contentVocabulary];Y_.default=c6});var X_=N(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});Vu.dynamicAnchor=void 0;var K_=be(),l6=qr(),uF=Du(),u6=Ym(),d6={keyword:"$dynamicAnchor",schemaType:"string",code:t=>dF(t,t.schema)};function dF(t,e){let{gen:n,it:r}=t;r.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,K_._)`${l6.default.dynamicAnchors}${(0,K_.getProperty)(e)}`,s=r.errSchemaPath==="#"?r.validateName:f6(t);n.if((0,K_._)`!${i}`,()=>n.assign(i,s))}Vu.dynamicAnchor=dF;function f6(t){let{schemaEnv:e,schema:n,self:r}=t.it,{root:i,baseId:s,localRefs:o,meta:a}=e.root,{schemaId:c}=r.opts,l=new uF.SchemaEnv({schema:n,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return uF.compileSchema.call(r,l),(0,u6.getValidate)(t,l)}Vu.default=d6});var J_=N(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});Wu.dynamicRef=void 0;var fF=be(),p6=qr(),pF=Ym(),h6={keyword:"$dynamicRef",schemaType:"string",code:t=>hF(t,t.schema)};function hF(t,e){let{gen:n,keyword:r,it:i}=t;if(e[0]!=="#")throw new Error(`"${r}" only supports hash fragment reference`);let s=e.slice(1);if(i.allErrors)o();else{let c=n.let("valid",!1);o(c),t.ok(c)}function o(c){if(i.schemaEnv.root.dynamicAnchors[s]){let l=n.let("_v",(0,fF._)`${p6.default.dynamicAnchors}${(0,fF.getProperty)(s)}`);n.if(l,a(l,c),a(i.validateName,c))}else a(i.validateName,c)()}function a(c,l){return l?()=>n.block(()=>{(0,pF.callRef)(t,c),n.let(l,!0)}):()=>(0,pF.callRef)(t,c)}}Wu.dynamicRef=hF;Wu.default=h6});var mF=N(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});var m6=X_(),g6=De(),y6={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,m6.dynamicAnchor)(t,""):(0,g6.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};Q_.default=y6});var gF=N(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});var T6=J_(),v6={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,T6.dynamicRef)(t,t.schema)};Z_.default=v6});var yF=N(eP=>{"use strict";Object.defineProperty(eP,"__esModule",{value:!0});var b6=X_(),S6=J_(),_6=mF(),P6=gF(),k6=[b6.default,S6.default,_6.default,P6.default];eP.default=k6});var vF=N(tP=>{"use strict";Object.defineProperty(tP,"__esModule",{value:!0});var TF=eg(),N6={keyword:"dependentRequired",type:"object",schemaType:"object",error:TF.error,code:t=>(0,TF.validatePropertyDeps)(t)};tP.default=N6});var bF=N(nP=>{"use strict";Object.defineProperty(nP,"__esModule",{value:!0});var R6=eg(),w6={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,R6.validateSchemaDeps)(t)};nP.default=w6});var SF=N(rP=>{"use strict";Object.defineProperty(rP,"__esModule",{value:!0});var E6=De(),C6={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){e.contains===void 0&&(0,E6.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};rP.default=C6});var _F=N(iP=>{"use strict";Object.defineProperty(iP,"__esModule",{value:!0});var D6=vF(),A6=bF(),I6=SF(),O6=[D6.default,A6.default,I6.default];iP.default=O6});var kF=N(sP=>{"use strict";Object.defineProperty(sP,"__esModule",{value:!0});var Vs=be(),PF=De(),M6=qr(),x6={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Vs._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},L6={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:x6,code(t){let{gen:e,schema:n,data:r,errsCount:i,it:s}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:o,props:a}=s;a instanceof Vs.Name?e.if((0,Vs._)`${a} !== true`,()=>e.forIn("key",r,d=>e.if(l(a,d),()=>c(d)))):a!==!0&&e.forIn("key",r,d=>a===void 0?c(d):e.if(u(a,d),()=>c(d))),s.props=!0,t.ok((0,Vs._)`${i} === ${M6.default.errors}`);function c(d){if(n===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,PF.alwaysValidSchema)(s,n)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:PF.Type.Str},f),o||e.if((0,Vs.not)(f),()=>e.break())}}function l(d,f){return(0,Vs._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let m in d)d[m]===!0&&p.push((0,Vs._)`${f} !== ${m}`);return(0,Vs.and)(...p)}}};sP.default=L6});var RF=N(oP=>{"use strict";Object.defineProperty(oP,"__esModule",{value:!0});var xo=be(),NF=De(),q6={message:({params:{len:t}})=>(0,xo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,xo._)`{limit: ${t}}`},$6={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:q6,code(t){let{gen:e,schema:n,data:r,it:i}=t,s=i.items||0;if(s===!0)return;let o=e.const("len",(0,xo._)`${r}.length`);if(n===!1)t.setParams({len:s}),t.fail((0,xo._)`${o} > ${s}`);else if(typeof n=="object"&&!(0,NF.alwaysValidSchema)(i,n)){let c=e.var("valid",(0,xo._)`${o} <= ${s}`);e.if((0,xo.not)(c),()=>a(c,s)),t.ok(c)}i.items=!0;function a(c,l){e.forRange("i",l,o,u=>{t.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:NF.Type.Num},c),i.allErrors||e.if((0,xo.not)(c),()=>e.break())})}}};oP.default=$6});var wF=N(aP=>{"use strict";Object.defineProperty(aP,"__esModule",{value:!0});var F6=kF(),B6=RF(),j6=[F6.default,B6.default];aP.default=j6});var CF=N(og=>{"use strict";Object.defineProperty(og,"__esModule",{value:!0});og.DiscrError=void 0;var EF;(function(t){t.Tag="tag",t.Mapping="mapping"})(EF||(og.DiscrError=EF={}))});var AF=N(lP=>{"use strict";Object.defineProperty(lP,"__esModule",{value:!0});var mc=be(),cP=CF(),DF=Du(),U6=Cu(),H6=De(),V6={message:({params:{discrError:t,tagName:e}})=>t===cP.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>(0,mc._)`{error: ${t}, tag: ${n}, tagValue: ${e}}`},W6={keyword:"discriminator",type:"object",schemaType:"object",error:V6,code(t){let{gen:e,data:n,schema:r,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=r.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,mc._)`${n}${(0,mc.getProperty)(a)}`);e.if((0,mc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:cP.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,mc._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:cP.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,mc.Name),m}function f(){var p;let m={},h=S(i),y=!0;for(let k=0;k<o.length;k++){let R=o[k];if(R?.$ref&&!(0,H6.schemaHasRulesButRef)(R,s.self.RULES)){let O=R.$ref;if(R=DF.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,O),R instanceof DF.SchemaEnv&&(R=R.schema),R===void 0)throw new U6.default(s.opts.uriResolver,s.baseId,O)}let q=(p=R?.properties)===null||p===void 0?void 0:p[a];if(typeof q!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(h||S(R)),b(q,k)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function S({required:k}){return Array.isArray(k)&&k.includes(a)}function b(k,R){if(k.const)v(k.const,R);else if(k.enum)for(let q of k.enum)v(q,R);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(k,R){if(typeof k!="string"||k in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[k]=R}}}};lP.default=W6});var IF=N((hDe,z6)=>{z6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}});var OF=N((mDe,G6)=>{G6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}});var MF=N((gDe,Y6)=>{Y6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}});var xF=N((yDe,K6)=>{K6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}});var LF=N((TDe,X6)=>{X6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}});var qF=N((vDe,J6)=>{J6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var $F=N((bDe,Q6)=>{Q6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var FF=N(uP=>{"use strict";Object.defineProperty(uP,"__esModule",{value:!0});var Z6=IF(),eQ=OF(),tQ=MF(),nQ=xF(),rQ=LF(),iQ=qF(),sQ=$F(),oQ=["/properties"];function aQ(t){return[Z6,eQ,tQ,nQ,e(this,rQ),iQ,e(this,sQ)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function e(n,r){return t?n.$dataMetaSchema(r,oQ):r}}uP.default=aQ});var BF=N((Pt,fP)=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.MissingRefError=Pt.ValidationError=Pt.CodeGen=Pt.Name=Pt.nil=Pt.stringify=Pt.str=Pt._=Pt.KeywordCxt=Pt.Ajv2019=void 0;var cQ=f$(),lQ=lF(),uQ=yF(),dQ=_F(),fQ=wF(),pQ=AF(),hQ=FF(),dP="https://json-schema.org/draft/2019-09/schema",gc=class extends cQ.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(uQ.default),lQ.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(dQ.default),this.addVocabulary(fQ.default),this.opts.discriminator&&this.addKeyword(pQ.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:n}=this.opts;n&&(hQ.default.call(this,e),this.refs["http://json-schema.org/schema"]=dP)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(dP)?dP:void 0)}};Pt.Ajv2019=gc;fP.exports=Pt=gc;fP.exports.Ajv2019=gc;Object.defineProperty(Pt,"__esModule",{value:!0});Pt.default=gc;var mQ=Eu();Object.defineProperty(Pt,"KeywordCxt",{enumerable:!0,get:function(){return mQ.KeywordCxt}});var yc=be();Object.defineProperty(Pt,"_",{enumerable:!0,get:function(){return yc._}});Object.defineProperty(Pt,"str",{enumerable:!0,get:function(){return yc.str}});Object.defineProperty(Pt,"stringify",{enumerable:!0,get:function(){return yc.stringify}});Object.defineProperty(Pt,"nil",{enumerable:!0,get:function(){return yc.nil}});Object.defineProperty(Pt,"Name",{enumerable:!0,get:function(){return yc.Name}});Object.defineProperty(Pt,"CodeGen",{enumerable:!0,get:function(){return yc.CodeGen}});var gQ=Bm();Object.defineProperty(Pt,"ValidationError",{enumerable:!0,get:function(){return gQ.default}});var yQ=Cu();Object.defineProperty(Pt,"MissingRefError",{enumerable:!0,get:function(){return yQ.default}})});var Sc=require("path"),He=L(aE());var Lf=class t{constructor(e,n,r,i){this._uri=e,this._languageId=n,this._version=r,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let n=this.offsetAt(e.start),r=this.offsetAt(e.end);return this._content.substring(n,r)}return this._content}update(e,n){for(let r of e)if(t.isIncremental(r)){let i=lE(r.range),s=this.offsetAt(i.start),o=this.offsetAt(i.end);this._content=this._content.substring(0,s)+r.text+this._content.substring(o,this._content.length);let a=Math.max(i.start.line,0),c=Math.max(i.end.line,0),l=this._lineOffsets,u=cE(r.text,!1,s);if(c-a===u.length)for(let f=0,p=u.length;f<p;f++)l[f+a+1]=u[f];else u.length<1e4?l.splice(a+1,c-a,...u):this._lineOffsets=l=l.slice(0,a+1).concat(u,l.slice(c+1));let d=r.text.length-(o-s);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(t.isFull(r))this._content=r.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=n}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=cE(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let n=this.getLineOffsets(),r=0,i=n.length;if(i===0)return{line:0,character:e};for(;r<i;){let o=Math.floor((r+i)/2);n[o]>e?i=o:r=o+1}let s=r-1;return{line:s,character:e-n[s]}}offsetAt(e){let n=this.getLineOffsets();if(e.line>=n.length)return this._content.length;if(e.line<0)return 0;let r=n[e.line],i=e.line+1<n.length?n[e.line+1]:this._content.length;return Math.max(Math.min(r+e.character,i),r)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let n=e;return n!=null&&typeof n.text=="string"&&n.range!==void 0&&(n.rangeLength===void 0||typeof n.rangeLength=="number")}static isFull(e){let n=e;return n!=null&&typeof n.text=="string"&&n.range===void 0&&n.rangeLength===void 0}},Lt;(function(t){function e(i,s,o,a){return new Lf(i,s,o,a)}t.create=e;function n(i,s,o){if(i instanceof Lf)return i.update(s,o),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}t.update=n;function r(i,s){let o=i.getText(),a=yT(s.map(sH),(u,d)=>{let f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f}),c=0,l=[];for(let u of a){let d=i.offsetAt(u.range.start);if(d<c)throw new Error("Overlapping edit");d>c&&l.push(o.substring(c,d)),u.newText.length&&l.push(u.newText),c=i.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}t.applyEdits=r})(Lt||(Lt={}));function yT(t,e){if(t.length<=1)return t;let n=t.length/2|0,r=t.slice(0,n),i=t.slice(n);yT(r,e),yT(i,e);let s=0,o=0,a=0;for(;s<r.length&&o<i.length;)e(r[s],i[o])<=0?t[a++]=r[s++]:t[a++]=i[o++];for(;s<r.length;)t[a++]=r[s++];for(;o<i.length;)t[a++]=i[o++];return t}function cE(t,e,n=0){let r=e?[n]:[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);(s===13||s===10)&&(s===13&&i+1<t.length&&t.charCodeAt(i+1)===10&&i++,r.push(n+i+1))}return r}function lE(t){let e=t.start,n=t.end;return e.line>n.line||e.line===n.line&&e.character>n.character?{start:n,end:e}:t}function sH(t){let e=lE(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var qf=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],$f=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var vT=L(require("url")),TE=require("crypto"),fa=require("path"),zt=L(U());var TT=L(U());var Kn=L(U());var te=class{constructor(e){this._children=[];this.syntaxIssues=[];this.resettableIssues=[];this._firstToken=e?.start,this._lastToken=e?.end}get issues(){return[...this.syntaxIssues,...this.resettableIssues]}resetIssues(){this.resettableIssues=[],this.children.forEach(e=>e.resetIssues())}get serializeIssues(){return this.issues.map(e=>e())}get firstToken(){return this._firstToken??this._children[0].firstToken}set firstToken(e){this._firstToken=e}get lastToken(){return this._lastToken??this._children[this._children.length-1]?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get fsPath(){return this.firstToken.fsPath}getTopMostAstNodeForFile(e){return fe(e,this.fsPath)?[this]:this.children.flatMap(n=>n.getTopMostAstNodeForFile(e))}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(r=>r.getDocumentSymbols(e)??[]);if(!fe(this.fsPath,e))return[];let n=ce(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:n,selectionRange:n,children:[...this.children.flatMap(r=>r.getDocumentSymbols(e)??[])]}]}getWorkspaceSymbols(){if(!this.docSymbolsMeta)return this.children.flatMap(i=>i.getWorkspaceSymbols()??[]);let e=this.docSymbolsMeta.kind;if(![Kn.SymbolKind.File,Kn.SymbolKind.Class,Kn.SymbolKind.Constant].some(i=>i===e))return[];let n=pn(this.fsPath),r=n?.range??ce(this);return[{location:Kn.Location.create(ue(n?.fsPath??this.fsPath),r),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(i=>i.getWorkspaceSymbols()??[]).filter(i=>i.kind===Kn.SymbolKind.File||i.kind===Kn.SymbolKind.Class||i.kind===Kn.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(n=>n.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(Hi(this.semanticTokenType),Vi(this.semanticTokenModifiers),this.firstToken,this.lastToken)}get children(){return this._children}get allDescendants(){return this.allDescendantsCache??=[...this._children,...this._children.flatMap(e=>e.allDescendants)],this.allDescendantsCache}addChild(e){e&&(e.parentNode=this,this._children.push(e)),this.allDescendantsCache=void 0}isAncestorOf(e){return this.children.some(n=>n===e||n.isAncestorOf(e))}toPrettyString(e){return this.toString()}toString(e){return"TODO"}get range(){return Kn.Range.create(Kn.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Kn.Position.create(this.lastToken.pos.line,this.lastToken.pos.colEnd))}get serializeURL(){return ue(this.fsPath)}serialize(e){return{url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var me=class extends te{get firstToken(){return this.operator?this.operator.firstToken:super.firstToken}toJson(){return-1}#e;resolve(e){return this.#e??=Hc(this.toString(),e),this.#e}#n;evaluate(e){return this.#n??=Me(`${this.operator?this.operator.toString():""}${this.resolve(e)}`),this.#n}#r;isTrue(e){return this.#r??=Me(`!!(${this.operator?this.operator.toString():""}${this.resolve(e)})`),typeof this.#r=="boolean"&&this.#r}toPrettyString(e){let n=this.evaluate(e);return`${n.toString()} /* ${this.toString()}${typeof n=="number"?` = 0x${n.toString(16)}`:""} */`}serialize(e){return{type:"EXPRESSION",value:this.toString(),evaluated:this.evaluate(e),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},rn=class t extends me{constructor(n,r,i){super();this.expression=n;this.wrapped=r;this.addChild(n),i&&(this.addChild(i.operator),this.addChild(i.expression),this.join=[],this.join?.push(i))}get firstToken(){return this.openBracket?this.openBracket:super.firstToken}get lastToken(){return this.closeBracket?this.closeBracket:super.lastToken}addExpression(n,r){this.addChild(n),this.addChild(r),this.join??=[],this.join?.push({operator:n,expression:r})}toString(){let n=this.children.map(r=>"radix"in r&&r.radix===16?`0x${r.toString()}`:r.toString()).join(" ");return this.wrapped?`(${n})`:`${n}`}isTrue(n){let r=`(${this.children.map(i=>i instanceof me?i.resolve(n):i.toString()).join(" ")})`;return Me(`!!(${this.operator?this.operator.toString():""}${r})`)}get flatJoin(){return this.wrapped?this.join??(this.expression instanceof t?this.expression.flatJoin:[]):[...this.expression instanceof t?this.expression.flatJoin:[],...this.join?.flatMap(n=>[{operator:n.operator,expression:n.expression instanceof t?n.expression.expression:n.expression},...n.expression instanceof t?n.expression.flatJoin:[]])??[]]}};var vi=class extends me{constructor(n,r,i){super(r);this.value=n;this.docSymbolsMeta={name:`param${i+1}`,kind:TT.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Wt=class extends me{constructor(n,r){super();this.functionName=n;this.params=r;this.addChild(n),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(n){return fe(this.fsPath,n)?[{name:this.functionName.name,kind:TT.SymbolKind.Function,range:ce(this),selectionRange:ce(this),children:this.params.flatMap(r=>r?.getDocumentSymbols(n)??[])}]:[]}toString(){return`${this.functionName.toString()}(${this.params.map(n=>n?.toString()??"").join(", ")})`}isTrue(n){if(this.functionName.name==="defined"){let r=!!(this.params.length===1&&this.params[0]&&n.has(this.params[0].value));return this.operator?Me(`!!(${this.operator}${r})`):r}return super.isTrue(n)}};var Kr=L(U());var hE=L(U());var uE=L(U());var re=class extends te{constructor(n,r){super(r);this.value=n;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:uE.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}serialize(){return{type:"STRING",value:this.value,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var fE=L(U());var dE=L(U());var sn=class extends me{constructor(n,r,i=10){super(r);this.value=n;this.radix=i;this.docSymbolsMeta={name:this.value.toString(),kind:dE.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}resolve(n){return this.value.toString()}evaluate(n){return this.value}isTrue(n){return!!this.value}toString(n){return this.value.toString(n??this.radix)}toJson(){return this.value}toPrettyString(n){let r=this.value;return this.radix===16?`0x${r.toString(16)} /* ${typeof r=="number"?`${r.toString(10)}`:""} */`:`${r.toString(10)} /* ${typeof r=="number"?`0x${r.toString(16)}`:""} */`}serialize(){return{type:"NUMBER_VALUE",value:`${this.radix===16?"0x":""}${this.toString()}`,evaluated:this.value,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var ct=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Cell Array",kind:fE.SymbolKind.Array},this.values.forEach(r=>this.addChild(r))}toString(){return`<${this.values.map(n=>n.toString()).join(" ")}>`}toPrettyString(n){return`<${this.values.map(r=>r.toPrettyString(n)).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(n=>n.value instanceof sn)){let n=new ArrayBuffer(8),r=new DataView(n);return this.values.map(i=>i.value.value).forEach((i,s)=>{r.setUint32(s*4,i)}),r.getBigUint64(0)}return this.values.map(n=>n.value?.toJson()??NaN)}serialize(n){return{type:"ARRAY_VALUE",value:this.values.map(r=>r.value?.serialize(n)??null),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var pE=L(U());var Mn=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Byte String Value",kind:pE.SymbolKind.Array},this.values.forEach(r=>this.addChild(r))}toString(){return`[${this.values.map(n=>n.toString(16).padStart(2,"0")).join(" ")}]`}toJson(){return this.values.map(n=>n.value?.toJson()??NaN)}serialize(){return{type:"BYTESTRING",values:this.values.map(n=>n.value?.serialize()??null),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Xe=class extends te{constructor(n,r){super(r);this.name=n;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}serialize(){return{value:this.name,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},Ne=class extends te{constructor(n,r=[]){super();this.propertyName=n;this.labels=r;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:hE.SymbolKind.Property},this.labels.forEach(i=>this.addChild(i)),this.addChild(n)}set values(n){if(this._values)throw new Error("Only one property name is allowed");this._values=n,this.addChild(n)}get values(){return this._values}get quickValues(){return this.values?.values.map(n=>n?n.value instanceof re?n.value.value:n.value instanceof ct?n.value.values.map(r=>r.value instanceof sn?r.value.value:NaN):n.value instanceof Mn?n.value.values.map(r=>r.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(n=>n?n.value instanceof re?n.value:n.value instanceof ct?n.value.values.map(r=>r.value):n.value instanceof Mn?n.value.values.map(r=>r.value):n.value:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(n=>n?.toString()??"NULL").join(", ")??"NULL"}`:""};`}toPrettyString(n,r){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(i=>i?.toPrettyString(n)??"NULL").join(r?`,
|
|
183
|
-
${" ".repeat(r)}`:", ")??"NULL"}`:""};${bi(this.fsPath)?" /* default value from binding */":""}`}serialize(n){return{name:this.propertyName?.serialize()??null,values:this.values===void 0?void 0:this.values?.values.map(r=>r?.value?.serialize(n)??null)??null,url:this.serializeURL,range:this.range,issues:[...this.serializeIssues,...this.values?.issues.map(r=>r())??[]]}}};var mE=L(U());var hn=class extends te{constructor(n,r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:n,kind:mE.SymbolKind.Function}}};var Xn=class extends hn{constructor(n){super("Delete Node",n);this._nodeNameOrRef=null}set nodeNameOrRef(n){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=n,this.addChild(n)}get nodeNameOrRef(){return this._nodeNameOrRef}};var lt=class extends hn{constructor(n){super("Delete Property",n);this._propertyName=null}set propertyName(n){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=n,this.addChild(n)}get propertyName(){return this._propertyName}};var gE=L(U());var ie=class extends te{constructor(n){super();this.label=n;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:gE.SymbolKind.Key},this.addChild(n)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}serialize(){return{type:"LABEL_REF",label:this.label?.toString()??null,nodePath:this.linksTo?.pathString??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var we=class t extends te{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof nt)return[this.pathName];if(!(this.parentNode instanceof t))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof t)}get deleteNodes(){return this.children.filter(e=>e instanceof Xn)}addNodeChild(e){this.addChild(e)}},nt=class extends we{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Kr.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ne)}#e;get name(){return this.#e??=new $e("/",he(this.firstToken)),this.#e}get identifierAst(){return this.name}get deleteProperties(){return this.children.filter(e=>e instanceof lt)}get nodes(){return this.children.filter(e=>e instanceof Ee)}get pathName(){return"/"}serialize(e){return{type:"ROOT",properties:this.properties.map(n=>n.serialize(e)),nodes:this.nodes.map(n=>n.serialize(e)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&se(this.openScope),scopeClose:this.closeScope&&se(this.closeScope,!1)}}},ut=class extends we{constructor(n=[]){super();this.labels=n;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Kr.SymbolKind.Class},n.forEach(r=>{super.addChild(r)})}get serializeIssues(){return[...this.issues,...this.reference?.issues??[]].map(n=>n())}get identifierAst(){return this.reference}set reference(n){if(this._reference)throw new Error("Only on label reference is allowed");this._reference=n;let r;n instanceof ie?r=n.value:r=n?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:r??"DTC Name",kind:Kr.SymbolKind.Class},this.addChild(n)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get reference(){return this._reference}get nodes(){return this.children.filter(n=>n instanceof Ee)}get pathName(){if(this.reference instanceof ie&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(n=>n instanceof Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof lt)}serialize(n){return{type:"REF",labels:this.labels.map(r=>r.serialize(n)),name:this.reference?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&se(this.openScope),scopeClose:this.closeScope&&se(this.closeScope,!1)}}},Ee=class t extends we{constructor(n=[],r){super();this.labels=n;this.omitIfNoRef=r;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Kr.SymbolKind.Class},r&&this.addChild(r),n.forEach(i=>{this.addChild(i)})}get identifierAst(){return this.name}get serializeIssues(){return[...this.issues,...this.name?.issues??[]].map(n=>n())}set name(n){if(this._name)throw new Error("Only on label reference is allowed");this._name=n,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:Kr.SymbolKind.Class},this.addChild(n)}get name(){return this._name}get nodes(){return this.children.filter(n=>n instanceof t)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(n=>n instanceof Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof lt)}serialize(n){return{type:"CHILD",labels:this.labels.map(r=>r.serialize(n)),name:this.name?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&se(this.openScope),scopeClose:this.closeScope&&se(this.closeScope,!1)}}},Vc=class extends te{constructor(n,r){super(r);this.address=n;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address?.map((n,r)=>n.toString(16).padStart(r?8:0,"0")).join("")??"NaN"}serialize(){return{address:this.address,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},$e=class extends te{constructor(n,r,i){super(r);this.name=n;this._address=i;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(n){if(this._address)throw new Error("Address can only be set once");n&&(this.lastToken=void 0,this._address=n,n.forEach(r=>this.addChild(r)))}get fullAddress(){return this._address?[...this._address.flatMap(n=>n.address)]:void 0}toString(){return this._address!==void 0?`${this.name}@${this._address.map(n=>n.toString()).join(",")}`:this.name}buildSemanticTokens(n){let r=this.firstToken;if(!r.value)return;let i={...r,pos:{...r.pos,len:this.name.length}};n(Hi("type"),Vi("declaration"),i,i),this.address!==void 0&&this.address.forEach(s=>{n(Hi("decorator"),Vi("declaration"),s.firstToken,s.lastToken),s.buildSemanticTokens(n)})}get serializeIssues(){return[...this.issues,...this._address?.flatMap(n=>n.issues)??[]].map(n=>n())}serialize(){let n=this.firstToken;return{fullName:this.toString(),name:{name:this.name,url:this.serializeURL,range:Kr.Range.create(Kr.Position.create(n.pos.line,n.pos.col),Kr.Position.create(n.pos.line,n.pos.colEnd)),issues:this.serializeIssues},address:this.address?.map(r=>r.serialize())??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var on=(t,e,n=!0,r=!0)=>({start:{line:t?.pos.line??0,character:n?t?.pos.col??0:(t?.pos.col??0)+(t?.pos.len??0)},end:{line:e?.pos.line??0,character:r?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var se=(t,e=!0)=>zt.Position.create(t.pos.line,e?t.pos.colEnd:t.pos.col),ce=t=>on(t.firstToken,t.lastToken),Hi=t=>qf.findIndex(e=>e===t),Vi=t=>$f.findIndex(e=>e===t),gs=(t,e,n)=>!fe(t.fsPath,e)||n.line<t.pos.line?!1:n.line>t.pos.line?!0:n.character>=t.pos.colEnd,bT=(t,e,n)=>fe(t.fsPath,e)?n.line<t.pos.line?!0:n.line>t.pos.line?!1:n.character<t.pos.col:!1,Qt=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!((r.pos.line<n.line||r.pos.line===n.line&&r.pos.col<=n.character)&&(i.pos.line>n.line||i.pos.line===n.line&&i.pos.colEnd>=n.character)&&fe(t.fsPath,e))},ao=(t,e)=>{let n=(i,s)=>i.line<s.line||i.line===s.line&&i.character<=s.character,r=(i,s)=>i.line>s.line||i.line===s.line&&i.character>=s.character;return n(t.start,e.start)&&r(t.end,e.end)},vE=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!(t.lastToken.value!==";"&&(r.pos.line===n.line||i.pos.line===n.line)&&n.character>=i.pos.colEnd&&fe(t.fsPath,e))},bE=(t,e,n)=>{if(!t)return!1;let i=t.filter(s=>s.pos.line===n.line).at(-1);return i&&i.pos.col>=n.character?!1:e.lastToken===i};var Jr=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>Qt(s,e,n));return r},Wc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].find(s=>bT(s.lastToken,e,n));return r===t?void 0:r},zc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>gs(s.firstToken,e,n));return r===t?void 0:r},ST="#virtual",bi=t=>t.includes(ST),jf=(t,e)=>`${t}?loc=${e.start.line}:${e.start.character}-${e.end.line}:${e.end.character}${ST}`,pn=t=>{if(!bi(t))return;let[e,n]=t.split("?"),[r,i]=n.replace("loc=","").replace(ST,"").split("-"),[s,o]=r.split(":"),[a,c]=i.split(":");return{fsPath:e,range:zt.Range.create(zt.Position.create(Number.parseInt(s),Number.parseInt(o)),zt.Position.create(Number.parseInt(a),Number.parseInt(c)))}},_T=t=>{let e=pn(t.fsPath);e&&(t.range=e.range,t.fsPath=e?.fsPath,t.virtual=!0,t.linkedTo=t.linkedTo.map(({range:n,fsPath:r})=>{let i=pn(r);return{range:i?.range??n,fsPath:i?.fsPath??r,templateStrings:[]}}))},Y=(t,e,n=e,r,{severity:i=zt.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,inclusiveStart:u,inclusiveEnd:d}={severity:zt.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let f={issues:Array.isArray(t)?t:[t],range:on(e,n,u,d),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:h,fsPath:y})=>{let S=pn(y);return S?{...S,templateStrings:[]}:{range:h,fsPath:y,templateStrings:[]}}),tags:o,templateStrings:a,edit:c,codeActionTitle:l};_T(f);let p,m=()=>(p??={severity:f.severity,range:f.range,message:f.issues?f.issues.map(lH).join(" or "):"",source:"devicetree",tags:f.tags,data:{firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},type:"SyntaxIssue",items:f.issues,edit:f.edit,codeActionTitle:f.codeActionTitle,virtual:!!f.virtual}},p);return r?.syntaxIssues.push(m),{raw:f,diagnostic:m}},Gt=(t,e,n,r,{severity:i=zt.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,linkedToTemplateStrings:u=[]}={severity:zt.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let d={issues:Array.isArray(t)?t:[t],range:on(e,n),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:m,fsPath:h},y)=>{let S=pn(h);return S?{...S,templateStrings:[]}:{range:m,fsPath:h,templateStrings:u.at(y)??[]}}),tags:o,templateStrings:a,edit:c,codeActionTitle:l};_T(d);let f,p=()=>(f??={severity:d.severity,range:d.range,message:uH(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(m=>({message:d.issues.map(h=>dH(h,m.templateStrings)).join(" or "),location:{uri:ue(m.fsPath),range:m.range}}))]},f);return r?.resettableIssues.push(p),{raw:d,diagnostic:p}},F=(t,e,n,r,{severity:i=zt.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l}={severity:zt.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let u={issues:Array.isArray(t)?t:[t],range:on(e,n),severity:i,fsPath:e.fsPath,linkedTo:s.map(({range:p,fsPath:m})=>{let h=pn(m);return h?{...h,templateStrings:[]}:{range:p,fsPath:m,templateStrings:[]}}),tags:o,templateStrings:a,edit:c,codeActionTitle:l};_T(u);let d,f=()=>(d??={severity:u.severity,range:u.range,message:fH(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(pH).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"StandardTypeIssue",firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},edit:u.edit,codeActionTitle:u.codeActionTitle,items:u.issues,virtual:!!u.virtual}},d);return Array.isArray(r)?r.forEach(p=>p.resettableIssues.push(f)):r?.resettableIssues.push(f),{raw:u,diagnostic:f}};function Ve(t,e,n,{severity:r=zt.DiagnosticSeverity.Warning,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:zt.DiagnosticSeverity.Warning,linkedTo:[],templateStrings:[],edit:[],codeActionTitle:void 0},l=n){let u={issues:Array.isArray(t)?t:[t],range:zt.Range.create(n,l),severity:r,fsPath:e,linkedTo:i.map(({range:p,fsPath:m})=>({range:p,fsPath:m,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c,virtual:bi(e)},d;return{raw:u,diagnostic:()=>(d??={severity:u.severity,range:u.range,message:hH(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(mH).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"FormattingIssues",items:u.issues,edit:u.edit,codeActionTitle:u.codeActionTitle,virtual:!!u.virtual}},d)}}var SE=(t,e)=>[...t].sort((r,i)=>{let s=e.getSortKey(r),o=e.getSortKey(i);if(s===void 0||o===void 0)throw new Error("Sort keys must be set");if(s!==o)return s-o;let a=r.lastToken,c=i.lastToken;return a.pos.line!==c.pos.line?a.pos.line-c.pos.line:a.pos.col-c.pos.col});async function Rt(t,e,n){let r=_e(t.textDocument.uri);if(!e)return[];let i=performance.now(),s=await e.getRuntime(),o,a,c=s.context.allParsers.flatMap(u=>u.injectedMacros).find(u=>Qt(u,r,t.position));if(c&&(o={runtime:s,item:null,ast:Jr(c,r,t.position)},a=Number.MAX_SAFE_INTEGER),!o){if(o=s.getDeepestAstNode(r,t.position),a=e.getSortKey(o?.ast),!a){let u=s.context.getFsPathParser(r),d=r;for(;!a&&u;){let f=u.includes.filter(m=>fe(m.fsPath,d)&&m.resolvedPath).at(-1);if(!f?.resolvedPath)break;let p=s.fileTopMostAsts(f.resolvedPath);a=e.getSortKey(p.sort((m,h)=>(e.getSortKey(m)??0)-(e.getSortKey(h)??0)).at(-1),!0),d=f.resolvedPath}}e.getSortKeyFile(t.position,r)}return console.log(`search: ${performance.now()-i}ms`),n(o,u=>{let d=t.position;if(fe(u.fsPath,r)){let f=u.lastToken;return f.pos.line<d.line||f.pos.line===d.line&&f.pos.colEnd<=d.character}return a!==void 0&&(e.getSortKey(u)??-1)<=a})}function he(t,e){return{start:t,end:e??t}}var H=(t,e)=>t?.tokens.some(n=>n===e),st=(t,e)=>n=>n?.value&&(e?.caseInsensitive?t.toLowerCase()===n.value.toLowerCase():t===n.value)?"yes":e?.allowPartial?oH(t)(n):"no",Fe=t=>e=>e?.tokens.some(n=>n===t)?"yes":"no",oH=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",mn=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&fe(t.fsPath,e.fsPath),Yt=(t,e)=>t?.tokens[0]===21&&e?.tokens[0]===21&&(t?.prevToken&&t.prevToken.value===e?.value||e?.prevToken&&e.prevToken.value===t?.value)?!0:!!t&&!!e&&t.pos.colEnd===e.pos.col&&mn(t,e),Uf=t=>t.map((e,n)=>({index:n,context:e,files:e.getContextFiles()})),Rn=(t,e,n,r)=>{if("id"in e){let s=t?.find(o=>o.id===e.id);return s||void 0}if("name"in e){let s=t?.find(o=>o.ctxNames.includes(e.name));return s||void 0}return n?.getContextFiles().find(s=>fe(s,e.fsPath))?n:Uf(t).sort(s=>s.context.id===r?-1:0).find(s=>s.files.some(o=>fe(o,e.fsPath)))?.context},PT=(t,e)=>Uf(t).filter(r=>r.files.some(i=>fe(i,e))).map(r=>r.context),_E=t=>{let e=/^(\w+)\s+(.*)$/,n=/^(\w+)\(([^)]*)\)\s+(.*)$/,r=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.*)$/,i;if(i=r.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o,u=c.slice(a.length).join(", ");return a.forEach((d,f)=>{l=l.replace(new RegExp(`(?<!#)#\\s*${d}\\b`,"g"),`"${c[f]??""}"`)}),l=l.replace(/(?<!#)#\s*__VA_ARGS__/g,`"${u}"`),a.forEach((d,f)=>{let p=new RegExp(`\\b${d}\\b`,"g");l=l.replace(p,c[f]??"")}),l=l.replace(/__VA_ARGS__/g,u),l}}else if(i=n.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{l=l.replace(new RegExp(`(?<!#)#\\s*${u}\\b`,"g"),`"${c[d]??""}"`)}),a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d]??"")}),l}}else if(i=e.exec(t)){let[,,s]=i;return s.trim()}};function aH(t){if(!t.trim())return[];let e=[],n="",r=0;for(let i=0;i<t.length;i++){let s=t[i];s===","&&r===0?(e.push(n.trim()),n=""):(s==="("?r++:s===")"&&r--,n+=s)}return n.trim()&&e.push(n.trim()),e}var cH=0,Hc=(t,e)=>{let n=s=>s.replace(/\s*##\s*/g,""),r=t,i;do i=r,r=n(i),r=r.replace(/\b(\w+)\(([^()]*(?:\([^()]*\)[^()]*)*)\)|\b(\w+)\b/g,(s,o,a,c)=>{if(o==="defined"){let l=a.split(",").map(u=>u.trim());return l[0]?e.get(l[0])?.resolver:l}else if(o&&typeof e.get(o)?.resolver=="function"){let l=aH(a).map(u=>u.trim()).map(u=>u==="__COUNTER__"?(cH++).toString():u).map(u=>Hc(u,e));return(e.get(o)?.resolver)(...l)}else if(c&&typeof e.get(c)?.resolver=="string")return e.get(c)?.resolver;return s});while(r!==i);return r};function kT(t){return t.replace(/'(.)'/g,(e,n)=>n.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Me(t){try{return(0,eval)(kT(t))}catch{}return t}var ue=t=>vT.default.pathToFileURL(t).toString(),_e=t=>dt(vT.default.fileURLToPath(t)),PE=(t,e)=>{let n=(0,fa.relative)(t,e);return!!n&&!n.startsWith("..")&&!(0,fa.isAbsolute)(n)},fe=(t,e)=>!t||!e?!1:t===e,dt=t=>(0,fa.normalize)(process.platform==="win32"?t.toLowerCase():t),Wi=t=>(0,TE.createHash)("sha256").update([dt(t.dtsFile),...t.includePaths.map(dt),...t.overlays.map(dt),t.bindingType,...t.zephyrBindings.map(dt),...t.deviceOrgBindingsMetaSchema.map(dt),...t.deviceOrgTreeBindings.map(dt),`showFormattingErrorAsDiagnostics-${t.showFormattingErrorAsDiagnostics}`,`disableFileWatchers-${t.disableFileWatchers}`].join(":")).digest("hex"),lH=t=>{switch(t){case 0:return"Expected value";case 1:return"Expected ';'";case 2:return"Expected '{'";case 3:return"Expected '}'";case 4:return"Expected '['";case 5:return"Expected ']'";case 12:return"Expected '>'";case 13:return"Expected '<'";case 16:return`Expected '"'`;case 17:return`Expected "'"\\`;case 24:return"Missing ':'";case 21:return"Missing '/'";case 26:return'Expected ")"';case 28:return'Missing ","';case 6:return"Expected property name";case 7:return"Expected node name";case 49:return"Node name shall start with a lower or upper case character";case 50:return"Node unit address should not start with 0x";case 51:return"Node unit address should not end with with ULL";case 8:return"Expected node address";case 9:return"Expected node path";case 48:return"Expected node path reference";case 10:return"Expected node reference";case 11:return"Expected root node name";case 14:return"Expected bytestring";case 15:return"Expected two digits for each byte in bytestring";case 20:return"Hex values are not allowed";case 18:return"Expected label name";case 19:return"Expected '/' at the start of a node path";case 23:return"Found ';' without a statement";case 25:return"Did you mean /delete-node/ or /delete-property/?";case 34:return"Did you mean /delete-node/?";case 35:return"Did you mean /delete-property/?";case 22:return"Unknown syntax";case 27:return"Expected expression";case 31:return"Expected macro identifier";case 30:return"Expected macro identifier or function like macro";case 29:return"White space is not allowed";case 32:return"Properties can only be defined in a node";case 53:return"Node name syntax can only be used inside a node definition.";case 33:return"Properties can only be deleted inside a node";case 36:return"Unable to resolve include";case 52:return"Unknown Node Address syntax";case 37:return"Expected start address";case 38:return"Expected end address";case 39:case 40:return"Expected 8|16|32|64";case 42:return"Unknown macro name";case 43:return"Expected function like macro";case 44:return"Macro expects less arguments";case 45:return"Macro expects more arguments";case 46:return"Missing #ENDIF";case 47:return"Block Unused";case 41:return"This syntax is not officially part of the DTS V0.4 standard"}},uH=t=>t.issues.map(e=>{switch(e){case 0:return`Property "${t.templateStrings[0]}" is replaced by a later definition`;case 1:return"Cannot delete a property before it has been defined";case 2:return"Node name already defined";case 5:return"Cannot delete a node before it has been defined";case 3:return`No node with that reference "${t.templateStrings[0]}" has been defined`;case 8:return`No node with name "${t.templateStrings[0]}" could be found in "/${t.templateStrings[1]}".`;case 4:return`Label name "${t.templateStrings[0]}" already defined`;case 6:return`Property "${t.templateStrings[0]}" was deleted`;case 7:return`Node "${t.templateStrings[0]}" was deleted`;case 9:return`The following node "${t.templateStrings[1]}" shall be present in "${t.templateStrings[0]}" node.`;case 10:return`The following node "${t.templateStrings[0]}" address range collides with another node. Address start: "${t.templateStrings[1]}", end: "${t.templateStrings[2]}".`}}).join(" or "),dH=(t,e)=>{switch(t){case 0:return"Property name already defined.";case 2:return"Defined here";case 4:return"Defined here";case 7:case 6:return"Deleted here";case 9:return"Node";case 10:return`Node "${e[0]}". Address start: "${e[1]}", end: "${e[2]}".`;default:return"TODO"}},fH=t=>t.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${t.templateStrings[0]}`;case 1:return"INTRO should be empty";case 8:return"INTRO can only be assigned one value";case 5:return"INTRO should be assigned a U32";case 6:return"INTRO should be assigned a U64";case 7:return"INTRO should be assigned a 'property encoded array'";case 2:return"INTRO should be assigned a string";case 3:return"INTRO should be assigned a string list";case 4:return`INTRO expects ${t.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 27:return"INTRO name is not permitted under this node";case 34:return"INTRO name is not defined in the type binding for this node";case 10:return"INTRO address value must match node address";case 12:return"INTRO should be 'cpu'";case 13:return"INTRO should be 'memory'";case 14:return"INTRO is deprecated and should not be used'";case 15:return`INTRO ${t.templateStrings[1]}'`;case 18:return"INTRO value must be unique in the entire Devicetree";case 19:return`INTRO should have format ${t.templateStrings[1]}`;case 16:return`INTRO requires property "${t.templateStrings[1]}" in node path "${t.templateStrings[2]}"`;case 17:return"Unable to resolve interrupt parent node";case 20:return`INTRO should have format ${t.templateStrings[1]}`;case 21:return"Node is disabled";case 22:return"Unable to resolve handle";case 23:return`Unable to find "${t.templateStrings[0]}" in ${t.templateStrings[1]}`;case 24:return t.templateStrings[0];case 25:return t.templateStrings[0];case 26:return t.templateStrings[0];case 28:return t.templateStrings[0];case 35:return"Unable to find mapping range for address";case 29:return`INTRO exceeds address space available for this mapping. The range ends at ${t.templateStrings[2]}, the node ends at ${t.templateStrings[1]}`;case 30:return"Map entry overlaps with others entries";case 31:return"Unable to match to a nexus map entry";case 32:return`Unknown node type "${t.templateStrings[0]}"`;case 33:return`Missing name for "${t.templateStrings[0]}" index ${t.templateStrings[1]}"`;case 36:return"Node address is missing";case 37:return`Binding should be used on bus type${t.templateStrings.length?"s":""}: ${t.templateStrings.join(" or ")}`;case 38:return"Empty ranges property should only be used when address size cells is identical to the parent node";case 39:return'The value shall be one of the following: "spin-table" or "[vendor],[method]"';case 40:return'The value shall match "[vendor],[method]"'}}).join(" or ").replace("INTRO",`Property "${t.templateStrings[0]}"`).replaceAll("INTRO ",""),pH=t=>{switch(t){case 16:case 0:return"Node";case 15:return"Ignored reason";case 18:return"Conflicting properties";case 8:return"Additional value";case 21:return"Disabled by";case 29:return"Mapping range";case 30:return"Map entry";case 31:return"Nexus map entries";case 33:return"Names property";case 35:return"Range property";default:return"TODO"}},hH=t=>t.issues.map(e=>{switch(e){case 4:return"Add end of line to end of file";case 1:return`${t.codeActionTitle}. Expecting ${t.templateStrings[0]}.`;case 0:return"Move to a new line";case 3:return"Remove trailing whitespace at the end of file.";case 2:return"Remove trailing whitespace at the end of the line.";case 5:return`Fix indentation. ${t.templateStrings.at(0)?.length===0?"No indentation expected":`Expecting ${t.templateStrings[0]}`}`;case 6:return`Move token "${t.templateStrings[0]}" next to expression`;case 7:return"Remove (...) enclosure. This expression should only be enclosed in the #define of the macro";case 8:return`Line is too long. ${t.codeActionTitle}`;case 9:return`Hex values must be lowercase. ${t.codeActionTitle}`;case 10:return"Node address is already a hex value. Remove '0x'.";case 11:return"Node address size is determined by '@size-cells', Remove 'ull'.";case 12:return`'\\' is not necessary. ${t.codeActionTitle}`;case 13:return`Node does not contribute anything. ${t.codeActionTitle}`;case 14:return`Property is redefined in same closure. ${t.codeActionTitle}`;case 15:return`${t.codeActionTitle}`}}).join(" or "),mH=t=>"TODO";var Dt=(t,e)=>{let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=t[t.length-n+r]??0,s=e[e.length-n+r]??0;if(i<s)return-1;if(i>s)return 1}return 0},Xr=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0,c=o+a+i;r[n-1-s]=c>>>0,i=c>4294967295?1:0}return i&&r.unshift(1),r},gH=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0;o-=i,o<a?(o+=4294967296,i=1):i=0,r[n-1-s]=o-a>>>0}for(;r.length>1&&r[0]===0;)r.shift();return r},yH=(t,e)=>Xr(t,e),kE=(t,e)=>{let n=[];for(let r of t){let i=r.childAddress,s=r.length,o=Xr(i,s);if(Dt(e,i)>=0&&Dt(e,o)<0){let a=gH(e,i),c=r.parentAddress,l=yH(c,a),u=Xr(c,s);n.push({start:l,end:u,range:on(r.rangeTokens.start,r.rangeTokens.end),fsPath:r.rangeTokens.start.fsPath})}}return n};function NE(t){return Array.isArray(t)&&Array.isArray(t[0])}function Gc(t){return!t||t instanceof Wt?t:Gc(t.parentNode)}function Jn(t,e){let n=e.filter(r=>!r.raw.virtual).flatMap(r=>r.raw.edit).filter(r=>!!r);return NT(t,n)}function NT(t,e){let n=t.getText(),r=e.slice().sort((s,o)=>{let a=t.offsetAt(s.range.start),c=t.offsetAt(o.range.start);if(a!==c)return c-a;let l=t.offsetAt(s.range.end),u=t.offsetAt(o.range.end);if(l!==u)return u-l;let d=a===l&&s.newText.length>0,f=c===u&&o.newText.length>0;return d!==f?d?1:-1:0}),i=n;for(let s of r){let o=t.offsetAt(s.range.start),a=t.offsetAt(s.range.end);i=i.slice(0,o)+s.newText+i.slice(a)}return i}function yE(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}function RE(t,e){return yE(t.end,e.start)>0&&yE(t.start,e.end)<0}var wE=(t,e)=>{let n=EE(t,e),r=CE(t,e);n&&(t.topComment=n),r&&(t.endComment=r)},EE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.lastToken===t.firstToken.prevToken&&(i.lastToken.pos.line===t.firstToken.pos.line||i.lastToken.pos.line+1===t.firstToken.pos.line));if(!n||n.astBeforeComment)return;n.astAfterComment=t;let r=EE(n,e);return r&&(r.astAfterComment=t,n.astAfterComment=void 0),r??n},CE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.firstToken.prevToken===t.lastToken&&i.firstToken.pos.line===t.lastToken.pos.line);if(!n)return;n.astBeforeComment=t;let r=CE(n,e);return r&&(r.astBeforeComment=t,n.astBeforeComment=void 0),r??n},co=(t,e,n)=>{let r=[42,44,45,36];return n||r.push(52,32,53,8,49),t.severity===zt.DiagnosticSeverity.Error&&fe(t.fsPath,e)&&!r.some(i=>t.issues.includes(i))};function Hf(t){let e=t?.charAt(0);return!!e&&(e>="A"&&e<="Z"||e>="a"&&e<="z")}var pa=t=>{if(t)return t instanceof we?t:pa(t?.parentNode)},ha=(t,e,n=0)=>{if(!e||!e.parentNode?.fsPath)return n;let r=pa(e.parentNode);return ha(t,r,n+1)};function DE(t,e,n,r){let i=n-e,s=r.length,o=t.length-i+s,a=new Array(o),c=0;for(let l=0;l<e;l++,c++)a[c]=t[l];for(let l=0;l<s;l++,c++)a[c]=r[l];for(let l=n;l<t.length;l++,c++)a[c]=t[l];return a}function ma(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):""}function Vf(t,e,n,r,i){let s=e.closeScope?.prevToken??e.lastToken.prevToken;if(!s)return;let o="";switch(r.types[0]){case"U32":case"U64":case"PROP_ENCODED_ARRAY":o=` = <${n==="reg"&&t.address?t.address.map(a=>`0x${a.toString(16)}`).join(" "):""}>`;break;case"STRING":case"STRINGLIST":o=' = ""';break;case"BYTESTRING":o=" = []";break}return zt.TextEdit.insert(zt.Position.create(s.pos.line,s.pos.col+1),`
|
|
183
|
+
${" ".repeat(r)}`:", ")??"NULL"}`:""};${bi(this.fsPath)?" /* default value from binding */":""}`}serialize(n){return{name:this.propertyName?.serialize()??null,values:this.values===void 0?void 0:this.values?.values.map(r=>r?.value?.serialize(n)??null)??null,url:this.serializeURL,range:this.range,issues:[...this.serializeIssues,...this.values?.issues.map(r=>r())??[]]}}};var mE=L(U());var hn=class extends te{constructor(n,r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:n,kind:mE.SymbolKind.Function}}};var Xn=class extends hn{constructor(n){super("Delete Node",n);this._nodeNameOrRef=null}set nodeNameOrRef(n){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=n,this.addChild(n)}get nodeNameOrRef(){return this._nodeNameOrRef}};var lt=class extends hn{constructor(n){super("Delete Property",n);this._propertyName=null}set propertyName(n){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=n,this.addChild(n)}get propertyName(){return this._propertyName}};var gE=L(U());var ie=class extends te{constructor(n){super();this.label=n;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:gE.SymbolKind.Key},this.addChild(n)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}serialize(){return{type:"LABEL_REF",label:this.label?.toString()??null,nodePath:this.linksTo?.pathString??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var we=class t extends te{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof nt)return[this.pathName];if(!(this.parentNode instanceof t))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof t)}get deleteNodes(){return this.children.filter(e=>e instanceof Xn)}addNodeChild(e){this.addChild(e)}},nt=class extends we{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Kr.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ne)}#e;get name(){return this.#e??=new $e("/",he(this.firstToken)),this.#e}get identifierAst(){return this.name}get deleteProperties(){return this.children.filter(e=>e instanceof lt)}get nodes(){return this.children.filter(e=>e instanceof Ee)}get pathName(){return"/"}serialize(e){return{type:"ROOT",properties:this.properties.map(n=>n.serialize(e)),nodes:this.nodes.map(n=>n.serialize(e)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&se(this.openScope),scopeClose:this.closeScope&&se(this.closeScope,!1)}}},ut=class extends we{constructor(n=[]){super();this.labels=n;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Kr.SymbolKind.Class},n.forEach(r=>{super.addChild(r)})}get serializeIssues(){return[...this.issues,...this.reference?.issues??[]].map(n=>n())}get identifierAst(){return this.reference}set reference(n){if(this._reference)throw new Error("Only on label reference is allowed");this._reference=n;let r;n instanceof ie?r=n.value:r=n?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:r??"DTC Name",kind:Kr.SymbolKind.Class},this.addChild(n)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get reference(){return this._reference}get nodes(){return this.children.filter(n=>n instanceof Ee)}get pathName(){if(this.reference instanceof ie&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(n=>n instanceof Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof lt)}serialize(n){return{type:"REF",labels:this.labels.map(r=>r.serialize(n)),name:this.reference?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&se(this.openScope),scopeClose:this.closeScope&&se(this.closeScope,!1)}}},Ee=class t extends we{constructor(n=[],r){super();this.labels=n;this.omitIfNoRef=r;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Kr.SymbolKind.Class},r&&this.addChild(r),n.forEach(i=>{this.addChild(i)})}get identifierAst(){return this.name}get serializeIssues(){return[...this.issues,...this.name?.issues??[]].map(n=>n())}set name(n){if(this._name)throw new Error("Only on label reference is allowed");this._name=n,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:Kr.SymbolKind.Class},this.addChild(n)}get name(){return this._name}get nodes(){return this.children.filter(n=>n instanceof t)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(n=>n instanceof Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof lt)}serialize(n){return{type:"CHILD",labels:this.labels.map(r=>r.serialize(n)),name:this.name?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&se(this.openScope),scopeClose:this.closeScope&&se(this.closeScope,!1)}}},Vc=class extends te{constructor(n,r){super(r);this.address=n;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address?.map((n,r)=>n.toString(16).padStart(r?8:0,"0")).join("")??"NaN"}serialize(){return{address:this.address,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},$e=class extends te{constructor(n,r,i){super(r);this.name=n;this._address=i;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(n){if(this._address)throw new Error("Address can only be set once");n&&(this.lastToken=void 0,this._address=n,n.forEach(r=>this.addChild(r)))}get fullAddress(){return this._address?[...this._address.flatMap(n=>n.address)]:void 0}toString(){return this._address!==void 0?`${this.name}@${this._address.map(n=>n.toString()).join(",")}`:this.name}buildSemanticTokens(n){let r=this.firstToken;if(!r.value)return;let i={...r,pos:{...r.pos,len:this.name.length}};n(Hi("type"),Vi("declaration"),i,i),this.address!==void 0&&this.address.forEach(s=>{n(Hi("decorator"),Vi("declaration"),s.firstToken,s.lastToken),s.buildSemanticTokens(n)})}get serializeIssues(){return[...this.issues,...this._address?.flatMap(n=>n.issues)??[]].map(n=>n())}serialize(){let n=this.firstToken;return{fullName:this.toString(),name:{name:this.name,url:this.serializeURL,range:Kr.Range.create(Kr.Position.create(n.pos.line,n.pos.col),Kr.Position.create(n.pos.line,n.pos.colEnd)),issues:this.serializeIssues},address:this.address?.map(r=>r.serialize())??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var on=(t,e,n=!0,r=!0)=>({start:{line:t?.pos.line??0,character:n?t?.pos.col??0:(t?.pos.col??0)+(t?.pos.len??0)},end:{line:e?.pos.line??0,character:r?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var se=(t,e=!0)=>zt.Position.create(t.pos.line,e?t.pos.colEnd:t.pos.col),ce=t=>on(t.firstToken,t.lastToken),Hi=t=>qf.findIndex(e=>e===t),Vi=t=>$f.findIndex(e=>e===t),gs=(t,e,n)=>!fe(t.fsPath,e)||n.line<t.pos.line?!1:n.line>t.pos.line?!0:n.character>=t.pos.colEnd,bT=(t,e,n)=>fe(t.fsPath,e)?n.line<t.pos.line?!0:n.line>t.pos.line?!1:n.character<t.pos.col:!1,Qt=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!((r.pos.line<n.line||r.pos.line===n.line&&r.pos.col<=n.character)&&(i.pos.line>n.line||i.pos.line===n.line&&i.pos.colEnd>=n.character)&&fe(t.fsPath,e))},ao=(t,e)=>{let n=(i,s)=>i.line<s.line||i.line===s.line&&i.character<=s.character,r=(i,s)=>i.line>s.line||i.line===s.line&&i.character>=s.character;return n(t.start,e.start)&&r(t.end,e.end)},vE=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!(t.lastToken.value!==";"&&(r.pos.line===n.line||i.pos.line===n.line)&&n.character>=i.pos.colEnd&&fe(t.fsPath,e))},bE=(t,e,n)=>{if(!t)return!1;let i=t.filter(s=>s.pos.line===n.line).at(-1);return i&&i.pos.col>=n.character?!1:e.lastToken===i};var Jr=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>Qt(s,e,n));return r},Wc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].find(s=>bT(s.lastToken,e,n));return r===t?void 0:r},zc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>gs(s.firstToken,e,n));return r===t?void 0:r},ST="#virtual",bi=t=>t.includes(ST),jf=(t,e)=>`${t}?loc=${e.start.line}:${e.start.character}-${e.end.line}:${e.end.character}${ST}`,pn=t=>{if(!bi(t))return;let[e,n]=t.split("?"),[r,i]=n.replace("loc=","").replace(ST,"").split("-"),[s,o]=r.split(":"),[a,c]=i.split(":");return{fsPath:e,range:zt.Range.create(zt.Position.create(Number.parseInt(s),Number.parseInt(o)),zt.Position.create(Number.parseInt(a),Number.parseInt(c)))}},_T=t=>{let e=pn(t.fsPath);e&&(t.range=e.range,t.fsPath=e?.fsPath,t.virtual=!0,t.linkedTo=t.linkedTo.map(({range:n,fsPath:r})=>{let i=pn(r);return{range:i?.range??n,fsPath:i?.fsPath??r,templateStrings:[]}}))},Y=(t,e,n=e,r,{severity:i=zt.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,inclusiveStart:u,inclusiveEnd:d}={severity:zt.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let f={issues:Array.isArray(t)?t:[t],range:on(e,n,u,d),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:h,fsPath:y})=>{let S=pn(y);return S?{...S,templateStrings:[]}:{range:h,fsPath:y,templateStrings:[]}}),tags:o,templateStrings:a,edit:c,codeActionTitle:l};_T(f);let p,m=()=>(p??={severity:f.severity,range:f.range,message:f.issues?f.issues.map(lH).join(" or "):"",source:"devicetree",tags:f.tags,data:{firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},type:"SyntaxIssue",items:f.issues,edit:f.edit,codeActionTitle:f.codeActionTitle,virtual:!!f.virtual}},p);return r?.syntaxIssues.push(m),{raw:f,diagnostic:m}},Gt=(t,e,n,r,{severity:i=zt.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,linkedToTemplateStrings:u=[]}={severity:zt.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let d={issues:Array.isArray(t)?t:[t],range:on(e,n),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:m,fsPath:h},y)=>{let S=pn(h);return S?{...S,templateStrings:[]}:{range:m,fsPath:h,templateStrings:u.at(y)??[]}}),tags:o,templateStrings:a,edit:c,codeActionTitle:l};_T(d);let f,p=()=>(f??={severity:d.severity,range:d.range,message:uH(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(m=>({message:d.issues.map(h=>dH(h,m.templateStrings)).join(" or "),location:{uri:ue(m.fsPath),range:m.range}}))]},f);return r?.resettableIssues.push(p),{raw:d,diagnostic:p}},F=(t,e,n,r,{severity:i=zt.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l}={severity:zt.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let u={issues:Array.isArray(t)?t:[t],range:on(e,n),severity:i,fsPath:e.fsPath,linkedTo:s.map(({range:p,fsPath:m})=>{let h=pn(m);return h?{...h,templateStrings:[]}:{range:p,fsPath:m,templateStrings:[]}}),tags:o,templateStrings:a,edit:c,codeActionTitle:l};_T(u);let d,f=()=>(d??={severity:u.severity,range:u.range,message:fH(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(pH).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"StandardTypeIssue",firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},edit:u.edit,codeActionTitle:u.codeActionTitle,items:u.issues,virtual:!!u.virtual}},d);return Array.isArray(r)?r.forEach(p=>p.resettableIssues.push(f)):r?.resettableIssues.push(f),{raw:u,diagnostic:f}};function Ve(t,e,n,{severity:r=zt.DiagnosticSeverity.Warning,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:zt.DiagnosticSeverity.Warning,linkedTo:[],templateStrings:[],edit:[],codeActionTitle:void 0},l=n){let u={issues:Array.isArray(t)?t:[t],range:zt.Range.create(n,l),severity:r,fsPath:e,linkedTo:i.map(({range:p,fsPath:m})=>({range:p,fsPath:m,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c,virtual:bi(e)},d;return{raw:u,diagnostic:()=>(d??={severity:u.severity,range:u.range,message:hH(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(mH).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"FormattingIssues",items:u.issues,edit:u.edit,codeActionTitle:u.codeActionTitle,virtual:!!u.virtual}},d)}}var SE=(t,e)=>[...t].sort((r,i)=>{let s=e.getSortKey(r),o=e.getSortKey(i);if(s===void 0||o===void 0)throw new Error("Sort keys must be set");if(s!==o)return s-o;let a=r.lastToken,c=i.lastToken;return a.pos.line!==c.pos.line?a.pos.line-c.pos.line:a.pos.col-c.pos.col});async function Rt(t,e,n){let r=_e(t.textDocument.uri);if(!e)return[];let i=performance.now(),s=await e.getRuntime(),o,a,c=s.context.allParsers.flatMap(u=>u.injectedMacros).find(u=>Qt(u,r,t.position));return c&&(o={runtime:s,item:null,ast:Jr(c,r,t.position)},a=Number.MAX_SAFE_INTEGER),o||(o=s.getDeepestAstNode(r,t.position),a=e.getSortKey(o?.ast)??e.getSortKeyFile(t.position,r)),console.log(`search: ${performance.now()-i}ms`),n(o,u=>{let d=t.position;if(fe(u.fsPath,r)){let f=u.lastToken;return f.pos.line<d.line||f.pos.line===d.line&&f.pos.colEnd<=d.character}return a!==void 0&&(e.getSortKey(u)??-1)<=a})}function he(t,e){return{start:t,end:e??t}}var H=(t,e)=>t?.tokens.some(n=>n===e),st=(t,e)=>n=>n?.value&&(e?.caseInsensitive?t.toLowerCase()===n.value.toLowerCase():t===n.value)?"yes":e?.allowPartial?oH(t)(n):"no",Fe=t=>e=>e?.tokens.some(n=>n===t)?"yes":"no",oH=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",mn=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&fe(t.fsPath,e.fsPath),Yt=(t,e)=>t?.tokens[0]===21&&e?.tokens[0]===21&&(t?.prevToken&&t.prevToken.value===e?.value||e?.prevToken&&e.prevToken.value===t?.value)?!0:!!t&&!!e&&t.pos.colEnd===e.pos.col&&mn(t,e),Uf=t=>t.map((e,n)=>({index:n,context:e,files:e.getContextFiles()})),Rn=(t,e,n,r)=>{if("id"in e){let s=t?.find(o=>o.id===e.id);return s||void 0}if("name"in e){let s=t?.find(o=>o.ctxNames.includes(e.name));return s||void 0}return n?.getContextFiles().find(s=>fe(s,e.fsPath))?n:Uf(t).sort(s=>s.context.id===r?-1:0).find(s=>s.files.some(o=>fe(o,e.fsPath)))?.context},PT=(t,e)=>Uf(t).filter(r=>r.files.some(i=>fe(i,e))).map(r=>r.context),_E=t=>{let e=/^(\w+)\s+(.*)$/,n=/^(\w+)\(([^)]*)\)\s+(.*)$/,r=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.*)$/,i;if(i=r.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o,u=c.slice(a.length).join(", ");return a.forEach((d,f)=>{l=l.replace(new RegExp(`(?<!#)#\\s*${d}\\b`,"g"),`"${c[f]??""}"`)}),l=l.replace(/(?<!#)#\s*__VA_ARGS__/g,`"${u}"`),a.forEach((d,f)=>{let p=new RegExp(`\\b${d}\\b`,"g");l=l.replace(p,c[f]??"")}),l=l.replace(/__VA_ARGS__/g,u),l}}else if(i=n.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{l=l.replace(new RegExp(`(?<!#)#\\s*${u}\\b`,"g"),`"${c[d]??""}"`)}),a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d]??"")}),l}}else if(i=e.exec(t)){let[,,s]=i;return s.trim()}};function aH(t){if(!t.trim())return[];let e=[],n="",r=0;for(let i=0;i<t.length;i++){let s=t[i];s===","&&r===0?(e.push(n.trim()),n=""):(s==="("?r++:s===")"&&r--,n+=s)}return n.trim()&&e.push(n.trim()),e}var cH=0,Hc=(t,e)=>{let n=s=>s.replace(/\s*##\s*/g,""),r=t,i;do i=r,r=n(i),r=r.replace(/\b(\w+)\(([^()]*(?:\([^()]*\)[^()]*)*)\)|\b(\w+)\b/g,(s,o,a,c)=>{if(o==="defined"){let l=a.split(",").map(u=>u.trim());return l[0]?e.get(l[0])?.resolver:l}else if(o&&typeof e.get(o)?.resolver=="function"){let l=aH(a).map(u=>u.trim()).map(u=>u==="__COUNTER__"?(cH++).toString():u).map(u=>Hc(u,e));return(e.get(o)?.resolver)(...l)}else if(c&&typeof e.get(c)?.resolver=="string")return e.get(c)?.resolver;return s});while(r!==i);return r};function kT(t){return t.replace(/'(.)'/g,(e,n)=>n.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Me(t){try{return(0,eval)(kT(t))}catch{}return t}var ue=t=>vT.default.pathToFileURL(t).toString(),_e=t=>dt(vT.default.fileURLToPath(t)),PE=(t,e)=>{let n=(0,fa.relative)(t,e);return!!n&&!n.startsWith("..")&&!(0,fa.isAbsolute)(n)},fe=(t,e)=>!t||!e?!1:t===e,dt=t=>(0,fa.normalize)(process.platform==="win32"?t.toLowerCase():t),Wi=t=>(0,TE.createHash)("sha256").update([dt(t.dtsFile),...t.includePaths.map(dt),...t.overlays.map(dt),t.bindingType,...t.zephyrBindings.map(dt),...t.deviceOrgBindingsMetaSchema.map(dt),...t.deviceOrgTreeBindings.map(dt),`showFormattingErrorAsDiagnostics-${t.showFormattingErrorAsDiagnostics}`,`disableFileWatchers-${t.disableFileWatchers}`].join(":")).digest("hex"),lH=t=>{switch(t){case 0:return"Expected value";case 1:return"Expected ';'";case 2:return"Expected '{'";case 3:return"Expected '}'";case 4:return"Expected '['";case 5:return"Expected ']'";case 12:return"Expected '>'";case 13:return"Expected '<'";case 16:return`Expected '"'`;case 17:return`Expected "'"\\`;case 24:return"Missing ':'";case 21:return"Missing '/'";case 26:return'Expected ")"';case 28:return'Missing ","';case 6:return"Expected property name";case 7:return"Expected node name";case 49:return"Node name shall start with a lower or upper case character";case 50:return"Node unit address should not start with 0x";case 51:return"Node unit address should not end with with ULL";case 8:return"Expected node address";case 9:return"Expected node path";case 48:return"Expected node path reference";case 10:return"Expected node reference";case 11:return"Expected root node name";case 14:return"Expected bytestring";case 15:return"Expected two digits for each byte in bytestring";case 20:return"Hex values are not allowed";case 18:return"Expected label name";case 19:return"Expected '/' at the start of a node path";case 23:return"Found ';' without a statement";case 25:return"Did you mean /delete-node/ or /delete-property/?";case 34:return"Did you mean /delete-node/?";case 35:return"Did you mean /delete-property/?";case 22:return"Unknown syntax";case 27:return"Expected expression";case 31:return"Expected macro identifier";case 30:return"Expected macro identifier or function like macro";case 29:return"White space is not allowed";case 32:return"Properties can only be defined in a node";case 53:return"Node name syntax can only be used inside a node definition.";case 33:return"Properties can only be deleted inside a node";case 36:return"Unable to resolve include";case 52:return"Unknown Node Address syntax";case 37:return"Expected start address";case 38:return"Expected end address";case 39:case 40:return"Expected 8|16|32|64";case 42:return"Unknown macro name";case 43:return"Expected function like macro";case 44:return"Macro expects less arguments";case 45:return"Macro expects more arguments";case 46:return"Missing #ENDIF";case 47:return"Block Unused";case 41:return"This syntax is not officially part of the DTS V0.4 standard"}},uH=t=>t.issues.map(e=>{switch(e){case 0:return`Property "${t.templateStrings[0]}" is replaced by a later definition`;case 1:return"Cannot delete a property before it has been defined";case 2:return"Node name already defined";case 5:return"Cannot delete a node before it has been defined";case 3:return`No node with that reference "${t.templateStrings[0]}" has been defined`;case 8:return`No node with name "${t.templateStrings[0]}" could be found in "/${t.templateStrings[1]}".`;case 4:return`Label name "${t.templateStrings[0]}" already defined`;case 6:return`Property "${t.templateStrings[0]}" was deleted`;case 7:return`Node "${t.templateStrings[0]}" was deleted`;case 9:return`The following node "${t.templateStrings[1]}" shall be present in "${t.templateStrings[0]}" node.`;case 10:return`The following node "${t.templateStrings[0]}" address range collides with another node. Address start: "${t.templateStrings[1]}", end: "${t.templateStrings[2]}".`}}).join(" or "),dH=(t,e)=>{switch(t){case 0:return"Property name already defined.";case 2:return"Defined here";case 4:return"Defined here";case 7:case 6:return"Deleted here";case 9:return"Node";case 10:return`Node "${e[0]}". Address start: "${e[1]}", end: "${e[2]}".`;default:return"TODO"}},fH=t=>t.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${t.templateStrings[0]}`;case 1:return"INTRO should be empty";case 8:return"INTRO can only be assigned one value";case 5:return"INTRO should be assigned a U32";case 6:return"INTRO should be assigned a U64";case 7:return"INTRO should be assigned a 'property encoded array'";case 2:return"INTRO should be assigned a string";case 3:return"INTRO should be assigned a string list";case 4:return`INTRO expects ${t.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 27:return"INTRO name is not permitted under this node";case 34:return"INTRO name is not defined in the type binding for this node";case 10:return"INTRO address value must match node address";case 12:return"INTRO should be 'cpu'";case 13:return"INTRO should be 'memory'";case 14:return"INTRO is deprecated and should not be used'";case 15:return`INTRO ${t.templateStrings[1]}'`;case 18:return"INTRO value must be unique in the entire Devicetree";case 19:return`INTRO should have format ${t.templateStrings[1]}`;case 16:return`INTRO requires property "${t.templateStrings[1]}" in node path "${t.templateStrings[2]}"`;case 17:return"Unable to resolve interrupt parent node";case 20:return`INTRO should have format ${t.templateStrings[1]}`;case 21:return"Node is disabled";case 22:return"Unable to resolve handle";case 23:return`Unable to find "${t.templateStrings[0]}" in ${t.templateStrings[1]}`;case 24:return t.templateStrings[0];case 25:return t.templateStrings[0];case 26:return t.templateStrings[0];case 28:return t.templateStrings[0];case 35:return"Unable to find mapping range for address";case 29:return`INTRO exceeds address space available for this mapping. The range ends at ${t.templateStrings[2]}, the node ends at ${t.templateStrings[1]}`;case 30:return"Map entry overlaps with others entries";case 31:return"Unable to match to a nexus map entry";case 32:return`Unknown node type "${t.templateStrings[0]}"`;case 33:return`Missing name for "${t.templateStrings[0]}" index ${t.templateStrings[1]}"`;case 36:return"Node address is missing";case 37:return`Binding should be used on bus type${t.templateStrings.length?"s":""}: ${t.templateStrings.join(" or ")}`;case 38:return"Empty ranges property should only be used when address size cells is identical to the parent node";case 39:return'The value shall be one of the following: "spin-table" or "[vendor],[method]"';case 40:return'The value shall match "[vendor],[method]"'}}).join(" or ").replace("INTRO",`Property "${t.templateStrings[0]}"`).replaceAll("INTRO ",""),pH=t=>{switch(t){case 16:case 0:return"Node";case 15:return"Ignored reason";case 18:return"Conflicting properties";case 8:return"Additional value";case 21:return"Disabled by";case 29:return"Mapping range";case 30:return"Map entry";case 31:return"Nexus map entries";case 33:return"Names property";case 35:return"Range property";default:return"TODO"}},hH=t=>t.issues.map(e=>{switch(e){case 4:return"Add end of line to end of file";case 1:return`${t.codeActionTitle}. Expecting ${t.templateStrings[0]}.`;case 0:return"Move to a new line";case 3:return"Remove trailing whitespace at the end of file.";case 2:return"Remove trailing whitespace at the end of the line.";case 5:return`Fix indentation. ${t.templateStrings.at(0)?.length===0?"No indentation expected":`Expecting ${t.templateStrings[0]}`}`;case 6:return`Move token "${t.templateStrings[0]}" next to expression`;case 7:return"Remove (...) enclosure. This expression should only be enclosed in the #define of the macro";case 8:return`Line is too long. ${t.codeActionTitle}`;case 9:return`Hex values must be lowercase. ${t.codeActionTitle}`;case 10:return"Node address is already a hex value. Remove '0x'.";case 11:return"Node address size is determined by '@size-cells', Remove 'ull'.";case 12:return`'\\' is not necessary. ${t.codeActionTitle}`;case 13:return`Node does not contribute anything. ${t.codeActionTitle}`;case 14:return`Property is redefined in same closure. ${t.codeActionTitle}`;case 15:return`${t.codeActionTitle}`}}).join(" or "),mH=t=>"TODO";var Dt=(t,e)=>{let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=t[t.length-n+r]??0,s=e[e.length-n+r]??0;if(i<s)return-1;if(i>s)return 1}return 0},Xr=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0,c=o+a+i;r[n-1-s]=c>>>0,i=c>4294967295?1:0}return i&&r.unshift(1),r},gH=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0;o-=i,o<a?(o+=4294967296,i=1):i=0,r[n-1-s]=o-a>>>0}for(;r.length>1&&r[0]===0;)r.shift();return r},yH=(t,e)=>Xr(t,e),kE=(t,e)=>{let n=[];for(let r of t){let i=r.childAddress,s=r.length,o=Xr(i,s);if(Dt(e,i)>=0&&Dt(e,o)<0){let a=gH(e,i),c=r.parentAddress,l=yH(c,a),u=Xr(c,s);n.push({start:l,end:u,range:on(r.rangeTokens.start,r.rangeTokens.end),fsPath:r.rangeTokens.start.fsPath})}}return n};function NE(t){return Array.isArray(t)&&Array.isArray(t[0])}function Gc(t){return!t||t instanceof Wt?t:Gc(t.parentNode)}function Jn(t,e){let n=e.filter(r=>!r.raw.virtual).flatMap(r=>r.raw.edit).filter(r=>!!r);return NT(t,n)}function NT(t,e){let n=t.getText(),r=e.slice().sort((s,o)=>{let a=t.offsetAt(s.range.start),c=t.offsetAt(o.range.start);if(a!==c)return c-a;let l=t.offsetAt(s.range.end),u=t.offsetAt(o.range.end);if(l!==u)return u-l;let d=a===l&&s.newText.length>0,f=c===u&&o.newText.length>0;return d!==f?d?1:-1:0}),i=n;for(let s of r){let o=t.offsetAt(s.range.start),a=t.offsetAt(s.range.end);i=i.slice(0,o)+s.newText+i.slice(a)}return i}function yE(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}function RE(t,e){return yE(t.end,e.start)>0&&yE(t.start,e.end)<0}var wE=(t,e)=>{let n=EE(t,e),r=CE(t,e);n&&(t.topComment=n),r&&(t.endComment=r)},EE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.lastToken===t.firstToken.prevToken&&(i.lastToken.pos.line===t.firstToken.pos.line||i.lastToken.pos.line+1===t.firstToken.pos.line));if(!n||n.astBeforeComment)return;n.astAfterComment=t;let r=EE(n,e);return r&&(r.astAfterComment=t,n.astAfterComment=void 0),r??n},CE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.firstToken.prevToken===t.lastToken&&i.firstToken.pos.line===t.lastToken.pos.line);if(!n)return;n.astBeforeComment=t;let r=CE(n,e);return r&&(r.astBeforeComment=t,n.astBeforeComment=void 0),r??n},co=(t,e,n)=>{let r=[42,44,45,36];return n||r.push(52,32,53,8,49),t.severity===zt.DiagnosticSeverity.Error&&fe(t.fsPath,e)&&!r.some(i=>t.issues.includes(i))};function Hf(t){let e=t?.charAt(0);return!!e&&(e>="A"&&e<="Z"||e>="a"&&e<="z")}var pa=t=>{if(t)return t instanceof we?t:pa(t?.parentNode)},ha=(t,e,n=0)=>{if(!e||!e.parentNode?.fsPath)return n;let r=pa(e.parentNode);return ha(t,r,n+1)};function DE(t,e,n,r){let i=n-e,s=r.length,o=t.length-i+s,a=new Array(o),c=0;for(let l=0;l<e;l++,c++)a[c]=t[l];for(let l=0;l<s;l++,c++)a[c]=r[l];for(let l=n;l<t.length;l++,c++)a[c]=t[l];return a}function ma(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):""}function Vf(t,e,n,r,i){let s=e.closeScope?.prevToken??e.lastToken.prevToken;if(!s)return;let o="";switch(r.types[0]){case"U32":case"U64":case"PROP_ENCODED_ARRAY":o=` = <${n==="reg"&&t.address?t.address.map(a=>`0x${a.toString(16)}`).join(" "):""}>`;break;case"STRING":case"STRINGLIST":o=' = ""';break;case"BYTESTRING":o=" = []";break}return zt.TextEdit.insert(zt.Position.create(s.pos.line,s.pos.col+1),`
|
|
184
184
|
${"".padEnd(ha(s.fsPath,e),i.context.formattingOptions.insertSpaces?" ".repeat(i.context.formattingOptions.tabSize):" ")}${n}${o};`)}var cl=require("fs"),Pa=require("path"),fo=L(U());var CD=require("path"),wr=L(U());var xn=class extends te{constructor(n,r,i,s){super();this.startLabels=n;this.value=r;this.endLabels=i;this.bits=s;this.startLabels.forEach(o=>{this.addChild(o)}),this.addChild(s),this.addChild(r),this.endLabels.forEach(o=>{this.addChild(o)})}toString(){return`${[this.value?.toString()??"NULL",...this.endLabels.map(n=>n.toString())].join(" ")}`}toPrettyString(n){return`${[this.value?.toPrettyString(n)??"NULL",...this.endLabels.map(r=>r.toString())].join(" ")}`}toJson(){return this.value?.toJson()}};var Zt=t=>t instanceof hn?!0:t instanceof we?!1:t.parentNode?Zt(t.parentNode):!1;var RT=t=>{if(t instanceof Ne)return t;if(!(t instanceof we))return t.parentNode?RT(t.parentNode):void 0},lo=t=>!t||t instanceof Ne?!1:t instanceof xn||lo(t.parentNode),wT=t=>{if(t instanceof Ee||t instanceof nt)return t.name;if(t instanceof ut)return t.reference},Wf=t=>[...t.map(wT)].filter(e=>!!e),ET=(t,e)=>e?e.parentNode===t||ET(t,e.parentNode):!1;var Kt=L(U());var AE=L(U());var Qr=class extends te{constructor(){super();this._pathParts=[]}addPath(n,r){this._pathParts.push(n),r&&this.addChild(r),this.addChild(n)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(n=>n?.toString()??"<NULL>").join("/")}buildSemanticTokens(n){this._children.forEach(r=>{r instanceof $e?r.buildSemanticTokens(n):n(Hi("operator"),Vi("declaration"),r.firstToken,r.lastToken)})}},rt=class extends te{constructor(n){super();this.path=n;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:AE.SymbolKind.Namespace},this.addChild(n)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}serialize(){let n=this.path?.toString();return{type:"NODE_PATH",nodePath:n==="/"?n:`/${n??""}`,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var W=class{constructor(e,n,r="optional",i=void 0,s,o){this.name=e;this.type=n;this.def=i;this.additionalTypeCheck=o;this.hideAutoComplete=!1;this.list=!1;this.onHover=()=>({kind:Kt.MarkupKind.Markdown,value:["### Type","**DTS native type** ",`${this.type.map(e=>e.types.join(" or ")).join(",")}
|
|
185
185
|
|
|
186
186
|
`,...this.bindingType?["**Binding type** ",`${this.bindingType}
|
|
@@ -293,7 +293,7 @@ ${" ".repeat(r-1)}};`}serialize(e,n,r=()=>!0){let i=this.mappedReg(n),s=this.imp
|
|
|
293
293
|
`){let o=this.lineNumber,a=this.columnNumber,c=n.length;this.pushToken({tokens:[21],value:n,pos:{col:a-c,line:o,len:c,colEnd:a}}),n=""}else if(this.currentChar==="\\"){let o=this.lineNumber;if(n+=this.currentChar??"",this.move())o===this.lineNumber&&(n+=this.currentChar??"");else break}else n+=this.currentChar??"";if(!this.move())break}n+=e;let r=this.lineNumber,i=this.columnNumber+1,s=n.length;this.pushToken({tokens:[21],value:n,pos:{col:i-s,line:r,len:s,colEnd:i}}),this.move()}lexIt(){for(;!this.endOfFile;){for(;this.isWhiteSpace();)this.move();let e=this.getWord();e&&this.process(e)}}static{this.SINGLE_CHAR_TOKENS=new Map([["{",[2]],["}",[3]],["(",[42]],[")",[43]],["[",[11]],["]",[12]],[";",[1]],[":",[50]],["=",[0]],[">",[4]],["<",[5]],["!",[6]],["|",[8]],["^",[9]],["&",[40,7]],["~",[10]],["/",[13]],["\\",[14]],["+",[15]],["-",[16]],["*",[17]],["%",[18]],["?",[44]],[".",[45]],["_",[48]],["@",[49]],[",",[24]]])}static{this.KEYWORD_TOKENS=new Map([["true",38],["false",39],["#define",25],["#include",26],["#line",27],["#undef",28],["#error",29],["#pragma",30],["#defined",31],["#if",32],["#ifdef",33],["#ifndef",34],["#elif",35],["#else",36],["#endif",37]])}process(e){let n=this.isString(e);if(!n){let i=t.KEYWORD_TOKENS.get(e.toLowerCase());if(i&&(n=!0,this.pushToken({tokens:[i],value:e.toLowerCase(),pos:this.generatePos(e,e.toLowerCase())}),i===39||i===38)){let s=this.tokens.length-1;if(Yt(this.tokens[s-1],this.tokens[s]))n=!1,this.tokens.pop();else return!0}}if(n||(n=this.isDigit(e)||this.isHexDigit(e)||this.isLetters(e)),!n&&e.length===1){let i=t.SINGLE_CHAR_TOKENS.get(e);if(i)return n=!0,this.pushToken({tokens:i,value:e,pos:this.generatePos(e,e)}),!0}if(n||(n=this.isHash(e)||this.unknownToken(e)),!n)throw new Error(`Lexer is not complete!!! Could not find token for "${e}"`);let r=this._tokens[this._tokens.length-1];return n&&!r?.tokens.some(i=>i===21)&&r&&r.pos.len<e.length?this.process(e.slice(r.pos.len)):!0}pushToken(e){let n={tokens:e.tokens,pos:e.pos,value:e.value,fsPath:this.fsPath},r=this._tokens[this._tokens.length-1];n.prevToken=r,r&&(r.nextToken=n),this._tokens.push(n)}isLetters(e){let n=e[0]?.charCodeAt(0);if(t.isLetterCode(n)){let r="";for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(t.isLetterCode(s))r+=e[i];else break}return this.pushToken({tokens:[47],value:r,pos:this.generatePos(e,r)}),!0}return!1}isDigit(e){let n=e[0],r=n?.charCodeAt(0);return r>=48&&r<=57?(this.pushToken({tokens:[20,19],value:n,pos:this.generatePos(e,n)}),!0):!1}isHexDigit(e){let n=e[0],r=n?.charCodeAt(0);return r>=65&&r<=70||r>=97&&r<=102?(this.pushToken({tokens:[20,47],value:n,pos:this.generatePos(e,n)}),!0):!1}isHash(e){let n="#";return e.startsWith(n)?(this.pushToken({tokens:[46],pos:this.generatePos(e,n),value:n}),!0):!1}unknownToken(e){return this.pushToken({tokens:[41],pos:this.generatePos(e," "),value:e}),!0}isString(e){if(this.inComment)return!1;let n=e[0];if(n==='"'||n==="'"){let r=e.length-1;if(this.columnNumber+1<r)throw new Error("Error while rewinding");return this.columnNumber-=r,this.getString(n),!0}return!1}generatePos(e,n){let r=this.columnNumber-e.length,i=n.length;return{line:this.lineNumber,col:r,len:i,colEnd:r+i}}};var WT=require("fs"),Sa=require("path"),il=L(U());var At=class extends te{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var DD=require("path"),np=L(U());var Zr=class extends te{constructor(n,r){super();this.keyword=n;this.path=r;this.docSymbolsMeta={name:`Include ${r}`,kind:np.SymbolKind.File},this.addChild(n),this.addChild(r)}get resolvedPath(){return this._resolvedPath}set resolvedPath(n){this.docSymbolsMeta={name:`Include ${n}`,kind:np.SymbolKind.File},this._resolvedPath=n}},va=class extends te{constructor(n,r,i){super(i);this._path=n;this.relative=r;this.docSymbolsMeta={name:(0,DD.basename)(this.path),kind:np.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var AD=L(U());var Tt=class extends me{constructor(n,r){super(r);this.name=n;this.docSymbolsMeta={name:this.name.toString(),kind:AD.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var rp=class extends te{constructor(n,r){super(r);this.operator=n;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var ID=L(U());var ba=class extends At{toString(){return"..."}},ei=class extends te{constructor(n,r){super();this.functionName=n;this.params=r;this.addChild(n),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(n){return fe(this.fsPath,n)?[{name:this.functionName.name,kind:ID.SymbolKind.Function,range:ce(this),selectionRange:ce(this),children:this.params.flatMap(r=>r.getDocumentSymbols(n))}]:[]}toString(){return`${this.functionName}(${this.params.map(n=>n.toString()).join(",")})`}};var zi=class t{constructor(){this.positionStack=[];this._issues=[];this.issueLengthPositionStack=[];this.moveEndOfLine=(e,n=!0,r=!1)=>{let i=e.pos.line;if(this.currentToken?.pos.line!==i||!fe(this.currentToken?.fsPath,e.fsPath))return;let s=this.currentToken,o=s;for(;this.currentToken?.pos.line===i&&fe(this.currentToken?.fsPath,e.fsPath);)o=this.moveToNextToken;return n&&this._issues.push(Y(22,s,o,null)),r&&o?.value==="\\"&&o.nextToken?this.moveEndOfLine(o.nextToken,n):o};this.parsing=new Promise(e=>{setTimeout(()=>{this.parse().then(e)})})}reset(){this.issueLengthPositionStack=[],this.positionStack=[],this._issues=[]}get issues(){return this._issues}get stable(){return this.parsing}get done(){return this.peekIndex()>=this.tokens.length}get moveToNextToken(){let e=this.currentToken;if(e)return this.moveStackIndex(),e}enqueueToStack(){this.issueLengthPositionStack.push(this._issues.length),this.positionStack.push(this.peekIndex())}popStack(){let e=this.issueLengthPositionStack.pop()??0;e!==this._issues.length&&this._issues.splice(e),this.positionStack.pop()}mergeStack(){let e=this.issueLengthPositionStack.pop(),n=this.positionStack.pop();if(n===void 0||e===void 0)throw new Error("Index out of bounds");this.positionStack[this.positionStack.length-1]=n}peekIndex(e=1){let n=this.positionStack.at(-1*e);if(n===void 0)throw new Error("Index out of bounds");return n}get currentToken(){return this.tokens.at(this.peekIndex())}get prevToken(){let e=this.peekIndex()-1;if(e!==-1)return this.tokens[e]}moveStackIndex(){let e=this.positionStack.length-1;if(this.positionStack[e]===void 0)throw new Error("Index out of bounds");this.positionStack[e]!==this.tokens.length&&this.positionStack[e]++}checkConcurrentTokens(e){this.enqueueToStack();let n=[];return e.every(r=>{let i=this.currentToken,s=r(i),o=!1;return s!=="no"&&i&&(n.push(i),this.moveToNextToken,o=Yt(i,this.currentToken)),s==="yes"&&o}),this.mergeStack(),n}consumeAnyConcurrentTokens(e){this.enqueueToStack();let n=[],r,i=!0;for(;e.some(s=>s(this.currentToken)==="yes"&&i);)n.push(this.currentToken),r=this.moveToNextToken,i=Yt(r,this.currentToken);return this.mergeStack(),n}getDocumentSymbols(e){return this.allAstItems.flatMap(n=>n.getDocumentSymbols(e))}getWorkspaceSymbols(){return this.allAstItems.flatMap(e=>e.getWorkspaceSymbols())}static push(e,n,r,i,s,o){if(!r||!i||!fe(r.fsPath,s)||!fe(i.fsPath,s))return;let a=i.pos.colEnd-r.pos.col;o.push({line:r.pos.line,char:r.pos.col,length:i===r?i.pos.len:a,tokenType:e,tokenModifiers:n})}buildSemanticTokens(e,n,r=[]){this.allAstItems.forEach(i=>{i.buildSemanticTokens((...s)=>t.push(...s,n,r))}),r.sort((i,s)=>i.line===s.line?i.char-s.char:i.line-s.line).forEach(i=>e.push(i.line,i.char,i.length,i.tokenType,i.tokenModifiers))}processCIdentifier(e,n,r=!1){this.enqueueToStack();let i=this.consumeAnyConcurrentTokens([19,47,48].map(Fe));if(!i.length){this.popStack();return}if(!i?.[0]?.value.match(/^[_A-Za-z]/)){this.popStack();return}let s=i.map(a=>a.value).join(""),o=new Tt(s,he(i[0],i.at(-1)));if(r&&!e.has(o.name)){this.popStack();return}return!n&&o.firstToken!==o.lastToken&&o.name!=="defined"&&(e.get(o.name)||this._issues.push(Y(42,o.firstToken,o.lastToken,o))),this.mergeStack(),o}isOperator(){this.enqueueToStack();let e=this.moveToNextToken;if(!e){this.popStack();return}let n=e,r;if(H(e,40)?(r="&",H(this.currentToken,40)&&(r="&&",n=this.moveToNextToken)):H(e,6)?(r="!",H(this.currentToken,0)&&(r="!=",n=this.moveToNextToken)):H(e,10)?r="~":H(e,8)?(r="|",H(this.currentToken,8)&&(r="||",n=this.moveToNextToken)):H(e,9)?r="^":H(e,4)?(r=">",H(this.currentToken,4)?(r=">>",n=this.moveToNextToken):H(this.currentToken,0)&&(r=">=",n=this.moveToNextToken)):H(e,5)?(r="<",H(this.currentToken,5)?(r="<<",n=this.moveToNextToken):H(this.currentToken,0)&&(r="<=",n=this.moveToNextToken)):H(e,15)?r="+":H(e,16)?r="-":H(e,17)?r="*":H(e,13)?r="/":H(e,18)?r="%":H(e,46)?H(this.currentToken,46)&&(r="##",n=this.moveToNextToken):H(e,0)&&H(this.currentToken,0)&&(r="==",n=this.moveToNextToken),r){let i=new rp(r,he(e,n));return this.mergeStack(),i}this.popStack()}parseScopedBlock(e,n,r){this.enqueueToStack();let i=this.moveToNextToken;if(!i||!e(i)){this.popStack();return}let s=this.peekIndex(),o=()=>{this.positionStack[this.positionStack.length-1]=s},a=m=>m.flatMap(h=>"items"in h?a(h.items):h),c=[i],l=[],u=[];u[0]={rewind:o,tokens:[]};let d=this.currentToken;for(;d&&!n(d);){if(r?.(d)){let m=this.peekIndex()+1,h=()=>{this.positionStack[this.positionStack.length-1]=m};c.push(d),l.push(d),u[u.length]={rewind:h,tokens:[]}}else if(e(d)){let m=this.parseScopedBlock(e,n,r);m&&(c.push(m),u[u.length-1].tokens.push(...a(m.items))),d=this.currentToken;continue}else c.push(d),u[u.length-1].tokens.push(d);this.moveToNextToken,d=this.currentToken}let f=d;f&&n(f)&&(this.moveToNextToken,c.push(f));let p={startToken:i,items:c,splitTokens:u,endToken:f,separatorTokens:l};return this.mergeStack(),p}isFunctionCall(e){this.enqueueToStack();let n=this.processCIdentifier(e,!1);if(!n){this.popStack();return}if(!(e.get(n.name)?.macro.identifier instanceof ei)&&!Yt(n.lastToken,this.currentToken)){this.popStack();return}let i=this.processMacroCallParams();if(!i){this.popStack();return}if(n.name==="defined")i.length>1?this._issues.push(Y(44,n.firstToken,n.lastToken,n)):i.length<1&&this._issues.push(Y(45,n.firstToken,n.lastToken,n));else{let o=e.get(n.name)?.macro;o&&(o?.identifier instanceof ei?o.identifier.params.at(-1)instanceof ba||(i.length>o.identifier.params.length?this._issues.push(Y(44,n.firstToken,n.lastToken,n,{linkedTo:[o]})):i.length<o.identifier.params.length&&this._issues.push(Y(45,n.firstToken,n.lastToken,n,{linkedTo:[o]}))):this._issues.push(Y(43,n.firstToken,n.lastToken,n)))}let s=new Wt(n,i);return s.lastToken=this.prevToken,this.mergeStack(),s}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([st("0"),st("x",{caseInsensitive:!0})]);if(e.length!==2){this.popStack();return}let n=this.consumeAnyConcurrentTokens([19,20].map(Fe));if(!n.length){this.popStack();return}let r=Number.parseInt(n.map(s=>s.value).join(""),16),i=new sn(r,he(e[0],n.at(-1)),16);return this.mergeStack(),i}processDec(e=!1){this.enqueueToStack();let n;e&&(H(this.currentToken,16)||H(this.currentToken,15))&&Yt(this.currentToken,this.currentToken?.nextToken)&&(n=this.moveToNextToken);let r=this.consumeAnyConcurrentTokens([19].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(o=>o.value).join(""),10);n&&H(n,16)&&(i=4294967295-i);let s=new sn(i,he(n??r[0],r.at(-1)),10);return this.mergeStack(),s}processEnclosedExpression(e,n){this.enqueueToStack();let r,i;if(H(this.currentToken,42)){let s;r=this.moveToNextToken,i=r;let o=this.processExpression(e,n,!0);return o&&(s=new rn(o,!0),o=new rn(s,!1),s.openBracket=r),H(this.currentToken,43)?(i=this.moveToNextToken,s&&(s.closeBracket=i)):r&&this._issues.push(Y(26,r,r,n)),this.mergeStack(),o}this.popStack()}processExpression(e,n,r=!1){this.enqueueToStack();let i,s;if(r&&(s=this.isOperator()),i=this.processEnclosedExpression(e,n)||this.isFunctionCall(e)||this.processCIdentifier(e,!1)||this.processHex()||this.processDec(!0),!i){this.popStack();return}if(s&&(i.operator=s),r){let o=this.isOperator();for(;o;){let a=this.processExpression(e,n,!0);a?i instanceof rn?i.addExpression(o,a):i=new rn(i,!1,{operator:o,expression:a}):this._issues.push(Y(27,o.firstToken,o.lastToken,n)),o=this.isOperator()}}return this.mergeStack(),i}processMacroCallParams(){if(!H(this.currentToken,42))return;let e=this.parseScopedBlock(r=>!!H(r,42),r=>!!H(r,43),r=>!!H(r,24));return e?.items.length===2&&H(e.endToken,43)?[]:e?.splitTokens.map((r,i)=>{if(r.tokens.length===0)return null;let s=new vi(r.tokens.map((o,a)=>{let c=o.value;return o.pos.line===r.tokens.at(a+1)?.pos.line?c=c.padEnd(r.tokens[a+1].pos.col-o.pos.col," "):o.value==="\\"&&(c=c.slice(0,-1)),c}).join(""),he(r.tokens[0],r.tokens.at(-1)),i);return s.splitToken=e.separatorTokens.at(i),s})}};var pr=class extends te{constructor(n){super();this.comments=n;this.disabled=!1;n.forEach(this.addChild.bind(this))}toString(){return this.comments.map(n=>n.toString()).join(`
|
|
294
294
|
`)}},hr=class extends te{constructor(n){super(n);this.disabled=!1;this.semanticTokenType="comment",this.semanticTokenModifiers="documentation"}toString(){let n,r=this.firstToken,i="";for(;r!==this.lastToken;)i+=r?.value.padStart(r.value.length+(n?r.pos.col-n.pos.colEnd:0)," "),n=r,r=r?.nextToken;r&&(i+=r?.value.padStart(r.value.length+(n?r.pos.col-n.pos.colEnd:0)," "));let s=i.match(/^\s*(?:(?:\/\/|\/\*+)\s*)?(.*?)\s*(?:\*\/)?\s*$/s);return s?s[1]:""}};var ip=class t extends zi{constructor(n,r=()=>Ln().requestTokens(this.fsPath,!0)){super();this.fsPath=n;this.getTokens=r;this.comments=[];this.tokens=[]}cleanUpComments(){let n=[];for(let r=0;r<this.tokens.length;r++){let i=t.processBlockComment(this.tokens,r)||t.processLineComment(this.tokens,r);i&&(r=i.index,n.push(...i.tokenUsed),this.comments.push(i.comment))}if(n.length>0){let r=new Set(n),i=[];for(let s=0;s<this.tokens.length;s++)r.has(s)||i.push(this.tokens[s]);this.tokens=i}}get allAstItems(){return this.comments}reset(){super.reset(),this.comments=[]}reparse(){return this.reset(),this.parse()}async parse(){this.tokens=this.getTokens(),this.cleanUpComments()}static processBlockComment(n,r){let i=[],s=()=>(i.push(r++),n[r]),o=()=>n[r],a=()=>n[r-1],c=o(),l=c;if(!c||!H(c,13)||(l=s(),!H(l,17)||c.pos.line!==l.pos.line||c.pos.col+1!==l.pos.col))return;let u=()=>!(!H(a(),17)||!H(o(),13)||!Yt(a(),o())),d=l.pos.line,f=c,p=[];l=s();do{if(o()?.pos.line!==d){let y=new hr(he(f,a()));p.push(y),d=o().pos.line??0,f=o()}l=s()}while(r<n.length&&!u());let m=new hr(he(f,o()));p.push(m);let h=new pr(p);return s(),{comment:h,tokenUsed:i,index:r-1}}static processLineComment(n,r){let i=[];if(!H(n[r],13)||n.length===r+1||!H(n[r+1],13)||!Yt(n[r],n[r+1]))return;for(;n[r].pos.line===n.at(r+1)?.pos.line;)i.push(r++);return i.push(r++),{comment:new hr(he(n[i[0]],n[i.at(-1)])),tokenUsed:i,index:r-1}}};var OD=L(U());var sp=class extends te{constructor(n,r){super(n);this.content=r}toString(){let n=this.content.filter(r=>!H(r,14));return n.map((r,i)=>{let s=r.value;return r.pos.line===n.at(i+1)?.pos.line?s=s.padEnd(n[i+1].pos.col-r.pos.col," "):n.at(i+1)&&(s=s.padEnd(s.length+1," ")),s}).join("")}},Zc=class extends te{constructor(n,r,i){super();this.keyword=n;this.identifier=r;this.content=i;this.addChild(n),this.addChild(this.identifier),this.content&&this.addChild(this.content)}get name(){return this.identifier instanceof Tt?this.identifier.name:this.identifier.functionName.name}toString(){return this.toStringCache??=[this.identifier.toString(),...this.content?[this.content?.toString()]:[]].join(" "),this.toStringCache}toMarkupContent(){return{kind:OD.MarkupKind.Markdown,value:["```cpp",`#define ${this.toString()}`,"```"].join(`
|
|
295
295
|
`)}}};var tl=class extends te{constructor(e){super(e)}},nl=class extends te{constructor(n,r){super();this.keyword=n;this.content=r;this.active=!1;this.addChild(n)}},rl=class extends nl{constructor(n,r,i){super(n,i);this.expression=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.expression&&n.has(this.expression.name)}},op=class extends nl{constructor(n,r,i){super(n,i);this.expression=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.expression?.isTrue(n)}},ap=class extends rl{useBlock(e){return this.expression&&!e.has(this.expression.name)}},cp=class extends nl{};var el=(t,e)=>{let n=t,r=[];for(;n&&(r.push(n),n!==e);)n=n.nextToken;return r},Er=class extends te{constructor(n,r,i){super();this.ifBlocks=n;this.endIf=r;this.elseOption=i;n.forEach(s=>this.addChild(s)),i&&this.addChild(i),this.addChild(r)}getInValidTokenRange(n){let r=this.ifBlocks.find(i=>i.useBlock(n));return r?r.active=!0:this.elseOption&&(this.elseOption.active=!0),this.getInValidTokenRangeWhenActiveBlock(r||this.elseOption)}get inactiveRanges(){let n=[],r=!!this.elseOption;this.ifBlocks.forEach((s,o)=>{if(s.active)return;let a=o===this.ifBlocks.length-1,c=s.firstToken,l=a?r?this.elseOption.firstToken:this.lastToken:s.content?.lastToken??this.ifBlocks[o+1].firstToken??s.lastToken;n.push(et.create(se(c),se(l)))});let i=n.length!==this.ifBlocks.length;if(this.elseOption&&i){let s=this.elseOption.firstToken,o=this.elseOption.content?.lastToken??this.endIf?.lastToken??this.lastToken;return n.push(et.create(se(s),se(o))),n}if(!i){let s=this.firstToken,o=this.lastToken;return[et.create(se(s),se(o))]}return n}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=!1;return this.ifBlocks.forEach(s=>{let o=s.expression?.lastToken??s.keyword.lastToken;el(s.firstToken,o).forEach(a=>r.add(a)),!i&&s===n?i=!0:s.content&&el(s.content.firstToken,s.content.lastToken).forEach(a=>r.add(a))}),this.elseOption&&(el(this.elseOption.keyword.firstToken,this.elseOption.keyword.lastToken).forEach(s=>r.add(s)),i&&this.elseOption.content&&el(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(s=>r.add(s))),this.endIf&&el(this.endIf.firstToken,this.endIf.lastToken).forEach(s=>r.add(s)),r}};var _a=class extends zi{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.getTokens=s;this.optimizeForFormatting=o;this.tokens=[];this.nodes=[];this._comments=[];this.dtsIncludes=[];this.macroSnapShot=new Map;this.macros=new Map;this.rangesToClean=new Set;this.macroStart=!1;i&&(Array.from(i).forEach(([a,c])=>this.macroSnapShot.set(a,c)),Array.from(i).forEach(([a,c])=>this.macros.set(a,c)))}get comments(){return this._comments}removeComments(n){this._comments=this._comments.filter(r=>!n.has(r))}get currentToken(){let n=this.prevToken,r=this.peekIndex(),i=this.tokens.at(r),s=mn(n,i)||!n||H(n,14)&&n.pos.line+1===i?.pos.line;if(!(this.macroStart&&!s))return this.macroStart&&H(i,14)?(this.moveStackIndex(),this.currentToken):i}reset(n){super.reset(),this.macros.clear(),n?(this.macroSnapShot.clear(),Array.from(n).forEach(([r,i])=>this.macroSnapShot.set(r,i)),Array.from(n).forEach(([r,i])=>this.macros.set(r,i))):Array.from(this.macroSnapShot).forEach(([r,i])=>this.macros.set(r,i)),this.nodes=[],this.dtsIncludes=[],this.rangesToClean=new Set}async reparse(n){let r=this.stable;return this.parsing=new Promise(i=>{r.then(()=>{if(n&&n.size===this.macroSnapShot.size){let s=Array.from(n);if(Array.from(this.macroSnapShot).every(([o,a],c)=>{let[l,u]=s[c];return l===o&&u.macro.toString()===a.macro.toString()})){console.log("header file cache hit",this.fsPath),i();return}}this.reset(n),this.parse().then(i)})}),this.parsing}async parse(){let n=new ip(this.fsPath,this.getTokens);if(await n.stable,this.tokens=n.tokens,this._comments=n.allAstItems,this.positionStack.push(0),this.tokens.length!==0){for(;!this.done;)await this.lineProcessor();if(this.rangesToClean.size&&!this.fsPath.endsWith(".h")&&(this.tokens=this.tokens.filter(r=>!this.rangesToClean.has(r))),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}}async lineProcessor(){if(this.enqueueToStack(),!(!this.prevToken||this.prevToken.pos.line!==this.currentToken?.pos.line||!fe(this.prevToken.fsPath,this.currentToken.fsPath))){this.moveEndOfLine(this.prevToken,!1),this.mergeStack();return}let r=this.currentToken,i=await this.processInclude()||this.processDefinitions()||this.processUndef()||this.processError();this.processIfDefBlocks(),r&&this.moveEndOfLine(r,!!i),this.mergeStack()}addTokensToClean(n){for(let r=n.start;r<n.start+n.count;r++){let i=this.tokens[r];i&&this.rangesToClean.add(i)}}processDefinitions(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!H(r,25))return this.popStack(),!1;this.macroStart=!0;let i=new At(he(r)),s=this.isFunctionDefinition()||this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(Y(30,i.firstToken,i.lastToken,i)),this.mergeStack(),this.macroStart=!1,!0;let o=this.consumeDefinitionContent(),a;o.length&&(a=new sp(he(o[0],o.at(-1)),o));let c=new Zc(i,s,a);this.macros.set(c.name,{macro:c,resolver:_E(c.toString())}),this.nodes.push(c);let l=this.peekIndex();return this.addTokensToClean({start:n,count:l-n}),this.mergeStack(),this.macroStart=!1,!0}processUndef(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!H(r,28))return this.popStack(),!1;this.macroStart=!0;let i=new At(he(r)),s=this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(Y(30,i.firstToken,i.lastToken,i)),this.mergeStack(),this.macroStart=!1,!0;let o=new Zc(i,s);this.macros.delete(s.name),this.nodes.push(o);let a=this.peekIndex();return this.addTokensToClean({start:n,count:a-n}),this.mergeStack(),this.macroStart=!1,!0}processError(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!H(r,29))return this.popStack(),!1;this.moveEndOfLine(r,!1,!0);let i=this.peekIndex();return this.addTokensToClean({start:n,count:i-n}),this.mergeStack(),!0}consumeDefinitionContent(){let n=[];for(;this.currentToken;){let r=this.moveToNextToken;r&&n.push(r)}return n}isFunctionDefinition(){this.enqueueToStack();let n=this.processCIdentifier(this.macros,!0);if(!n){this.popStack();return}let r=this.moveToNextToken;if(!H(r,42)||!Yt(n.lastToken,r)){this.popStack();return}let i=[],s=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;s;)i.push(s),!H(this.currentToken,24)&&!H(this.currentToken,43)?this._issues.push(Y(28,s.firstToken,s.lastToken,s)):H(this.currentToken,43)||(r=this.moveToNextToken),s=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new ei(n,i);if(H(this.currentToken,43))r=this.moveToNextToken,o.lastToken=r;else{o.lastToken=this.prevToken;let a=i.at(-1)??o;this._issues.push(Y(26,a.firstToken,a.lastToken,a))}return this.mergeStack(),o}processVariadic(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(45),Fe(45),Fe(45)]);if(n.length!==3){this.popStack();return}let r=new ba(he(n[0],n.at(-1)));return this.mergeStack(),r}processIfDefBlocks(){let n=this.peekIndex(),r=this.parseScopedBlock(a=>!!a&&[33,34,32].some(c=>H(a,c))&&!mn(a.prevToken,a),a=>!!a&&[37].some(c=>H(a,c))&&!mn(a.prevToken,a),a=>!!a&&[36,35].some(c=>H(a,c))&&!mn(a.prevToken,a));if(!r)return;let i=this.processIfBlock(r);this.nodes.push(i);let s=i.getInValidTokenRange(this.macros);this.tokens=this.tokens.filter(a=>!s.has(a));let o=i.inactiveRanges;this._comments.forEach(a=>{o.some(c=>ao(c,a.range))&&(a.disabled=!0)}),[...i.ifBlocks,...i.elseOption?[i.elseOption]:[]].forEach(a=>{!a.active&&a.content&&this._issues.push(Y(47,a.content.firstToken,a.content.lastToken,a.content,{severity:il.DiagnosticSeverity.Hint,tags:[il.DiagnosticTag.Unnecessary]}))}),this.positionStack[this.positionStack.length-1]=n}processIfBlock(n){this.enqueueToStack();let r=new At(he(n.startToken)),i=[],s;n.splitTokens.forEach((c,l)=>{c.rewind();let u=this.prevToken,d=l===n.splitTokens.length-1&&H(u,36),f=new At(he(u));this.macroStart=!0;let p,m;if(H(f.firstToken,33)||H(f.firstToken,34)?(m=this.processCIdentifier(this.macros,!0),p=m):(p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0),p instanceof Tt&&p.name.toLowerCase()==="defined"&&(p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0))),this.macroStart=!1,d){let h=u,y=new At(he(h)),S;c.tokens.length&&(S=new tl(he(c.tokens[0],c.tokens.at(-1)))),s=new cp(y,S??null)}else{p||this._issues.push(Y(31,f.firstToken,f.lastToken,f));let h,y=c.tokens.indexOf(p?.lastToken??r.lastToken)+1,S=c.tokens[y];y!==-1&&S&&(h=new tl(he(S,c.tokens.at(-1)))),H(f.firstToken,33)?i.push(new rl(f,m??null,h??null)):H(f.firstToken,34)?i.push(new ap(f,m??null,h??null)):i.push(new op(f,p??null,h??null))}});let o;n.endToken?o=new At(he(n.endToken)):this._issues.push(Y(46,r.firstToken,r.lastToken,r));let a=new Er(i,o??null,s);return this.mergeStack(),a}get allAstItems(){return[...this.dtsIncludes,...this.nodes,...this.comments]}resolveInclude(n){if(n.path.path)return n.path.relative?[(0,Sa.resolve)((0,Sa.dirname)(n.fsPath),n.path.path),...this.incudes.map(r=>(0,Sa.resolve)(r,n.path.path))].find(r=>(0,WT.existsSync)(r)):this.incudes.map(r=>(0,Sa.resolve)(r,n.path.path)).find(r=>(0,WT.existsSync)(r))}async processInclude(){this.enqueueToStack();let n=this.peekIndex(),r=this.currentToken;if(!r)return this.popStack(),!1;let i=r,s=r;if(H(r,26))this.moveToNextToken;else{let h=this.checkConcurrentTokens([Fe(13),st("include"),Fe(13)]);if(h.length!==3)return this.popStack(),!1;i=h[0],s=h.at(-1)}let o=i,a=new At(he(i,s));r=this.moveToNextToken;let c=r,l=!!H(r,21);if(!c||!l&&!H(r,5))return o&&this.moveEndOfLine(o),this.mergeStack(),!0;let u="";if(l)u=r?.value??"";else for(;this.currentToken?.pos.line===o.pos.line&&!H(this.currentToken,4);)u+=this.currentToken?.value??"",r=this.moveToNextToken;let d=new va(u,l,he(c,r)),f=new Zr(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!H(this.currentToken,4)?this._issues.push(Y(12,f.firstToken,f.lastToken,f)):(r=this.moveToNextToken,d.lastToken=r)),this.mergeStack();let p=this.peekIndex(),m=this.resolveInclude(f);if(f.resolvedPath=m,m||this._issues.push(Y(36,f.path.firstToken,f.path.lastToken,f.path,{severity:il.DiagnosticSeverity.Warning})),m&&!this.optimizeForFormatting){Ln().requestTokens(m,!0);let h=sl().getCPreprocessorParser(m,this.incudes,this.macros,this.fsPath);await h.stable,this._issues.push(...h.issues),this.macros.clear(),Array.from(h.macros).forEach(([y,S])=>this.macros.set(y,S)),m.endsWith(".h")?this.addTokensToClean({start:n,count:p-n}):(this.tokens=DE(this.tokens,n,p,h.tokens),this.positionStack[this.positionStack.length-1]=n),this.nodes.push(...h.nodes),this.dtsIncludes.push(...h.dtsIncludes)}else this.addTokensToClean({start:n,count:p-n});return!0}};var zT,lp=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,n,r,i){e=dt(e);let s=`${Array.from(r).map(l=>l[1].macro.toString()).join("::")}`,o=this.headerFiles.get(e)?.get(s);if(o)return o.reparse(r),o;console.log("No c-preprocessor cache",e);let a=new _a(e,n,r),c=this.includeOwners.get(a)??new Set;return c.add(i),this.includeOwners.set(a,c),this.headerFiles.has(e)||this.headerFiles.set(e,new Map),this.headerFiles.get(e)?.set(s,a),a}reset(e){e=dt(e);let n=this.headerFiles.get(e);n&&Array.from(n).forEach(([r,i])=>{console.log("disposing c-preprocessor cache for",e),Array.from(this.includeOwners.get(i)??[]).forEach(this.reset.bind(this)),this.headerFiles.delete(e)})}};function sl(){return zT??=new lp,zT}function MD(){zT=new lp}var GT,up=class t{constructor(){this.fileMap=new Map}static clone(e){let n=e.length;if(n===0)return[];let r=new Array(n),i;for(let s=0;s<n;s++){let o=e[s],a={tokens:o.tokens,pos:o.pos,value:o.value,fsPath:o.fsPath,prevToken:i,nextToken:void 0};i&&(i.nextToken=a),r[s]=a,i=a}return r}needsRenew(e,n){return e=dt(e),this.fileMap.get(e)?.text!==n}getDocument(e,n){return Lt.create(e,"devicetree",0,n??this.fileMap.get(e)?.text??(0,ol.readFileSync)(e).toString())}renewLexer(e,n){if(e=dt(e),sl().reset(e),!n&&!(0,ol.existsSync)(e))return[];try{n??=(0,ol.readFileSync)(e).toString();let r=new er(n,e);return this.fileMap.set(e,r),t.clone(r.tokens)}catch{}return[]}requestTokens(e,n){e=dt(e);let r=this.fileMap.get(e)?.tokens;return!r&&n?[...this.renewLexer(e)]:t.clone(r??[])}reset(e){e=dt(e),sl().reset(e),this.fileMap.delete(e)}};function Ln(){return GT??=new up,GT}function xD(){GT=new up}var Pi=class t{constructor(e){this.context=e;this.comments=[];this.references=[];this.unlinkedDeletes=[];this.unlinkedRefNodes=[];this.globalDeletes=[];this.rootNode=new X(this.context.bindingLoader,"/");this.labelsUsedCache=new Map;this.fileTopMostAstCache=new Map}fileTopMostAsts(e){let n=this.fileTopMostAstCache.get(e);if(n)return n;let r=[...this.rootNode.implementations,...this.references,...this.unlinkedDeletes,...this.unlinkedRefNodes,...this.globalDeletes,...this.context.overlayParsers.flatMap(i=>[...i.cPreprocessorParser.allAstItems,...i.unhandledStatements.children]),...this.context.parser.cPreprocessorParser.allAstItems,...this.context.parser.unhandledStatements.children].flatMap(i=>i.getTopMostAstNodeForFile(e));return this.fileTopMostAstCache.set(e,r),r}getDeepestAstNode(e,n){let r=this.fileTopMostAsts(e),i=Ln().requestTokens(e,!1),s=r.find(o=>Qt(o,e,n)||bE(i,o,n));if(!s){let o=this.context.allParsers.flatMap(l=>l.includes),a=(l,u)=>{let d=o.find(f=>fe(f.resolvedPath,l));return d&&this.context.getSortKeyFile(u,l)===void 0?a(d.lastToken.fsPath,se(d.lastToken)):d},c=a(e,n);c&&(s=r.at(-1)?.parentNode,e=c.fsPath,n=LD.Position.create(c.lastToken.pos.line,c.lastToken.pos.colEnd))}if(s instanceof ut){let a=this.rootNode.getReferenceBy(s)?.getDeepestAstNode(e,n);return a?{...a,runtime:this}:{item:null,runtime:this,ast:Jr(s,e,n)}}else if(s instanceof nt&&s.path){let o=this.rootNode.getDeepestAstNode(e,n);return o?{...o,runtime:this}:void 0}else if(s instanceof Ee&&s.path){let o=t.getNodeFromPath(s.path.slice(1),this.rootNode)?.getDeepestAstNode(e,n);return o?{...o,runtime:this}:void 0}else if(s)return{runtime:this,item:null,ast:Jr(s,e,n)}}static getNodeFromPath(e,n,r=!0){if(e.length===0)return n;let i=e[0].split("@"),s=i[0],a=i.at(1)?.split(",").map(u=>Number.parseInt(u,16)),c=e.slice(1),l=n.getNode(s,a,r);return l?t.getNodeFromPath(c,l,r):void 0}resolvePath(e,n){if(!e.at(0)?.startsWith("&"))return e;let r=this.labelsUsedCache.get(e[0].slice(1));return r||(n??=this.rootNode.allDescendantsLabels,n.find(s=>s.label.value===e.at(0)?.slice(1)&&s.parentNode instanceof we)?.lastLinkedTo?.path)}get issues(){return this.issuesCache??=[...this.labelIssues(),...this.rootNode.getIssues(this.context.macros)],this.issuesCache}labelIssues(){let e=[],n=new Map;return this.rootNode.allDescendantsLabelsMapped.forEach(r=>{n.has(r.label.label.value)?n.get(r.label.label.value)?.push(r):n.set(r.label.label.value,[r])}),Array.from(n).forEach(r=>{let i=r[1];if(i.length>1){let s=i.find(a=>a.owner instanceof X);if(!i.every(a=>a&&a.owner===s?.owner)||!s){let a=i[i.length-1].label;e.push(Gt(4,a.firstToken,a.lastToken,a,{linkedTo:i.slice(0,-1).map(c=>c.label),templateStrings:[i.at(0).label.label.value]}))}}}),e}get typesIssues(){let e=n=>[...n.nodeType?.getIssue(this,n)??[],...n.nodes.flatMap(r=>e(r))];return this.typesIssuesCache??=e(this.rootNode),this.typesIssuesCache}getOrderedNodeAst(e){return SE(e.implementations,this.context)}};var al=L(U());var qD=L(U());var dp=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Values",kind:qD.SymbolKind.String},this.values.forEach(r=>this.addChild(r))}toString(){return this.values.map(n=>n?.toString()).join(",")}toJson(){return this.values.length===1?this.values[0]?.toJson():this.values.map(n=>n?.toJson())}};var $D=L(U());var fp=class extends te{constructor(n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:"DTS Document version",kind:$D.SymbolKind.Function}}};var ki=class extends te{constructor(n,r){super();this.value=n;this.labels=r;this.labels.forEach(i=>{this.addChild(i)}),this.addChild(this.value)}toString(n){return`${this.labels.map(r=>r.toString()).join(" ")}${this.value?.toString(n)??"NULL"}`}toPrettyString(n){return`${this.labels.map(r=>r.toString()).join(" ")}${this.value?.toPrettyString(n)??"NULL"}`}};var FD=L(U());var pp=class extends te{constructor(n,r,i){super();this.keyword=n;this.startAddress=r;this.endAddress=i;this.addChild(n),this.docSymbolsMeta={name:"Memreserve",kind:FD.SymbolKind.Function},this.addChild(r),this.addChild(i)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var BD=L(U());var hp=class extends te{constructor(n,r){super();this.keyword=n;this.bitsSize=r;this.addChild(n),this.docSymbolsMeta={name:"bits",kind:BD.SymbolKind.Function},this.addChild(r)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var Cr=class extends zi{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.tokens=[];this.others=[];this.rootDocument=new we;this.unhandledStatements=new nt;this.injectedMacros=[];this.#e=!1;this.cPreprocessorParser=new _a(this.fsPath,this.incudes,i,s,o)}get issues(){return[...this._issues,...this.cPreprocessorParser.issues]}getFiles(){return[this.fsPath,...this.cPreprocessorParser.dtsIncludes.flatMap(n=>n.resolvedPath).filter(n=>!!n)]}reset(){super.reset(),this.others=[],this.rootDocument=new we,this._issues=[],this.unhandledStatements=new nt,this.#e=!1}async reparse(){let n=performance.now(),r=this.stable;return this.parsing=new Promise(i=>{r.then(async()=>{this.reset(),await this.cPreprocessorParser.reparse(),await this.parse(),console.log("parsing",performance.now()-n),i()})}),this.parsing}async parse(){if(await this.cPreprocessorParser.stable,this.tokens=this.cPreprocessorParser.tokens,dt(this.fsPath).endsWith(".h")||(this.positionStack.push(0),this.tokens.length===0))return;let n=async()=>{if(!(this.isDtsDocumentVersion()||this.isMemreserve()||this.isPlugin()||this.isRootNodeDefinition(this.rootDocument)||this.isDeleteNode(this.rootDocument,"Ref")||this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros)||this.isChildNode(this.rootDocument,"Ref")||this.isProperty(this.unhandledStatements)||this.isDeleteProperty(this.unhandledStatements)||this.isChildNode(this.unhandledStatements,"Name"))){let s=this.moveToNextToken;s&&(this._issues.push(Y(22,s,s,null)),this.reportExtraEndStatements())}};for(;!this.done;)await n();this.fsPath.endsWith(".dtsi")||(this.unhandledStatements.nodes.forEach(s=>{this._issues.push(Y(53,s.firstToken,s.lastToken,s))}),this.unhandledStatements.properties.forEach(s=>{this._issues.push(Y(32,s.firstToken,s.lastToken,s))}),this.unhandledStatements.deleteProperties.forEach(s=>{this._issues.push(Y(33,s.firstToken,s.lastToken,s))}));let r=this.allAstItems.flatMap(s=>[s,...s.allDescendants]),i=this.cPreprocessorParser.comments;if(i.length&&r.forEach(s=>{(s instanceof we||s instanceof Ne||s instanceof Zr)&&wE(s,i)}),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}processInjectPreProcessorMacros(n){let r=this.peekIndex(),i=this.isFunctionCall(n)||this.processCIdentifier(n,!0,!0);return this.injectPreProcessorResults(n,i,r)}injectPreProcessorResults(n,r,i){let s=r?.resolve(n);if(r&&typeof s=="string"){s=kT(s);let o=jf(r.fsPath,ce(r)),a=new Set;if(this.cPreprocessorParser.comments.forEach(l=>{Qt(r,r.fsPath,l.range.start)&&a.add(l)}),this.cPreprocessorParser.removeComments(a),this.injectedMacros.push(r),r instanceof Tt&&s.includes(r.name)||r instanceof Wt&&s.includes(r.functionName.name))return!0;let c=new er(s,o);return this.tokens.splice(i,this.peekIndex()-i,...c.tokens),this.positionStack[this.positionStack.length-1]=i,!0}}isRootNodeDefinition(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!r||!H(r,13))return this.popStack(),!1;if(i=this.moveToNextToken,!i||!H(i,2))return this.popStack(),!1;let s=new nt;s.openScope=i,n.addNodeChild(s),this.processNode(s,"Name");let o=this.nodeEnd(s)??i;return s.firstToken=r,s.lastToken=o,this.mergeStack(),!0}nodeEnd(n){let r=this.currentToken;if(H(r,3))this.moveToNextToken;else{let i=this.prevToken;return i&&this._issues.push(Y(3,i,i,n)),this.endStatement(n,!1)}return this.prevToken?.value==="}"&&(n.closeScope=this.prevToken),this.endStatement(n)}isNodeEnd(){return H(this.currentToken,3)||H(this.currentToken,1)}endStatement(n,r=!0){let i=this.currentToken;if(!H(i,1)){let s=this.prevToken;if(s&&r)return this._issues.push(Y(1,s,s,n)),s}return this.moveToNextToken,this.reportExtraEndStatements(),i}reportExtraEndStatements(){for(;H(this.currentToken,1);){let n=this.moveToNextToken;n&&this._issues.push(Y(23,n,n,null))}}processNode(n,r){if(this.done)return!1;let i=!1,s=!1;do{for(;this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros););if(s=this.isChildNode(n,r)||this.isProperty(n)||this.isDeleteNode(n,r)||this.isDeleteProperty(n),!s&&!this.isNodeEnd()&&!this.done){let o=this.moveToNextToken;o&&(this._issues.push(Y(22,o,o,null)),this.reportExtraEndStatements())}else if(this.done)break;i=i||s}while(!this.isNodeEnd());return i}processOptionalLabelAssign(n=!1){let r=[],i=this.isLabelAssign(n);for(;i;)r.push(i),i=this.isLabelAssign(n);return r}isChildNode(n,r){this.enqueueToStack();let i;r==="Name"&&(i=this.isOmitIfNoRefNode());let s=this.processOptionalLabelAssign(),o,a,c=r==="Ref"?new ut(s):new Ee(s,i);if(r==="Ref"?(this.enqueueToStack(),a=this.processNodePathRef(c),!a||!H(this.currentToken,2)?(this.popStack(),a=void 0):this.mergeStack(),a??=this.isLabelRef(c)):r==="Name"&&(o=this.isNodeName()),!a&&!o){if(!H(this.currentToken,2))return this.popStack(),!1;c.firstToken=this.currentToken,this._issues.push(Y(r==="Name"?[7]:[10,48,11],c.firstToken,this.currentToken?.nextToken,c))}let l=!1;if(a&&c instanceof ut?(c.reference=a,l=!0):o&&c instanceof Ee&&(l=o.address!==void 0,c.name=o),H(this.currentToken,2)){c.openScope=this.moveToNextToken;let u=!1;do u=this.processNode(c,"Name");while(u);let d=this.nodeEnd(c);c.lastToken=d}else if(l){let u=a??o;u&&this._issues.push(Y(2,u.firstToken,u.lastToken,u))}else return this.popStack(),!1;return n.addNodeChild(c),this.mergeStack(),!0}processNodeAddress(n){let r=this.prevToken;this.enqueueToStack();let i=this.checkConcurrentTokens([st("0"),st("x",{caseInsensitive:!0})]);i.length!==2?(i=[],this.popStack()):(this._issues.push(Y(50,i[0],i[1],n,{severity:al.DiagnosticSeverity.Warning})),r=i.at(-1),this.mergeStack());let s=this.consumeAnyConcurrentTokens([19,20,48].map(Fe)),o=l=>{l.length%8!==0&&(l=l.padStart(Math.ceil(l.length/8)*8,"0"));let u=[];for(let d=0;d<l.length;d+=8){let f=l.slice(d,d+8);u.push(parseInt(f,16)>>>0)}return u},a=s.length?o(s.filter(l=>l.value!=="_").map(l=>l.value).join("")):[NaN];return r&&(a.some(l=>Number.isNaN(l))?this._issues.push(Y(8,r,r,n)):!Number.isNaN(a)&&!Yt(r,s[0])&&!bi(s[0].fsPath)&&this._issues.push(Y(29,r,s[0],n,{inclusiveStart:!1,inclusiveEnd:!1}))),this.currentToken?.value.toUpperCase()==="ULL"&&(this._issues.push(Y(51,this.currentToken,this.currentToken,n,{severity:al.DiagnosticSeverity.Warning})),this.moveToNextToken),new Vc(a,he(i.at(0)??s[0]??this.prevToken,this.prevToken))}processNodeAddresses(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Fe(49)]);if(r.length){Yt(n.lastToken,r[0])||this._issues.push(Y(29,n.lastToken,r[0],n,{inclusiveStart:!1,inclusiveEnd:!1}));let i=[],s=()=>{this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros),i.push(this.processNodeAddress(n)),H(this.currentToken,24)&&(this.prevToken&&!Yt(this.prevToken,this.currentToken)&&this._issues.push(Y(29,this.prevToken,this.currentToken,n,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken,s())};s();let o=this.currentToken;for(;!H(this.currentToken,2)&&!H(this.currentToken,1)&&!H(this.currentToken,3)&&!H(this.currentToken,13)&&mn(this.currentToken,i.at(-1)?.lastToken);)this.moveToNextToken;if(o&&o!==this.currentToken){this._issues.push(Y(52,o,this.currentToken,n));let a=new Vc([],he(o,this.prevToken));i.push(a)}return this.mergeStack(),i}this.popStack()}isNodeName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16].map(Fe));if(!n.length){this.popStack();return}let r=n.map(o=>o.value).join(""),i=new $e(r,he(n[0],n.at(-1))),s=this.processNodeAddresses(i);return i.address=s,Hf(r)||this._issues.push(Y(49,i.firstToken,i.lastToken,i)),this.mergeStack(),i}isPropertyName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16,44,46].map(Fe));if(!n.length){this.popStack();return}let r=new Xe(n.map(i=>i.value).join(""),he(n[0],n.at(-1)));return this.mergeStack(),r}isLabelName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Fe));if(!n.length){this.popStack();return}if(!Hf(n?.[0].value)){this.popStack();return}let r=n.map(s=>s.value).join(""),i=new gn(r,he(n[0],n[n.length-1]));return this.mergeStack(),i}isLabelAssign(n){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,48].map(Fe));if(!r.length){this.popStack();return}if(!Hf(r?.[0].value)){this.popStack();return}let i=r.map(c=>c.value).join(""),s=this.currentToken,o=s&&H(s,50),a=new ys(new gn(i,he(r[0],r.at(-1))),he(r[0],o?s:r.at(-1)));if(o){let c=r.at(-1);c&&(s.pos.line!==a.firstToken.pos.line||s.pos.col!==c.pos.colEnd)&&this._issues.push(Y(29,c,s,a,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken}else if(n)this._issues.push(Y(24,a.firstToken,a.lastToken,a));else{this.popStack();return}return this.mergeStack(),a}isProperty(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(),i=this.isPropertyName();if(!i)return this.popStack(),!1;if(H(this.currentToken,2)||H(this.currentToken,49))return this.popStack(),!1;let s=new Ne(i,r),o;H(this.currentToken,0)?(s.assignOperatorToken=this.moveToNextToken,o=this.processValue(n),o?.values.filter(c=>!!c).length||this._issues.push(Y(0,s.firstToken,s.lastToken,s)),s.values=o??null):s.values=void 0;let a=this.endStatement(s);return s.lastToken=a,n.addNodeChild(s),this.mergeStack(),!0}isDtsDocumentVersion(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),st("d"),st("ts"),Fe(16),st("v"),st("1")]);if(n.length!==6)return this.popStack(),!1;let r=n[0],i=r,s=new At;s.firstToken=r;let o=new fp(s);if(this.others.push(o),H(this.currentToken,13))i=this.moveToNextToken;else return s.lastToken=n.at(-1),this._issues.push(Y(21,o.firstToken,o.lastToken,o)),this.mergeStack(),!0;return s.lastToken=i,o.lastToken=this.endStatement(o),this.mergeStack(),!0}isMemreserve(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),st("memreserve")]);if(n.length!==2)return this.popStack(),!1;let r=new At;r.firstToken=n[0];let s=n[0];H(this.currentToken,13)?(s=this.moveToNextToken,r.lastToken=s):(r.lastToken=n.at(-1),this._issues.push(Y(21,r.firstToken,r.lastToken,r)));let o=this.processHex()||this.processDec(),a=o&&(this.processHex()||this.processDec()),c=new pp(r,o,a);if(this.others.push(c),o||this._issues.push(Y(37,r.firstToken,r.lastToken,r)),!a){let l=o??r;this._issues.push(Y(38,l.firstToken,l.lastToken,c))}return c.lastToken=this.endStatement(c),this.mergeStack(),!0}isPlugin(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),st("plugin"),Fe(13)]);if(n.length!==3)return this.popStack(),!1;let r=new At(he(n[0],n.at(-1)));return r.lastToken=this.endStatement(r),this.mergeStack(),this.others.push(r),!0}processBits(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),st("b"),st("its")]);if(n.length!==3){this.popStack();return}let r=new At;r.firstToken=n[0];let s=n[0];H(this.currentToken,13)?(s=this.moveToNextToken,r.lastToken=s):(r.lastToken=n.at(-1),this._issues.push(Y(21,r.firstToken,r.lastToken,r)));let o=this.processDec(),a=new hp(r,o);return this.others.push(a),o?o.value!==8&&o.value!==16&&o.value!==32&&o.value!==64&&this._issues.push(Y(40,o.firstToken,o.lastToken,o)):this._issues.push(Y(39,r.firstToken,r.lastToken,r)),this._issues.push(Y(41,a.firstToken,a.lastToken,a,{severity:al.DiagnosticSeverity.Warning})),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),st("omit"),Fe(16),st("if"),Fe(16),st("no"),Fe(16),st("ref"),Fe(13)]);if(n.length!==9){this.popStack();return}let r=new At(he(n[0],n.at(-1)));return this.mergeStack(),r}isDeleteNode(n,r){this.enqueueToStack();let i=this.checkConcurrentTokens([Fe(13),st("d"),st("e"),st("lete",{allowPartial:!0}),Fe(16),st("node",{allowPartial:!0})]);if(!i.length)return this.popStack(),!1;let s=i[0],o=s,a=new At;if(a.firstToken=s,i.length===1&&!H(this.currentToken,2)){this._issues.push(Y(25,a.firstToken,a.lastToken,a)),a.lastToken=i.at(-1);let d=new Xn(a);return n.addNodeChild(d),this.mergeStack(),!0}let c=i.map(d=>d.value??"").join("");if(!"/delete-node/".startsWith(c)||c.endsWith("-"))return this.popStack(),!1;a.lastToken=i.at(-1),c!=="/delete-node"?this._issues.push(Y(c.startsWith("/delete-n")?34:25,a.firstToken,a.lastToken,a)):H(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(Y(21,a.firstToken,a.lastToken,a));let l=new Xn(a);if(mn(a.lastToken,s)){let d=this.processNodePathRef(n);d&&r==="Name"&&this._issues.push(Y(7,d.firstToken,d.lastToken,d));let f=d?void 0:this.isLabelRef(n);f&&r==="Name"&&this._issues.push(Y(7,f.firstToken,f.lastToken,f));let p=d||f?void 0:this.isNodeName();p&&r==="Ref"&&this._issues.push(Y(10,p.firstToken,p.lastToken,p)),!d&&!p&&!f&&this._issues.push(Y([7,10],l.firstToken,l.lastToken,l)),l.nodeNameOrRef=d??f??p??null}else r==="Name"?this._issues.push(Y(7,a.firstToken,a.lastToken,a)):r==="Ref"&&this._issues.push(Y(10,a.firstToken,a.lastToken,a));let u=this.endStatement(l);return l.lastToken=u,n.addNodeChild(l),this.mergeStack(),!0}isDeleteProperty(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Fe(13),st("d"),st("e"),st("lete",{allowPartial:!0}),Fe(16),st("property",{allowPartial:!0})]);if(!r.length)return this.popStack(),!1;let i=r[0],s=i,o=new At;if(o.firstToken=i,r.length===1&&!H(this.currentToken,2)){this._issues.push(Y(25,o.firstToken,o.lastToken,o)),o.lastToken=r.at(-1);let u=new lt(o);return n.addNodeChild(u),this.mergeStack(),!0}let a=r.map(u=>u.value??"").join("");if(!"/delete-property/".startsWith(a)||a.endsWith("-"))return this.popStack(),!1;o.lastToken=r.at(-1),a!=="/delete-property"?this._issues.push(Y(a.startsWith("/delete-p")?35:25,o.firstToken,o.lastToken,o)):H(this.currentToken,13)?(s=this.moveToNextToken,o.lastToken=s):this._issues.push(Y(21,o.firstToken,o.lastToken,o));let c=new lt(o);if(mn(o.lastToken,i)){let u=this.isPropertyName();u||this._issues.push(Y(6,c.firstToken,c.lastToken,c)),c.propertyName=u??null}else this._issues.push(Y(6,o.firstToken,o.lastToken,o));let l=this.endStatement(c);return c.lastToken=l,n.addNodeChild(c),this.mergeStack(),!0}isNodePathRef(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processNodePathRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&s.push(...this.processOptionalLabelAssign(!0));let o=new xn(r,i,s);return this.mergeStack(),o}processValue(n){this.enqueueToStack();let i=(()=>{let o=()=>(this.processStringValue()||this.isNodePathRef(n)||this.isLabelRefValue(n)||this.arrayValues(n)||this.processByteStringValue()||this.isExpressionValue(n))??null,a=o();if(!a)return[];let c=[a];for(;!H(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d,f=H(this.currentToken,24);if(f)d=this.currentToken,this.moveToNextToken;else if(!mn(this.prevToken,this.currentToken))break;let p=o();if(u&&p===null&&f){let h=new te(he(u,this.currentToken));this._issues.push(Y(0,h.firstToken,h.lastToken,h))}if(!f&&p===null)break;if(l&&!f&&p){let h=new te(he(l));this._issues.push(Y(28,h.firstToken,h.lastToken,h))}let m=c.at(-1);m&&(m.nextValueSeparator??=d),c.push(p)}return c})();if(i.length===0){this.popStack();return}return this.mergeStack(),new dp(i)}processStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.consumeAnyConcurrentTokens([Fe(21)]);if(!r.length){this.popStack();return}if(r.some(u=>u.value===void 0))throw new Error("Token must have value");let i=r.map(u=>u.value).join(`
|
|
296
|
-
`),s=i,o=['"',"'"].some(u=>s.endsWith(u));o&&(s=s.slice(1,-1));let a=new re(s,he(r[0],r.at(-1)));o||this._issues.push(Y(i.startsWith('"')?16:17,a.firstToken,a.lastToken,a));let c=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(c=this.processOptionalLabelAssign(!0));let l=new xn(n,a,c);return this.mergeStack(),l}arrayValues(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(H(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(n)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new xn(r,o,a,i);if(!H(this.currentToken,4))this._issues.push(Y(12,c.firstToken,c.lastToken,c));else{let u=this.moveToNextToken;o&&(o.closeBracket=u)}let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=s,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.moveToNextToken,i=r;if(!H(i,11)){this.popStack();return}let s=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];s.forEach(u=>{let d=0;u.value&&u.value.firstToken===u.value.lastToken&&(d=u.value.firstToken.pos.len),d%2!==0&&this._issues.push(Y(15,u.firstToken,u.lastToken,u))});let a=new Mn(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=r,this._issues.push(Y(14,a.firstToken,a.lastToken,a,{severity:al.DiagnosticSeverity.Information})));let c=new xn(n,a,o);H(this.currentToken,12)?a.closeBracket=this.moveToNextToken:this._issues.push(Y(5,c.firstToken,c.lastToken,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=r,a.lastToken=this.prevToken,c}processLabeledValue(n){this.enqueueToStack();let r=n(),i=[];if(!r)return this.popStack(),[];for(;r;)i.push(r),r=n();if(i.length){let s=n();s&&i.push(s)}return this.mergeStack(),i}processArrayValues(n){this.enqueueToStack();let r=this.processLabeledValue(()=>{let s=()=>this.processRefValue(n,!1)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1,n),o=this.peekIndex(),a=s();return a&&!this.cPreprocessorParser.optimizeForFormatting&&(a.value instanceof Wt&&a.value.params.every(c=>!!c)&&this.cPreprocessorParser.macros.has(a.value.functionName.name)||a.value instanceof Tt&&this.cPreprocessorParser.macros.has(a.value.name))&&typeof a.value.evaluate(this.cPreprocessorParser.macros)=="string"?(this.injectPreProcessorResults(this.cPreprocessorParser.macros,a.value,o),s()):a}),i=new ct(r);return r.length===0&&(i.firstToken=this.currentToken),this.mergeStack(),i}processLabeledHex(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processHex();if(!i){this.popStack();return}let s=new ki(i,r);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),r=this.checkConcurrentTokens([20,20].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(a=>a.value).join(""),16),s=new sn(i,he(r[0],r.at(-1)),16),o=new ki(s,n);return this.mergeStack(),o}processLabeledDec(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processDec();if(!i){this.popStack();return}let s=new ki(i,r);return this.mergeStack(),s}processLabeledExpression(n=!0,r=n,i){this.enqueueToStack();let s=[];n&&(s=this.processOptionalLabelAssign(r));let o=this.processExpression(this.cPreprocessorParser.macros,i);if(!o){this.popStack();return}let a=new ki(o,s);return this.mergeStack(),a}isExpressionValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!1),i=this.processExpression(this.cPreprocessorParser.macros,n);if(!i){this.popStack();return}let s=this.processOptionalLabelAssign(!0),o=new xn(r,i,s);return this.mergeStack(),o}isLabelRef(n){this.enqueueToStack();let r=this.currentToken;if(!r||!H(r,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new ie(null);return this._issues.push(Y(18,r,r,n)),o.firstToken=r,this.mergeStack(),o}r&&(i.firstToken.pos.line!==r.pos.line||i.firstToken.pos.col!==r.pos.colEnd)&&this._issues.push(Y(29,r,i.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));let s=new ie(i);return s.firstToken=r,this.mergeStack(),s}isLabelRefValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.isLabelRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(s=this.processOptionalLabelAssign(!0));let o=new xn(r,i,s);return this.mergeStack(),o}processRefValue(n,r){this.enqueueToStack();let i=this.processOptionalLabelAssign(r),s=this.currentToken;if(!s||!H(s,40)){this.popStack();return}let o=this.processNodePathRef(n);if(o!==void 0){let l=new ki(o,i);return this.mergeStack(),l}let a=this.isLabelRef(n);if(a===void 0){this._issues.push(Y([18,9],s,s,n));let l=new ki(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new ki(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(n=!0,r=new Qr){this.enqueueToStack();let i;if(H(this.currentToken,13))i=this.moveToNextToken;else{if(!n){this.popStack();return}this.prevToken&&this._issues.push(Y(19,this.prevToken,this.prevToken,r))}let s=this.isNodeName(),o=i??this.prevToken;if(!s&&o&&!n&&this._issues.push(Y(7,o,o,r)),!n||s?r.addPath(s??null,i?new te(he(i)):void 0):n&&!s&&i&&(r.addPath(new $e("/",he(i))),r.firstToken=i),n&&!i&&r.children.length===0){this.mergeStack();return}return this.processNodePath(!1,r),this.mergeStack(),r}processNodePathRef(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!H(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!H(i,2)){this.popStack();return}r&&!Yt(r,s)&&this._issues.push(Y(29,r,s,n,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new rt(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Yt(u.lastToken,l)){this._issues.push(Y(29,u.lastToken,l,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Yt(s,u?.firstToken)){this._issues.push(Y(29,s,u?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}let f=o?.children[d+1];u&&f&&!Yt(u.lastToken,f.firstToken)&&this._issues.push(Y(29,u.lastToken,f?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}))}),H(c,3)?this.moveToNextToken:this.prevToken&&this._issues.push(Y(3,this.prevToken,this.prevToken,n)),a.firstToken=r,a.lastToken=c??this.prevToken,this.mergeStack(),a}get includes(){return this.cPreprocessorParser.dtsIncludes}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties,...this.unhandledStatements.nodes]}#e;get latestSemanticTokensBuilt(){return this.#e}buildSemanticTokens(n,r){let i=[];this.injectedMacros.forEach(s=>{s.buildSemanticTokens((...o)=>zi.push(...o,r,i))}),super.buildSemanticTokens(n,r,i),this.#e=!0}};var mp=class t{constructor(e,n,r){this.settings=e;this.formattingOptions=n;this.bindingLoader=r;this._issues=[];this.overlayParsers=[];this.overlays=[];this.ctxNames_=new Set;this.sortKeys=new WeakMap;this.staleFsPaths=new Set;let i={...e,ctxName:e.ctxName??(0,Pa.basename)(e.dtsFile)};this.isFullContext=this.settings.dtsFile.toLowerCase().endsWith(".dts"),this.overlays=i.overlays,this.overlays.filter(cl.existsSync);let s=this.isFullContext&&r?.type==="Zephyr"?[(0,Pa.join)((0,Pa.dirname)(this.settings.dtsFile),"dts"),...i.includePaths]:i.includePaths;this.parser=new Cr(i.dtsFile,s),this.ctxNames_.add(i.ctxName),this.id=Wi(i),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Cr(o,s,this.parser.cPreprocessorParser.macros))??[]})}get macros(){return this.allParsers.at(-1).cPreprocessorParser.macros}get ctxNames(){return Array.from(this.ctxNames_)}addCtxName(e){this.ctxNames_.add(e)}removeCtxName(e){this.ctxNames_.delete(e)}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async getFileTree(){let e=new Map,n=r=>({fsPath:r,includes:(e.get(r)??[]).map(i=>n(i.resolvedPath??i.path))});return[...this.parser.includes,...this.overlayParsers.flatMap(r=>r.includes)].forEach(r=>{let i=e.get(r.fsPath);i||(i=[],e.set(r.fsPath,i)),i.push({path:r.path.path,resolvedPath:r.resolvedPath})}),{mainDtsPath:n(this.parser.fsPath),overlays:this.overlays.map(n)}}async stable(){await Promise.all([this.parser.stable,...this.overlayParsers.map(e=>e.stable)])}async getRuntime(){return await this.stable(),this._runtime??=this.evaluate(),this._runtime}getContextFiles(){return[...this.overlayParsers.flatMap(e=>e.getFiles()),...this.parser.getFiles()]}isInContext(e){return this.getContextFiles().some(n=>fe(n,e))}getFsPathParser(e){return this.allParsers.find(r=>r.getFiles().some(i=>fe(i,e)))}async getAllStableParsers(){return await this.stable(),this.allParsers}get allParsers(){return[this.parser,...this.overlayParsers]}async getDocumentLinks(e,n){if(!this.isInContext(e))return[];let i=(await this.getRuntime()).rootNode.allBindingsProperties.filter(s=>fe(s.ast.fsPath,e)&&s.ast.values&&(!n||Qt(s.ast.values,e,n))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof re&&l.compatible===o.value.value);return c?{range:ce(o.value),target:ue(c.bindingsPath)}:void 0})).filter(s=>!!s)??[];return[...[...this.parser.cPreprocessorParser.dtsIncludes,...this.overlayParsers.flatMap(s=>s.cPreprocessorParser.dtsIncludes)].filter(s=>fe(s.fsPath,e)&&(!n||Qt(s,e,n))).map(s=>{let o=this.parser.cPreprocessorParser.resolveInclude(s);if(o)return{range:ce(s.path),target:ue(o)}}).filter(s=>!!s)??[],...i]}linkPropertiesLabelsAndNodePaths(e){let n=s=>[...s.properties,...s.nodes.flatMap(n)],r=n(e.rootNode),i=e.rootNode.allDescendantsLabels;r.forEach(s=>s.ast.allDescendants.forEach(o=>{if(o instanceof ie){let a=e.resolvePath([`&${o.label?.value}`],i);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(Gt(3,o.firstToken,o.lastToken,o,{templateStrings:[o.value]}))}else o instanceof Qr&&this.linkNodePath(o,e.rootNode)}))}linkNodePath(e,n){let r=n,i=e.pathParts;for(let s=0;s<i.length&&i[s];s++){let o=!1,a=i[s];if(a){let c=s===0&&a.name==="/"?n:r?.getNode(a.name,a.fullAddress,!1);a.linksTo=c,!o&&!c&&(o=!0,this._issues.push(Gt(8,a.firstToken,a.lastToken,a,{templateStrings:[a.toString(),`${e.pathParts.filter(l=>l?.linksTo).map(l=>l?.toString()).join("/")}`]}))),c?.linkedNodeNamePaths.push(a),r=c}else break}}setStaleFsPath(e){this.staleFsPaths.add(e)}async reevaluate(e){this.setStaleFsPath(e);let n=new Set;return this.staleFsPaths.forEach(r=>{let i=this.getFsPathParser(r);i&&n.add(i)}),n.size?(this.sortKeys=new WeakMap,await Promise.all(Array.from(n).map(r=>r.reparse())),this._runtime=this.evaluate(),this._runtime):this._runtime}getSortKey(e,n=!1){if(e)return this.sortKeys.get(n?e.lastToken:e.firstToken)}async evaluate(){let e=performance.now();await this.stable();let n=new Pi(this);this.staleFsPaths.clear(),this._issues=[],this.parser.rootDocument.resetIssues(),this.processRoot(this.parser.rootDocument,n);for(let i=0;i<this.overlayParsers.length;i++)this.overlayParsers[i].rootDocument.resetIssues(),this.processRoot(this.overlayParsers[i].rootDocument,n);let r=await Promise.all(n.rootNode.defaultProperties.map(async i=>{let s=new er(i.text,i.fsPath),o=new Cr(i.fsPath,[],void 0,()=>s.tokens);return await o.stable,this.processRoot(o.rootDocument,n),o}));return n.comments=this.parser.cPreprocessorParser.allAstItems.filter(i=>i instanceof hr),[...this.allParsers,...r].flatMap(i=>i.tokens).forEach((i,s)=>this.sortKeys.set(i,s)),this.linkPropertiesLabelsAndNodePaths(n),this.reportNodeNameAndPropertyClashes(n),console.log(`(ID: ${this.id}) evaluate`,performance.now()-e),n}getSortKeyFile(e,n){let r=this.findTokenBeforePosition(e,n),i=r,s=i?this.sortKeys.get(i):void 0;for(;i&&!s;)i=i.nextToken,s=i?this.sortKeys.get(i):void 0;if(s!==void 0)return s;for(i=r,s=i?this.sortKeys.get(i):void 0;i&&!s;)i=i.prevToken,s=i?this.sortKeys.get(i):void 0;return s}findTokenBeforePosition(e,n){let r=this.allParsers.flatMap(i=>({parser:i,tokens:i.tokens}));for(let[i,s]of r.entries()){if(s.tokens.length===0&&fe(s.parser.fsPath,n)){let c=r[i-1];return i?c.tokens[c.tokens.length-1]:void 0}let o=s.tokens.find((c,l)=>gs(c,n,e)&&(l===s.tokens.length-1||!c.nextToken||bT(c.nextToken,n,e)));if(o)return o;let a=s.parser.includes.find(c=>c.resolvedPath===n);if(a)return a.lastToken}}reportNodeNameAndPropertyClashes(e){let n=r=>{r.properties.forEach(i=>{r.nodes.filter(o=>o.address===void 0&&o.name===i.ast.propertyName?.name&&o.definitions.at(-1)?.name).forEach(o=>{let a=o.definitions,c=a[a.length-1].name;this._issues.push(Gt(2,c.firstToken,c.lastToken,c,{linkedTo:[i.ast,...i.allReplaced.map(l=>l.ast)]}))})}),r.nodes.forEach(n)};n(e.rootNode)}processRoot(e,n){for(let r=0;r<e.children.length;r++){let i=e.children[r];this.processChild(i,n.rootNode,n)}}processChild(e,n,r){e instanceof we?this.processDtcBaseNode(e,n,r):e instanceof Ne?this.processDtcProperty(e,n,r):e instanceof Xn?this.processDeleteNode(e,n,r):e instanceof lt&&this.processDeleteProperty(e,n,r)}checkNodeUniqueNames(e,n){let r=(o,a)=>o.filter(c=>c.name===a.name&&(c.address===a.fullAddress&&c.address===void 0||Dt(c.address??[],a.fullAddress??[])===0)).map(c=>c.issueAst),i=n.nodes.map(o=>{let a=o.definitions[0];return{name:o.name,address:o.address,issueAst:a.name??a}}),s=[];e.children.forEach(o=>{if(o instanceof Ee&&o.name){let a=r(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(Gt(2,o.name.firstToken,o.name.lastToken,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Xn&&o.nodeNameOrRef instanceof $e){let a=o.nodeNameOrRef;r(i,a)&&(s=s.filter(c=>r(s.map(l=>({name:l.name,address:l.fullAddress,issueAst:l})),c).length))}})}getCompileCommands(){if(!(!this.settings.compileCommands||!(0,cl.existsSync)(this.settings.compileCommands)))return JSON.parse((0,cl.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,n,r){e instanceof nt?this.processDtcRootNode(e,r):e instanceof Ee?this.processDtcChildNode(e,n,r):e instanceof ut&&this.processDtcRefNode(e,r)}processDtcRootNode(e,n){n.rootNode.implementations.push(e),this.checkNodeUniqueNames(e,n.rootNode),e.children.forEach(r=>this.processChild(r,n.rootNode,n))}processDtcChildNode(e,n,r){if(e.name?.name){let i=e.path?r.resolvePath(e.path):void 0,o=(i?r.rootNode.getChild(i):void 0)??new X(this.bindingLoader,e.name.name,e.name.fullAddress,n);o.implementations.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),n=o,this.checkNodeUniqueNames(e,o)}e.children.forEach(i=>this.processChild(i,n,r))}processDtcRefNodeLabelRef(e,n,r){let i,s=e.resolveNodePath??(e.pathName?r.resolvePath([e.pathName]):void 0);return s?(e.resolveNodePath??=[...s],i=r.rootNode.getChild(s),n.linksTo=i,e.labels.forEach(o=>o.lastLinkedTo=i),i?.linkedRefLabels.push(n),i?.implementations.push(e),e.labels.forEach(o=>{r.labelsUsedCache.set(o.label.value,s)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):(this._issues.push(Gt(3,n.firstToken,n.lastToken,n,{templateStrings:[n.label?.value??""]})),r.unlinkedRefNodes.push(e)),i}processDtcRefNodeNodePathRef(e,n,r){let i;n.path&&this.linkNodePath(n.path,r.rootNode);let o=n.path?.pathParts.at(-1)?.linksTo?.path;return o?(e.resolveNodePath??=o,i=r.rootNode.getChild(o),e.labels.forEach(a=>a.lastLinkedTo=i),i?.implementations.push(e),e.labels.forEach(a=>{r.labelsUsedCache.set(a.label.value,o)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):r.unlinkedRefNodes.push(e),i}processDtcRefNode(e,n){let r;e.reference?e.reference instanceof ie?r=this.processDtcRefNodeLabelRef(e,e.reference,n):r=this.processDtcRefNodeNodePathRef(e,e.reference,n):n.unlinkedRefNodes.push(e),e.children.forEach(i=>this.processChild(i,r??new X(this.bindingLoader,""),n))}processDtcProperty(e,n,r){e.propertyName?.name&&n.addProperty(new Je(e,n)),e.children.forEach(i=>this.processChild(i,n,r))}processDeleteNode(e,n,r){if(e.nodeNameOrRef instanceof $e&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!n.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(Gt(5,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef));else{n.deletes.push(e);let i=n.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress);e.nodeNameOrRef.linksTo=i,n.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.fullAddress),i?.labels.forEach(s=>{r.labelsUsedCache.delete(s.label.value)})}}else if(e.nodeNameOrRef instanceof ie&&e.nodeNameOrRef.value){let i=r.resolvePath([`&${e.nodeNameOrRef.value}`]),s;i?(s=r.rootNode.getChild(i),n.deletes.push(e),e.nodeNameOrRef.linksTo=s,s?.labels.forEach(o=>{r.labelsUsedCache.delete(o.label.value)}),s?.linkedRefLabels.push(e.nodeNameOrRef),s?.parent?.deleteNode(s.name,e,s.address),e.parentNode instanceof we&&!e.parentNode.pathName&&r.globalDeletes.push(e)):(r.unlinkedDeletes.push(e),this._issues.push(Gt(3,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof rt&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(i=>!i)){let i=r.rootNode,s=e.nodeNameOrRef.path.pathParts;for(let c=0;c<s.length&&s[c];c++){let l=s[c];if(l){let u=i?.getNode(l.name,l.fullAddress,!1);l.linksTo=u,u?.linkedNodeNamePaths.push(l),i=u}}let o=e.nodeNameOrRef.path.pathParts.find(c=>c&&!c.linksTo),a=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;a||(r.unlinkedDeletes.push(e),o&&this._issues.push(Gt(8,o.firstToken,o.lastToken,o,{templateStrings:[o.toString(),`${e.nodeNameOrRef.path.pathParts.filter(c=>c?.linksTo).map(c=>c?.toString()).join("/")}`]}))),n.deletes.push(e),a?.labels.forEach(c=>{r.labelsUsedCache.delete(c.label.value)}),a?.parent?.deleteNode(a.name,e,a.address),e.parentNode instanceof we&&!e.parentNode.pathName&&r.globalDeletes.push(e)}else r.unlinkedDeletes.push(e);e.children.forEach(i=>this.processChild(i,n,r))}processDeleteProperty(e,n,r){e.propertyName?.name&&!n.hasProperty(e.propertyName.name)?this._issues.push(Gt(1,e.propertyName.firstToken,e.propertyName.lastToken,e.propertyName)):e.propertyName?.name&&(n.deletes.push(e),n.deleteProperty(e.propertyName.name,e)),e.children.forEach(i=>this.processChild(i,n,r))}static#e(e,n,r){let i=r.get(n);i||(i=[],r.set(n,i)),i.push(e)}getIssues(e,n=new Map,r=i=>{if(!(i.raw.severity===fo.DiagnosticSeverity.Hint&&i.raw.virtual))return i.raw.severity===fo.DiagnosticSeverity.Error&&!this.isFullContext&&(i.raw.severity=fo.DiagnosticSeverity.Warning),i}){return e.forEach(i=>{let s=r(i);s&&t.#e(s.diagnostic(),s.raw.fsPath,n)}),n}async getSyntaxIssues(e=new Map,n=r=>{if(r.raw.severity===fo.DiagnosticSeverity.Error&&!this.isFullContext&&!co(r.raw,r.raw.fsPath,!1)&&(r.raw.severity=fo.DiagnosticSeverity.Warning),!(r.raw.severity===fo.DiagnosticSeverity.Hint&&r.raw.virtual))return r}){return(await this.getAllStableParsers()).forEach(r=>this.getIssues(r.issues,e,n)),e}async getDiagnostics(){let e=new Map;try{await this.getSyntaxIssues(e);let n=await this.getContextIssues()??[];this.getIssues(n,e);let r=await this.getRuntime();return this.getIssues(r.typesIssues,e),e}catch(n){throw console.error(n),n}}async toFullString(){return`/dts-v1/;
|
|
296
|
+
`),s=i,o=['"',"'"].some(u=>s.endsWith(u));o&&(s=s.slice(1,-1));let a=new re(s,he(r[0],r.at(-1)));o||this._issues.push(Y(i.startsWith('"')?16:17,a.firstToken,a.lastToken,a));let c=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(c=this.processOptionalLabelAssign(!0));let l=new xn(n,a,c);return this.mergeStack(),l}arrayValues(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(H(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(n)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new xn(r,o,a,i);if(!H(this.currentToken,4))this._issues.push(Y(12,c.firstToken,c.lastToken,c));else{let u=this.moveToNextToken;o&&(o.closeBracket=u)}let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=s,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.moveToNextToken,i=r;if(!H(i,11)){this.popStack();return}let s=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];s.forEach(u=>{let d=0;u.value&&u.value.firstToken===u.value.lastToken&&(d=u.value.firstToken.pos.len),d%2!==0&&this._issues.push(Y(15,u.firstToken,u.lastToken,u))});let a=new Mn(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=r,this._issues.push(Y(14,a.firstToken,a.lastToken,a,{severity:al.DiagnosticSeverity.Information})));let c=new xn(n,a,o);H(this.currentToken,12)?a.closeBracket=this.moveToNextToken:this._issues.push(Y(5,c.firstToken,c.lastToken,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=r,a.lastToken=this.prevToken,c}processLabeledValue(n){this.enqueueToStack();let r=n(),i=[];if(!r)return this.popStack(),[];for(;r;)i.push(r),r=n();if(i.length){let s=n();s&&i.push(s)}return this.mergeStack(),i}processArrayValues(n){this.enqueueToStack();let r=this.processLabeledValue(()=>{let s=()=>this.processRefValue(n,!1)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1,n),o=this.peekIndex(),a=s();return a&&!this.cPreprocessorParser.optimizeForFormatting&&(a.value instanceof Wt&&a.value.params.every(c=>!!c)&&this.cPreprocessorParser.macros.has(a.value.functionName.name)||a.value instanceof Tt&&this.cPreprocessorParser.macros.has(a.value.name))&&typeof a.value.evaluate(this.cPreprocessorParser.macros)=="string"?(this.injectPreProcessorResults(this.cPreprocessorParser.macros,a.value,o),s()):a}),i=new ct(r);return r.length===0&&(i.firstToken=this.currentToken),this.mergeStack(),i}processLabeledHex(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processHex();if(!i){this.popStack();return}let s=new ki(i,r);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),r=this.checkConcurrentTokens([20,20].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(a=>a.value).join(""),16),s=new sn(i,he(r[0],r.at(-1)),16),o=new ki(s,n);return this.mergeStack(),o}processLabeledDec(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processDec();if(!i){this.popStack();return}let s=new ki(i,r);return this.mergeStack(),s}processLabeledExpression(n=!0,r=n,i){this.enqueueToStack();let s=[];n&&(s=this.processOptionalLabelAssign(r));let o=this.processExpression(this.cPreprocessorParser.macros,i);if(!o){this.popStack();return}let a=new ki(o,s);return this.mergeStack(),a}isExpressionValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!1),i=this.processExpression(this.cPreprocessorParser.macros,n);if(!i){this.popStack();return}let s=this.processOptionalLabelAssign(!0),o=new xn(r,i,s);return this.mergeStack(),o}isLabelRef(n){this.enqueueToStack();let r=this.currentToken;if(!r||!H(r,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new ie(null);return this._issues.push(Y(18,r,r,n)),o.firstToken=r,this.mergeStack(),o}r&&(i.firstToken.pos.line!==r.pos.line||i.firstToken.pos.col!==r.pos.colEnd)&&this._issues.push(Y(29,r,i.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));let s=new ie(i);return s.firstToken=r,this.mergeStack(),s}isLabelRefValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.isLabelRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(s=this.processOptionalLabelAssign(!0));let o=new xn(r,i,s);return this.mergeStack(),o}processRefValue(n,r){this.enqueueToStack();let i=this.processOptionalLabelAssign(r),s=this.currentToken;if(!s||!H(s,40)){this.popStack();return}let o=this.processNodePathRef(n);if(o!==void 0){let l=new ki(o,i);return this.mergeStack(),l}let a=this.isLabelRef(n);if(a===void 0){this._issues.push(Y([18,9],s,s,n));let l=new ki(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new ki(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(n=!0,r=new Qr){this.enqueueToStack();let i;if(H(this.currentToken,13))i=this.moveToNextToken;else{if(!n){this.popStack();return}this.prevToken&&this._issues.push(Y(19,this.prevToken,this.prevToken,r))}let s=this.isNodeName(),o=i??this.prevToken;if(!s&&o&&!n&&this._issues.push(Y(7,o,o,r)),!n||s?r.addPath(s??null,i?new te(he(i)):void 0):n&&!s&&i&&(r.addPath(new $e("/",he(i))),r.firstToken=i),n&&!i&&r.children.length===0){this.mergeStack();return}return this.processNodePath(!1,r),this.mergeStack(),r}processNodePathRef(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!H(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!H(i,2)){this.popStack();return}r&&!Yt(r,s)&&this._issues.push(Y(29,r,s,n,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new rt(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Yt(u.lastToken,l)){this._issues.push(Y(29,u.lastToken,l,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Yt(s,u?.firstToken)){this._issues.push(Y(29,s,u?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}let f=o?.children[d+1];u&&f&&!Yt(u.lastToken,f.firstToken)&&this._issues.push(Y(29,u.lastToken,f?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}))}),H(c,3)?this.moveToNextToken:this.prevToken&&this._issues.push(Y(3,this.prevToken,this.prevToken,n)),a.firstToken=r,a.lastToken=c??this.prevToken,this.mergeStack(),a}get includes(){return this.cPreprocessorParser.dtsIncludes}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties,...this.unhandledStatements.nodes]}#e;get latestSemanticTokensBuilt(){return this.#e}buildSemanticTokens(n,r){let i=[];this.injectedMacros.forEach(s=>{s.buildSemanticTokens((...o)=>zi.push(...o,r,i))}),super.buildSemanticTokens(n,r,i),this.#e=!0}};var mp=class t{constructor(e,n,r){this.settings=e;this.formattingOptions=n;this.bindingLoader=r;this._issues=[];this.overlayParsers=[];this.overlays=[];this.ctxNames_=new Set;this.sortKeys=new WeakMap;this.staleFsPaths=new Set;let i={...e,ctxName:e.ctxName??(0,Pa.basename)(e.dtsFile)};this.isFullContext=this.settings.dtsFile.toLowerCase().endsWith(".dts"),this.overlays=i.overlays,this.overlays.filter(cl.existsSync);let s=this.isFullContext&&r?.type==="Zephyr"?[(0,Pa.join)((0,Pa.dirname)(this.settings.dtsFile),"dts"),...i.includePaths]:i.includePaths;this.parser=new Cr(i.dtsFile,s),this.ctxNames_.add(i.ctxName),this.id=Wi(i),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Cr(o,s,this.parser.cPreprocessorParser.macros))??[]})}get macros(){return this.allParsers.at(-1).cPreprocessorParser.macros}get ctxNames(){return Array.from(this.ctxNames_)}addCtxName(e){this.ctxNames_.add(e)}removeCtxName(e){this.ctxNames_.delete(e)}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async getFileTree(){let e=new Map,n=r=>({fsPath:r,includes:(e.get(r)??[]).map(i=>n(i.resolvedPath??i.path))});return[...this.parser.includes,...this.overlayParsers.flatMap(r=>r.includes)].forEach(r=>{let i=e.get(r.fsPath);i||(i=[],e.set(r.fsPath,i)),i.push({path:r.path.path,resolvedPath:r.resolvedPath})}),{mainDtsPath:n(this.parser.fsPath),overlays:this.overlays.map(n)}}async stable(){await Promise.all([this.parser.stable,...this.overlayParsers.map(e=>e.stable)])}async getRuntime(){return await this.stable(),this._runtime??=this.evaluate(),this._runtime}getContextFiles(){return[...this.overlayParsers.flatMap(e=>e.getFiles()),...this.parser.getFiles()]}isInContext(e){return this.getContextFiles().some(n=>fe(n,e))}getFsPathParser(e){return this.allParsers.find(r=>r.getFiles().some(i=>fe(i,e)))}async getAllStableParsers(){return await this.stable(),this.allParsers}get allParsers(){return[this.parser,...this.overlayParsers]}async getDocumentLinks(e,n){if(!this.isInContext(e))return[];let i=(await this.getRuntime()).rootNode.allBindingsProperties.filter(s=>fe(s.ast.fsPath,e)&&s.ast.values&&(!n||Qt(s.ast.values,e,n))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof re&&l.compatible===o.value.value);return c?{range:ce(o.value),target:ue(c.bindingsPath)}:void 0})).filter(s=>!!s)??[];return[...[...this.parser.cPreprocessorParser.dtsIncludes,...this.overlayParsers.flatMap(s=>s.cPreprocessorParser.dtsIncludes)].filter(s=>fe(s.fsPath,e)&&(!n||Qt(s,e,n))).map(s=>{let o=this.parser.cPreprocessorParser.resolveInclude(s);if(o)return{range:ce(s.path),target:ue(o)}}).filter(s=>!!s)??[],...i]}linkPropertiesLabelsAndNodePaths(e){let n=s=>[...s.properties,...s.nodes.flatMap(n)],r=n(e.rootNode),i=e.rootNode.allDescendantsLabels;r.forEach(s=>s.ast.allDescendants.forEach(o=>{if(o instanceof ie){let a=e.resolvePath([`&${o.label?.value}`],i);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(Gt(3,o.firstToken,o.lastToken,o,{templateStrings:[o.value]}))}else o instanceof Qr&&this.linkNodePath(o,e.rootNode)}))}linkNodePath(e,n){let r=n,i=e.pathParts;for(let s=0;s<i.length&&i[s];s++){let o=!1,a=i[s];if(a){let c=s===0&&a.name==="/"?n:r?.getNode(a.name,a.fullAddress,!1);a.linksTo=c,!o&&!c&&(o=!0,this._issues.push(Gt(8,a.firstToken,a.lastToken,a,{templateStrings:[a.toString(),`${e.pathParts.filter(l=>l?.linksTo).map(l=>l?.toString()).join("/")}`]}))),c?.linkedNodeNamePaths.push(a),r=c}else break}}setStaleFsPath(e){this.staleFsPaths.add(e)}async reevaluate(e){this.setStaleFsPath(e);let n=new Set;return this.staleFsPaths.forEach(r=>{let i=this.getFsPathParser(r);i&&n.add(i)}),n.size?(this.sortKeys=new WeakMap,await Promise.all(Array.from(n).map(r=>r.reparse())),this._runtime=this.evaluate(),this._runtime):this._runtime}getSortKey(e,n=!1){if(e)return this.sortKeys.get(n?e.lastToken:e.firstToken)}async evaluate(){let e=performance.now();await this.stable();let n=new Pi(this);this.staleFsPaths.clear(),this._issues=[],this.parser.rootDocument.resetIssues(),this.processRoot(this.parser.rootDocument,n);for(let i=0;i<this.overlayParsers.length;i++)this.overlayParsers[i].rootDocument.resetIssues(),this.processRoot(this.overlayParsers[i].rootDocument,n);let r=await Promise.all(n.rootNode.defaultProperties.map(async i=>{let s=new er(i.text,i.fsPath),o=new Cr(i.fsPath,[],void 0,()=>s.tokens);return await o.stable,this.processRoot(o.rootDocument,n),o}));return n.comments=this.parser.cPreprocessorParser.allAstItems.filter(i=>i instanceof hr),[...this.allParsers,...r].flatMap(i=>i.tokens).forEach((i,s)=>this.sortKeys.set(i,s)),this.linkPropertiesLabelsAndNodePaths(n),this.reportNodeNameAndPropertyClashes(n),console.log(`(ID: ${this.id}) evaluate`,performance.now()-e),n}getSortKeyFile(e,n){let r=this.findTokenBeforePosition(e,n),i=r,s=i?this.sortKeys.get(i):void 0;for(;i&&!s;)i=i.nextToken,s=i?this.sortKeys.get(i):void 0;if(s!==void 0)return s;for(i=r,s=i?this.sortKeys.get(i):void 0;i&&!s;)i=i.prevToken,s=i?this.sortKeys.get(i):void 0;return s}findTokenBeforePosition(e,n){let r=this.allParsers.flatMap(i=>({parser:i,tokens:i.tokens}));for(let[i,s]of r.entries()){if(s.tokens.length===0&&fe(s.parser.fsPath,n)){let c=r[i-1];return i?c.tokens[c.tokens.length-1]:void 0}let o=s.tokens.find((c,l)=>gs(c,n,e)&&(l===s.tokens.length-1||!c.nextToken||bT(c.nextToken,n,e)));if(o)return o;let a=s.parser.includes.find(c=>c.resolvedPath===n);if(a)return a.lastToken;if(s.parser.getFiles().some(c=>fe(c,n)))return s.tokens[s.tokens.length-1]}}reportNodeNameAndPropertyClashes(e){let n=r=>{r.properties.forEach(i=>{r.nodes.filter(o=>o.address===void 0&&o.name===i.ast.propertyName?.name&&o.definitions.at(-1)?.name).forEach(o=>{let a=o.definitions,c=a[a.length-1].name;this._issues.push(Gt(2,c.firstToken,c.lastToken,c,{linkedTo:[i.ast,...i.allReplaced.map(l=>l.ast)]}))})}),r.nodes.forEach(n)};n(e.rootNode)}processRoot(e,n){for(let r=0;r<e.children.length;r++){let i=e.children[r];this.processChild(i,n.rootNode,n)}}processChild(e,n,r){e instanceof we?this.processDtcBaseNode(e,n,r):e instanceof Ne?this.processDtcProperty(e,n,r):e instanceof Xn?this.processDeleteNode(e,n,r):e instanceof lt&&this.processDeleteProperty(e,n,r)}checkNodeUniqueNames(e,n){let r=(o,a)=>o.filter(c=>c.name===a.name&&(c.address===a.fullAddress&&c.address===void 0||Dt(c.address??[],a.fullAddress??[])===0)).map(c=>c.issueAst),i=n.nodes.map(o=>{let a=o.definitions[0];return{name:o.name,address:o.address,issueAst:a.name??a}}),s=[];e.children.forEach(o=>{if(o instanceof Ee&&o.name){let a=r(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(Gt(2,o.name.firstToken,o.name.lastToken,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Xn&&o.nodeNameOrRef instanceof $e){let a=o.nodeNameOrRef;r(i,a)&&(s=s.filter(c=>r(s.map(l=>({name:l.name,address:l.fullAddress,issueAst:l})),c).length))}})}getCompileCommands(){if(!(!this.settings.compileCommands||!(0,cl.existsSync)(this.settings.compileCommands)))return JSON.parse((0,cl.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,n,r){e instanceof nt?this.processDtcRootNode(e,r):e instanceof Ee?this.processDtcChildNode(e,n,r):e instanceof ut&&this.processDtcRefNode(e,r)}processDtcRootNode(e,n){n.rootNode.implementations.push(e),this.checkNodeUniqueNames(e,n.rootNode),e.children.forEach(r=>this.processChild(r,n.rootNode,n))}processDtcChildNode(e,n,r){if(e.name?.name){let i=e.path?r.resolvePath(e.path):void 0,o=(i?r.rootNode.getChild(i):void 0)??new X(this.bindingLoader,e.name.name,e.name.fullAddress,n);o.implementations.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),n=o,this.checkNodeUniqueNames(e,o)}e.children.forEach(i=>this.processChild(i,n,r))}processDtcRefNodeLabelRef(e,n,r){let i,s=e.resolveNodePath??(e.pathName?r.resolvePath([e.pathName]):void 0);return s?(e.resolveNodePath??=[...s],i=r.rootNode.getChild(s),n.linksTo=i,e.labels.forEach(o=>o.lastLinkedTo=i),i?.linkedRefLabels.push(n),i?.implementations.push(e),e.labels.forEach(o=>{r.labelsUsedCache.set(o.label.value,s)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):(this._issues.push(Gt(3,n.firstToken,n.lastToken,n,{templateStrings:[n.label?.value??""]})),r.unlinkedRefNodes.push(e)),i}processDtcRefNodeNodePathRef(e,n,r){let i;n.path&&this.linkNodePath(n.path,r.rootNode);let o=n.path?.pathParts.at(-1)?.linksTo?.path;return o?(e.resolveNodePath??=o,i=r.rootNode.getChild(o),e.labels.forEach(a=>a.lastLinkedTo=i),i?.implementations.push(e),e.labels.forEach(a=>{r.labelsUsedCache.set(a.label.value,o)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):r.unlinkedRefNodes.push(e),i}processDtcRefNode(e,n){let r;e.reference?e.reference instanceof ie?r=this.processDtcRefNodeLabelRef(e,e.reference,n):r=this.processDtcRefNodeNodePathRef(e,e.reference,n):n.unlinkedRefNodes.push(e),e.children.forEach(i=>this.processChild(i,r??new X(this.bindingLoader,""),n))}processDtcProperty(e,n,r){e.propertyName?.name&&n.addProperty(new Je(e,n)),e.children.forEach(i=>this.processChild(i,n,r))}processDeleteNode(e,n,r){if(e.nodeNameOrRef instanceof $e&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!n.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(Gt(5,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef));else{n.deletes.push(e);let i=n.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress);e.nodeNameOrRef.linksTo=i,n.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.fullAddress),i?.labels.forEach(s=>{r.labelsUsedCache.delete(s.label.value)})}}else if(e.nodeNameOrRef instanceof ie&&e.nodeNameOrRef.value){let i=r.resolvePath([`&${e.nodeNameOrRef.value}`]),s;i?(s=r.rootNode.getChild(i),n.deletes.push(e),e.nodeNameOrRef.linksTo=s,s?.labels.forEach(o=>{r.labelsUsedCache.delete(o.label.value)}),s?.linkedRefLabels.push(e.nodeNameOrRef),s?.parent?.deleteNode(s.name,e,s.address),e.parentNode instanceof we&&!e.parentNode.pathName&&r.globalDeletes.push(e)):(r.unlinkedDeletes.push(e),this._issues.push(Gt(3,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof rt&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(i=>!i)){let i=r.rootNode,s=e.nodeNameOrRef.path.pathParts;for(let c=0;c<s.length&&s[c];c++){let l=s[c];if(l){let u=i?.getNode(l.name,l.fullAddress,!1);l.linksTo=u,u?.linkedNodeNamePaths.push(l),i=u}}let o=e.nodeNameOrRef.path.pathParts.find(c=>c&&!c.linksTo),a=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;a||(r.unlinkedDeletes.push(e),o&&this._issues.push(Gt(8,o.firstToken,o.lastToken,o,{templateStrings:[o.toString(),`${e.nodeNameOrRef.path.pathParts.filter(c=>c?.linksTo).map(c=>c?.toString()).join("/")}`]}))),n.deletes.push(e),a?.labels.forEach(c=>{r.labelsUsedCache.delete(c.label.value)}),a?.parent?.deleteNode(a.name,e,a.address),e.parentNode instanceof we&&!e.parentNode.pathName&&r.globalDeletes.push(e)}else r.unlinkedDeletes.push(e);e.children.forEach(i=>this.processChild(i,n,r))}processDeleteProperty(e,n,r){e.propertyName?.name&&!n.hasProperty(e.propertyName.name)?this._issues.push(Gt(1,e.propertyName.firstToken,e.propertyName.lastToken,e.propertyName)):e.propertyName?.name&&(n.deletes.push(e),n.deleteProperty(e.propertyName.name,e)),e.children.forEach(i=>this.processChild(i,n,r))}static#e(e,n,r){let i=r.get(n);i||(i=[],r.set(n,i)),i.push(e)}getIssues(e,n=new Map,r=i=>{if(!(i.raw.severity===fo.DiagnosticSeverity.Hint&&i.raw.virtual))return i.raw.severity===fo.DiagnosticSeverity.Error&&!this.isFullContext&&(i.raw.severity=fo.DiagnosticSeverity.Warning),i}){return e.forEach(i=>{let s=r(i);s&&t.#e(s.diagnostic(),s.raw.fsPath,n)}),n}async getSyntaxIssues(e=new Map,n=r=>{if(r.raw.severity===fo.DiagnosticSeverity.Error&&!this.isFullContext&&!co(r.raw,r.raw.fsPath,!1)&&(r.raw.severity=fo.DiagnosticSeverity.Warning),!(r.raw.severity===fo.DiagnosticSeverity.Hint&&r.raw.virtual))return r}){return(await this.getAllStableParsers()).forEach(r=>this.getIssues(r.issues,e,n)),e}async getDiagnostics(){let e=new Map;try{await this.getSyntaxIssues(e);let n=await this.getContextIssues()??[];this.getIssues(n,e);let r=await this.getRuntime();return this.getIssues(r.typesIssues,e),e}catch(n){throw console.error(n),n}}async toFullString(){return`/dts-v1/;
|
|
297
297
|
|
|
298
298
|
${(await this.getRuntime()).rootNode.toFullString((await this.getAllStableParsers()).at(-1).cPreprocessorParser.macros,this.settings.cwd)}`}async serialize(){let e={};return await this.stable,await this.getDiagnostics(),(await this?.getRuntime())?.rootNode.serialize(e,(await this.getAllStableParsers()).at(-1).cPreprocessorParser.macros),e}};var jD=require("fs"),ka=require("path"),It=L(U());function bH(t){if(!t||!(t.ast instanceof va))return[];let e=r=>r.flatMap(i=>{try{return(0,jD.readdirSync)(i,{withFileTypes:!0,recursive:!0}).filter(s=>s.name.toLowerCase().endsWith(".dtsi")||s.name.toLowerCase().endsWith(".h")).map(s=>({label:`${(0,ka.join)((0,ka.relative)(i,s.parentPath),s.name)}`,kind:It.CompletionItemKind.File}))}catch{return[]}});if(t.ast.relative)return e([(0,ka.dirname)(t.ast.fsPath)]);let n=t.runtime.context.settings.includePaths??[];return e(n)}var gp=(t,e)=>[...t.labels.filter(e),...t.deletedNodes.filter(n=>!e(n.by)).flatMap(n=>gp(n.node,e)),...t.nodes.flatMap(n=>gp(n,e))],YT=(t,e)=>[...t.labels,...t.deletedNodes.filter(n=>!e(n.by)).flatMap(n=>YT(n.node,e)),...t.nodes.flatMap(n=>YT(n,e))];function SH(t,e){if(!t||!(t.item instanceof Je)||!(t.ast instanceof ie))return[];let n=i=>YT(i,e),r=new Map;return n(t.runtime.rootNode).forEach(i=>r.set(i.label.value,i)),Array.from(r).map(([,i])=>({label:`${i.label.value}`,kind:It.CompletionItemKind.Method,documentation:i.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function _H(t,e){if(!t||t.item!==null||!(t.ast instanceof ie)||!(t.ast.parentNode instanceof ut))return[];let n=r=>gp(r,e).filter(i=>e(i));return[...Array.from(new Set(n(t.runtime.rootNode).map(r=>r.label.value))).map(r=>({label:r,insertText:t.ast.lastToken.nextToken?.value==="{"?r:`${r} {
|
|
299
299
|
$1
|
|
@@ -343,4 +343,4 @@ ${r}`]})]},RQ=(t,e)=>jF(t,e.split("/").filter(n=>n)),jF=(t,e)=>{if(e.length===0)
|
|
|
343
343
|
`).length-1,o=i.lastIndexOf(`
|
|
344
344
|
`),a=o===-1?r+1:r-o,c=a+n[0].length;return On.Range.create(On.Position.create(s,a),On.Position.create(s,c))}var vc=require("fs");var xQ=(t,e)=>{let n=(0,vc.readFileSync)(t).toString();if(Ln().needsRenew(t,n))Ln().renewLexer(t,n),e(t);else return console.log("file changed event has the same text, skipping.",t)},fg=class{constructor(e,n,r){this.file=e;this.cb=n;this.isFileDirty=r}#e=0;watch(){if(this.count++,this.count===1){console.log("create watch for",this.file);let e=this.file,n=this.cb;this.onChange=()=>{if(console.log("onChange - file watcher",e),this.isFileDirty()){console.log("onChange - file is dirty, skipping");return}xQ(e,n)},(0,vc.watchFile)(e,this.onChange)}}unwatch(){this.count===1&&(console.log("dispose watch for",this.file),(0,vc.unwatchFile)(this.file,this.onChange),this.onChange=void 0),this.count--}get count(){return this.#e}set count(e){this.#e=e,e<0&&(this.#e=0,console.warn("unwatching an un watched file",this.file))}};var Ut=L(require("path")),vP=require("fs");var hi=t=>{if(t)return Array.isArray(t)?t:[t]},LQ=t=>({...t,deviceOrgBindingsMetaSchema:hi(t.deviceOrgBindingsMetaSchema),deviceOrgTreeBindings:hi(t.deviceOrgTreeBindings),includePaths:hi(t.includePaths),lockRenameEdits:hi(t.lockRenameEdits),zephyrBindings:hi(t.zephyrBindings),overlays:hi(t.overlays)}),aB=t=>({...t,defaultDeviceOrgBindingsMetaSchema:hi(t.defaultDeviceOrgBindingsMetaSchema),defaultDeviceOrgTreeBindings:hi(t.defaultDeviceOrgTreeBindings),defaultIncludePaths:hi(t.defaultIncludePaths),defaultLockRenameEdits:hi(t.defaultLockRenameEdits),defaultZephyrBindings:hi(t.defaultZephyrBindings),contexts:t.contexts?.map(LQ)}),jr=async(t,e=[],n)=>{let r=n?e.map(s=>_e(s.uri)).sort((s,o)=>s.split(Ut.sep).length-o.split(Ut.sep).length).find(s=>PE(s,n)):void 0;return[...e.at(0)?[{replace:"${workspaceFolder}",fsPath:r??_e(e[0].uri)}]:[],...e.map(s=>({replace:`\${workspaceFolder:${s.name}}`,fsPath:_e(s.uri)}))].forEach(s=>t=t.replaceAll(s.replace,s.fsPath)),t},zs={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],defaultLockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0,defaultShowFormattingErrorAsDiagnostics:!0,disableFileWatchers:!1,autoAddMissingPropertiesOnCompletion:!0},bP=async(t,e,n)=>{let r=await jr(t.cwd??"${workspaceFolder}",n,t.dtsFile)??e.cwd,i=await Promise.all((t.includePaths??e.defaultIncludePaths).map(p=>jr(p,n,t.dtsFile))),s=await Promise.all((t.zephyrBindings??e.defaultZephyrBindings).map(p=>jr(p,n,t.dtsFile))),o=t.bindingType??e.defaultBindingType,a=await Promise.all((t.deviceOrgTreeBindings??e.defaultDeviceOrgTreeBindings).map(p=>jr(p,n,t.dtsFile))),c=await Promise.all((t.deviceOrgBindingsMetaSchema??e.defaultDeviceOrgBindingsMetaSchema).map(p=>jr(p,n,t.dtsFile))),l=await Promise.all((t.lockRenameEdits??e.defaultLockRenameEdits).map(p=>jr(p,n,t.dtsFile)));if(r&&o==="Zephyr"&&(!s||s.length===0)&&(s=["./zephyr/dts/bindings"]),!t.dtsFile){console.log("Context is missing dtsFile, skipping...");return}let u=t.dtsFile,d=t.overlays??[],f=t.compileCommands;return r&&(s=s.map(p=>(0,Ut.resolve)(r,p)).filter(p=>(0,vP.existsSync)(p)),a=a?.map(p=>(0,Ut.resolve)(r,p)),c=c.map(p=>(0,Ut.resolve)(r,p)),i=i.map(p=>(0,Ut.resolve)(r,p)),u=(0,Ut.resolve)(r,u),d=d.map(p=>(0,Ut.resolve)(r,p)),l=l.map(p=>(0,Ut.resolve)(r,p)),f=f?(0,Ut.resolve)(r,f):void 0),{ctxName:t.ctxName??(0,Ut.basename)(u),cwd:r?dt(r):void 0,includePaths:i.map(dt),zephyrBindings:s.map(dt),bindingType:o,deviceOrgTreeBindings:a.map(dt),deviceOrgBindingsMetaSchema:c.map(dt),dtsFile:dt(u),overlays:d.map(dt),lockRenameEdits:l.map(dt),compileCommands:f?dt(f):void 0,showFormattingErrorAsDiagnostics:t.showFormattingErrorAsDiagnostics??e.defaultShowFormattingErrorAsDiagnostics,disableFileWatchers:t.disableFileWatchers??e.disableFileWatchers,autoAddMissingPropertiesOnCompletion:t.autoAddMissingPropertiesOnCompletion??e.autoAddMissingPropertiesOnCompletion}},Yu=async(t,e)=>{let n=t.cwd?await jr(t.cwd,e):void 0,r=t.defaultBindingType,i=t.defaultDeviceOrgBindingsMetaSchema=await Promise.all((t.defaultDeviceOrgBindingsMetaSchema??[]).map(d=>jr(d,e))),s=t.defaultDeviceOrgTreeBindings=await Promise.all((t.defaultDeviceOrgTreeBindings??[]).map(d=>jr(d,e))),o=t.defaultIncludePaths=await Promise.all((t.defaultIncludePaths??[]).map(d=>jr(d,e))),a=t.defaultZephyrBindings=await Promise.all((t.defaultZephyrBindings??[]).map(d=>jr(d,e))),c=t.defaultLockRenameEdits=await Promise.all((t.defaultLockRenameEdits??[]).map(d=>jr(d,e)));n&&(o=t.defaultIncludePaths=(t.defaultIncludePaths??[]).map(d=>(0,Ut.resolve)(n,d)),r==="Zephyr"&&!t.defaultZephyrBindings&&(a=["./zephyr/dts/bindings"]),a=a.map(d=>(0,Ut.resolve)(n,d)),i=i.map(d=>(0,Ut.resolve)(n,d)),s=(t.defaultDeviceOrgTreeBindings??[]).map(d=>(0,Ut.resolve)(n,d)),c=c.map(d=>(0,Ut.resolve)(n,d)));let l={cwd:n,defaultDeviceOrgBindingsMetaSchema:i,defaultDeviceOrgTreeBindings:s,defaultIncludePaths:o,defaultZephyrBindings:a,defaultLockRenameEdits:c,defaultBindingType:r,autoChangeContext:t.autoChangeContext??zs.autoChangeContext,allowAdhocContexts:t.allowAdhocContexts??zs.allowAdhocContexts,defaultShowFormattingErrorAsDiagnostics:t.defaultShowFormattingErrorAsDiagnostics??zs.defaultShowFormattingErrorAsDiagnostics,disableFileWatchers:t.disableFileWatchers??!1,autoAddMissingPropertiesOnCompletion:t.autoAddMissingPropertiesOnCompletion??!0},u=(await Promise.all(t.contexts?.map(d=>bP(d,l,e))??[])).filter(d=>!!d).filter(d=>[d.dtsFile,...d.overlays].every(f=>(0,vP.existsSync)(f)&&Ut.default.isAbsolute(f)));return{...l,contexts:u}};var cB=t=>`DT_PROP(${SP(t.parent)}, ${t.name.replaceAll("-","_")}))`,lB=t=>t.parent.labels.map(e=>`DT_PROP(DT_NODELABEL(${e.label.toString()}), ${t.name.replaceAll("-","_")})`);var SP=t=>`DT_PATH(${t.path.slice(1).map(e=>e.replace("@","_").replaceAll("-","_")).join(",")})`,uB=t=>t.labels.map(e=>`DT_NODELABEL(${e.label.toString()})`),dB=t=>{let e=[];return Pi.getNodeFromPath(["aliases"],t.root)?.properties.filter(i=>{if(i.ast.quickValues?.at(0)===t.pathString)return!0;let s=i.ast.values?.values.at(0)?.value;if(s instanceof ie&&s.linksTo===t||s instanceof rt&&s.path?.pathParts.at(-1)?.linksTo===t)return!0})?.forEach(i=>e.push(`DT_ALIAS(${i.name.replaceAll("-","_")})`)),e};function qQ(t,e){if(!t||!(t.item instanceof Je)||!(t.ast instanceof Xe))return[];let n=[];return e.settings.bindingType==="Zephyr"&&(n.push({type:"dt_zephyr_macro_prop_node_path",data:cB(t.item)}),lB(t.item).forEach(r=>{n.push({type:"dt_zephyr_macro_prop_node_label",data:r})})),n}function $Q(t,e){if(!t||t.item===null)return[];let n;if(t.item instanceof X?n=t.item:t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo?n=t.ast.parentNode.linksTo:t.ast instanceof $e&&t.ast.linksTo&&(n=t.ast.linksTo),!n)return[];let r=[{type:"path",data:n.pathString}];return e.settings.bindingType==="Zephyr"&&(uB(n).forEach(i=>{r.push({type:"dt_zephyr_macro_node_label",data:i})}),r.push({type:"dt_zephyr_macro_node_path",data:SP(n)}),dB(n).forEach(i=>{r.push({type:"dt_zephyr_macro_prop_node_alias",data:i})})),r}async function fB(t,e){return e?Rt(t,e,n=>[...$Q(n,e),...qQ(n,e)]):[]}var pB=L(U());function FQ(t){return!t||!(t.item instanceof Je)?void 0:t.item.parent.nodeType?.getSignatureHelp?.(t.item,t.ast,t.beforeAst,t.afterAst)}async function BQ(t){let e=Gc(t?.ast);if(!e||!e.params.length||!t?.ast||t.ast===e.functionName)return;let r=(await t.runtime.context.getAllStableParsers()).at(-1).cPreprocessorParser.macros.get(e.functionName.name)?.macro.identifier;if(!r||!(r instanceof ei))return;let i=r.params.map(o=>({label:o instanceof Tt?o.name:"..."})),s=e.params.find(o=>o&&(t.ast===o||o.isAncestorOf(t.ast)));return s??=t.afterAst?e.params.find(o=>o&&(t.afterAst===o||o.isAncestorOf(t.afterAst))):void 0,s??=t.beforeAst?e.params.find(o=>o&&(t.beforeAst===o||o.isAncestorOf(t.beforeAst))):void 0,{signatures:[pB.SignatureInformation.create(`${e.functionName.name}(${i.map(o=>o.label).join(", ")})`,void 0,...i.flat())],activeSignature:0,activeParameter:s?e.params.indexOf(s):void 0}}async function hB(t,e){if(e)return(await Rt(t,e,async n=>[await BQ(n)||FQ(n)])).at(0)}var mB=require("timers"),gB=require("events");var _P=class extends gB.EventEmitter{constructor(e=3e3,n=1e3){super(),this.thresholdBytes=e*1024*1024,this.interval=(0,mB.setInterval)(()=>{let r=process.memoryUsage().heapUsed;r>this.thresholdBytes&&this.emit("thresholdExceeded",{usedMb:(r/1024/1024).toFixed(2),thresholdMb:e})},n)}stop(){clearInterval(this.interval)}},jQ=new _P(3e3),yB=()=>{jQ.on("thresholdExceeded",({usedMb:t,thresholdMb:e})=>{console.warn(`[HeapMonitor] Heap usage exceeded ${e}MB: ${t}MB used`),xD(),MD()})};var TB=t=>`0x${t.map((e,n)=>e.toString(16).padStart(n?8:0,"0")).join("")}`;function vB(t,e){let n=e.nodePath,r=e.labels.at(0);e.disabled&&(r+=" <DISABLED>");let i=e.nodePath.split("/").pop()??e.nodePath,s=r?`${r} (${i})`:i,o=t.children.filter(a=>{let c=Xr(e.start,e.size),l=Xr(a.start,a.size),u=Dt(e.start,a.start)>=0,d=Dt(c,l)<=0,f=Dt(e.start,a.start)===0&&Dt(e.size,a.size)===0;return u&&d&&!f});if(o.length>0){for(let a of o)vB(a,e);return}t.children.push({name:s,start:e.start,size:e.size,children:[],path:n,disabled:e.disabled})}function UQ(t){let e={};for(let n of t){let r={name:n.name,children:[],path:n.path};for(let i of n.partitions)vB(r,i);e[n.name]=r}return e}function bB(t,e="",n=!0){let r={};for(let d of t.children){let f=`${d.start}-${d.size}`;r[f]||(r[f]=[]),r[f].push(d)}let i="",s=e?n?"\u2514\u2500 ":"\u251C\u2500 ":"",o=[];"start"in t&&t.start.length&&o.push(`start: ${TB(t.start)}`),"size"in t&&t.size.length&&o.push(`size: ${TB(t.size)}`);let a=o.length>0?`[${o.join(", ")}]`:"",c=t.name;i+=`${e}${s}${c} ${a}
|
|
345
345
|
`;let l=e+(n?" ":"\u2502 "),u=Object.keys(r);return u.forEach((d,f)=>{let p=r[d],m=Array.from(new Set(p.map(b=>b.name))).join(", "),h={};p.forEach(b=>{b.children.forEach(v=>{let k=`${v.start}-${v.size}-${v.name}`;h[k]=v})});let y=Object.values(h),S={name:m,start:p[0].start,size:p[0].size,children:y,path:t.path};i+=bB(S,l,f===u.length-1)}),i}function SB(t){return UQ(t)}function _B(t){return Object.values(t).map(e=>bB(e)).join(`
|
|
346
|
-
`)}var Ie=[],le,Gs,hg=new WeakMap,Ku=new Map;yB();var gg=new Map,kB=t=>{t.settings.disableFileWatchers||t.getContextFiles().forEach(e=>{Ku.has(e)||Ku.set(e,new fg(e,CP,()=>{let n=td(e),r=gg.get(e);return!n||r===void 0?!1:r!==n.version})),Ku.get(e)?.watch()})},RP=async t=>{let e=Ie.indexOf(t);if(e===-1)return;Ju(t,void 0,!0),hg.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let n=await Ks(t);if(J.sendNotification("devicetree/contextDeleted",{ctxNames:t.ctxNames.map(r=>r.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:n.type}),Ie.splice(e,1),await IP(),t===le&&(le=void 0,Ie.length)){let r=Gs?Rn(Ie,{fsPath:Gs}):void 0;r??=Ie[0],console.log("Active context was deleted. Forcing active to",r.id),await bn({id:r.id},!0)}t.settings.disableFileWatchers||t.getContextFiles().map(r=>{Ku.get(r)?.unwatch()}),setTimeout(async()=>{await Oe();let r=new Set(Ie.flatMap(i=>i.getContextFiles()));t.getContextFiles().map(i=>{r.has(i)||Ln().reset(i)})},2e3),t.bindingLoader?.dispose()},HQ=t=>{let e=hg.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},Oe=async()=>{await Promise.all(Ie.map(HQ))},wP=async(t,e)=>(await NB(e)).indexOf(t)!==-1,NB=async t=>{let e=await RB(t);return Ie.filter(n=>!e.some(r=>r===n))},RB=async t=>{let e=await NP(t);return Ie.filter(n=>e.contexts.find(r=>Wi(r)===n.id))},VQ=async t=>{let e=await XQ(t);return Ie.filter(n=>e.contexts.find(r=>Wi(r)===n.id))},WQ=async(t,e)=>(await VQ(e)).indexOf(t)!==-1,zQ=async(t,e)=>{if(t===e)return!0;let n=(await t.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath),r=(await e.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath);return r.some(i=>fe(i.resolvedPath,t.parser.fsPath))&&n.length?n.every(i=>r.some(s=>s.resolvedPath===i.resolvedPath&&s.firstToken.pos.col===i.firstToken.pos.col&&s.firstToken.pos.len===i.firstToken.pos.len&&s.firstToken.pos.line===i.firstToken.pos.line&&s.lastToken.pos.col===i.lastToken.pos.col&&s.lastToken.pos.len===i.lastToken.pos.len&&s.lastToken.pos.line===i.lastToken.pos.line)):e.getContextFiles().some(i=>fe(i,t.parser.fsPath))},GQ=async t=>{if(!await wP(t))return;let e=await NB(),n=await RB(),r=await Uf(e);if(Ie.indexOf(t)===-1)return;let i=await Promise.all(r.flatMap(a=>[...n,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await zQ(a.context,c)})))),s=t.getContextFiles(),o=r.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&fe(a.context.parser.fsPath,t.parser.fsPath)&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&await Promise.all(o.map(RP))},J=(0,He.createConnection)(He.ProposedFeatures.all),un=new He.TextDocuments(Lt),EP=!1,mg=!1,wB=!1,EB=!1,CB=!1,PP;J.onInitialize(async t=>{PP=t.workspaceFolders??[],J.console.log(`[Server(${process.pid}) ${PP?.at(0)?.uri} Version 0.10.1 ] Started and initialize received`);let e=t.capabilities;EP=!!(e.workspace&&e.workspace.configuration),mg=!!(e.workspace&&e.workspace.workspaceFolders),wB=!!e.workspace?.diagnostics?.refreshSupport,EB=!!e.workspace?.semanticTokens?.refreshSupport,CB=!!e.workspace?.foldingRange?.refreshSupport;let n={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:He.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[He.CodeActionKind.QuickFix,He.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:qf,tokenModifiers:$f},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,documentRangeFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return mg&&(n.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),await MB(t.initializationOptions),n});var kP,YQ={tabSize:8,insertSpaces:!1,trimTrailingWhitespace:!0,insertFinalNewline:!0,wordWrapColumn:100},DB=t=>({tabSize:t?.["editor.tabSize"],insertSpaces:t?.["editor.insertSpaces"],trimFinalNewlines:t?.["files.trimFinalNewlines"],trimTrailingWhitespace:t?.["files.trimTrailingWhitespace"],insertFinalNewline:t?.["editor.insertFinalNewline"],wordWrapColumn:t?.["editor.wordWrapColumn"],removeMacroMultiline:t?.["editor.removeMacroMultiline"],wrapLongLines:t?.["editor.wrapLongLines"],indentExpressions:t?.["editor.indentExpressions"],removeEmptyReferences:t?.["editor.removeEmptyReferences"],removeEmptyNodes:t?.["editor.removeEmptyNodes"],removeEmptyRoots:t?.["editor.removeEmptyRoots"],sortNodesAndProperties:t?.["editor.sortNodesAndProperties"]});J.onInitialized(async()=>{if(EP&&(J.client.register(He.DidChangeConfigurationNotification.type,{}),!kP)){let t=await J.workspace.getConfiguration("editor").catch(()=>{}),e=await J.workspace.getConfiguration("files").catch(()=>{}),n=await J.workspace.getConfiguration("[devicetree]").catch(()=>{}),r=DB(n);(t||e||r)&&(kP={...t,...e,...r})}mg&&J.workspace.onDidChangeWorkspaceFolders(async t=>{J.console.log("Workspace folder change event received"),await ed()})});J.onRequest("workspace/workspaceFolders",async()=>PP??null);var KQ=async t=>{let e=AB();return e={...zs,...e},Yu(e,t??await Zu())},NP=async t=>{let e=QQ();return e={...zs,...e},Yu(e,t??await Zu())},XQ=async t=>{let e=ZQ();return e={...zs,...e},Yu(e,t??await Zu())},Qu=async t=>{let e=JQ();return e={...zs,...e},Yu(e,t??await Zu())},Zu=async()=>mg?await J.workspace.getWorkspaceFolders()??[]:[],PB=async t=>{let e=Rn(Ie,{id:Wi(t)});if(e)return e.ctxNames.includes(t.ctxName)||console.log(`(ID: ${e.id}) Adding name ${t.ctxName} for [${e.ctxNames.join(",")}]`),e.addCtxName(t.ctxName),e;let n=Wi(t);console.log(`(ID: ${n}) New context [${t.ctxName}]`),console.log(`(ID: ${n}) Settings: ${JSON.stringify(t,void 0," ")}`);let r=(0,Sc.join)((0,Sc.dirname)(t.dtsFile),"dts","bindings"),i=new mp(t,kP??YQ,t.bindingType?tB({zephyrBindings:t.zephyrBindings?[r,...t.zephyrBindings]:[r],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ie.push(i);let s=performance.now();await i.stable(),console.log(`(ID: ${n}) New context took ${performance.now()-s}ms to start [${t.ctxName}]`),kB(i);let o=await Ks(i);return J.sendNotification("devicetree/contextCreated",{ctxNames:i.ctxNames.map(a=>a.toString()),id:i.id,...await i.getFileTree(),settings:i.settings,active:i===le,type:o.type}),await GQ(i),await IP(),i},ed=async()=>{let t=await NP(),e=await Qu();e.allowAdhocContexts||(e=await NP());let n=e.contexts.map(Wi),r=Ie.filter(i=>!n.includes(i.id));await Promise.all(r.map(RP)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await PB(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await KQ()).contexts?.reduce((s,o)=>s.then(async()=>{Rn(Ie,{fsPath:o.dtsFile})||await PB(o)}),Promise.resolve()),setTimeout(async()=>{Gs?await bn({fsPath:Gs}):!le&&Ie.length&&(console.log(`No active context using first context (ID: ${Ie[0].id}) [${Ie[0].ctxNames.join(",")}]`),await bn({id:Ie[0].id}))})},Ur,Ys,Xu=new Map,bc=new Map,JQ=()=>!Ys&&!Ur?void 0:{...Ys,...Ur,contexts:[...Ur?.contexts??[],...Array.from(bc.values()),...Array.from(Xu.values())]},AB=()=>!Ys&&!Ur?void 0:{...Ys,...Ur,contexts:[...Array.from(Xu.values())]},QQ=()=>!Ys&&!Ur?void 0:{...Ys,...Ur,contexts:[...Ur?.contexts??[],...Array.from(bc.values())]},ZQ=()=>!Ys&&!Ur?void 0:{...Ur,contexts:[...Ur?.contexts??[]]};function e8(t){let e={...t};for(let n in e)e[n]===null&&delete e[n];return e}var IB=async()=>{let t=await Qu();console.log("Resolved settings",JSON.stringify(t,void 0," ")),J.sendNotification("devicetree/settingsChanged",t),await ed(),Oe().then(()=>{wB&&J.languages.diagnostics.refresh()})},t8=async()=>{let t=le?.getContextFiles();await Promise.all(Array.from(un.keys()).filter(Jt).map(async e=>{t?.some(n=>fe(n,_e(e)))||await J.sendDiagnostics({uri:e,version:un.get(e)?.version,diagnostics:[{severity:He.DiagnosticSeverity.Information,range:He.Range.create(He.Position.create(0,0),He.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},CP=async t=>{let e=PT(Ie,t);if(e.length)e.sort((n,r)=>n===le?-1:r===le?1:0).forEach(n=>{hg.get(n)?.abort.abort(),le===n&&J.sendNotification("devicetree/activeContextBusyNotification",n.id),J.sendNotification("devicetree/contextBusyNotification",n.id);let r=new AbortController,i=new Promise(s=>{setTimeout(async()=>{if(n.setStaleFsPath(t),r.signal.aborted){console.log("Abort parsing due to new request"),s();return}let o=performance.now(),a=le===n,c=a?OB(n):[],l=n.getContextFiles();if(await n.reevaluate(t),kB(n),l.forEach(p=>Ku.get(p)?.unwatch()),a&&OP(n)?.length&&(DP(n).then(p=>{let m=p.items.map(h=>({uri:h.uri,version:h.version??void 0,diagnostics:h.items}));Ju(n,c.filter(h=>m.every(y=>y.uri!==h.uri))),m.forEach(h=>{J.sendDiagnostics(h)}),nd.set(n,!0)}),Gs)){let p=n.getFsPathParser(Gs);p&&setTimeout(()=>{p.latestSemanticTokensBuilt||J.languages.semanticTokens.refresh()},50)}let[u,d]=await Promise.all([Ks(n),n.getFileTree()]),f={ctxNames:n.ctxNames.map(p=>p.toString()),id:n.id,...d,settings:n.settings,active:a,type:u.type};le===n&&J.sendNotification("devicetree/activeContextStableNotification",f),J.sendNotification("devicetree/contextStableNotification",f),s(),console.log("reevaluate",performance.now()-o)})});hg.set(n,{abort:r,promise:i})});else{if((await Qu()).allowAdhocContexts===!1)return;await ed(),await bn({fsPath:t})}},n8=t=>un.keys().find(e=>fe(_e(e),t)),td=t=>{let e=n8(t);if(e)return un.get(e)},OB=t=>t.getContextFiles().map(e=>({uri:ue(e),version:td(e)?.version,diagnostics:[]})),nd=new WeakMap,Ju=async(t,e=OB(t),n=!1)=>{if(!n&&t!==le)return;let r=performance.now();await Promise.all(e.filter(i=>t===le||!le?.getContextFiles().some(s=>fe(_e(i.uri),s))).map(i=>J.sendDiagnostics({uri:i.uri,version:un.get(i.uri)?.version,diagnostics:[]}))),nd.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-r)},pg=new Map,r8=async t=>{let e=pg.get(t);if(e||!EP)return e;pg.delete(t);let n=await J.workspace.getConfiguration({scopeUri:ue(t),section:"[devicetree]"}).catch(()=>{});if(n){let r=DB(n);return pg.set(t,r),r}},DP=async t=>{await t.stable();let e=performance.now(),n=await t.getDiagnostics(),r=await Promise.all(t.getContextFiles().map(async i=>{let s=td(i),o=[];if(s&&t.settings.showFormattingErrorAsDiagnostics){let a=await r8(i);o.push(...(await wi({textDocument:s,options:{...t.formattingOptions,...a}},s.getText(),"File Diagnostics").catch(()=>[])).map(c=>c.diagnostic()))}return{uri:ue(i),kind:He.DocumentDiagnosticReportKind.Full,items:[...n.get(i)??[],...o],version:s?.version??null}}));return console.log(`(ID: ${t.id})`,"workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-e),{items:[...r]}},AP=async t=>{let{items:e}=await DP(t);e.map(n=>({uri:n.uri,version:n.version??void 0,diagnostics:n.items})).forEach(async n=>{J.sendDiagnostics(n)}),nd.set(t,!0)},IP=async()=>{let t=await Promise.all(Ie.map(e=>Ks(e)));console.log("======== Context List ========"),t.forEach(e=>{console.log(`(ID: ${e.ctx.id}) [${e.ctx.ctxNames.join(",")}]`,`[${e.type}]`,le===e.ctx?" [ACTIVE]":"")}),console.log("==============================")},Ks=async(t,e)=>{let n=await wP(t,e),r=!n&&await WQ(t,e);return{ctx:t,type:n?"Ad Hoc":r?"User":"3rd Party"}},bn=async(t,e=!1)=>{if("fsPath"in t){if(!Jt(t.fsPath))return!1;Gs=t.fsPath,console.log("Active File Uri",Gs)}let n=await Qu();if(le&&!e&&!n.autoChangeContext||(await Oe(),!e&&le?.getContextFiles().find(o=>"fsPath"in t&&fe(o,t.fsPath))))return!1;let r=le,i=Rn(Ie,t),s=r!==i;return s&&(r&&Ju(r),le=i,i?(Ks(i).then(async o=>{let a=await i.getFileTree();!i||i!==le&&!Ie.includes(i)||J.sendNotification("devicetree/newActiveContext",{ctxNames:i.ctxNames.map(c=>c.toString()),id:i.id,...a,settings:i.settings,active:le===i,type:o.type})}),OP(i)?.length&&AP(i),await IP()):J.sendNotification("devicetree/newActiveContext",void 0)),CB&&J.languages.foldingRange.refresh(),EB&&J.languages.semanticTokens.refresh(),s},Jt=t=>[".dts",".dtsi",".dtso",".overlay",".keymap"].some(e=>t.endsWith(e));un.listen(J);var OP=t=>t?.getContextFiles()?.filter(e=>td(e));un.onDidSave(t=>{gg.set(_e(t.document.uri),t.document.version)});un.onDidClose(async t=>{let e=_e(t.document.uri);if(!Jt(e))return;gg.delete(e);let n=PT(Ie,e);if(n.length===0){Xu.delete(e),J.sendDiagnostics({uri:t.document.uri,version:un.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(n.map(async r=>{!!OP(r)?.filter(s=>s!==e).length?le?.getContextFiles().some(s=>fe(s,e))?le?.getContextFiles().some(s=>fe(s,e))&&(await Ju(le),await AP(le)):J.sendDiagnostics({uri:t.document.uri,version:un.get(t.document.uri)?.version,diagnostics:[]}):await wP(r)?(await RP(r),Xu.delete(r.settings.dtsFile)):Ju(r)}))});un.onDidOpen(async t=>{let e=_e(t.document.uri);if(!Jt(e))return;gg.set(e,t.document.version),await Oe(),t8();let n=Rn(Ie,{fsPath:e});if(console.log("onDidOpen",n?.id,e),n)n!==le?await bn({id:n.id}):n===le&&(!nd.get(n)||n.getContextFiles().some(r=>!fe(r,e)))&&await AP(n);else{let r={ctxName:(0,Sc.basename)(e),dtsFile:e};Xu.set(e,r),await CP(e)}});un.onDidChangeContent(async t=>{let e=_e(t.document.uri);if(!Jt(e))return;let n=t.document.getText(),r=Ln();r.needsRenew(e,n)&&(console.log("Content changed",e),r.renewLexer(e,n),await CP(e))});var MB=async t=>{t?.settings?.devicetree&&(Ur=aB(e8(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await IB())};J.onDidChangeConfiguration(async t=>{await MB(t)});J.listen();J.languages.diagnostics.onWorkspace(async()=>{await Oe();let t=le;return t?DP(t).finally(()=>{nd.set(t,!0)}):{items:[]}});J.onDidChangeWatchedFiles(t=>{J.console.log("We received a file change event")});J.onCompletion(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return i0(t,le,un.get(t.textDocument.uri));if(!Jt(e))return[];await Oe(),bn({fsPath:e});let n=Hn(e);return n?[...await UD(t,n),...await L0(t,n)]:[]});J.onCompletionResolve(t=>t);var Hn=t=>{let e=AB();return Rn(Ie,{fsPath:t},le,e?.preferredContext)};J.onDocumentSymbol(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return[];await Oe();let n=Hn(e);return n?n.getFsPathParser(e)?.getDocumentSymbols(e):[]});J.onWorkspaceSymbol(async()=>{await Oe();let t=le;return t?(await t.getAllStableParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});J.languages.semanticTokens.on(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return{data:[]};try{await Oe();let n=Hn(e),r=new He.SemanticTokensBuilder,i=n?.isInContext(e);return!n||!i?{data:[]}:((await n.getAllStableParsers()).forEach(s=>s.buildSemanticTokens(r,e)),r.build())}catch(n){throw console.log(n),n}});J.onDocumentLinks(async t=>{await Oe();let e=_e(t.textDocument.uri);return Jt(e)?Hn(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&le?le.bindingLoader?.getDocumentLinks?.(un.get(t.textDocument.uri))??[]:[]});J.onPrepareRename(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return u0(t,n)});J.onRenameRequest(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return l0(t,n)});J.onReferences(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return s0(t,n)});J.onDefinition(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return p0(t,le,un.get(t.textDocument.uri));if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e),r=(await n?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>He.Location.create(i.target,i.range))??[];return r.length?r:f0(t,n)});J.onDeclaration(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return y0(t,le,un.get(t.textDocument.uri));if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return g0(t,n)});J.onCodeAction(async t=>{let e=_e(t.textDocument.uri);if(Jt(e))return v0(t)});var xB=async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);if(!n)return[];if((await n.getSyntaxIssues(void 0,l=>co(l.raw,e,!1)?l:void 0)).get(e)?.length)return[];let i=un.get(t.textDocument.uri)??Ln().getDocument(e),s=i.getText();pg.set(e,t.options);let o=await wi({...t,options:{...n.formattingOptions,...t.options}},s,"New Text").catch(()=>s);if(o===s)return[];let a=i.lineCount-1,c=i.getText({start:{line:a,character:0},end:{line:a+1,character:0}}).length;return[He.TextEdit.replace(He.Range.create(He.Position.create(0,0),He.Position.create(i.lineCount,c)),o)]};J.onDocumentRangeFormatting(xB);J.onDocumentFormatting(xB);J.onHover(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return sM(t,le,un.get(t.textDocument.uri));if(!Jt(e))return;await Oe();let n=Hn(e);return(await q0(t,n)).at(0)});J.onFoldingRanges(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe();let n=Hn(e),r=n?.isInContext(e);if(!n||!r)return[];let i=(await n.getAllStableParsers()).find(s=>s.getFiles().some(o=>o===e));return i?nB(e,i):[]});J.onTypeDefinition(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return oB(t,n)});J.onSignatureHelp(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return hB(t,n)});J.onRequest("devicetree/getContexts",async()=>(await Oe(),Promise.all(Ie.map(async t=>{let e=await Ks(t);return{ctxNames:t.ctxNames.map(n=>n.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:e.type}}))));J.onRequest("devicetree/setActive",async t=>(await Oe(),console.log("devicetree/setActive",t),await bn(t,!0)));J.onRequest("devicetree/getActiveContext",async()=>{if(await Oe(),console.log("devicetree/getActiveContext"),!le)return;let t=await Ks(le);return le?{ctxNames:le.ctxNames.map(e=>e.toString()),id:le.id,...await le.getFileTree(),settings:le.settings,active:!0,type:t.type}:void 0});J.onRequest("devicetree/setDefaultSettings",async t=>{await Oe(),Ys=t,console.log("Integration Settings",t),await IB()});J.onRequest("devicetree/requestContext",async t=>{await Oe();let e=await Zu(),n=await Qu(e),r=await bP(t,n,e);if(!r)throw console.log("Failed to resolve context",t),new Error("Failed to resolve context");console.log("devicetree/requestContext",r);let i=Wi(r),s=Array.from(bc).find(([,c])=>c.ctxName===t.ctxName);if(s){let c=s[0].split(":",1)[0];Rn(Ie,{name:r.ctxName.toString()})?.removeCtxName(r.ctxName),console.log(`Removing integration context with ID ${c} and name ${t.ctxName}`),bc.delete(s[0])}bc.set(`${i}:${t.ctxName}`,t),await ed();let o=Ie.find(c=>c.id===i);if(!o)throw new Error("Failed to create context");let a=await Ks(o,e);return{ctxNames:o.ctxNames.map(c=>c.toString()),id:i,...await o.getFileTree(),settings:o.settings,active:!0,type:a.type}});J.onRequest("devicetree/removeContext",async({id:t,name:e})=>{await Oe(),bc.delete(`${t}:${e}`);let n=Rn(Ie,{id:t});if(n){if(n.removeCtxName(e),n.ctxNames.length){console.log("Context will not be deleted as it is still in use by others");return}await ed()}});J.onRequest("devicetree/compiledDtsOutput",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t});if(!e||!e.settings.dtsFile){console.log("Context or DTS file not found for ID",t);return}let n=await e.toFullString();return wi({textDocument:{uri:ue(e.settings.dtsFile)},options:e.formattingOptions},n,"New Text").catch(()=>n)});J.onRequest("devicetree/serializedContext",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t}),n=performance.now();return e?.serialize().finally(()=>{console.info("serializedContext",performance.now()-n)})});J.onRequest("devicetree/activePath",async t=>{if(await Oe(),!le)return;let e=n=>{if(n?.item)return n.item instanceof X?{nodePath:n.item.pathString}:{nodePath:n.item.parent.pathString,propertyName:n.item.name}};return(await Rt(t,le,n=>[e(n)])).at(0)});J.onRequest("devicetree/customActions",async t=>(await Oe(),fB(t,le)));J.onRequest("devicetree/activeFsPath",async t=>{await Oe(),bn({fsPath:t})});J.onRequest("devicetree/formattingText",async t=>{let e=_e(t.textDocument.uri),n=td(e)??Ln().getDocument(e,t.text),r=await wi(t,n.getText(),"New Text");return{text:r,diagnostics:(await wi(t,n.getText(),"File Diagnostics")).map(i=>i.diagnostic()),nonActionableDiagnostics:(await wi(t,r,"File Diagnostics")).map(i=>i.diagnostic())}});J.onRequest("devicetree/formatTextEdits",async t=>{await Oe();let e=Ln().getDocument(_e(t.textDocument.uri),t.text),n=e.positionAt(e.getText().length),r=He.TextEdit.replace(He.Range.create(He.Position.create(0,0),n),""),i=NT(e,t.edits),s=await wi({...t},i,"New Text").catch(()=>i);return r.newText=s,r});J.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await Oe();let n=_e(t);bn({fsPath:n});let r=Hn(n);if(!r)return[];let i=e?(await r.getDiagnostics()).get(n):(await r.getSyntaxIssues(void 0,s=>co(s.raw,n,!!e)?s:void 0)).get(n);if(i?.length)return i});J.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await Oe();let n=Rn(Ie,{id:e});return n?t.map(r=>{let i=Hc(r,n.macros),s=Me(i);return{macro:r,evaluated:typeof s=="number"?s:i}}):[]});J.onRequest("devicetree/memoryViews",async({ctxId:t})=>{let e=Rn(Ie,{id:t});if(!e)return;await e?.stable();let n=await e.getRuntime(),r=n.rootNode.getMemoryViews(n.context.macros).sort((o,a)=>Dt(o.start,a.start)===0?Dt(a.size,o.size):Dt(o.start,a.start)),i=new Map;r.forEach(o=>{let a=i.get(o.name),c={nodePath:o.nodePath,labels:o.labels,start:o.start,size:o.size,disabled:o.disabled};a?a.partitions.push(c):i.set(o.name,{name:o.name,partitions:[c],path:o.nodePath})});let s=SB(Array.from(i.values()));return{trees:s,treeStr:_B(s)}});J.onRequest("devicetree/zephyrTypeBindings",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t});return e?.bindingLoader?.getZephyrContextBinding()?.map(n=>({...n,vendor:n.compatible&&e?.bindingLoader?.getBindingVendorString(n.compatible)}))});J.onRequest("devicetree/contextMacroNames",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t});return Array.from(e?.macros.keys()??[])});J.onRequest("devicetree/locationScopedInformation",async t=>{await Oe();let e=Rn(Ie,{id:t.id}),n=_e(t.textDocument.uri);if(!(!e||!e.isInContext(n)))return new Promise(async r=>{let i=await e.getRuntime(),s=await Rt(t,e,(o,a)=>{let c=i.context.macros,l={};if(!o?.item)return i.rootNode.serialize(l,c,a),[{inNode:!1,inScope:l,parentNode:i.rootNode.pathString}];let u=null;return o.item instanceof X?u=o.item:u=o.item?.parent,u.serialize(l,i.context.macros,a),[{inNode:!0,inScope:l,parentNode:u.pathString}]});r(s[0])})});
|
|
346
|
+
`)}var Ie=[],le,Gs,hg=new WeakMap,Ku=new Map;yB();var gg=new Map,kB=t=>{t.settings.disableFileWatchers||t.getContextFiles().forEach(e=>{Ku.has(e)||Ku.set(e,new fg(e,CP,()=>{let n=td(e),r=gg.get(e);return!n||r===void 0?!1:r!==n.version})),Ku.get(e)?.watch()})},RP=async t=>{let e=Ie.indexOf(t);if(e===-1)return;Ju(t,void 0,!0),hg.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let n=await Ks(t);if(J.sendNotification("devicetree/contextDeleted",{ctxNames:t.ctxNames.map(r=>r.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:n.type}),Ie.splice(e,1),await IP(),t===le&&(le=void 0,Ie.length)){let r=Gs?Rn(Ie,{fsPath:Gs}):void 0;r??=Ie[0],console.log("Active context was deleted. Forcing active to",r.id),await bn({id:r.id},!0)}t.settings.disableFileWatchers||t.getContextFiles().map(r=>{Ku.get(r)?.unwatch()}),setTimeout(async()=>{await Oe();let r=new Set(Ie.flatMap(i=>i.getContextFiles()));t.getContextFiles().map(i=>{r.has(i)||Ln().reset(i)})},2e3),t.bindingLoader?.dispose()},HQ=t=>{let e=hg.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},Oe=async()=>{await Promise.all(Ie.map(HQ))},wP=async(t,e)=>(await NB(e)).indexOf(t)!==-1,NB=async t=>{let e=await RB(t);return Ie.filter(n=>!e.some(r=>r===n))},RB=async t=>{let e=await NP(t);return Ie.filter(n=>e.contexts.find(r=>Wi(r)===n.id))},VQ=async t=>{let e=await XQ(t);return Ie.filter(n=>e.contexts.find(r=>Wi(r)===n.id))},WQ=async(t,e)=>(await VQ(e)).indexOf(t)!==-1,zQ=async(t,e)=>{if(t===e)return!0;let n=(await t.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath),r=(await e.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath);return r.some(i=>fe(i.resolvedPath,t.parser.fsPath))&&n.length?n.every(i=>r.some(s=>s.resolvedPath===i.resolvedPath&&s.firstToken.pos.col===i.firstToken.pos.col&&s.firstToken.pos.len===i.firstToken.pos.len&&s.firstToken.pos.line===i.firstToken.pos.line&&s.lastToken.pos.col===i.lastToken.pos.col&&s.lastToken.pos.len===i.lastToken.pos.len&&s.lastToken.pos.line===i.lastToken.pos.line)):e.getContextFiles().some(i=>fe(i,t.parser.fsPath))},GQ=async t=>{if(!await wP(t))return;let e=await NB(),n=await RB(),r=await Uf(e);if(Ie.indexOf(t)===-1)return;let i=await Promise.all(r.flatMap(a=>[...n,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await zQ(a.context,c)})))),s=t.getContextFiles(),o=r.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&fe(a.context.parser.fsPath,t.parser.fsPath)&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&await Promise.all(o.map(RP))},J=(0,He.createConnection)(He.ProposedFeatures.all),un=new He.TextDocuments(Lt),EP=!1,mg=!1,wB=!1,EB=!1,CB=!1,PP;J.onInitialize(async t=>{PP=t.workspaceFolders??[],J.console.log(`[Server(${process.pid}) ${PP?.at(0)?.uri} Version 0.10.2 ] Started and initialize received`);let e=t.capabilities;EP=!!(e.workspace&&e.workspace.configuration),mg=!!(e.workspace&&e.workspace.workspaceFolders),wB=!!e.workspace?.diagnostics?.refreshSupport,EB=!!e.workspace?.semanticTokens?.refreshSupport,CB=!!e.workspace?.foldingRange?.refreshSupport;let n={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:He.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[He.CodeActionKind.QuickFix,He.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:qf,tokenModifiers:$f},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,documentRangeFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return mg&&(n.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),await MB(t.initializationOptions),n});var kP,YQ={tabSize:8,insertSpaces:!1,trimTrailingWhitespace:!0,insertFinalNewline:!0,wordWrapColumn:100},DB=t=>({tabSize:t?.["editor.tabSize"],insertSpaces:t?.["editor.insertSpaces"],trimFinalNewlines:t?.["files.trimFinalNewlines"],trimTrailingWhitespace:t?.["files.trimTrailingWhitespace"],insertFinalNewline:t?.["editor.insertFinalNewline"],wordWrapColumn:t?.["editor.wordWrapColumn"],removeMacroMultiline:t?.["editor.removeMacroMultiline"],wrapLongLines:t?.["editor.wrapLongLines"],indentExpressions:t?.["editor.indentExpressions"],removeEmptyReferences:t?.["editor.removeEmptyReferences"],removeEmptyNodes:t?.["editor.removeEmptyNodes"],removeEmptyRoots:t?.["editor.removeEmptyRoots"],sortNodesAndProperties:t?.["editor.sortNodesAndProperties"]});J.onInitialized(async()=>{if(EP&&(J.client.register(He.DidChangeConfigurationNotification.type,{}),!kP)){let t=await J.workspace.getConfiguration("editor").catch(()=>{}),e=await J.workspace.getConfiguration("files").catch(()=>{}),n=await J.workspace.getConfiguration("[devicetree]").catch(()=>{}),r=DB(n);(t||e||r)&&(kP={...t,...e,...r})}mg&&J.workspace.onDidChangeWorkspaceFolders(async t=>{J.console.log("Workspace folder change event received"),await ed()})});J.onRequest("workspace/workspaceFolders",async()=>PP??null);var KQ=async t=>{let e=AB();return e={...zs,...e},Yu(e,t??await Zu())},NP=async t=>{let e=QQ();return e={...zs,...e},Yu(e,t??await Zu())},XQ=async t=>{let e=ZQ();return e={...zs,...e},Yu(e,t??await Zu())},Qu=async t=>{let e=JQ();return e={...zs,...e},Yu(e,t??await Zu())},Zu=async()=>mg?await J.workspace.getWorkspaceFolders()??[]:[],PB=async t=>{let e=Rn(Ie,{id:Wi(t)});if(e)return e.ctxNames.includes(t.ctxName)||console.log(`(ID: ${e.id}) Adding name ${t.ctxName} for [${e.ctxNames.join(",")}]`),e.addCtxName(t.ctxName),e;let n=Wi(t);console.log(`(ID: ${n}) New context [${t.ctxName}]`),console.log(`(ID: ${n}) Settings: ${JSON.stringify(t,void 0," ")}`);let r=(0,Sc.join)((0,Sc.dirname)(t.dtsFile),"dts","bindings"),i=new mp(t,kP??YQ,t.bindingType?tB({zephyrBindings:t.zephyrBindings?[r,...t.zephyrBindings]:[r],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ie.push(i);let s=performance.now();await i.stable(),console.log(`(ID: ${n}) New context took ${performance.now()-s}ms to start [${t.ctxName}]`),kB(i);let o=await Ks(i);return J.sendNotification("devicetree/contextCreated",{ctxNames:i.ctxNames.map(a=>a.toString()),id:i.id,...await i.getFileTree(),settings:i.settings,active:i===le,type:o.type}),await GQ(i),await IP(),i},ed=async()=>{let t=await NP(),e=await Qu();e.allowAdhocContexts||(e=await NP());let n=e.contexts.map(Wi),r=Ie.filter(i=>!n.includes(i.id));await Promise.all(r.map(RP)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await PB(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await KQ()).contexts?.reduce((s,o)=>s.then(async()=>{Rn(Ie,{fsPath:o.dtsFile})||await PB(o)}),Promise.resolve()),setTimeout(async()=>{Gs?await bn({fsPath:Gs}):!le&&Ie.length&&(console.log(`No active context using first context (ID: ${Ie[0].id}) [${Ie[0].ctxNames.join(",")}]`),await bn({id:Ie[0].id}))})},Ur,Ys,Xu=new Map,bc=new Map,JQ=()=>!Ys&&!Ur?void 0:{...Ys,...Ur,contexts:[...Ur?.contexts??[],...Array.from(bc.values()),...Array.from(Xu.values())]},AB=()=>!Ys&&!Ur?void 0:{...Ys,...Ur,contexts:[...Array.from(Xu.values())]},QQ=()=>!Ys&&!Ur?void 0:{...Ys,...Ur,contexts:[...Ur?.contexts??[],...Array.from(bc.values())]},ZQ=()=>!Ys&&!Ur?void 0:{...Ur,contexts:[...Ur?.contexts??[]]};function e8(t){let e={...t};for(let n in e)e[n]===null&&delete e[n];return e}var IB=async()=>{let t=await Qu();console.log("Resolved settings",JSON.stringify(t,void 0," ")),J.sendNotification("devicetree/settingsChanged",t),await ed(),Oe().then(()=>{wB&&J.languages.diagnostics.refresh()})},t8=async()=>{let t=le?.getContextFiles();await Promise.all(Array.from(un.keys()).filter(Jt).map(async e=>{t?.some(n=>fe(n,_e(e)))||await J.sendDiagnostics({uri:e,version:un.get(e)?.version,diagnostics:[{severity:He.DiagnosticSeverity.Information,range:He.Range.create(He.Position.create(0,0),He.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},CP=async t=>{let e=PT(Ie,t);if(e.length)e.sort((n,r)=>n===le?-1:r===le?1:0).forEach(n=>{hg.get(n)?.abort.abort(),le===n&&J.sendNotification("devicetree/activeContextBusyNotification",n.id),J.sendNotification("devicetree/contextBusyNotification",n.id);let r=new AbortController,i=new Promise(s=>{setTimeout(async()=>{if(n.setStaleFsPath(t),r.signal.aborted){console.log("Abort parsing due to new request"),s();return}let o=performance.now(),a=le===n,c=a?OB(n):[],l=n.getContextFiles();if(await n.reevaluate(t),kB(n),l.forEach(p=>Ku.get(p)?.unwatch()),a&&OP(n)?.length&&(DP(n).then(p=>{let m=p.items.map(h=>({uri:h.uri,version:h.version??void 0,diagnostics:h.items}));Ju(n,c.filter(h=>m.every(y=>y.uri!==h.uri))),m.forEach(h=>{J.sendDiagnostics(h)}),nd.set(n,!0)}),Gs)){let p=n.getFsPathParser(Gs);p&&setTimeout(()=>{p.latestSemanticTokensBuilt||J.languages.semanticTokens.refresh()},50)}let[u,d]=await Promise.all([Ks(n),n.getFileTree()]),f={ctxNames:n.ctxNames.map(p=>p.toString()),id:n.id,...d,settings:n.settings,active:a,type:u.type};le===n&&J.sendNotification("devicetree/activeContextStableNotification",f),J.sendNotification("devicetree/contextStableNotification",f),s(),console.log("reevaluate",performance.now()-o)})});hg.set(n,{abort:r,promise:i})});else{if((await Qu()).allowAdhocContexts===!1)return;await ed(),await bn({fsPath:t})}},n8=t=>un.keys().find(e=>fe(_e(e),t)),td=t=>{let e=n8(t);if(e)return un.get(e)},OB=t=>t.getContextFiles().map(e=>({uri:ue(e),version:td(e)?.version,diagnostics:[]})),nd=new WeakMap,Ju=async(t,e=OB(t),n=!1)=>{if(!n&&t!==le)return;let r=performance.now();await Promise.all(e.filter(i=>t===le||!le?.getContextFiles().some(s=>fe(_e(i.uri),s))).map(i=>J.sendDiagnostics({uri:i.uri,version:un.get(i.uri)?.version,diagnostics:[]}))),nd.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-r)},pg=new Map,r8=async t=>{let e=pg.get(t);if(e||!EP)return e;pg.delete(t);let n=await J.workspace.getConfiguration({scopeUri:ue(t),section:"[devicetree]"}).catch(()=>{});if(n){let r=DB(n);return pg.set(t,r),r}},DP=async t=>{await t.stable();let e=performance.now(),n=await t.getDiagnostics(),r=await Promise.all(t.getContextFiles().map(async i=>{let s=td(i),o=[];if(s&&t.settings.showFormattingErrorAsDiagnostics){let a=await r8(i);o.push(...(await wi({textDocument:s,options:{...t.formattingOptions,...a}},s.getText(),"File Diagnostics").catch(()=>[])).map(c=>c.diagnostic()))}return{uri:ue(i),kind:He.DocumentDiagnosticReportKind.Full,items:[...n.get(i)??[],...o],version:s?.version??null}}));return console.log(`(ID: ${t.id})`,"workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-e),{items:[...r]}},AP=async t=>{let{items:e}=await DP(t);e.map(n=>({uri:n.uri,version:n.version??void 0,diagnostics:n.items})).forEach(async n=>{J.sendDiagnostics(n)}),nd.set(t,!0)},IP=async()=>{let t=await Promise.all(Ie.map(e=>Ks(e)));console.log("======== Context List ========"),t.forEach(e=>{console.log(`(ID: ${e.ctx.id}) [${e.ctx.ctxNames.join(",")}]`,`[${e.type}]`,le===e.ctx?" [ACTIVE]":"")}),console.log("==============================")},Ks=async(t,e)=>{let n=await wP(t,e),r=!n&&await WQ(t,e);return{ctx:t,type:n?"Ad Hoc":r?"User":"3rd Party"}},bn=async(t,e=!1)=>{if("fsPath"in t){if(!Jt(t.fsPath))return!1;Gs=t.fsPath,console.log("Active File Uri",Gs)}let n=await Qu();if(le&&!e&&!n.autoChangeContext||(await Oe(),!e&&le?.getContextFiles().find(o=>"fsPath"in t&&fe(o,t.fsPath))))return!1;let r=le,i=Rn(Ie,t),s=r!==i;return s&&(r&&Ju(r),le=i,i?(Ks(i).then(async o=>{let a=await i.getFileTree();!i||i!==le&&!Ie.includes(i)||J.sendNotification("devicetree/newActiveContext",{ctxNames:i.ctxNames.map(c=>c.toString()),id:i.id,...a,settings:i.settings,active:le===i,type:o.type})}),OP(i)?.length&&AP(i),await IP()):J.sendNotification("devicetree/newActiveContext",void 0)),CB&&J.languages.foldingRange.refresh(),EB&&J.languages.semanticTokens.refresh(),s},Jt=t=>[".dts",".dtsi",".dtso",".overlay",".keymap"].some(e=>t.endsWith(e));un.listen(J);var OP=t=>t?.getContextFiles()?.filter(e=>td(e));un.onDidSave(t=>{gg.set(_e(t.document.uri),t.document.version)});un.onDidClose(async t=>{let e=_e(t.document.uri);if(!Jt(e))return;gg.delete(e);let n=PT(Ie,e);if(n.length===0){Xu.delete(e),J.sendDiagnostics({uri:t.document.uri,version:un.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(n.map(async r=>{!!OP(r)?.filter(s=>s!==e).length?le?.getContextFiles().some(s=>fe(s,e))?le?.getContextFiles().some(s=>fe(s,e))&&(await Ju(le),await AP(le)):J.sendDiagnostics({uri:t.document.uri,version:un.get(t.document.uri)?.version,diagnostics:[]}):await wP(r)?(await RP(r),Xu.delete(r.settings.dtsFile)):Ju(r)}))});un.onDidOpen(async t=>{let e=_e(t.document.uri);if(!Jt(e))return;gg.set(e,t.document.version),await Oe(),t8();let n=Rn(Ie,{fsPath:e});if(console.log("onDidOpen",n?.id,e),n)n!==le?await bn({id:n.id}):n===le&&(!nd.get(n)||n.getContextFiles().some(r=>!fe(r,e)))&&await AP(n);else{let r={ctxName:(0,Sc.basename)(e),dtsFile:e};Xu.set(e,r),await CP(e)}});un.onDidChangeContent(async t=>{let e=_e(t.document.uri);if(!Jt(e))return;let n=t.document.getText(),r=Ln();r.needsRenew(e,n)&&(console.log("Content changed",e),r.renewLexer(e,n),await CP(e))});var MB=async t=>{t?.settings?.devicetree&&(Ur=aB(e8(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await IB())};J.onDidChangeConfiguration(async t=>{await MB(t)});J.listen();J.languages.diagnostics.onWorkspace(async()=>{await Oe();let t=le;return t?DP(t).finally(()=>{nd.set(t,!0)}):{items:[]}});J.onDidChangeWatchedFiles(t=>{J.console.log("We received a file change event")});J.onCompletion(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return i0(t,le,un.get(t.textDocument.uri));if(!Jt(e))return[];await Oe(),bn({fsPath:e});let n=Hn(e);return n?[...await UD(t,n),...await L0(t,n)]:[]});J.onCompletionResolve(t=>t);var Hn=t=>{let e=AB();return Rn(Ie,{fsPath:t},le,e?.preferredContext)};J.onDocumentSymbol(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return[];await Oe();let n=Hn(e);return n?n.getFsPathParser(e)?.getDocumentSymbols(e):[]});J.onWorkspaceSymbol(async()=>{await Oe();let t=le;return t?(await t.getAllStableParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});J.languages.semanticTokens.on(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return{data:[]};try{await Oe();let n=Hn(e),r=new He.SemanticTokensBuilder,i=n?.isInContext(e);return!n||!i?{data:[]}:((await n.getAllStableParsers()).forEach(s=>s.buildSemanticTokens(r,e)),r.build())}catch(n){throw console.log(n),n}});J.onDocumentLinks(async t=>{await Oe();let e=_e(t.textDocument.uri);return Jt(e)?Hn(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&le?le.bindingLoader?.getDocumentLinks?.(un.get(t.textDocument.uri))??[]:[]});J.onPrepareRename(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return u0(t,n)});J.onRenameRequest(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return l0(t,n)});J.onReferences(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return s0(t,n)});J.onDefinition(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return p0(t,le,un.get(t.textDocument.uri));if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e),r=(await n?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>He.Location.create(i.target,i.range))??[];return r.length?r:f0(t,n)});J.onDeclaration(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return y0(t,le,un.get(t.textDocument.uri));if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return g0(t,n)});J.onCodeAction(async t=>{let e=_e(t.textDocument.uri);if(Jt(e))return v0(t)});var xB=async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);if(!n)return[];if((await n.getSyntaxIssues(void 0,l=>co(l.raw,e,!1)?l:void 0)).get(e)?.length)return[];let i=un.get(t.textDocument.uri)??Ln().getDocument(e),s=i.getText();pg.set(e,t.options);let o=await wi({...t,options:{...n.formattingOptions,...t.options}},s,"New Text").catch(()=>s);if(o===s)return[];let a=i.lineCount-1,c=i.getText({start:{line:a,character:0},end:{line:a+1,character:0}}).length;return[He.TextEdit.replace(He.Range.create(He.Position.create(0,0),He.Position.create(i.lineCount,c)),o)]};J.onDocumentRangeFormatting(xB);J.onDocumentFormatting(xB);J.onHover(async t=>{let e=_e(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return sM(t,le,un.get(t.textDocument.uri));if(!Jt(e))return;await Oe();let n=Hn(e);return(await q0(t,n)).at(0)});J.onFoldingRanges(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe();let n=Hn(e),r=n?.isInContext(e);if(!n||!r)return[];let i=(await n.getAllStableParsers()).find(s=>s.getFiles().some(o=>o===e));return i?nB(e,i):[]});J.onTypeDefinition(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return oB(t,n)});J.onSignatureHelp(async t=>{let e=_e(t.textDocument.uri);if(!Jt(e))return;await Oe(),bn({fsPath:e});let n=Hn(e);return hB(t,n)});J.onRequest("devicetree/getContexts",async()=>(await Oe(),Promise.all(Ie.map(async t=>{let e=await Ks(t);return{ctxNames:t.ctxNames.map(n=>n.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:e.type}}))));J.onRequest("devicetree/setActive",async t=>(await Oe(),console.log("devicetree/setActive",t),await bn(t,!0)));J.onRequest("devicetree/getActiveContext",async()=>{if(await Oe(),console.log("devicetree/getActiveContext"),!le)return;let t=await Ks(le);return le?{ctxNames:le.ctxNames.map(e=>e.toString()),id:le.id,...await le.getFileTree(),settings:le.settings,active:!0,type:t.type}:void 0});J.onRequest("devicetree/setDefaultSettings",async t=>{await Oe(),Ys=t,console.log("Integration Settings",t),await IB()});J.onRequest("devicetree/requestContext",async t=>{await Oe();let e=await Zu(),n=await Qu(e),r=await bP(t,n,e);if(!r)throw console.log("Failed to resolve context",t),new Error("Failed to resolve context");console.log("devicetree/requestContext",r);let i=Wi(r),s=Array.from(bc).find(([,c])=>c.ctxName===t.ctxName);if(s){let c=s[0].split(":",1)[0];Rn(Ie,{name:r.ctxName.toString()})?.removeCtxName(r.ctxName),console.log(`Removing integration context with ID ${c} and name ${t.ctxName}`),bc.delete(s[0])}bc.set(`${i}:${t.ctxName}`,t),await ed();let o=Ie.find(c=>c.id===i);if(!o)throw new Error("Failed to create context");let a=await Ks(o,e);return{ctxNames:o.ctxNames.map(c=>c.toString()),id:i,...await o.getFileTree(),settings:o.settings,active:!0,type:a.type}});J.onRequest("devicetree/removeContext",async({id:t,name:e})=>{await Oe(),bc.delete(`${t}:${e}`);let n=Rn(Ie,{id:t});if(n){if(n.removeCtxName(e),n.ctxNames.length){console.log("Context will not be deleted as it is still in use by others");return}await ed()}});J.onRequest("devicetree/compiledDtsOutput",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t});if(!e||!e.settings.dtsFile){console.log("Context or DTS file not found for ID",t);return}let n=await e.toFullString();return wi({textDocument:{uri:ue(e.settings.dtsFile)},options:e.formattingOptions},n,"New Text").catch(()=>n)});J.onRequest("devicetree/serializedContext",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t}),n=performance.now();return e?.serialize().finally(()=>{console.info("serializedContext",performance.now()-n)})});J.onRequest("devicetree/activePath",async t=>{if(await Oe(),!le)return;let e=n=>{if(n?.item)return n.item instanceof X?{nodePath:n.item.pathString}:{nodePath:n.item.parent.pathString,propertyName:n.item.name}};return(await Rt(t,le,n=>[e(n)])).at(0)});J.onRequest("devicetree/customActions",async t=>(await Oe(),fB(t,le)));J.onRequest("devicetree/activeFsPath",async t=>{await Oe(),bn({fsPath:t})});J.onRequest("devicetree/formattingText",async t=>{let e=_e(t.textDocument.uri),n=td(e)??Ln().getDocument(e,t.text),r=await wi(t,n.getText(),"New Text");return{text:r,diagnostics:(await wi(t,n.getText(),"File Diagnostics")).map(i=>i.diagnostic()),nonActionableDiagnostics:(await wi(t,r,"File Diagnostics")).map(i=>i.diagnostic())}});J.onRequest("devicetree/formatTextEdits",async t=>{await Oe();let e=Ln().getDocument(_e(t.textDocument.uri),t.text),n=e.positionAt(e.getText().length),r=He.TextEdit.replace(He.Range.create(He.Position.create(0,0),n),""),i=NT(e,t.edits),s=await wi({...t},i,"New Text").catch(()=>i);return r.newText=s,r});J.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await Oe();let n=_e(t);bn({fsPath:n});let r=Hn(n);if(!r)return[];let i=e?(await r.getDiagnostics()).get(n):(await r.getSyntaxIssues(void 0,s=>co(s.raw,n,!!e)?s:void 0)).get(n);if(i?.length)return i});J.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await Oe();let n=Rn(Ie,{id:e});return n?t.map(r=>{let i=Hc(r,n.macros),s=Me(i);return{macro:r,evaluated:typeof s=="number"?s:i}}):[]});J.onRequest("devicetree/memoryViews",async({ctxId:t})=>{let e=Rn(Ie,{id:t});if(!e)return;await e?.stable();let n=await e.getRuntime(),r=n.rootNode.getMemoryViews(n.context.macros).sort((o,a)=>Dt(o.start,a.start)===0?Dt(a.size,o.size):Dt(o.start,a.start)),i=new Map;r.forEach(o=>{let a=i.get(o.name),c={nodePath:o.nodePath,labels:o.labels,start:o.start,size:o.size,disabled:o.disabled};a?a.partitions.push(c):i.set(o.name,{name:o.name,partitions:[c],path:o.nodePath})});let s=SB(Array.from(i.values()));return{trees:s,treeStr:_B(s)}});J.onRequest("devicetree/zephyrTypeBindings",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t});return e?.bindingLoader?.getZephyrContextBinding()?.map(n=>({...n,vendor:n.compatible&&e?.bindingLoader?.getBindingVendorString(n.compatible)}))});J.onRequest("devicetree/contextMacroNames",async t=>{if(await Oe(),!t)return;let e=Rn(Ie,{id:t});return Array.from(e?.macros.keys()??[])});J.onRequest("devicetree/locationScopedInformation",async t=>{await Oe();let e=Rn(Ie,{id:t.id}),n=_e(t.textDocument.uri);if(!(!e||!e.isInContext(n)))return new Promise(async r=>{let i=await e.getRuntime(),s=await Rt(t,e,(o,a)=>{let c=i.context.macros,l={};if(!o?.item)return i.rootNode.serialize(l,c,a),[{inNode:!1,inScope:l,parentNode:i.rootNode.pathString}];let u=null;return o.item instanceof X?u=o.item:u=o.item?.parent,u.serialize(l,i.context.macros,a),[{inNode:!0,inScope:l,parentNode:u.pathString}]});r(s[0])})});
|