scip-query 0.19.0 → 0.19.3
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/CHANGELOG.md +25 -0
- package/README.md +17 -1
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-YHYTDWFT.js → chunk-24ET4VLC.js} +2 -2
- package/dist/{chunk-GBB2RUDN.js → chunk-26JI77AY.js} +130 -130
- package/dist/{chunk-MFBXBLHA.js → chunk-2E7QY4B5.js} +2 -2
- package/dist/{chunk-PXJIEMND.js → chunk-2ROSOG2I.js} +2 -2
- package/dist/{chunk-XKWEMFHP.js → chunk-2WCXKANA.js} +2 -2
- package/dist/{chunk-EZGT3NJX.js → chunk-33RLKB6L.js} +2 -2
- package/dist/{chunk-GJ3FR5WG.js → chunk-34MLC6UI.js} +2 -2
- package/dist/{chunk-G6RQVDTI.js → chunk-4BUMNEYQ.js} +2 -2
- package/dist/{chunk-XTSVYYAL.js → chunk-4CZJ4YJB.js} +2 -2
- package/dist/{chunk-TCVRJ56J.js → chunk-4FMT4HPC.js} +2 -2
- package/dist/{chunk-7FG5M53V.js → chunk-53SUJOJA.js} +2 -2
- package/dist/{chunk-AEDB4WXE.js → chunk-5FUAFNMP.js} +2 -2
- package/dist/chunk-5GCAM4JE.js +122 -0
- package/dist/{chunk-YBAC3RON.js → chunk-5GOBZI34.js} +2 -2
- package/dist/{chunk-LJD7V7UO.js → chunk-5OR4QRPR.js} +2 -2
- package/dist/{chunk-X36LKKVG.js → chunk-5OZCNAVM.js} +2 -2
- package/dist/{chunk-7EI4MU5A.js → chunk-5TZ2MQBG.js} +2 -2
- package/dist/{chunk-GNJHHPZE.js → chunk-64QITTX7.js} +2 -2
- package/dist/{chunk-HOXI4F5I.js → chunk-6EWBPAA3.js} +2 -2
- package/dist/{chunk-EZHARAL4.js → chunk-6FIA5BEB.js} +2 -2
- package/dist/{chunk-4ZCNFENR.js → chunk-77IOFJVY.js} +2 -2
- package/dist/{chunk-T5CSWYAZ.js → chunk-AD7WUFFT.js} +2 -2
- package/dist/{chunk-OGHGTD6Z.js → chunk-AEM24WSF.js} +2 -2
- package/dist/{chunk-S65OEY2G.js → chunk-AFVU2GB2.js} +2 -2
- package/dist/{chunk-SATRCB5O.js → chunk-AOSFSYEA.js} +2 -2
- package/dist/{chunk-3OSRXJKK.js → chunk-APLNTJPJ.js} +2 -2
- package/dist/{chunk-TDGCALH6.js → chunk-AYRHVJXW.js} +2 -2
- package/dist/{chunk-MDDF67O2.js → chunk-B26UX7ZD.js} +2 -2
- package/dist/{chunk-JFGUBZWE.js → chunk-C3KCSAQ4.js} +2 -2
- package/dist/{chunk-XESK6725.js → chunk-C3VQZFP2.js} +2 -2
- package/dist/{chunk-FLIF3JWA.js → chunk-CAKPEQZB.js} +2 -2
- package/dist/{chunk-PKAPOFF5.js → chunk-CIYUFF24.js} +2 -2
- package/dist/{chunk-J3U47L4Q.js → chunk-DO775SYA.js} +2 -2
- package/dist/{chunk-AM2LGOEX.js → chunk-EGKWRX5I.js} +2 -2
- package/dist/{chunk-PAZFJMXB.js → chunk-EHU4TZJJ.js} +2 -2
- package/dist/{chunk-YYR7ADNB.js → chunk-EII5ZHL2.js} +2 -2
- package/dist/{chunk-F5L7WEZF.js → chunk-EYF5HOUZ.js} +2 -2
- package/dist/{chunk-RIGY5DDE.js → chunk-FB6IKAKZ.js} +2 -2
- package/dist/{chunk-BGUYAA3Q.js → chunk-FBUNGRKI.js} +2 -2
- package/dist/{chunk-M2TRDR25.js → chunk-FC5K7T35.js} +1 -1
- package/dist/{chunk-KWBA6FDD.js → chunk-FRXB74RQ.js} +2 -2
- package/dist/{chunk-BYPVNKJT.js → chunk-FTRNGQGR.js} +2 -2
- package/dist/{chunk-54UYBTZW.js → chunk-FUFNRZFJ.js} +2 -2
- package/dist/{chunk-TDZXQAH7.js → chunk-FYE4PWWP.js} +2 -2
- package/dist/{chunk-QNMOZ3CJ.js → chunk-GAE7WCBK.js} +2 -2
- package/dist/{chunk-2ZNZSNVW.js → chunk-HAC5EI2T.js} +2 -2
- package/dist/{chunk-WT7TOU2C.js → chunk-HCSTQGQE.js} +2 -2
- package/dist/{chunk-UXOVHGT6.js → chunk-HFBNIIZX.js} +2 -2
- package/dist/{chunk-JHK2DMUQ.js → chunk-HGFDYOVB.js} +1 -1
- package/dist/{chunk-UJL3N6TC.js → chunk-HHOJH3RJ.js} +2 -2
- package/dist/{chunk-X65VYV2S.js → chunk-HNTLCR4F.js} +2 -2
- package/dist/{chunk-RJLU7IMR.js → chunk-IICQP2DY.js} +2 -2
- package/dist/{chunk-J65FQLDL.js → chunk-IXAALOUP.js} +2 -2
- package/dist/{chunk-XDVT7QPG.js → chunk-J4MYRIYT.js} +2 -2
- package/dist/{chunk-TAB7AWKO.js → chunk-J5XJWCB3.js} +2 -2
- package/dist/{chunk-DWN7QDTV.js → chunk-JFO2UVQP.js} +2 -2
- package/dist/{chunk-FMC3BI4I.js → chunk-JRCJEHRG.js} +2 -2
- package/dist/{chunk-4XTPZ5CR.js → chunk-KMOMNTB4.js} +2 -2
- package/dist/{chunk-ZL5Y23AJ.js → chunk-LM72NQ7T.js} +1 -1
- package/dist/{chunk-4ZHJAHLE.js → chunk-LSJDKJIB.js} +2 -2
- package/dist/{chunk-VV5WJLRO.js → chunk-MP43RX4O.js} +1 -1
- package/dist/{chunk-D5OXYOJP.js → chunk-MQ2B33LQ.js} +1 -1
- package/dist/{chunk-MTFHE7ZO.js → chunk-MRYPDVOS.js} +2 -2
- package/dist/{chunk-GMZYT44R.js → chunk-NLNZK7RL.js} +5 -5
- package/dist/{chunk-ZXWFN7CK.js → chunk-OAM22BCR.js} +2 -2
- package/dist/{chunk-TOYQTO44.js → chunk-OLG2YPLS.js} +2 -2
- package/dist/{chunk-PBADFBRR.js → chunk-OQ6TCHBB.js} +2 -2
- package/dist/{chunk-3KQOIXLO.js → chunk-PCIFZHWS.js} +2 -2
- package/dist/{chunk-KD6TPIXM.js → chunk-PJENL245.js} +2 -2
- package/dist/{chunk-F334Z5UA.js → chunk-PLDIXTKR.js} +2 -2
- package/dist/{chunk-BOXAKNN6.js → chunk-PNESKY2Z.js} +2 -2
- package/dist/{chunk-QHOUNTDZ.js → chunk-PTYQQHZM.js} +2 -2
- package/dist/{chunk-2FAJTZSX.js → chunk-QKW7ISEW.js} +2 -2
- package/dist/{chunk-AWSRND4W.js → chunk-QNO3QIMN.js} +2 -2
- package/dist/{chunk-DV6B262O.js → chunk-SJ6XSCG7.js} +2 -2
- package/dist/{chunk-XPYXEEDO.js → chunk-SOS256TP.js} +2 -2
- package/dist/{chunk-DQIJMKNE.js → chunk-TDUU63FC.js} +2 -2
- package/dist/chunk-TOIS2VAI.js +4 -0
- package/dist/{chunk-TC3X33N6.js → chunk-TYEGFDOP.js} +2 -2
- package/dist/chunk-UJKZQLDB.js +2 -0
- package/dist/chunk-V27BEQJN.js +7 -0
- package/dist/{chunk-J6BR4MD6.js → chunk-VIKEPD4D.js} +2 -2
- package/dist/{chunk-XDSB47KO.js → chunk-WAU7HVDI.js} +2 -2
- package/dist/chunk-WFWQWQK6.js +3 -0
- package/dist/chunk-WWCZCH7W.js +3 -0
- package/dist/{chunk-QB5WSOTY.js → chunk-XAMVIPE2.js} +2 -2
- package/dist/{chunk-A45K6VUK.js → chunk-XWE7PZQH.js} +2 -2
- package/dist/{chunk-547VY366.js → chunk-XWJ3JYRG.js} +2 -2
- package/dist/{chunk-QN67MWDU.js → chunk-XYBNOILR.js} +2 -2
- package/dist/{chunk-IWK562KR.js → chunk-XYNWAZ6J.js} +2 -2
- package/dist/{chunk-UVMME4FI.js → chunk-YGBHQOB2.js} +2 -2
- package/dist/{chunk-ZNSLF5AC.js → chunk-YGQBJUS6.js} +2 -2
- package/dist/{chunk-6DHPQS72.js → chunk-YILKXTIY.js} +2 -2
- package/dist/{chunk-X3OOU7CF.js → chunk-Z7M7X3ZG.js} +2 -2
- package/dist/{chunk-G6QQCX45.js → chunk-ZJGZCBYT.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{command-descriptors-SWFWGIFK.js → command-descriptors-QJEYYND2.js} +168 -166
- package/dist/direct-navigation-TT23TDBS.js +3 -0
- package/dist/index.js +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +24 -24
- package/dist/reindex.js +38 -38
- package/dist/runtime.d.ts +6 -1
- package/dist/runtime.js +2 -2
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/watch-server.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-42QYU6FD.js +0 -3
- package/dist/chunk-6SHX42QQ.js +0 -6
- package/dist/chunk-AERYQJ52.js +0 -3
- package/dist/chunk-IXORBCMR.js +0 -120
- package/dist/chunk-NEG77KKH.js +0 -4
- package/dist/chunk-OYYZLJVT.js +0 -2
- package/dist/direct-navigation-RKMPBXMI.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as G}from"./chunk-P5XHIJHI.js";import{a as Qe,c as nn,g as rn}from"./chunk-
|
|
2
|
-
`:i),ti(r,t)}function nt(t,e){let n=t.split("/").at(-1)??t;if(Rn.has(n)||n===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(n))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(t.toLowerCase()))return"ambient";let r=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return e.some(i=>(hn[i]??[]).includes(r))?"source":"other"}function gn(t,e,n){let r=t.split("/").at(-1)??t;if(n?.includes(t)||n?.includes(r)||Rn.has(r))return!0;let i=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return(hn[e]??[]).includes(i)}function Sn(t){if(typeof t!="object"||t===null)return null;let e=t;return typeof e.version!="number"||!dn(e.languages)||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||!dn(e.typescriptProjects)||e.clojureConfigPath!==void 0&&typeof e.clojureConfigPath!="string"||!Array.isArray(e.files)||!e.files.every(ii)?null:e}function
|
|
3
|
-
`).filter(Boolean)}catch{return null}}function hi(t){let e=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?vn(t,r):t,s;try{s=li(i,{withFileTypes:!0})}catch{continue}for(let o of s){let a=r?`${r}/${o.name}`:o.name;if(o.isDirectory()){Mn(a)||n.push(a);continue}e.push(a)}}return e}function Mn(t){let e=t.split("/");return t==="meta.json"||e.some(n=>bi.has(n))||t.endsWith(".db")||t.endsWith(".db-wal")||t.endsWith(".db-shm")||t.endsWith(".scip")}var bi=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);function xn(t){let e=new Map,n=vi(t),r=new Map;return i=>{let s=Ii(i),o=r.get(s);if(o!==void 0)return o;if(!n.has(i.file))return r.set(s,i.symbol),i.symbol;let a=e.get(i.file);a||(a=Mi(W(t,i.file)),e.set(i.file,a));let c=xi(a,i);return r.set(s,c),c}}function Ii(t){return`${t.file}\0${t.symbol}\0${t.line}`}function vi(t){return new Set(t.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function Mi(t){let e=new Map,n=new Map;for(let r of t){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let s=n.get(r.startLine);s?s.push(r):n.set(r.startLine,[r])}return{definitions:t,byLeaf:e,byStartLine:n}}function xi(t,e){if(t.definitions.length===0)return e.symbol;let n=Ti(e.symbol),r=Ci(t.byLeaf,n),i=Di(r,e.line);if(i)return i.symbol;let s=t.byStartLine.get(e.line)??[];return s.length===1?s[0].symbol:e.symbol}function Ci(t,e){let n=[],r=new Set;for(let i of e)for(let s of t.get(i)??[])r.has(s.symbolId)||(r.add(s.symbolId),n.push(s));return n}function Di(t,e){let n=null;for(let r of t)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r)}return n}function Ti(t){let e=new Set([t]),r=t.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function Cn(t,e){let r=Zt(t,e).map(i=>ki(e,i));return{usage:r,positions:Fi(t,e,r)}}function Dn(t,e){return{importUsage(n){let r=t.importUsageFacts(n);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(n,r.positions);return i.available?Pi(r.usage,i.sourcePaths):r.usage}}}function Pi(t,e){return t.map((n,r)=>{let i=e.get(String(r));return i?{...n,sourcePath:i}:n})}function ki(t,e){let n=e.isTypeOnly===!0,r=e.kind==="side-effect"||n||e.used;return{importer:t,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:n,isUsed:r,isTypeUsed:n,isValueUsed:e.kind==="side-effect"||!n&&e.used,references:[]}}function Fi(t,e,n){let r=Qt(t,e);if(!r)return[];let i=wi(r.rootNode),s=new Map;for(let a of i){let c=s.get(st(a.importedName,a.localName));c?c.push(a.position):s.set(st(a.importedName,a.localName),[a.position])}let o=[];return n.forEach((a,c)=>{let l=s.get(st(a.importedName,a.localName??a.importedName))?.shift();l&&o.push({...l,id:String(c),file:e})}),o}function wi(t){let e=[];for(let n of t.descendantsOfType("use_declaration")){let r=n.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Ie(r,""))}return e.filter(n=>n.importedName!=="*")}function Ie(t,e){switch(t.type){case"identifier":case"super":case"self":case"crate":return[{importedName:t.text,localName:t.text,position:it(t,t.text)}];case"scoped_identifier":{let n=t.text.split("::").pop()??t.text;return[{importedName:n,localName:n,position:it(t,n)}]}case"scoped_use_list":{let n=t.namedChild(0),r=t.namedChild(1);if(!n||!r)return[];let i=Xt(e,n.text);return r.namedChildren.flatMap(s=>Ie(s,i))}case"use_list":return t.namedChildren.flatMap(n=>Ie(n,e));case"use_as_clause":{let n=t.namedChild(0),r=t.namedChild(1);return!n||!r?[]:Ie(n,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let n=t.namedChild(0),r="*";return[{importedName:r,localName:r,position:it(n??t,r)}]}default:return[]}}function it(t,e){let n=Math.max(0,t.text.lastIndexOf(e));return{id:"",file:"",line:t.startPosition.row,column:t.startPosition.column+n+Ei(e)}}function Ei(t){return Math.max(0,Math.min(t.length-1,1))}function st(t,e){return`${t}\0${e}`}import{spawnSync as mt}from"child_process";import{existsSync as yt}from"fs";import{fileURLToPath as vs}from"url";function ve(t){let e=un(cn,t),n=e.runnable;return{available:n,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,reason:n?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as ss,mkdtempSync as Kn,readFileSync as Vn,rmSync as lt}from"fs";import{tmpdir as Jn}from"os";import{join as ut}from"path";import{fileURLToPath as we,pathToFileURL as os}from"url";import{SHARE_ENV as as,Worker as cs}from"worker_threads";function q(t,e,n=new Set){let r=new Map;for(let i of t)n.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function $(t,e,n){let r=G(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(t/Math.max(1,n)));return Math.max(12e4,3e4+i*e)}import{spawn as Ki}from"child_process";import{createHash as Vi,randomUUID as Ji}from"crypto";import{existsSync as On,mkdirSync as Nn,readFileSync as Pe,realpathSync as Yi,rmSync as ct}from"fs";import{tmpdir as Gi}from"os";import{resolve as A}from"path";import{execFileSync as Wi}from"child_process";import{existsSync as Ni,readFileSync as Ai}from"fs";import{deserializeSCIP as _i,SymbolRole as ji}from"@c4312/scip";import{existsSync as Ea,readFileSync as Na}from"fs";import{relative as _a,resolve as ja,sep as La}from"path";import{fileURLToPath as Ua,pathToFileURL as Ba}from"url";function Tn(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort((n,r)=>{let i=n.file.localeCompare(r.file);return i!==0?i:n.line!==r.line?n.line-r.line:n.column-r.column})}var ot=new WeakMap,Li="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function Ka(t,e){let n=new Map,r=Me(),i=e.filter(o=>kn(o,r));if(i.length===0)return n;let s=Fn(t);if(!s)return n;for(let o of i){let a=Pn(s,o);a!==null&&n.set(o.symbolId,a)}return n}function Va(t,e){if(!kn(e,Me()))return null;let n=Fn(t);return n?Pn(n,e):null}function Pn(t,e){return t.referencesBySymbol.get(e.symbol)??[]}function kn(t,e="safe"){if(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||re(t.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(t.symbol))return!1;if(e==="all")return!0;let n=ge(t.symbol);if(n==="method")return!0;if(n!=="term")return!1;let r=en(t.symbol);return"kind"in r?!1:!Oi(r)}function Oi(t){for(let e=0;e<t.descriptors.length-1;e+=1)if(t.descriptors[e]?.suffix==="type")return!0;return!1}function Fn(t){if(ot.has(t))return ot.get(t)??null;let e=Ui(t);return ot.set(t,e),e}function Ui(t){if(!Ni(t.config.indexPath))return null;try{let e=_i(Ai(t.config.indexPath)),n=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||t.isIgnored(i)))for(let s of r.occurrences??[]){if(!s.symbol||(s.symbolRoles&ji.Definition)!==0)continue;let o=Bi(i,s.range);if(!o)continue;let a=n.get(s.symbol)??[];a.push(o),n.set(s.symbol,a)}}for(let[r,i]of n)n.set(r,Tn(i));return{referencesBySymbol:n}}catch{return null}}function Bi(t,e){if(e.length<3)return null;let n=e[0],r=e[1];return!Number.isInteger(n)||!Number.isInteger(r)?null:{file:t,line:n,column:r}}function Me(){return process.env[Li]==="all"?"all":"safe"}var wn=new Map;function at(t){let n=ve(t).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:n,version:n?qi(t,n):"unavailable"}}function Xa(t){return{...at(t),scipOccurrenceReferenceMode:Me()}}function qi(t,e){let n=`${t}\0${e}`,r=wn.get(n);if(r)return r;let i;try{i=Wi(e,["--version"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return wn.set(n,i),i}import{createHash as zi}from"crypto";var $i=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function En(t){let e=rt(t,{includePath:Hi});return zi("sha256").update(JSON.stringify(e)).digest("hex")}function Hi(t){let e=t.replaceAll("\\","/"),n=e.split("/").at(-1)??e;return e.endsWith(".rs")||$i.has(n)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}var Un=2,Qi=5e3,Xi=5e3,Bn=10,Zi=3e4;function An(t,e,n,r=Hn){let i=r.engineIdentity(t),s={protocolVersion:Un,projectRoot:r.canonicalProjectRoot(t),projectFingerprint:r.projectFingerprint(t),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:qn(r.environment())};return{key:Te(De(s)),...s}}function xe(t,e,n){return t.protocolVersion===Un&&(e-t.heartbeatAtMs<=Qi||t.busyUntilMs!==void 0&&e<=t.busyUntilMs)&&n(t.pid)}function Wn(t,e,n){let r;try{r=Te(Pe(e))}catch{r="missing"}let i=Te(De({projectRoot:A(t),serverPath:A(e),serverFingerprint:r})).slice(0,20);return A(n,`scip-query-rust-session-${i}`)}function _n(t){let e=t===void 0?Number.NaN:Number(t);return Number.isInteger(e)&&e>=0?e:0}function qn(t){return Object.fromEntries(Object.entries(t).filter(([e])=>$n(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function zn(t,e){let n=e.runtime??is,r=e.identityRuntime??Hn,i=Wn(t,e.serverPath,e.tempRoot??Gi()),s=!1,o=(a,c)=>{if(s)throw new Error("Durable Rust semantic session was already disposed.");return ts(i,e.serverPath,e.semanticWorkerPath,a,c,n)};return{requestSemantic(a,c){let l=An(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"semantic",identityKey:l.key,workerEnvironment:Ln(),request:{...a,readinessDeadlineMs:p,referenceRetryTimeoutMs:es(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:_n(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let l=An(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"import-definitions",identityKey:l.key,workerEnvironment:Ln(),request:{...a,readinessDeadlineMs:p,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:_n(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){s=!0}}}function es(t,e){return e!==void 0?e:t===void 0?Zi:void 0}function ts(t,e,n,r,i,s){let o=s.randomId(),a=s.now(),c=A(t,"requests"),l=A(t,"responses"),p=A(c,`${o}.json`),u=A(l,`${o}.json`);Nn(c,{recursive:!0}),Nn(l,{recursive:!0}),be(p,{id:o,request:r});let f=s.now()+i;try{for(jn(t,e,n,f,s);s.now()<=f;){if(On(u)){let m=ns(Pe(u,"utf8"));if(!m.ok)throw new Error(m.error);return B()&&de({type:"span",name:"rust.semantic.durable-session.request",durationMs:s.now()-a,ok:!0,session:m.session,kind:r.kind}),m.response}let d=Ce(t);(!d||!xe(d,s.now(),s.isProcessAlive))&&jn(t,e,n,f,s),s.sleep(Bn)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}finally{ct(p,{force:!0}),ct(u,{force:!0})}}function jn(t,e,n,r,i){let s=Ce(t);if(s&&xe(s,i.now(),i.isProcessAlive))return;ct(A(t,"server.json"),{force:!0}),i.spawnServer(e,t,n);let o=Math.min(r,i.now()+Xi);for(;i.now()<=o;){let a=Ce(t);if(a&&xe(a,i.now(),i.isProcessAlive))return;i.sleep(Bn)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function Ce(t){try{let e=JSON.parse(Pe(A(t,"server.json"),"utf8"));return typeof e.protocolVersion!="number"||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"?null:{protocolVersion:e.protocolVersion,pid:e.pid,heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs}}}catch{return null}}function ns(t){try{let e=JSON.parse(t);return e.ok===!0&&(e.session==="created"||e.session==="reused"||e.session==="invalidated")&&e.response&&typeof e.response=="object"?{ok:!0,session:e.session,response:e.response}:{ok:!1,error:typeof e.error=="string"?e.error:"helper wrote an invalid response"}}catch(e){return{ok:!1,error:`helper wrote malformed JSON: ${e instanceof Error?e.message:String(e)}`}}}function Ln(){return Object.fromEntries(Object.entries(process.env).filter(([t])=>rs(t)).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>[t,e??null]))}function $n(t){return t==="HOME"||t==="PATH"||t.startsWith("CARGO_")||t.startsWith("RA_")||t.startsWith("RUST")}function rs(t){return $n(t)||t.startsWith("SCIP_RUST_")||t==="SCIP_QUERY_PROFILE"||t==="SCIP_QUERY_PROFILE_CACHE_STATE"||t==="SCIP_QUERY_PROFILE_COMMAND"||t==="SCIP_QUERY_PROFILE_OUT"||t==="SCIP_QUERY_PROFILE_RUN_ID"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||t==="SCIP_QUERY_PROFILE_MIN_MS"}var Hn={canonicalProjectRoot(t){try{return Yi(t)}catch{return A(t)}},projectFingerprint(t){return En(t)},engineIdentity:at,fileFingerprint(t){return Te(Pe(t))},environment(){return qn(process.env)}},is={now:Date.now,randomId:Ji,isProcessAlive:he,spawnServer(t,e,n){if(!On(t))throw new Error(`Durable Rust semantic session helper was not found at ${t}. Run npm run build first.`);Ki(process.execPath,[t,e,n],{detached:!0,stdio:"ignore"}).unref()},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function De(t){return Array.isArray(t)?`[${t.map(De).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${De(n)}`).join(",")}}`:JSON.stringify(t)}function Te(t){return Vi("sha256").update(t).digest("hex")}var Yn=15e3,Gn=8,Xn=5e3,ls=64,us=96,ft=class{constructor(e,n,r={}){this.projectRoot=e;this.status=n;this.opts=r;this.requester=r.requester??ms(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,references:ie(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,references:q(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ie(e)}}}calleesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,callees:se(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,callees:pt(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:se(e)}}}referencesAndCalleesForDefinitions(e,n){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:ie(e),callees:se(n)};let i=[...e,...n];try{let s=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:n.length>0,referenceDefinitions:e,calleeDefinitions:n});return{available:s.available,resolvedBinary:r.resolvedBinary,reason:s.reason,references:q(e,new Map(s.references),new Set(s.incompleteReferenceSymbolIds??[])),callees:pt(n,new Map(s.callees??[]))}}catch(s){return this.fallbackReferencesAndCallees(r,e,n,s)}}signaturesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,signatures:Qn(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,signatures:hs(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:Qn(e)}}}importDefinitionsForFile(e,n){let r=this.status(this.projectRoot);if(n.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(n.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,n);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(n.map(s=>[s.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,n,r){let i=ke(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yn),s=Fe(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),o=ke(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Gn),a=Fe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,l=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,p=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,u=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,...r}),f={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...n],...c?{referenceDefinitions:c}:{},...l?{calleeDefinitions:l}:{},...p?{signatureDefinitions:p}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:a,settleDelayMs:u,concurrency:o,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=bs(f);return C("rust.semantic.session.request",()=>this.requester.requestSemantic(f,$(d,dt(i,f.referenceRetryTimeoutMs),o)),()=>({definitions:n.length,operationDefinitions:d,referenceDefinitions:f.referenceDefinitions?.length,calleeDefinitions:f.calleeDefinitions?.length,signatureDefinitions:f.signatureDefinitions?.length,references:f.includeReferences!==!1,callees:f.includeCallees===!0,signatures:f.includeSignatures===!0,referenceRetryTimeoutMs:f.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,n,r,i){let s=n.length===0?{available:!0,references:ie(n)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(n),o=r.length===0?{available:!0,callees:se(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return s&&o?{available:s.available&&o.available,resolvedBinary:s.resolvedBinary??o.resolvedBinary??e.resolvedBinary,reason:s.reason??o.reason,references:q(n,s.references),callees:pt(r,o.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ie(n),callees:se(r)}}requestImportDefinitions(e,n,r){let i=ke(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yn),s=ke(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Gn),o=Fe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Fe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Xn),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:n,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:o,settleDelayMs:a,concurrency:s};return C("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,$(r.length,i,s)),()=>({file:n,positions:r.length}))}};function Zn(t,e,n={}){return new ft(t,e,n)}function oe(t,e){let n=tr(t);if(n!==null)return n;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=ls||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=us?0:Xn}function ps(t){let e=t?.trim().toLowerCase(),n=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:n||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||n||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function fs(t){return ps(t).transport}function ds(t,e){let n=null,r=!1,i=!1,s=!1,o=()=>n??=e(),a=()=>{i||(t.shutdown(),i=!0)},c=(p,u,f)=>{let d=Rs(p);r=!0;try{a()}catch{}B()&&de({type:"span",name:"rust.semantic.durable-session.request",durationMs:f,ok:!1,kind:u,session:"worker-fallback",reason:d})},l=(p,u,f)=>{if(s)throw new Error("Rust semantic failover session was already disposed.");if(r)return f(o());let d=Date.now();try{return u(t)}catch(m){c(m,p,Date.now()-d)}return f(o())};return{requestSemantic(p,u){return l("semantic",f=>f.requestSemantic(p,u),f=>f.requestSemantic(p,u))},requestImportDefinitions(p,u){return l("import-definitions",f=>f.requestImportDefinitions(p,u),f=>f.requestImportDefinitions(p,u))},shutdown(){if(s)return;s=!0;let p=[];try{a()}catch(u){p.push(u)}try{n?.shutdown()}catch(u){p.push(u)}if(p.length>0)throw p[0]}}}function ms(t,e,n={worker:()=>ys(),durable:()=>zn(t,{serverPath:we(Is()),semanticWorkerPath:we(er())})}){return fs(e)==="durable"?ds(n.durable(),n.worker):n.worker()}function ys(t={}){let e=null,n=null,r=1,i=!1,s=()=>{n&&(lt(n,{recursive:!0,force:!0}),n=null)},o=()=>{let l=e;e=null,l&&l.terminate(),s()},a=()=>{if(e)return e;let l=t.semanticWorkerPath?os(t.semanticWorkerPath):er();if(!ss(we(l)))throw new Error(`Rust semantic session worker was not found at ${we(l)}. Run npm run build before using built semantic Rust queries.`);return n=Kn(ut(Jn(),"scip-query-rust-session-")),e=new cs(l,t.shareEnvironment?{env:as}:void 0),e.unref(),e},c=()=>{let l=n??Kn(ut(Jn(),"scip-query-rust-session-"));return n=l,ut(l,`${r++}.json`)};return{requestSemantic(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"semantic",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let y=gs(Vn(f,"utf8"));if(!y.ok)throw new Error(y.error);return y.response}finally{lt(f,{force:!0})}},requestImportDefinitions(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"import-definitions",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic import-definition session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let y=Ss(Vn(f,"utf8"));if(!y.ok)throw new Error(y.error);return y.response}finally{lt(f,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){s();return}let l=c(),p=new SharedArrayBuffer(4),u=new Int32Array(p);e.postMessage({kind:"shutdown",responsePath:l,sharedBuffer:p}),Atomics.wait(u,0,0,5e3),o()}}}function gs(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ss(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Rs(t){let e=t instanceof Error?`${t.name} ${t.message}`.toLowerCase():String(t).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ie(t){return new Map(t.map(e=>[e.symbolId,[]]))}function se(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Qn(t){return new Map(t.map(e=>[e.symbolId,null]))}function pt(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??[]]))}function hs(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function bs(t){let e=0;return t.includeReferences!==!1&&(e+=(t.referenceDefinitions??t.definitions).length),t.includeCallees===!0&&(e+=(t.calleeDefinitions??t.definitions).length),t.includeSignatures===!0&&(e+=(t.signatureDefinitions??t.definitions).length),Math.max(1,e)}function dt(t,e){return e&&e>0?Math.max(t,e):t}function er(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Is(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function ke(t,e){return G(t)??e}function Fe(t,e){return tr(t)??e}function tr(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)&&e>=0?e:null}var gt=15e3,St=8;function sr(t,e={}){let n=e.status??ve,r=Cs(t,n),i=Ds(t,n),s=Ts(t,n),o=e.referenceResolver||e.calleeResolver||e.signatureResolver||!Ms(e)?null:Zn(t,n,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:s}),a=e.referenceResolver??o??r,c=e.calleeResolver??o??i,l=e.signatureResolver??o??s,p=e.importUsageResolver??Dn(e.sourceImportUsageResolver??xs(),e.importDefinitionResolver??o),u=e.calleeSymbolResolver,f=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,m=new Map,h=new Map,y=null,S=null,v=()=>(y??=n(t),y),j=()=>{let g=v();return g.dependencyAvailable?S??g:g},P=g=>{if(g.length===0)return new Map;let I=ae(g);try{let R=a.referencesForDefinitions(I),M=v();return S={...M,available:R.available,resolvedBinary:R.resolvedBinary??M.resolvedBinary,reason:R.reason??M.reason},R.available?new Map(R.references):q(I,R.references)}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},H(I)}},L=g=>{if(g.length===0)return new Map;let I=ae(g),R=I.filter(nr);if(R.length===0)return K(I);let M=new Map,ne=ir(R,d),N=[];for(let x of R)h.has(x.symbolId)?M.set(x.symbolId,h.get(x.symbolId)??[]):ne.has(x.symbolId)?M.set(x.symbolId,ne.get(x.symbolId)??[]):rr(x,f)?M.set(x.symbolId,[]):N.push(x);if(N.length===0)return Q(I,M,void 0);try{let x=c.calleesForDefinitions(N),U=v();S={...U,available:x.available,resolvedBinary:x.resolvedBinary??U.resolvedBinary,reason:x.reason??U.reason};let D=Q(N,x.callees,u);for(let[J,Ke]of D)M.set(J,Ke);return Q(I,M,void 0)}catch(x){return S={...v(),available:!1,reason:x instanceof Error?x.message:String(x)},K(I)}},O=(g,I)=>{let R=ae(g),M=ae(I),ne=M.filter(nr),N=new Map,x=ir(ne,d),U=[];for(let D of ne)x.has(D.symbolId)?N.set(D.symbolId,x.get(D.symbolId)??[]):rr(D,f)?N.set(D.symbolId,[]):U.push(D);if(R.length===0&&U.length===0)return{references:H(R),callees:Q(M,N,void 0)};try{let D=o?o.referencesAndCalleesForDefinitions(R,U):ws(a,c,{referenceDefinitions:R,calleeDefinitions:U}),J=v();S={...J,available:D.available,resolvedBinary:D.resolvedBinary??J.resolvedBinary,reason:D.reason??J.reason};let Ke=D.available?new Map(D.references):q(R,D.references);for(let[Ve,Je]of D.callees)N.set(Ve,Je);let Bt=Q(M,N,u);for(let[Ve,Je]of Bt)h.set(Ve,Je);return{references:Ke,callees:Bt}}catch(D){return S={...v(),available:!1,reason:D instanceof Error?D.message:String(D)},{references:H(R),callees:K(M)}}},E=g=>{if(g.length===0)return new Map;let I=ae(g);try{let R=l.signaturesForDefinitions(I),M=v();return S={...M,available:R.available,resolvedBinary:R.resolvedBinary??M.resolvedBinary,reason:R.reason??M.reason},or(I,R.signatures)}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},Ee(I)}};return{language:"rust",availability:j,dispose:()=>{o?.dispose()},importUsage:g=>{let I=m.get(g);if(I)return I;try{let R=p.importUsage(g);return m.set(g,R),R}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},[]}},referencesFor:g=>P([g]).get(g.symbolId)??[],referencesForDefinitions:P,referencesAndCalleesForDefinitions:O,calleesFor:g=>L([g]).get(g.symbolId)??[],calleesForDefinitions:L,signatureFor:g=>E([g]).get(g.symbolId)??null}}function Ms(t){if(t.usePersistentSession!==void 0)return t.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function xs(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function ae(t){return t.map(e=>{let n=e;return{...e,leaf:typeof n.leaf=="string"?n.leaf:z(e.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:tn(e.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function nr(t){return t.isFunctionLike}function rr(t,e){if(!e)return!1;try{return e(t)}catch{return!1}}function ir(t,e){if(!e||t.length===0)return new Map;try{return e(t)}catch{return new Map}}function Cs(t,e){return{referencesForDefinitions:n=>Ps(t,e,n)}}function Ds(t,e){return{calleesForDefinitions:n=>ks(t,e,n)}}function Ts(t,e){return{signaturesForDefinitions:n=>Fs(t,e,n)}}function Ps(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:H(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:H(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=Ne(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),c=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),p={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,...o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:c,settleDelayMs:l,concurrency:a},u=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(p),encoding:"utf8",maxBuffer:50*1024*1024,timeout:$(n.length,dt(s,p.referenceRetryTimeoutMs),a)}),f=ht(u.stdout);if(f)return{available:f.available,resolvedBinary:r.resolvedBinary,reason:f.reason,references:q(n,new Map(f.references),new Set(f.incompleteReferenceSymbolIds??[]))};let d=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:H(n)}}function ks(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:K(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:K(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!0},p=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:$(n.length,s,o)}),u=ht(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,callees:Q(n,new Map(u.callees??[]),void 0)};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,callees:K(n)}}function Fs(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:Ee(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:Ee(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!1,includeSignatures:!0},p=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:$(n.length,s,o)}),u=ht(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,signatures:or(n,new Map(u.signatures??[]))};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,signatures:Ee(n)}}function ws(t,e,n){let r=n.referenceDefinitions.length>0?t.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:H(n.referenceDefinitions)},i=n.calleeDefinitions.length>0?e.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:K(n.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function H(t){return new Map(t.map(e=>[e.symbolId,[]]))}function K(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Ee(t){return new Map(t.map(e=>[e.symbolId,null]))}function Q(t,e,n){let r=0,i=0;return C("rust.semantic.callees.complete-map",()=>{let s=new Map;for(let o of t){let a=e.get(o.symbolId)??[];a.length>0&&(r+=1),i+=a.length,s.set(o.symbolId,a.map(c=>({...c,symbol:n?n(c):c.symbol})))}return s},()=>({definitions:t.length,rows:r,callees:i,resolveSymbols:!!n}))}function or(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function Rt(){return vs(new URL("./rust-semantic-worker.js",import.meta.url))}function ht(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e;return typeof n.available!="boolean"||!Array.isArray(n.references)?null:{available:n.available,reason:typeof n.reason=="string"?n.reason:void 0,references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0}}catch{return null}}function X(t,e){return G(t)??e}function Ne(t,e){if(!t)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}import{existsSync as Es,readFileSync as Ns}from"fs";import{deserializeSCIP as As,SymbolRole as _s}from"@c4312/scip";var bt=new WeakMap;function cr(t,e){let n=e.filter(js);if(n.length===0)return new Map;let r=!1,i=0,s=0;return C("rust.scip-occurrence.callees",()=>{let o=Us(t);if(r=!!o,!o)return new Map;let a=new Map;for(let c of n){let l=Ls(t,o,c);l!==null&&(a.set(c.symbolId,l),i+=1,s+=l.length)}return a},()=>({definitions:e.length,candidates:n.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:s}))}function js(t){return!(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||!t.isFunctionLike||t.leaf==="main"||re(t.symbol))}function Ls(t,e,n){let r=me(t,n.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(l=>l.startLine!==n.startLine||l.endLine!==n.endLine?!1:l.name===n.leaf||n.leaf.endsWith(l.name)||l.name.endsWith(n.leaf));if(!i)return null;let s=r.callSites.filter(l=>l.line>=i.startLine&&l.line<=i.endLine);if(s.length===0)return null;let o=(e.occurrencesByFile.get(n.relativePath)??[]).filter(l=>l.line>=i.startLine&&l.line<=i.endLine&&l.callee.symbol!==n.symbol);if(o.some(l=>l.traitImplMember)||!Os(s,o))return null;let a=[],c=new Set;for(let l of o){let p=`${l.callee.symbol}\0${l.callee.file}\0${l.callee.line}`;c.has(p)||(c.add(p),a.push(l.callee))}return a}function Os(t,e){let n=ar(t),r=ar(e);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function ar(t){let e=new Map;for(let n of t){let r=n.calleeLeaf??n.leaf;if(!r)continue;let i=`${n.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function Us(t){if(bt.has(t))return bt.get(t)??null;let e=Bs(t);return bt.set(t,e),e}function Bs(t){if(!Es(t.config.indexPath))return null;try{let e=Se(t).filter(s=>s.symbol.startsWith("rust-analyzer ")&&s.relativePath.endsWith(".rs")&&s.isFunctionLike),n=new Map(e.map(s=>[s.symbol,s])),r=As(Ns(t.config.indexPath)),i=new Map;for(let s of r.documents??[]){let o=s.relativePath;if(!o||!o.endsWith(".rs")||t.isIgnored(o))continue;let a=[];for(let c of s.occurrences??[]){if(!c.symbol||(c.symbolRoles&_s.Definition)!==0)continue;let l=n.get(c.symbol);if(!l)continue;let p=c.range?.[0];Number.isInteger(p)&&a.push({line:p,leaf:l.leaf,traitImplMember:re(l.symbol),callee:{symbol:l.symbol,file:l.relativePath,line:l.startLine}})}i.set(o,a)}return{occurrencesByFile:i}}catch{return null}}var Ae=class{sessions=new WeakMap;getOrCreate(e,n,r){let i=Ws(e,n),s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let o=s.get(i);if(o)return o.hits+=1,o.lastUsedAtMs=Date.now(),o.provider;let a=Date.now(),c=r();return s.set(i,{key:i,language:n,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let n=this.sessions.get(e);if(n)for(let r of n.values())r.provider.dispose?.();this.sessions.delete(e)}};function Ws(t,e){return`${t.config.projectRoot}:${e}-workspace`}import{randomUUID as Po}from"crypto";import{existsSync as ko,mkdirSync as Lr,readFileSync as Fo,rmSync as Or}from"fs";import{dirname as wo,resolve as Ur}from"path";import{readFileSync as qs}from"fs";import{join as It}from"path";var lr=5e3,zs="watch.lock",$s="watch-state.json",Hs="watch-activity.json";function ur(t){return{lockPath:It(t,zs),statePath:It(t,$s),activityPath:It(t,Hs)}}function vt(t){try{return Ks(JSON.parse(qs(t,"utf8")))}catch{return null}}function Ks(t){if(!t||typeof t!="object")return null;let e=t;return e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||e.worktreeId!==void 0&&(typeof e.worktreeId!="string"||e.worktreeId.length===0)||typeof e.cliVersion!="string"||!w(e.startedAt)||!w(e.heartbeatAt)||!w(e.lastActivityAt)||!Vs(e.watcher)||e.idleDeadlineAt!==void 0&&!w(e.idleDeadlineAt)||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Js(e.lastError)||e.lastRefresh!==void 0&&!Ys(e.lastRefresh)||e.typescriptSemantic!==void 0&&!Gs(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!Qs(e.typescriptIndex)?null:e}function w(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function Vs(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return k(e.changedFiles)&&k(e.reindexAt);case"indexing":return k(e.startedAt);case"cooldown":return k(e.until)&&typeof e.dirty=="boolean";default:return!1}}function Js(t){if(!t||typeof t!="object")return!1;let e=t;return w(e.at)&&typeof e.message=="string"}function Ys(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&w(e.startedAt)&&w(e.completedAt)&&k(e.durationMs)}function Gs(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&k(e.requests)&&k(e.sessionsCreated)&&k(e.sessionsReused)&&k(e.sessionsRefreshed)&&k(e.sessionsReplaced)&&k(e.projectsCreated)&&(e.lastRequestAt===void 0||w(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||w(e.busyUntil))}function Qs(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&V(e.requests)&&V(e.sessionsCreated)&&V(e.sessionsReplaced)&&V(e.initializations)&&V(e.programUpdates)&&V(e.documentsEmitted)&&V(e.documentsRemoved)&&(e.lastRequestAt===void 0||w(e.lastRequestAt))&&(e.lastDurationMs===void 0||k(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||w(e.busyUntil))}function k(t){return typeof t=="number"&&Number.isFinite(t)}function V(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}import{performance as b}from"perf_hooks";function F(t,e,n){if(t.has(e))return t.get(e);let r=n();return t.set(e,r),r}import pr from"path";function Xs(t,e){return t.getReferences().map(n=>{let r=n.getNode();return _e(r,e)})}function Zs(t){let e=t;return typeof e.findReferences=="function"?e.findReferences():[]}function fr(t,e,n,r){let i=[];for(let s of Zs(t))for(let o of Xs(s,r))o.file===e.relativePath&&o.line>=e.startLine&&o.line<=e.endLine||i.push(o);for(let s of n)i.push(s);return Z(i)}function dr(t,e,n,r){let i=[],s=n?.getStart();for(let o of t.getReferences()){let a=o.getNode();ee(r,a.getSourceFile().getFilePath())===e&&(s!==void 0&&a.getStart()===s||i.push({location:_e(a,r),node:a}))}return i}function _e(t,e){let n=t.getSourceFile(),r=n.getLineAndColumnAtPos(t.getStart());return{file:ee(e,n.getFilePath())??n.getBaseName(),line:r.line-1,column:r.column-1}}function mr(t,e,n){let r=t.getSourceFile(),i=xt(r,t),s=t.getText(),o=new RegExp(`\\b${Yt(s)}\\b`,"g"),a=r.getFullText().split(`
|
|
4
|
-
`),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let p=a[l]??"";o.lastIndex=0;let u;for(;(u=o.exec(p))!==null;)c.push({file:e,line:l,column:u.index})}return Z(c.filter(l=>ee(n,pr.join(n,l.file))===e))}function Mt(t){for(let e=t;e;e=e.getParent()){let n=e.getKindName();if(n.includes("Type")||n==="InterfaceDeclaration"||n==="TypeAliasDeclaration")return!0;if(n==="CallExpression"||n==="NewExpression"||n==="ExpressionStatement")return!1}return!1}function xt(t,e){return t.getLineAndColumnAtPos(e.getStart()).line-1}function Z(t){let e=new Set,n=[];for(let r of t){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),n.push(r))}return n}function ee(t,e){let n=pr.relative(t||process.cwd(),e).replace(/\\/g,"/");return!n||n.startsWith("..")?null:n}function yr(t,e,n,r){let i=eo(e,r);return i.size===0?new Map:to(t,n,i)}function eo(t,e){let n=new Map;for(let r of W(t,e)){let i=z(r.symbol)??r.leaf;if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push(r)}return n}function to(t,e,n){let r=new Map,i=new Map;return e.forEachDescendant(s=>{for(let o of no(t,s)){let a=n.get(o);if(!a)continue;let c=xt(e,s);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let p=Math.abs(c-l.startLine),u=i.get(l.symbolId);u!==void 0&&u<=p||(i.set(l.symbolId,p),r.set(l.symbolId,s))}}}),r}function no(t,e){let n=[],r=i=>{i&&!n.includes(i)&&n.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return t.Node.isIdentifier(e)&&r(e.getText()),n}var ro=qt("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function gr(t,e,n,r){let i=Tt(t,e),s=Ct(i.get(r)??[],n);if(s)return s;let o=[];for(let a of i.values())for(let c of a)((c.leaf||z(c.symbol)||"").includes(r)||c.symbol.includes(r))&&o.push(c);return Ct(o,n)}function Dt(t,e,n,r){return Ct(Tt(t,e).get(r)??[],n)}function Sr(t,e){let n=new Map;for(let[r,i]of Tt(t,e)){let s=i[0];s&&n.set(r,s)}return n}function Tt(t,e){return ro.get(t,e,()=>{let n=new Map;for(let r of W(t,e)){let i=r.leaf||z(r.symbol);if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push({...r,leaf:i})}for(let r of n.values())r.sort((i,s)=>i.startLine-s.startLine||i.endLine-s.endLine||i.symbolId-s.symbolId);return n})}function Ct(t,e){let n=null,r=Number.POSITIVE_INFINITY;for(let i of t){let s=Math.abs(i.startLine-e);(s<r||s===r&&n&&i.startLine<n.startLine)&&(n=i,r=s)}return n}import Pt from"path";var ce=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function _(t){let e=t.toLowerCase();return ce.some(n=>e.endsWith(n))}function Rr(t,e){let n=new Map,r=null,i=null,s=()=>(i??=Y(t,{extensions:ce}),i),o=()=>(r??=C("typescript.source-file-index",()=>io(t.config.projectRoot,e,s()),()=>({projects:e.length,indexedDocuments:s().length})),r),a=c=>_(c)?F(n,c,()=>{let l=le(Pt.resolve(t.config.projectRoot,c));for(let{project:p,sourceFiles:u}of o()){let f=u.get(l)??null;if(f||(f=p.addSourceFileAtPathIfExists(l)??null,f&&u.set(le(f.getFilePath()),f)),f)return{project:p,sourceFile:f}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:s}}function io(t,e,n){let r=e.map(({project:i})=>({project:i,sourceFiles:new Map(i.getSourceFiles().map(s=>[le(s.getFilePath()),s]))}));for(let i of n){let s=le(Pt.resolve(t,i));for(let o of r){if(o.sourceFiles.has(s))break;let a=o.project.addSourceFileAtPathIfExists(s)??null;if(a){o.sourceFiles.set(le(a.getFilePath()),a);break}}}return r}function le(t){return Pt.resolve(t)}function kt(t,e){for(let n of t)if(e===n.name||e.startsWith(`${n.name}/`))return n.name;return null}function hr(t){let e=`${t.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as ue,readFileSync as so}from"fs";import T from"path";var Ft=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function wt(t,e){let r=e?T.dirname(T.join(t,e)):t,i=T.resolve(t);for(;r.startsWith(i);){for(let o of Ft){let a=T.join(r,o);if(ue(a))return a}let s=T.dirname(r);if(s===r)break;r=s}for(let s of Ft){let o=T.join(t,s);if(ue(o))return o}return null}function br(t){let e=t.config.projectRoot,n=new Set(oo(e,t.config.semantic?.typescript?.tsconfigs)),r=Y(t,{includeIgnored:!1,extensions:ce});for(let i of r){let s=wt(e,i);s&&n.add(T.resolve(s))}if(n.size===0){let i=wt(e);i&&n.add(T.resolve(i))}return[...n].filter(i=>!Ir(e,i)).sort((i,s)=>i.localeCompare(s))}function oo(t,e=[]){let n=new Set;for(let r of e){let i=T.isAbsolute(r)?r:T.join(t,r);ue(i)&&n.add(T.resolve(i))}for(let r of ao(t))for(let i of Ft){let s=T.join(r,i);ue(s)&&n.add(T.resolve(s))}if(n.size===0){let r=wt(t);r&&n.add(T.resolve(r))}return[...n].filter(r=>!Ir(t,r)).sort((r,i)=>r.localeCompare(i))}function ao(t){let e=T.join(t,"package.json");if(!ue(e))return[];let n;try{n=JSON.parse(so(e,"utf8"))}catch{return[]}return(Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[]).flatMap(i=>Ht(t,i))}function Ir(t,e){let n=T.relative(t,e).replace(/\\/g,"/");return n.startsWith("..")||n.includes("/node_modules/")||n.startsWith("node_modules/")||n.includes("/dist/")||n.startsWith("dist/")}import{createRequire as co}from"module";var vr=co(import.meta.url),pe,je;function Et(){if(pe!==void 0)return pe;try{pe=vr("ts-morph")}catch{pe=null}return pe}function Le(){if(je)return je;let t=Et();if(!t)return"ts-morph:unavailable";let e="unknown";try{e=vr("ts-morph/package.json").version??"unknown"}catch{}return je=`ts-morph:${e}:typescript:${t.ts.version}`,je}function Mr(t,e){return e.map(n=>({tsconfigPath:n,project:new t.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function Oe(t,e,n){return{language:"typescript",availability:()=>({available:!1,reason:t,tsconfigPath:e,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function Ue(t,e){let n=new Map(t.map(i=>[i.symbol,i])),r=new Map(t.map(i=>[i.symbolId,[]]));for(let i of e.values())for(let s of i){let o=n.get(s.targetSymbol);o&&r.get(o.symbolId).push(s.location)}for(let[i,s]of r)r.set(i,lo(s));return r}function Dr(t,e,n){let r=Cr(t,e),i=Cr(t,n),s=[...r].filter(u=>!i.has(u)).sort(),o=[...i].filter(u=>!r.has(u)).sort(),a=xr(t,e),c=xr(t,n),l=[...a].filter(u=>!c.has(u)).sort(),p=[...c].filter(u=>!a.has(u)).sort();return{passed:s.length===0&&o.length===0,expectedCount:r.size,actualCount:i.size,missing:s,extra:o,callerFiles:{passed:l.length===0&&p.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:p}}}function xr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function Tr(t,e,n){let r=new Set(n),i=new Map(n.map(s=>[s,[]]));for(let s of t)for(let o of e.get(s.symbolId)??[])r.has(o.file)&&i.get(o.file).push({targetSymbol:s.symbol,location:o});for(let[s,o]of i)i.set(s,uo(o));return i}function Cr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function lo(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort(Pr)}function uo(t){let e=new Map;for(let n of t){let{location:r}=n;e.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...e.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||Pr(n.location,r.location))}function Pr(t,e){return t.file.localeCompare(e.file)||t.line-e.line||t.column-e.column}var po=32;function Ar(t,e){let n=C("typescript.provider.load",()=>Et());if(!n)return Oe("ts-morph is not installed");let r=C("typescript.provider.tsconfig-discovery",()=>br(t));if(r.length===0)return Oe("no tsconfig found");try{let i=C("typescript.provider.project-bundles",()=>Mr(n,r),()=>({tsconfigs:r.length}));return fo(t,n,i)}catch(i){return Oe(i instanceof Error?i.message:String(i),r[0],r)}}function fo(t,e,n,r={}){return C("typescript.provider.construct",()=>new At(t,e,n),()=>({tsconfigs:n.length,reusedProjects:r.reusedProjects===!0}))}var At=class{constructor(e,n,r){this.db=e;this.tsMorph=n;this.projects=r;this.workspacePackages=$t(e.config.projectRoot),this.sourceFiles=Rr(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return F(this.importUsageCache,e,()=>{let n=this.sourceFiles.sourceFile(e);if(!n)return[];let r=yo();return C("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,n,r),()=>({file:e,...r}))})}referencesFor(e){return F(this.referencesCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,n)})}referencesForDefinitions(e,n={}){let r=new Map,i=B(),s=[];for(let p of e){let u=this.referencesCache.get(p.symbolId);u?r.set(p.symbolId,u):s.push(p)}if(s.length===0)return r;let o=s,a=n.exact?[]:s.filter(p=>!Fr(p));if(a.length>=po){let p=this.referencesForDefinitionsBySymbolScan(a);for(let u of a){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}if(o=s.filter(u=>Fr(u)),o.length===0)return r}let c=new Map;for(let p of o){let u=c.get(p.relativePath);u?u.push(p):c.set(p.relativePath,[p])}let l=[];for(let[p,u]of c){let f=wr();C("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(p);for(let m of u){i&&(f.cacheMisses+=1);let h=d.get(m.symbolId)??null;i&&(h?f.nodeHits+=1:f.nodeMisses+=1);try{let y=this.referencesForDefinitionNode(m,h,i?f:void 0);this.referencesCache.set(m.symbolId,y),r.set(m.symbolId,y)}catch{f.preciseSearchFailures+=1,l.push(m)}}},()=>({relativePath:p,definitions:u.length,...Er(f)}))}if(l.length>0){let p=this.referencesForDefinitionsBySymbolScan(l);for(let u of l){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}}return r}referenceFragmentsForFiles(e){let n=Se(this.db).filter(s=>_(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(n,r);return Tr(n,i,r)}referencesForDefinitionsBySymbolScan(e,n){let r=B(),i=wr(),s=new Map,o=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)s.set(c.symbolId,[]);return C("typescript.references-map.inverted-scan",()=>{let c=r?b.now():0,l=n?this.packageImportReferencesForFiles(n):this.packageImportReferences();for(let y of e){let S=l.get(y.symbolId)??[];if(S.length>0){let v=s.get(y.symbolId)??[];v.push(...S),s.set(y.symbolId,v)}r&&(i.packageReferenceCount+=S.length)}r&&(i.packageRefsMs+=b.now()-c);let p=new Map,u=new Map,f=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(y=>y.leaf).filter(Boolean)),m=r?b.now():0;for(let y of n??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(y))continue;let S=this.sourceFiles.sourceFile(y);S&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(S,y,o,a,f,d,p,u,s,r?i:void 0))}r&&(i.scanMs+=b.now()-m);let h=r?b.now():0;this.addHierarchyMemberReferences(e,s,r?i:void 0),r&&(i.hierarchyMs+=b.now()-h);for(let[y,S]of s){let v=Z(S);s.set(y,v),r&&(i.referenceCount+=v.length)}},()=>({definitions:e.length,...Er(i)})),s}addReferencesFromSourceFileScan(e,n,r,i,s,o,a,c,l,p){let u=this.compilerCheckerForSourceFile(e),f=e.compilerNode,d=Ro(e),m=h=>{if(this.tsMorph.ts.isIdentifier(h)){if(p&&(p.identifiers+=1),!o.has(h.text)&&!d.has(h.text)){this.tsMorph.ts.forEachChild(h,m);return}let y=this.compilerReferenceSymbol(u,h,p);if(y){let S;a.has(y)?S=a.get(y)??null:(S=this.referenceDefinitionFromCompilerSymbol(y),a.set(y,S)),p&&(S?p.targetHits+=1:p.targetMisses+=1);let v=F(c,y,()=>this.compilerSymbolKeys(y)),j=null,P=null,L=S&&r.has(S.symbolId)?i.get(S.symbolId):void 0;if(L&&(j=Nt(f,h),!kr(L,n,j))){let O=f.getLineAndCharacterOfPosition(h.getStart(f));P={file:n,line:O.line,column:O.character};let E=l.get(L.symbolId)??[];E.push(P),l.set(L.symbolId,E),p&&(p.requestedHits+=1)}for(let O of v)for(let E of s.get(O)?.values()??[]){if(j??=Nt(f,h),kr(E,n,j))continue;if(!P){let I=f.getLineAndCharacterOfPosition(h.getStart(f));P={file:n,line:I.line,column:I.character}}let g=l.get(E.symbolId)??[];g.push(P),l.set(E.symbolId,g),p&&(p.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(h,m)};m(f)}hierarchyTargetsForDefinitions(e){let n=new Map;for(let r of e){let i=this.nodeForDefinition(r),s=i?.compilerNode;if(!s||!this.isHierarchyMethod(s))continue;let o=s.parent;if(!this.isHierarchyContainer(o))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(s.name);if(c)for(let l of this.hierarchyMemberSymbols(a,o,c))for(let p of this.compilerSymbolKeys(l)){let u=n.get(p)??new Map;u.set(r.symbolId,r),n.set(p,u)}}return n}hierarchyMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(!s.has(a)){s.add(a),i.add(c);for(let p of l){let u=p.getProperty(r.name);u&&o(p,u,this.hierarchyAncestorTypesForType(e,p))}}};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}addHierarchyMemberReferences(e,n,r){let i=new Map;for(let s of e){let o=this.nodeForDefinition(s),a=o?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let l=this.compilerCheckerForSourceFile(o.getSourceFile()),p=l.getSymbolAtLocation(a.name);if(!p)continue;let u=a.getSourceFile(),f=u.getLineAndCharacterOfPosition(a.name.getStart(u)),d={definition:s,location:{file:s.relativePath,line:f.line,column:f.character}},m=n.get(s.symbolId)??[];for(let y of this.hierarchyMemberSymbols(l,c,p))if(y!==p)for(let S of this.compilerSymbolLocations(y))m.push(S),r&&(r.hierarchyReferences+=1);n.set(s.symbolId,m);let h=this.hierarchyRootMemberSymbols(l,c,p);for(let y of h){let S=i.get(y)??new Map;S.set(s.symbolId,d),i.set(y,S)}r&&(r.hierarchyDefinitions+=1)}for(let s of i.values())if(!(s.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:o}of s.values()){let a=n.get(o.symbolId)??[];for(let c of s.values())c.definition.symbolId!==o.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));n.set(o.symbolId,a)}}}hierarchyRootMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(s.has(a))return;s.add(a);let p=!1;for(let u of l){let f=u.getProperty(r.name);f&&(p=!0,o(u,f,this.hierarchyAncestorTypesForType(e,u)))}if(!p)for(let u of this.compilerSymbolKeys(c))i.add(u)};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(n=>{let r=n.getSourceFile();return`${r.fileName}\0${n.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let n=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),s=ee(this.db.config.projectRoot,i.fileName);if(!s)continue;let o=r.name,a=i.getLineAndCharacterOfPosition((o??r).getStart(i));n.push({file:s,line:a.line,column:a.character})}return n}baseTypes(e,n){try{return e.getBaseTypes(n)??[]}catch{return[]}}hierarchyAncestorTypes(e,n){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(n)));for(let i of n.heritageClauses??[])for(let s of i.types)r.add(e.getTypeAtLocation(s));return[...r]}hierarchyAncestorTypesForType(e,n){let r=new Set(this.baseTypes(e,n));for(let i of n.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let s of i.heritageClauses??[])for(let o of s.types)r.add(e.getTypeAtLocation(o));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,n,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(n);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return F(this.calleesCache,e.symbolId,()=>F(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let n=new Map,r=new Map;for(let i of e){let s=r.get(i.relativePath);s?s.push(i):r.set(i.relativePath,[i])}for(let[i,s]of r){let o=this.fileCalleesCache.get(i),a=new Set(s.map(l=>l.symbolId)),c=o??this.calleeMapForFile(i,a);for(let l of s){let p=c.get(l.symbolId)??[];this.calleesCache.set(l.symbolId,p),n.set(l.symbolId,p)}}return n}referencesForDefinitionNode(e,n,r){let i=r?b.now():0,s=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=b.now()-i,r.packageReferenceCount+=s.length),!n)return s;let o=r?b.now():0,a=fr(n,e,s,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=b.now()-o,r.referenceCount+=a.length),a}signatureFor(e){return F(this.signatureCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);if(!n||!this.tsMorph.Node.isFunctionDeclaration(n)&&!this.tsMorph.Node.isMethodDeclaration(n)&&!this.tsMorph.Node.isArrowFunction(n)&&!this.tsMorph.Node.isFunctionExpression(n)&&!this.tsMorph.Node.isConstructorDeclaration(n))return null;let r=n.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(o=>{let a=o.getDeclarations()[0],c=a?o.getTypeAtLocation(a).getText(a):o.getValueDeclaration()?.getType().getText()??"unknown";return Nr(c)}),s=r.getReturnType().getText(n);return`(${i.join(",")})=>${Nr(s)}`})}importUsageForSourceFile(e,n,r){let i=[],s=new Map;for(let o of n.getImportDeclarations()){r.declarations+=1;let a=Ge(this.db,e,o.getModuleSpecifierValue()),c=o.getImportClause()?.isTypeOnly()??!1;for(let l of _t(o)){r.entries+=1;let p=c?null:l.identifier?.getSymbol()?.compilerSymbol??null;!c&&l.identifier&&(p?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let u={sourcePath:a,entry:l,typeOnlyDeclaration:c,bindingSymbol:p,references:[]};if(i.push(u),c||!l.localName||!p)continue;let f=s.get(l.localName);f?f.push(u):s.set(l.localName,[u])}}return s.size>0&&n.forEachDescendant(o=>{if(o.getKindName()!=="Identifier")return;let a=s.get(o.getText());if(!a||go(o))return;r.scannedIdentifiers+=1;let c=o.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let l of a)if(l.bindingSymbol===c){l.references.push({location:_e(o,this.db.config.projectRoot),node:o}),r.matchedReferences+=1;break}}}),i.map(o=>o.typeOnlyDeclaration?mo(e,o.sourcePath,o.entry):o.entry.identifier&&!o.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,o.sourcePath,o.entry)):this.valueImportUsageFromLocations(e,o.sourcePath,o.entry,o.references))}valueImportUsageForEntry(e,n,r){let i=r.identifier?r.identifier.findReferences():[],s=[];for(let o of i)for(let a of dr(o,e,r.identifier,this.db.config.projectRoot))s.push(a);return this.valueImportUsageFromLocations(e,n,r,s)}valueImportUsageFromLocations(e,n,r,i){let s=i.some(c=>!Mt(c.node)),o=i.some(c=>Mt(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:n,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||o,isValueUsed:s,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let n=new Map,r=new Set;for(let s of e){let o=this.sourceFiles.sourceFile(s);if(o)for(let a of o.getImportDeclarations()){let c=kt(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return n;let i=this.packageExportsForNames(r);for(let s of e)this.addPackageImportReferencesForDocument(n,i,s);for(let[s,o]of n)n.set(s,Z(o));return n}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,n=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,n,r);for(let[r,i]of e)e.set(r,Z(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,n,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let s of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,n,r,s)}addPackageImportReferencesForDeclaration(e,n,r,i){let s=kt(this.workspacePackages,i.getModuleSpecifierValue());if(!s)return;let o=n.get(s);if(o)for(let a of _t(i)){if(a.kind!=="named"||!a.identifier)continue;let c=o.get(a.importedName);if(!c||c.size===0)continue;let l=mr(a.identifier,r,this.db.config.projectRoot);l.length>0&&vo(e,c,l)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let n=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let s of hr(r))this.collectPackageExports(r,s,i,new Set);i.size>0&&n.set(r.name,i)}return n}collectPackageExports(e,n,r,i){if(i.has(n))return;i.add(n);let s=this.sourceFiles.sourceFile(n);if(s)for(let o of s.getExportDeclarations()){let a=o.getModuleSpecifierValue(),c=a?Ge(this.db,n,a):n;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let l=o.getNamedExports();if(l.length===0){if(o.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let p of l){let u=p.getNameNode().getText(),f=p.getAliasNode()?.getText()??u,d=this.indexedDefinitionByLeaf(c,u);if(!d)continue;let m=r.get(f);m||(m=new Set,r.set(f,m)),m.add(d.symbolId)}}}indexedDefinitionByLeaf(e,n){return F(this.indexedDefinitionLeafCache,e,()=>Sr(this.db,e)).get(n)??null}nodeForDefinition(e){return F(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return F(this.fileDefinitionNodeCache,e,()=>{let n=this.sourceFiles.sourceFile(e);return n?yr(this.tsMorph,this.db,n,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,n,r=!1){let i=e.name,s=n?b.now():0,o=e.declarations??[];n&&(n.declarationsMs+=b.now()-s,n.declarationChecks+=o.length);for(let a of o){let c=n?b.now():0,l=a.getSourceFile(),p=ee(this.db.config.projectRoot,l.fileName),u=l.getLineAndCharacterOfPosition(a.getStart(l)).line;if(n&&(n.declarationLocationMs+=b.now()-c),!p||this.db.isIgnored(p))continue;let f=n?b.now():0,d=this.compilerDeclarationName(a),m=r?Dt(this.db,p,u,i)??(d&&d!==i?Dt(this.db,p,u,d):null):gr(this.db,p,u,i);if(n&&(n.indexedLookupMs+=b.now()-f),m)return{symbolId:m.symbolId,symbol:m.symbol,file:m.relativePath,line:m.startLine}}return null}compilerDeclarationName(e){let n=e.name;return n&&this.tsMorph.ts.isIdentifier(n)?n.text:null}calleeMapForFile(e,n){let r=B(),i=0,s=0,o=0,a=0,c=0,l=0,p=0,u=0,f=r?bo():void 0;return C("typescript.callee-map.file",()=>{let d=r?b.now():0,m=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(b.now()-d)),!m)return new Map;let h=r?b.now():0,y=W(this.db,e).sort((g,I)=>g.startLine-I.startLine||I.endLine-g.endLine);if(r&&(l=Math.round(b.now()-h)),i=y.length,y.length===0)return new Map;let S=new Map,v=r?b.now():0,j=this.compilerCheckerForSourceFile(m),P=m.compilerNode;r&&(p=Math.round(b.now()-v));let L=new Map,O=g=>{if(this.tsMorph.ts.isCallExpression(g)||this.tsMorph.ts.isNewExpression(g)){r&&(s+=1);let I=this.semanticCalleeForCallNode(j,P,y,g,L,n,f);I&&(r&&(o+=1),So(S,I.callerId,I.target))}this.tsMorph.ts.forEachChild(g,O)},E=r?b.now():0;O(P),r&&(u=Math.round(b.now()-E));for(let[g,I]of S)S.set(g,Mo(I));return a=S.size,S},()=>({relativePath:e,definitions:i,callNodes:s,resolvedCallees:o,outputRows:a,requestedDefinitions:n?.size??i,sourceFileLookupMs:c,definitionsLoadMs:l,checkerLookupMs:p,traversalMs:u,...f?Io(f):{}}))}semanticCalleeForCallNode(e,n,r,i,s,o,a){let c=a?b.now():0,l=ho(r,Nt(n,i));if(a&&(a.callerLookupMs+=b.now()-c),!l)return null;if(o&&!o.has(l.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let p=i.expression,u=this.compilerSymbolForExpression(e,p,a),f=null;if(u)if(a&&(a.targetSymbolHits+=1),s.has(u))a&&(a.compilerSymbolCacheHits+=1),f=s.get(u)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?b.now():0;f=this.definitionFromCompilerSymbol(u,a),a&&(a.targetLookupMs+=b.now()-d),s.set(u,f)}else a&&(a.targetMisses+=1);return f?{callerId:l.symbolId,target:{symbol:f.symbol,file:f.file,line:f.line}}:null}compilerSymbolForExpression(e,n,r){let i=r?b.now():0,s=e.getSymbolAtLocation(n);if(r&&(r.expressionSymbolMs+=b.now()-i),s)return s;r&&(r.typeFallbacks+=1);let o=r?b.now():0,a=e.getTypeAtLocation(n).getSymbol();return r&&(r.typeSymbolMs+=b.now()-o),a}compilerCheckerForSourceFile(e){let n=e.getProject(),r=this.compilerCheckerCache.get(n);return r||(r=n.getTypeChecker().compilerObject,this.compilerCheckerCache.set(n,r)),r}};function _t(t){let e=[],n=t.getDefaultImport();n&&e.push({identifier:n,importedName:"default",localName:n.getText(),kind:"default",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});let r=t.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});for(let i of t.getNamedImports()){let s=i.getNameNode(),a=i.getAliasNode()??(s.getKindName()==="Identifier"?s:null);e.push({identifier:a,importedName:s.getText(),localName:a?.getText()??s.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(t.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function mo(t,e,n){return{importer:t,sourcePath:e,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function yo(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function go(t){for(let e=t;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function So(t,e,n){let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}function Ro(t){let e=new Set;for(let n of t.getImportDeclarations())for(let r of _t(n))r.localName&&e.add(r.localName);return e}function ho(t,e){let n=null;for(let r of t)e<r.startLine||e>r.endLine||(!n||r.startLine>=n.startLine)&&(n=r);return n}function Nt(t,e){return t.getLineAndCharacterOfPosition(e.getStart(t)).line}function kr(t,e,n){return e===t.relativePath&&n>=t.startLine&&n<=t.endLine}function Fr(t){return t.symbol.includes("#")?ge(t.symbol)==="type"&&t.relativePath.endsWith(".d.ts"):!1}function bo(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function Io(t){return{...t,callerLookupMs:Math.round(t.callerLookupMs),expressionSymbolMs:Math.round(t.expressionSymbolMs),typeSymbolMs:Math.round(t.typeSymbolMs),targetLookupMs:Math.round(t.targetLookupMs),declarationsMs:Math.round(t.declarationsMs),declarationLocationMs:Math.round(t.declarationLocationMs),indexedLookupMs:Math.round(t.indexedLookupMs)}}function wr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function Er(t){return{...t,scanMs:Math.round(t.scanMs),packageRefsMs:Math.round(t.packageRefsMs),semanticRefsMs:Math.round(t.semanticRefsMs),hierarchyMs:Math.round(t.hierarchyMs)}}function vo(t,e,n){for(let r of e){let i=t.get(r)??[];i.push(...n),t.set(r,i)}}function Mo(t){let e=new Set,n=[];for(let r of t){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),n.push(r))}return n}function Nr(t){return t.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{createHash as xo}from"crypto";import{readFileSync as Co}from"fs";import{dirname as Do,join as Be}from"path";var We=2,To="typescript-semantic";function _r(t){let e=Be(t,To);return{rootDir:e,requestDir:Be(e,"requests"),responseDir:Be(e,"responses")}}function jr(t){try{let e=JSON.parse(Co(Be(Do(t),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:xo("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}var Eo=12e4,No=5;function qr(t,e,n={}){let r=new jt(t,n),i=null,s=null,o=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Ar(t,e),i),c=(u,f,d)=>{if(o)return d();try{return f(r.request(u))}catch{return o=!0,d()}},l=(u,f)=>c({kind:"references",definitions:[...u],...f?.exact?{exact:!0}:{}},d=>Wr(d),()=>a().referencesForDefinitions?.(u,f)??new Map(u.map(d=>[d.symbolId,a().referencesFor(d)]))),p=u=>c({kind:"callees",definitions:[...u]},f=>Wr(f),()=>a().calleesForDefinitions?.(u)??new Map(u.map(f=>[f.symbolId,a().calleesFor(f)])));return{language:"typescript",availability:()=>(s??=c({kind:"availability"},jo,()=>a().availability()),s),importUsage:u=>c({kind:"import-usage",file:u},f=>f,()=>a().importUsage(u)),referencesFor:u=>l([u]).get(u.symbolId)??[],referencesForDefinitions:l,referenceFragmentsForFiles:u=>c({kind:"reference-fragments",files:[...u]},f=>_o(f),()=>a().referenceFragmentsForFiles?.(u)??new Map),calleesFor:u=>p([u]).get(u.symbolId)??[],calleesForDefinitions:p,signatureFor:u=>c({kind:"signature",definition:u},Lo,()=>a().signatureFor(u)),dispose:()=>i?.dispose?.()}}var jt=class{constructor(e,n={}){this.db=e;this.runtime=n.runtime??Uo,this.timeoutMs=n.timeoutMs??Oo(),this.cacheDir=wo(e.config.dbPath),this.projectRoot=rn(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;request(e){let n=ur(this.cacheDir),r=_r(this.cacheDir),i=vt(n.statePath);if(!Br(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let s=jr(this.db.config.dbPath);if(!s)throw new Error("Published TypeScript generation identity is unavailable.");let o=this.runtime.randomId(),a=Ur(r.requestDir,`${o}.json`),c=Ur(r.responseDir,`${o}.json`),l=this.runtime.now()+this.timeoutMs;Lr(r.requestDir,{recursive:!0}),Lr(r.responseDir,{recursive:!0}),be(a,{protocolVersion:We,id:o,generation:s,deadlineAtMs:l,profileEnvironment:Kt(),request:e});try{for(;this.runtime.now()<=l;){if(ko(c))return Ao(Fo(c,"utf8"),o,s);let p=vt(n.statePath);if(!Br(p,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(No)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}finally{Or(a,{force:!0}),Or(c,{force:!0})}}};function Br(t,e,n){let r=t!==null&&n.now()-Date.parse(t.heartbeatAt)<=lr,i=t?.typescriptSemantic?.busyUntil!==void 0&&n.now()<=Date.parse(t.typescriptSemantic.busyUntil);return t!==null&&t.projectRoot===e&&t.typescriptSemantic?.protocolVersion===We&&n.isProcessAlive(t.pid)&&(r||i)}function Ao(t,e,n){let r=JSON.parse(t);if(r.protocolVersion!==We||r.id!==e||r.ok===!0&&r.generation!==n)throw new Error("TypeScript semantic service wrote an incompatible response.");if(r.ok===!0)return r.response;throw new Error(typeof r.error=="string"?r.error:"TypeScript semantic service request failed.")}function Wr(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(t)}function _o(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(t)}function jo(t){if(!t||typeof t!="object"||typeof t.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return t}function Lo(t){if(t!==null&&typeof t!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return t}function Oo(){let t=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(t)&&t>0?t:Eo}var Uo={now:Date.now,randomId:Po,sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)},isProcessAlive:he};var zr=new Ae;Wt({name:"semantic-provider",groups:["semantic-provider"],clearAll:t=>zr.clear(t)});function Lt(t,e){let n=Bo(e)??"typescript";return zr.getOrCreate(t,n,()=>n==="rust"?sr(t.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>Cn(t,r)},calleeSymbolResolver:xn(t),sourceZeroCalleeOracle:r=>Wo(t,r),scipOccurrenceCalleeOracle:r=>cr(t,r)}):qr(t,e))}function Bo(t){return t?Gt(t)==="rust"?"rust":_(t)?"typescript":null:"typescript"}function Wo(t,e){let n=me(t,e.relativePath);if(!n||n.language!=="rust")return!1;let r=n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!n.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}import{readFileSync as Ho}from"fs";import{dirname as Ko,join as Vo}from"path";function ze(t){let e=qe(t.projectFiles),n=new Set(e),r=new Map(t.snapshot.files.map(u=>[u.path,u])),i=t.snapshot.files.filter(u=>{let f=nt(u.path,["typescript"]);return f==="config"||f==="ambient"}).map(u=>u.path),s=qe([...e,...i]),o=s.find(u=>!r.has(u)),a=new Set(t.snapshot.files.map(u=>u.path)).size!==t.snapshot.files.length,c=!o&&s.some(u=>$r(r.get(u))),l=Ye(JSON.stringify({pnpmWorkspaces:t.snapshot.pnpmWorkspaces,typescriptProjectMode:t.snapshot.typescriptProjectMode,typescriptProjects:qe(t.snapshot.typescriptProjects),membership:e})),p=new Map;return{identityFor(u,f){if(!n.has(u))return te("target-outside-project");if(a)return te("duplicate-input-path");if(o)return te("missing-input-fingerprint");if(c)return te("unreadable-input");let d=[],m,h;if(t.graph===null)d.push("dependency-graph-unavailable"),h="whole-project",m=s;else{let v=zo(u,t.graph,p);if(v.find(P=>!r.has(P)))return te("missing-input-fingerprint");if(m=qe([...v,...i]),m.some(P=>$r(r.get(P))))return te("unreadable-input");h="dependency-closure"}let y=m.map(v=>$o(r.get(v)));return{version:1,key:Ye(JSON.stringify({version:1,engineIdentity:t.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:y})),mode:h,inputFiles:m,reasons:d}}}}function qo(t,e){let n=new Set,r=[t];for(let i=0;i<r.length;i+=1){let s=r[i];if(!(s===void 0||n.has(s))){n.add(s);for(let o of[...e.get(s)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function zo(t,e,n){let r=n.get(t);if(r)return r;let i=qo(t,e);return n.set(t,i),i}function $o(t){return{path:t.path,size:t.size,hash:t.hash}}function $r(t){return t.size<0||t.hash==="unreadable"}function te(t){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[t]}}function qe(t){return[...new Set(t)].sort()}var Jo=zt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Ot(t,e,n){let r=Jo.get(t,()=>Yo(t));if(!r)return null;let i=`${n}\0${e}`,s=r.identities.get(i);if(s)return s;let o=r.builder.identityFor(e,n);return r.identities.set(i,o),o}function fe(t){return Y(t,{includeIgnored:!1}).filter(_).sort()}function Yo(t){try{let e=JSON.parse(Ho(Vo(Ko(t.config.dbPath),"meta.json"),"utf8")),n=Sn(e.fingerprint);return n?{builder:ze({projectFiles:fe(t),snapshot:n,graph:ye(t),engineIdentity:Le()}),identities:new Map}:null}catch{return null}}var Ut="typescript-reference-fragment-v2",He=Vt({kind:"typescript-reference-fragments",invalidation:Jt("typescript-reference-fragments"),serialize:t=>JSON.stringify(t),deserialize:Qo});function Eu(t,e,n,r=t){let i=fe(t),s=ze({projectFiles:i,snapshot:e,graph:ye(t),engineIdentity:Le()}),o=[...n].map(([a,c])=>({relativePath:a,contentHash:s.identityFor(a,Ut).key,value:[...c]}));if(o.some(a=>a.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return He.writeBatch(r,o.map(a=>({...a,contentHash:a.contentHash}))),o.length}function Nu(t,e,n){let r=e.filter(s=>_(s.relativePath));if(r.length===0)return $e("no TypeScript definitions");let i=$e("shadow did not run");return C("typescript.reference-fragments.shadow",()=>{try{let s=Lt(t,r[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return i=$e("TypeScript reference fragment provider is unavailable"),i;let o=fe(t),a=new Set(o),c=s.referenceFragmentsForFiles(o),l=Ue(r,c),p=Dr(r,Go(n,a),l);if(!p.passed)return i={state:"failing",files:o.length,keyedFiles:0,writtenFiles:0,...p},i;let u=[];for(let f of o){let d=Ot(t,f,Ut);d?.key&&u.push({relativePath:f,contentHash:d.key,value:c.get(f)??[]})}return He.writeBatch(t,u),i={state:"passing",files:o.length,keyedFiles:u.length,writtenFiles:u.length,...p},i}catch(s){return i=$e(s instanceof Error?s.message:String(s)),i}},()=>({...i}))}function Go(t,e){return new Map([...t].map(([n,r])=>[n,r.filter(i=>e.has(i.file))]))}function Au(t,e){if(e.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let n="fallback",r=0,i=0,s=0,o=0;return C("typescript.reference-fragments.materialize",()=>{try{let a=fe(t);r=a.length;let c=new Map,l=new Map,p=[];for(let d of a){let m=Ot(t,d,Ut);if(!m?.key)return null;c.set(d,m.key);let h=He.read(t,d,m.key);h===null?(s+=1,p.push(d)):(i+=1,l.set(d,h))}if(s===0)return n="hit",{references:Ue(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o};let u=Lt(t,e[0].relativePath);if(!u.availability().available||!u.referenceFragmentsForFiles)return null;let f=u.referenceFragmentsForFiles(p);if(p.some(d=>!f.has(d)))return null;o=f.size,He.writeBatch(t,p.map(d=>({relativePath:d,contentHash:c.get(d),value:f.get(d)??[]})));for(let[d,m]of f)l.set(d,m);return n="computed",{references:Ue(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o}}catch{return null}},()=>({state:n,files:r,cacheHits:i,cacheMisses:s,computedFiles:o}))}function $e(t){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:t}}function Qo(t){try{let e=JSON.parse(t);return!Array.isArray(e)||!e.every(Xo)?null:e}catch{return null}}function Xo(t){if(!t||typeof t!="object")return!1;let e=t,n=e.location;return typeof e.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}export{cn as a,Jr as b,et as c,sa as d,Qr as e,oa as f,he as g,be as h,Tn as i,Ka as j,Va as k,Xa as l,nt as m,Sn as n,fa as o,yi as p,rt as q,ha as r,lr as s,ur as t,vt as u,_ as v,Lt as w,Bo as x,ze as y,Ot as z,Eu as A,Nu as B,Au as C};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as G}from"./chunk-P5XHIJHI.js";import{a as Qe,c as nn,g as rn}from"./chunk-LM72NQ7T.js";import{a as ye}from"./chunk-AOSFSYEA.js";import{b as en,e as $,f as ge,h as tn,j as re,s as q,t as Se}from"./chunk-AYRHVJXW.js";import{a as Yt,f as me,n as Xt,p as Zt}from"./chunk-GAE7WCBK.js";import{B as Gt,E as Qt,e as $t,f as Ht,s as Ge}from"./chunk-WAU7HVDI.js";import{a as Wt,c as qt,d as zt,g as Ye,q as W,r as Kt,s as C,u as de,v as Vt,x as Jt}from"./chunk-FC5K7T35.js";import{a as Y}from"./chunk-64MNV6AB.js";import{execFileSync as on}from"child_process";import{existsSync as Xe,readFileSync as Hr}from"fs";import{createRequire as Kr}from"module";import{platform as an}from"os";import{dirname as sn,join as Re}from"path";var Vr=Kr(import.meta.url),cn={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Ze(t){return[t.indexerBinary,...t.binaryAliases??[]]}function Jr(t){let e=Ze(t);return e.length===1?e[0]:e.join(" or ")}function et(t){for(let e of Ze(t))if(an()==="win32"){let n=nn(e);if(n)return n}else if(Qe(e))return e;return Gr(t)}function oa(t){return et(t)!==null||Yr(t)}function Yr(t){return ln(t)!==null}function Gr(t){let e=ln(t);if(!e)return null;let r=JSON.parse(Hr(e,"utf8")).bin;if(!r)return null;if(typeof r=="string")return Re(sn(e),r);for(let i of Ze(t)){let s=r[i];if(s)return Re(sn(e),s)}return null}function ln(t){if(!t.bundledNpmPackage)return null;try{return Vr.resolve(`${t.bundledNpmPackage}/package.json`)}catch{return null}}function Qr(t,e){for(let n of t.projectLocalBinaries??[]){let r=Re(e,n);if(Xe(r))return r}return null}function Xr(t,e){return Qr(t,e)??et(t)}function aa(t,e=process.env,n=t.indexerBinary){if(t.indexerBinary!=="scip-dotnet"||tt(n,e))return e;let r=pn(n,e);return r?{...e,DOTNET_ROOT:r}:e}function un(t,e){let n=Jr(t),r=e?Xr(t,e):et(t);if(!r)return{language:t.language,binaryLabel:n,installed:!1,runnable:!1,resolvedBinary:null,installUrl:t.installUrl};if(t.indexerBinary!=="scip-dotnet")return{language:t.language,binaryLabel:n,installed:!0,runnable:!0,resolvedBinary:r};let i=Zr(r);return{language:t.language,binaryLabel:n,installed:!0,runnable:i.runnable,resolvedBinary:r,installUrl:t.installUrl,note:i.note}}function Zr(t){if(tt(t,process.env))return{runnable:!0};let e=pn(t,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let n=fn(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function pn(t,e){for(let n of fn(e))if(tt(t,{...e,DOTNET_ROOT:n}))return n;return null}function fn(t){let e=[],n=t.DOTNET_ROOT;if(n&&Xe(n)&&e.push(n),an()==="darwin"&&Qe("brew"))try{let r=on("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:t}).toString().trim(),i=Re(r,"libexec");Xe(i)&&!e.includes(i)&&e.push(i)}catch{}return e}function tt(t,e){try{return on(t,["--version"],{stdio:"pipe",env:e}),!0}catch{return!1}}function he(t){try{return process.kill(t,0),!0}catch(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EPERM"}}import{mkdirSync as ei,renameSync as ti,writeFileSync as ni}from"fs";import{dirname as ri}from"path";function be(t,e,n={}){ei(ri(t),{recursive:!0});let r=`${t}.${process.pid}.${Date.now()}.tmp`,i=JSON.stringify(e,null,n.spacing);ni(r,n.trailingNewline?`${i}
|
|
2
|
+
`:i),ti(r,t)}function nt(t,e){let n=t.split("/").at(-1)??t;if(Rn.has(n)||n===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(n))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(t.toLowerCase()))return"ambient";let r=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return e.some(i=>(hn[i]??[]).includes(r))?"source":"other"}function gn(t,e,n){let r=t.split("/").at(-1)??t;if(n?.includes(t)||n?.includes(r)||Rn.has(r))return!0;let i=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return(hn[e]??[]).includes(i)}function Sn(t){if(typeof t!="object"||t===null)return null;let e=t;return typeof e.version!="number"||!dn(e.languages)||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||!dn(e.typescriptProjects)||e.clojureConfigPath!==void 0&&typeof e.clojureConfigPath!="string"||!Array.isArray(e.files)||!e.files.every(ii)?null:e}function da(t,e){let n=new Map((t?.files??[]).map(a=>[a.path,a])),r=new Map(e.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),s=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),p=nt(a,e.languages);!c&&l?s.push({kind:"added",path:a,inputKind:p,after:l}):c&&!l?s.push({kind:"deleted",path:a,inputKind:p,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&s.push({kind:"modified",path:a,inputKind:p,before:c,after:l})}let o=new Set;return t||o.add("prior-snapshot-unavailable"),t&&t.version!==e.version&&o.add("snapshot-version-changed"),(mn(t?.files??[])||mn(e.files))&&o.add("duplicate-input-path"),[...t?.files??[],...e.files].some(si)&&o.add("unreadable-input"),{version:1,changes:s,projectIdentityChanged:t?!oi(t,e):!0,uncertainty:[...o].sort()}}function dn(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function mn(t){return new Set(t.map(e=>e.path)).size!==t.length}function ii(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.path=="string"&&typeof e.size=="number"&&typeof e.hash=="string"}function si(t){return t.hash==="unreadable"||t.size<0}function oi(t,e){return yn(t.languages,e.languages)&&t.pnpmWorkspaces===e.pnpmWorkspaces&&t.typescriptProjectMode===e.typescriptProjectMode&&yn(t.typescriptProjects,e.typescriptProjects)&&t.clojureConfigPath===e.clojureConfigPath}function yn(t,e){if(t.length!==e.length)return!1;let n=[...t].sort(),r=[...e].sort();return n.every((i,s)=>i===r[s])}var Rn=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),hn={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import{execFileSync as ai}from"child_process";import{createHash as bn}from"crypto";import{lstatSync as ci,readdirSync as li,readFileSync as ui,readlinkSync as pi,realpathSync as In}from"fs";import{isAbsolute as fi,join as vn,relative as di,sep as mi}from"path";function yi(t){return[...new Set((t??[]).map(e=>e.trim()).filter(Boolean))].sort((e,n)=>e.localeCompare(n))}function gi(t){return(Ri(t)??hi(t)).filter(e=>e&&!xn(e)).sort()}function rt(t,e={}){let n=gi(t).filter(i=>!e.language||gn(i,e.language,e.markerFiles)).filter(i=>!e.includePath||e.includePath(i)),r=In(t);return n.map(i=>{let s=vn(t,i);try{if(ci(s).isSymbolicLink()){let a=In(s),c=di(r,a);if(c===".."||c.startsWith(`..${mi}`)||fi(c))throw new Error("external symlink");let l=pi(s);return{path:i,size:Buffer.byteLength(l),hash:bn("sha256").update("symlink\0").update(l).digest("hex")}}let o=ui(s);return{path:i,size:o.byteLength,hash:bn("sha256").update(o).digest("hex")}}catch{return{path:i,size:-1,hash:"unreadable"}}})}function ba(t,e,n){return{version:2,languages:[...e].sort(),pnpmWorkspaces:n.typescriptProjectMode!=="workspace"&&n.pnpmWorkspaces===!0,typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:yi(n.typescriptProjects),clojureConfigPath:Si(n.clojureConfigPath),files:rt(t)}}function Si(t){return t?.trim()||void 0}function Ri(t){try{return ai("git",["-C",t,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
|
|
3
|
+
`).filter(Boolean)}catch{return null}}function hi(t){let e=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?vn(t,r):t,s;try{s=li(i,{withFileTypes:!0})}catch{continue}for(let o of s){let a=r?`${r}/${o.name}`:o.name;if(o.isDirectory()){xn(a)||n.push(a);continue}e.push(a)}}return e}function xn(t){let e=t.split("/");return t==="meta.json"||e.some(n=>bi.has(n))||t.endsWith(".db")||t.endsWith(".db-wal")||t.endsWith(".db-shm")||t.endsWith(".scip")}var bi=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);function Mn(t){let e=new Map,n=vi(t),r=new Map;return i=>{let s=Ii(i),o=r.get(s);if(o!==void 0)return o;if(!n.has(i.file))return r.set(s,i.symbol),i.symbol;let a=e.get(i.file);a||(a=xi(q(t,i.file)),e.set(i.file,a));let c=Mi(a,i);return r.set(s,c),c}}function Ii(t){return`${t.file}\0${t.symbol}\0${t.line}`}function vi(t){return new Set(t.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function xi(t){let e=new Map,n=new Map;for(let r of t){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let s=n.get(r.startLine);s?s.push(r):n.set(r.startLine,[r])}return{definitions:t,byLeaf:e,byStartLine:n}}function Mi(t,e){if(t.definitions.length===0)return e.symbol;let n=Ti(e.symbol),r=Ci(t.byLeaf,n),i=Di(r,e.line);if(i)return i.symbol;let s=t.byStartLine.get(e.line)??[];return s.length===1?s[0].symbol:e.symbol}function Ci(t,e){let n=[],r=new Set;for(let i of e)for(let s of t.get(i)??[])r.has(s.symbolId)||(r.add(s.symbolId),n.push(s));return n}function Di(t,e){let n=null;for(let r of t)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r)}return n}function Ti(t){let e=new Set([t]),r=t.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function Cn(t,e){let r=Zt(t,e).map(i=>ki(e,i));return{usage:r,positions:Fi(t,e,r)}}function Dn(t,e){return{importUsage(n){let r=t.importUsageFacts(n);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(n,r.positions);return i.available?Pi(r.usage,i.sourcePaths):r.usage}}}function Pi(t,e){return t.map((n,r)=>{let i=e.get(String(r));return i?{...n,sourcePath:i}:n})}function ki(t,e){let n=e.isTypeOnly===!0,r=e.kind==="side-effect"||n||e.used;return{importer:t,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:n,isUsed:r,isTypeUsed:n,isValueUsed:e.kind==="side-effect"||!n&&e.used,references:[]}}function Fi(t,e,n){let r=Qt(t,e);if(!r)return[];let i=wi(r.rootNode),s=new Map;for(let a of i){let c=s.get(st(a.importedName,a.localName));c?c.push(a.position):s.set(st(a.importedName,a.localName),[a.position])}let o=[];return n.forEach((a,c)=>{let l=s.get(st(a.importedName,a.localName??a.importedName))?.shift();l&&o.push({...l,id:String(c),file:e})}),o}function wi(t){let e=[];for(let n of t.descendantsOfType("use_declaration")){let r=n.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Ie(r,""))}return e.filter(n=>n.importedName!=="*")}function Ie(t,e){switch(t.type){case"identifier":case"super":case"self":case"crate":return[{importedName:t.text,localName:t.text,position:it(t,t.text)}];case"scoped_identifier":{let n=t.text.split("::").pop()??t.text;return[{importedName:n,localName:n,position:it(t,n)}]}case"scoped_use_list":{let n=t.namedChild(0),r=t.namedChild(1);if(!n||!r)return[];let i=Xt(e,n.text);return r.namedChildren.flatMap(s=>Ie(s,i))}case"use_list":return t.namedChildren.flatMap(n=>Ie(n,e));case"use_as_clause":{let n=t.namedChild(0),r=t.namedChild(1);return!n||!r?[]:Ie(n,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let n=t.namedChild(0),r="*";return[{importedName:r,localName:r,position:it(n??t,r)}]}default:return[]}}function it(t,e){let n=Math.max(0,t.text.lastIndexOf(e));return{id:"",file:"",line:t.startPosition.row,column:t.startPosition.column+n+Ei(e)}}function Ei(t){return Math.max(0,Math.min(t.length-1,1))}function st(t,e){return`${t}\0${e}`}import{spawnSync as mt}from"child_process";import{existsSync as yt}from"fs";import{fileURLToPath as vs}from"url";function ve(t){let e=un(cn,t),n=e.runnable;return{available:n,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,reason:n?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as ss,mkdtempSync as Kn,readFileSync as Vn,rmSync as lt}from"fs";import{tmpdir as Jn}from"os";import{join as ut}from"path";import{fileURLToPath as we,pathToFileURL as os}from"url";import{SHARE_ENV as as,Worker as cs}from"worker_threads";function z(t,e,n=new Set){let r=new Map;for(let i of t)n.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function H(t,e,n){let r=G(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(t/Math.max(1,n)));return Math.max(12e4,3e4+i*e)}import{spawn as Ki}from"child_process";import{createHash as Vi,randomUUID as Ji}from"crypto";import{existsSync as On,mkdirSync as Nn,readFileSync as Pe,realpathSync as Yi,rmSync as ct}from"fs";import{tmpdir as Gi}from"os";import{resolve as _}from"path";import{execFileSync as Wi}from"child_process";import{existsSync as Ni,readFileSync as Ai}from"fs";import{deserializeSCIP as _i,SymbolRole as ji}from"@c4312/scip";import{existsSync as Na,readFileSync as Aa}from"fs";import{relative as ja,resolve as La,sep as Oa}from"path";import{fileURLToPath as Ba,pathToFileURL as Wa}from"url";function Tn(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort((n,r)=>{let i=n.file.localeCompare(r.file);return i!==0?i:n.line!==r.line?n.line-r.line:n.column-r.column})}var ot=new WeakMap,Li="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function Va(t,e){let n=new Map,r=xe(),i=e.filter(o=>kn(o,r));if(i.length===0)return n;let s=Fn(t);if(!s)return n;for(let o of i){let a=Pn(s,o);a!==null&&n.set(o.symbolId,a)}return n}function Ja(t,e){if(!kn(e,xe()))return null;let n=Fn(t);return n?Pn(n,e):null}function Pn(t,e){return t.referencesBySymbol.get(e.symbol)??[]}function kn(t,e="safe"){if(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||re(t.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(t.symbol))return!1;if(e==="all")return!0;let n=ge(t.symbol);if(n==="method")return!0;if(n!=="term")return!1;let r=en(t.symbol);return"kind"in r?!1:!Oi(r)}function Oi(t){for(let e=0;e<t.descriptors.length-1;e+=1)if(t.descriptors[e]?.suffix==="type")return!0;return!1}function Fn(t){if(ot.has(t))return ot.get(t)??null;let e=Ui(t);return ot.set(t,e),e}function Ui(t){if(!Ni(t.config.indexPath))return null;try{let e=_i(Ai(t.config.indexPath)),n=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||t.isIgnored(i)))for(let s of r.occurrences??[]){if(!s.symbol||(s.symbolRoles&ji.Definition)!==0)continue;let o=Bi(i,s.range);if(!o)continue;let a=n.get(s.symbol)??[];a.push(o),n.set(s.symbol,a)}}for(let[r,i]of n)n.set(r,Tn(i));return{referencesBySymbol:n}}catch{return null}}function Bi(t,e){if(e.length<3)return null;let n=e[0],r=e[1];return!Number.isInteger(n)||!Number.isInteger(r)?null:{file:t,line:n,column:r}}function xe(){return process.env[Li]==="all"?"all":"safe"}var wn=new Map;function at(t){let n=ve(t).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:n,version:n?qi(t,n):"unavailable"}}function Za(t){return{...at(t),scipOccurrenceReferenceMode:xe()}}function qi(t,e){let n=`${t}\0${e}`,r=wn.get(n);if(r)return r;let i;try{i=Wi(e,["--version"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return wn.set(n,i),i}import{createHash as zi}from"crypto";var $i=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function En(t){let e=rt(t,{includePath:Hi});return zi("sha256").update(JSON.stringify(e)).digest("hex")}function Hi(t){let e=t.replaceAll("\\","/"),n=e.split("/").at(-1)??e;return e.endsWith(".rs")||$i.has(n)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}var Un=2,Qi=5e3,Xi=5e3,Bn=10,Zi=3e4;function An(t,e,n,r=Hn){let i=r.engineIdentity(t),s={protocolVersion:Un,projectRoot:r.canonicalProjectRoot(t),projectFingerprint:r.projectFingerprint(t),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:qn(r.environment())};return{key:Te(De(s)),...s}}function Me(t,e,n){return t.protocolVersion===Un&&(e-t.heartbeatAtMs<=Qi||t.busyUntilMs!==void 0&&e<=t.busyUntilMs)&&n(t.pid)}function Wn(t,e,n){let r;try{r=Te(Pe(e))}catch{r="missing"}let i=Te(De({projectRoot:_(t),serverPath:_(e),serverFingerprint:r})).slice(0,20);return _(n,`scip-query-rust-session-${i}`)}function _n(t){let e=t===void 0?Number.NaN:Number(t);return Number.isInteger(e)&&e>=0?e:0}function qn(t){return Object.fromEntries(Object.entries(t).filter(([e])=>$n(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function zn(t,e){let n=e.runtime??is,r=e.identityRuntime??Hn,i=Wn(t,e.serverPath,e.tempRoot??Gi()),s=!1,o=(a,c)=>{if(s)throw new Error("Durable Rust semantic session was already disposed.");return ts(i,e.serverPath,e.semanticWorkerPath,a,c,n)};return{requestSemantic(a,c){let l=An(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"semantic",identityKey:l.key,workerEnvironment:Ln(),request:{...a,readinessDeadlineMs:p,referenceRetryTimeoutMs:es(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:_n(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let l=An(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"import-definitions",identityKey:l.key,workerEnvironment:Ln(),request:{...a,readinessDeadlineMs:p,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:_n(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){s=!0}}}function es(t,e){return e!==void 0?e:t===void 0?Zi:void 0}function ts(t,e,n,r,i,s){let o=s.randomId(),a=s.now(),c=_(t,"requests"),l=_(t,"responses"),p=_(c,`${o}.json`),u=_(l,`${o}.json`);Nn(c,{recursive:!0}),Nn(l,{recursive:!0}),be(p,{id:o,request:r});let f=s.now()+i;try{for(jn(t,e,n,f,s);s.now()<=f;){if(On(u)){let m=ns(Pe(u,"utf8"));if(!m.ok)throw new Error(m.error);return W()&&de({type:"span",name:"rust.semantic.durable-session.request",durationMs:s.now()-a,ok:!0,session:m.session,kind:r.kind}),m.response}let d=Ce(t);(!d||!Me(d,s.now(),s.isProcessAlive))&&jn(t,e,n,f,s),s.sleep(Bn)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}finally{ct(p,{force:!0}),ct(u,{force:!0})}}function jn(t,e,n,r,i){let s=Ce(t);if(s&&Me(s,i.now(),i.isProcessAlive))return;ct(_(t,"server.json"),{force:!0}),i.spawnServer(e,t,n);let o=Math.min(r,i.now()+Xi);for(;i.now()<=o;){let a=Ce(t);if(a&&Me(a,i.now(),i.isProcessAlive))return;i.sleep(Bn)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function Ce(t){try{let e=JSON.parse(Pe(_(t,"server.json"),"utf8"));return typeof e.protocolVersion!="number"||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"?null:{protocolVersion:e.protocolVersion,pid:e.pid,heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs}}}catch{return null}}function ns(t){try{let e=JSON.parse(t);return e.ok===!0&&(e.session==="created"||e.session==="reused"||e.session==="invalidated")&&e.response&&typeof e.response=="object"?{ok:!0,session:e.session,response:e.response}:{ok:!1,error:typeof e.error=="string"?e.error:"helper wrote an invalid response"}}catch(e){return{ok:!1,error:`helper wrote malformed JSON: ${e instanceof Error?e.message:String(e)}`}}}function Ln(){return Object.fromEntries(Object.entries(process.env).filter(([t])=>rs(t)).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>[t,e??null]))}function $n(t){return t==="HOME"||t==="PATH"||t.startsWith("CARGO_")||t.startsWith("RA_")||t.startsWith("RUST")}function rs(t){return $n(t)||t.startsWith("SCIP_RUST_")||t==="SCIP_QUERY_PROFILE"||t==="SCIP_QUERY_PROFILE_CACHE_STATE"||t==="SCIP_QUERY_PROFILE_COMMAND"||t==="SCIP_QUERY_PROFILE_OUT"||t==="SCIP_QUERY_PROFILE_RUN_ID"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||t==="SCIP_QUERY_PROFILE_MIN_MS"}var Hn={canonicalProjectRoot(t){try{return Yi(t)}catch{return _(t)}},projectFingerprint(t){return En(t)},engineIdentity:at,fileFingerprint(t){return Te(Pe(t))},environment(){return qn(process.env)}},is={now:Date.now,randomId:Ji,isProcessAlive:he,spawnServer(t,e,n){if(!On(t))throw new Error(`Durable Rust semantic session helper was not found at ${t}. Run npm run build first.`);Ki(process.execPath,[t,e,n],{detached:!0,stdio:"ignore"}).unref()},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function De(t){return Array.isArray(t)?`[${t.map(De).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${De(n)}`).join(",")}}`:JSON.stringify(t)}function Te(t){return Vi("sha256").update(t).digest("hex")}var Yn=15e3,Gn=8,Xn=5e3,ls=64,us=96,ft=class{constructor(e,n,r={}){this.projectRoot=e;this.status=n;this.opts=r;this.requester=r.requester??ms(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,references:ie(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,references:z(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ie(e)}}}calleesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,callees:se(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,callees:pt(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:se(e)}}}referencesAndCalleesForDefinitions(e,n){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:ie(e),callees:se(n)};let i=[...e,...n];try{let s=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:n.length>0,referenceDefinitions:e,calleeDefinitions:n});return{available:s.available,resolvedBinary:r.resolvedBinary,reason:s.reason,references:z(e,new Map(s.references),new Set(s.incompleteReferenceSymbolIds??[])),callees:pt(n,new Map(s.callees??[]))}}catch(s){return this.fallbackReferencesAndCallees(r,e,n,s)}}signaturesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,signatures:Qn(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,signatures:hs(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:Qn(e)}}}importDefinitionsForFile(e,n){let r=this.status(this.projectRoot);if(n.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(n.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,n);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(n.map(s=>[s.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,n,r){let i=ke(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yn),s=Fe(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),o=ke(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Gn),a=Fe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,l=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,p=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,u=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,...r}),f={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...n],...c?{referenceDefinitions:c}:{},...l?{calleeDefinitions:l}:{},...p?{signatureDefinitions:p}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:a,settleDelayMs:u,concurrency:o,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=bs(f);return C("rust.semantic.session.request",()=>this.requester.requestSemantic(f,H(d,dt(i,f.referenceRetryTimeoutMs),o)),()=>({definitions:n.length,operationDefinitions:d,referenceDefinitions:f.referenceDefinitions?.length,calleeDefinitions:f.calleeDefinitions?.length,signatureDefinitions:f.signatureDefinitions?.length,references:f.includeReferences!==!1,callees:f.includeCallees===!0,signatures:f.includeSignatures===!0,referenceRetryTimeoutMs:f.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,n,r,i){let s=n.length===0?{available:!0,references:ie(n)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(n),o=r.length===0?{available:!0,callees:se(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return s&&o?{available:s.available&&o.available,resolvedBinary:s.resolvedBinary??o.resolvedBinary??e.resolvedBinary,reason:s.reason??o.reason,references:z(n,s.references),callees:pt(r,o.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ie(n),callees:se(r)}}requestImportDefinitions(e,n,r){let i=ke(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yn),s=ke(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Gn),o=Fe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Fe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Xn),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:n,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:o,settleDelayMs:a,concurrency:s};return C("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,H(r.length,i,s)),()=>({file:n,positions:r.length}))}};function Zn(t,e,n={}){return new ft(t,e,n)}function oe(t,e){let n=tr(t);if(n!==null)return n;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=ls||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=us?0:Xn}function ps(t){let e=t?.trim().toLowerCase(),n=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:n||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||n||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function fs(t){return ps(t).transport}function ds(t,e){let n=null,r=!1,i=!1,s=!1,o=()=>n??=e(),a=()=>{i||(t.shutdown(),i=!0)},c=(p,u,f)=>{let d=Rs(p);r=!0;try{a()}catch{}W()&&de({type:"span",name:"rust.semantic.durable-session.request",durationMs:f,ok:!1,kind:u,session:"worker-fallback",reason:d})},l=(p,u,f)=>{if(s)throw new Error("Rust semantic failover session was already disposed.");if(r)return f(o());let d=Date.now();try{return u(t)}catch(m){c(m,p,Date.now()-d)}return f(o())};return{requestSemantic(p,u){return l("semantic",f=>f.requestSemantic(p,u),f=>f.requestSemantic(p,u))},requestImportDefinitions(p,u){return l("import-definitions",f=>f.requestImportDefinitions(p,u),f=>f.requestImportDefinitions(p,u))},shutdown(){if(s)return;s=!0;let p=[];try{a()}catch(u){p.push(u)}try{n?.shutdown()}catch(u){p.push(u)}if(p.length>0)throw p[0]}}}function ms(t,e,n={worker:()=>ys(),durable:()=>zn(t,{serverPath:we(Is()),semanticWorkerPath:we(er())})}){return fs(e)==="durable"?ds(n.durable(),n.worker):n.worker()}function ys(t={}){let e=null,n=null,r=1,i=!1,s=()=>{n&&(lt(n,{recursive:!0,force:!0}),n=null)},o=()=>{let l=e;e=null,l&&l.terminate(),s()},a=()=>{if(e)return e;let l=t.semanticWorkerPath?os(t.semanticWorkerPath):er();if(!ss(we(l)))throw new Error(`Rust semantic session worker was not found at ${we(l)}. Run npm run build before using built semantic Rust queries.`);return n=Kn(ut(Jn(),"scip-query-rust-session-")),e=new cs(l,t.shareEnvironment?{env:as}:void 0),e.unref(),e},c=()=>{let l=n??Kn(ut(Jn(),"scip-query-rust-session-"));return n=l,ut(l,`${r++}.json`)};return{requestSemantic(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"semantic",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let y=gs(Vn(f,"utf8"));if(!y.ok)throw new Error(y.error);return y.response}finally{lt(f,{force:!0})}},requestImportDefinitions(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"import-definitions",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic import-definition session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let y=Ss(Vn(f,"utf8"));if(!y.ok)throw new Error(y.error);return y.response}finally{lt(f,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){s();return}let l=c(),p=new SharedArrayBuffer(4),u=new Int32Array(p);e.postMessage({kind:"shutdown",responsePath:l,sharedBuffer:p}),Atomics.wait(u,0,0,5e3),o()}}}function gs(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ss(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Rs(t){let e=t instanceof Error?`${t.name} ${t.message}`.toLowerCase():String(t).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ie(t){return new Map(t.map(e=>[e.symbolId,[]]))}function se(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Qn(t){return new Map(t.map(e=>[e.symbolId,null]))}function pt(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??[]]))}function hs(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function bs(t){let e=0;return t.includeReferences!==!1&&(e+=(t.referenceDefinitions??t.definitions).length),t.includeCallees===!0&&(e+=(t.calleeDefinitions??t.definitions).length),t.includeSignatures===!0&&(e+=(t.signatureDefinitions??t.definitions).length),Math.max(1,e)}function dt(t,e){return e&&e>0?Math.max(t,e):t}function er(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Is(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function ke(t,e){return G(t)??e}function Fe(t,e){return tr(t)??e}function tr(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)&&e>=0?e:null}var gt=15e3,St=8;function sr(t,e={}){let n=e.status??ve,r=Cs(t,n),i=Ds(t,n),s=Ts(t,n),o=e.referenceResolver||e.calleeResolver||e.signatureResolver||!xs(e)?null:Zn(t,n,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:s}),a=e.referenceResolver??o??r,c=e.calleeResolver??o??i,l=e.signatureResolver??o??s,p=e.importUsageResolver??Dn(e.sourceImportUsageResolver??Ms(),e.importDefinitionResolver??o),u=e.calleeSymbolResolver,f=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,m=new Map,h=new Map,y=null,S=null,v=()=>(y??=n(t),y),L=()=>{let g=v();return g.dependencyAvailable?S??g:g},P=g=>{if(g.length===0)return new Map;let I=ae(g);try{let R=a.referencesForDefinitions(I),x=v();return S={...x,available:R.available,resolvedBinary:R.resolvedBinary??x.resolvedBinary,reason:R.reason??x.reason},R.available?new Map(R.references):z(I,R.references)}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},K(I)}},O=g=>{if(g.length===0)return new Map;let I=ae(g),R=I.filter(nr);if(R.length===0)return V(I);let x=new Map,ne=ir(R,d),A=[];for(let M of R)h.has(M.symbolId)?x.set(M.symbolId,h.get(M.symbolId)??[]):ne.has(M.symbolId)?x.set(M.symbolId,ne.get(M.symbolId)??[]):rr(M,f)?x.set(M.symbolId,[]):A.push(M);if(A.length===0)return Q(I,x,void 0);try{let M=c.calleesForDefinitions(A),B=v();S={...B,available:M.available,resolvedBinary:M.resolvedBinary??B.resolvedBinary,reason:M.reason??B.reason};let D=Q(A,M.callees,u);for(let[J,Ke]of D)x.set(J,Ke);return Q(I,x,void 0)}catch(M){return S={...v(),available:!1,reason:M instanceof Error?M.message:String(M)},V(I)}},U=(g,I)=>{let R=ae(g),x=ae(I),ne=x.filter(nr),A=new Map,M=ir(ne,d),B=[];for(let D of ne)M.has(D.symbolId)?A.set(D.symbolId,M.get(D.symbolId)??[]):rr(D,f)?A.set(D.symbolId,[]):B.push(D);if(R.length===0&&B.length===0)return{references:K(R),callees:Q(x,A,void 0)};try{let D=o?o.referencesAndCalleesForDefinitions(R,B):ws(a,c,{referenceDefinitions:R,calleeDefinitions:B}),J=v();S={...J,available:D.available,resolvedBinary:D.resolvedBinary??J.resolvedBinary,reason:D.reason??J.reason};let Ke=D.available?new Map(D.references):z(R,D.references);for(let[Ve,Je]of D.callees)A.set(Ve,Je);let Bt=Q(x,A,u);for(let[Ve,Je]of Bt)h.set(Ve,Je);return{references:Ke,callees:Bt}}catch(D){return S={...v(),available:!1,reason:D instanceof Error?D.message:String(D)},{references:K(R),callees:V(x)}}},N=g=>{if(g.length===0)return new Map;let I=ae(g);try{let R=l.signaturesForDefinitions(I),x=v();return S={...x,available:R.available,resolvedBinary:R.resolvedBinary??x.resolvedBinary,reason:R.reason??x.reason},or(I,R.signatures)}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},Ee(I)}};return{language:"rust",availability:L,dispose:()=>{o?.dispose()},importUsage:g=>{let I=m.get(g);if(I)return I;try{let R=p.importUsage(g);return m.set(g,R),R}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},[]}},referencesFor:g=>P([g]).get(g.symbolId)??[],referencesForDefinitions:P,referencesAndCalleesForDefinitions:U,calleesFor:g=>O([g]).get(g.symbolId)??[],calleesForDefinitions:O,signatureFor:g=>N([g]).get(g.symbolId)??null}}function xs(t){if(t.usePersistentSession!==void 0)return t.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function Ms(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function ae(t){return t.map(e=>{let n=e;return{...e,leaf:typeof n.leaf=="string"?n.leaf:$(e.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:tn(e.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function nr(t){return t.isFunctionLike}function rr(t,e){if(!e)return!1;try{return e(t)}catch{return!1}}function ir(t,e){if(!e||t.length===0)return new Map;try{return e(t)}catch{return new Map}}function Cs(t,e){return{referencesForDefinitions:n=>Ps(t,e,n)}}function Ds(t,e){return{calleesForDefinitions:n=>ks(t,e,n)}}function Ts(t,e){return{signaturesForDefinitions:n=>Fs(t,e,n)}}function Ps(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:K(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:K(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=Ne(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),c=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),p={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,...o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:c,settleDelayMs:l,concurrency:a},u=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(p),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,dt(s,p.referenceRetryTimeoutMs),a)}),f=ht(u.stdout);if(f)return{available:f.available,resolvedBinary:r.resolvedBinary,reason:f.reason,references:z(n,new Map(f.references),new Set(f.incompleteReferenceSymbolIds??[]))};let d=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:K(n)}}function ks(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:V(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:V(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!0},p=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,s,o)}),u=ht(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,callees:Q(n,new Map(u.callees??[]),void 0)};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,callees:V(n)}}function Fs(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:Ee(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:Ee(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!1,includeSignatures:!0},p=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,s,o)}),u=ht(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,signatures:or(n,new Map(u.signatures??[]))};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,signatures:Ee(n)}}function ws(t,e,n){let r=n.referenceDefinitions.length>0?t.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:K(n.referenceDefinitions)},i=n.calleeDefinitions.length>0?e.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:V(n.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function K(t){return new Map(t.map(e=>[e.symbolId,[]]))}function V(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Ee(t){return new Map(t.map(e=>[e.symbolId,null]))}function Q(t,e,n){let r=0,i=0;return C("rust.semantic.callees.complete-map",()=>{let s=new Map;for(let o of t){let a=e.get(o.symbolId)??[];a.length>0&&(r+=1),i+=a.length,s.set(o.symbolId,a.map(c=>({...c,symbol:n?n(c):c.symbol})))}return s},()=>({definitions:t.length,rows:r,callees:i,resolveSymbols:!!n}))}function or(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function Rt(){return vs(new URL("./rust-semantic-worker.js",import.meta.url))}function ht(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e;return typeof n.available!="boolean"||!Array.isArray(n.references)?null:{available:n.available,reason:typeof n.reason=="string"?n.reason:void 0,references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0}}catch{return null}}function X(t,e){return G(t)??e}function Ne(t,e){if(!t)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}import{existsSync as Es,readFileSync as Ns}from"fs";import{deserializeSCIP as As,SymbolRole as _s}from"@c4312/scip";var bt=new WeakMap;function cr(t,e){let n=e.filter(js);if(n.length===0)return new Map;let r=!1,i=0,s=0;return C("rust.scip-occurrence.callees",()=>{let o=Us(t);if(r=!!o,!o)return new Map;let a=new Map;for(let c of n){let l=Ls(t,o,c);l!==null&&(a.set(c.symbolId,l),i+=1,s+=l.length)}return a},()=>({definitions:e.length,candidates:n.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:s}))}function js(t){return!(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||!t.isFunctionLike||t.leaf==="main"||re(t.symbol))}function Ls(t,e,n){let r=me(t,n.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(l=>l.startLine!==n.startLine||l.endLine!==n.endLine?!1:l.name===n.leaf||n.leaf.endsWith(l.name)||l.name.endsWith(n.leaf));if(!i)return null;let s=r.callSites.filter(l=>l.line>=i.startLine&&l.line<=i.endLine);if(s.length===0)return null;let o=(e.occurrencesByFile.get(n.relativePath)??[]).filter(l=>l.line>=i.startLine&&l.line<=i.endLine&&l.callee.symbol!==n.symbol);if(o.some(l=>l.traitImplMember)||!Os(s,o))return null;let a=[],c=new Set;for(let l of o){let p=`${l.callee.symbol}\0${l.callee.file}\0${l.callee.line}`;c.has(p)||(c.add(p),a.push(l.callee))}return a}function Os(t,e){let n=ar(t),r=ar(e);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function ar(t){let e=new Map;for(let n of t){let r=n.calleeLeaf??n.leaf;if(!r)continue;let i=`${n.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function Us(t){if(bt.has(t))return bt.get(t)??null;let e=Bs(t);return bt.set(t,e),e}function Bs(t){if(!Es(t.config.indexPath))return null;try{let e=Se(t).filter(s=>s.symbol.startsWith("rust-analyzer ")&&s.relativePath.endsWith(".rs")&&s.isFunctionLike),n=new Map(e.map(s=>[s.symbol,s])),r=As(Ns(t.config.indexPath)),i=new Map;for(let s of r.documents??[]){let o=s.relativePath;if(!o||!o.endsWith(".rs")||t.isIgnored(o))continue;let a=[];for(let c of s.occurrences??[]){if(!c.symbol||(c.symbolRoles&_s.Definition)!==0)continue;let l=n.get(c.symbol);if(!l)continue;let p=c.range?.[0];Number.isInteger(p)&&a.push({line:p,leaf:l.leaf,traitImplMember:re(l.symbol),callee:{symbol:l.symbol,file:l.relativePath,line:l.startLine}})}i.set(o,a)}return{occurrencesByFile:i}}catch{return null}}var Ae=class{sessions=new WeakMap;getOrCreate(e,n,r){let i=Ws(e,n),s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let o=s.get(i);if(o)return o.hits+=1,o.lastUsedAtMs=Date.now(),o.provider;let a=Date.now(),c=r();return s.set(i,{key:i,language:n,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let n=this.sessions.get(e);if(n)for(let r of n.values())r.provider.dispose?.();this.sessions.delete(e)}};function Ws(t,e){return`${t.config.projectRoot}:${e}-workspace`}import{randomUUID as ko}from"crypto";import{existsSync as Fo,mkdirSync as Lr,readFileSync as wo,rmSync as Or}from"fs";import{dirname as Eo,resolve as Ur}from"path";import{readFileSync as qs}from"fs";import{join as It}from"path";var lr=5e3,zs="watch.lock",$s="watch-state.json",Hs="watch-activity.json";function ur(t){return{lockPath:It(t,zs),statePath:It(t,$s),activityPath:It(t,Hs)}}function vt(t){try{return Ks(JSON.parse(qs(t,"utf8")))}catch{return null}}function Ks(t){if(!t||typeof t!="object")return null;let e=t;return e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||e.worktreeId!==void 0&&(typeof e.worktreeId!="string"||e.worktreeId.length===0)||typeof e.cliVersion!="string"||!w(e.startedAt)||!w(e.heartbeatAt)||!w(e.lastActivityAt)||!Vs(e.watcher)||e.idleDeadlineAt!==void 0&&!w(e.idleDeadlineAt)||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Js(e.lastError)||e.lastRefresh!==void 0&&!Ys(e.lastRefresh)||e.reindexActivity!==void 0&&!Gs(e.reindexActivity)||e.typescriptSemantic!==void 0&&!Qs(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!Xs(e.typescriptIndex)?null:e}function w(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function Vs(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return F(e.changedFiles)&&F(e.reindexAt);case"indexing":return F(e.startedAt);case"cooldown":return F(e.until)&&typeof e.dirty=="boolean";default:return!1}}function Js(t){if(!t||typeof t!="object")return!1;let e=t;return w(e.at)&&typeof e.message=="string"}function Ys(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&w(e.startedAt)&&w(e.completedAt)&&F(e.durationMs)}function Gs(t){if(!t||typeof t!="object")return!1;let e=t;return!w(e.windowStartedAt)||!w(e.windowEndedAt)||!k(e.runs)||!k(e.rebuilt)||!k(e.reused)||!k(e.failed)||!k(e.suppressed)||!F(e.estimatedLogicalOutputBytes)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"?!1:Object.values(e.byTrigger).every(n=>n===void 0||k(n))}function Qs(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&F(e.requests)&&F(e.sessionsCreated)&&F(e.sessionsReused)&&F(e.sessionsRefreshed)&&F(e.sessionsReplaced)&&F(e.projectsCreated)&&(e.lastRequestAt===void 0||w(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||w(e.busyUntil))}function Xs(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&k(e.requests)&&k(e.sessionsCreated)&&k(e.sessionsReplaced)&&k(e.initializations)&&k(e.programUpdates)&&k(e.documentsEmitted)&&k(e.documentsRemoved)&&(e.lastRequestAt===void 0||w(e.lastRequestAt))&&(e.lastDurationMs===void 0||F(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||w(e.busyUntil))}function F(t){return typeof t=="number"&&Number.isFinite(t)}function k(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}import{performance as b}from"perf_hooks";function E(t,e,n){if(t.has(e))return t.get(e);let r=n();return t.set(e,r),r}import pr from"path";function Zs(t,e){return t.getReferences().map(n=>{let r=n.getNode();return _e(r,e)})}function eo(t){let e=t;return typeof e.findReferences=="function"?e.findReferences():[]}function fr(t,e,n,r){let i=[];for(let s of eo(t))for(let o of Zs(s,r))o.file===e.relativePath&&o.line>=e.startLine&&o.line<=e.endLine||i.push(o);for(let s of n)i.push(s);return Z(i)}function dr(t,e,n,r){let i=[],s=n?.getStart();for(let o of t.getReferences()){let a=o.getNode();ee(r,a.getSourceFile().getFilePath())===e&&(s!==void 0&&a.getStart()===s||i.push({location:_e(a,r),node:a}))}return i}function _e(t,e){let n=t.getSourceFile(),r=n.getLineAndColumnAtPos(t.getStart());return{file:ee(e,n.getFilePath())??n.getBaseName(),line:r.line-1,column:r.column-1}}function mr(t,e,n){let r=t.getSourceFile(),i=Mt(r,t),s=t.getText(),o=new RegExp(`\\b${Yt(s)}\\b`,"g"),a=r.getFullText().split(`
|
|
4
|
+
`),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let p=a[l]??"";o.lastIndex=0;let u;for(;(u=o.exec(p))!==null;)c.push({file:e,line:l,column:u.index})}return Z(c.filter(l=>ee(n,pr.join(n,l.file))===e))}function xt(t){for(let e=t;e;e=e.getParent()){let n=e.getKindName();if(n.includes("Type")||n==="InterfaceDeclaration"||n==="TypeAliasDeclaration")return!0;if(n==="CallExpression"||n==="NewExpression"||n==="ExpressionStatement")return!1}return!1}function Mt(t,e){return t.getLineAndColumnAtPos(e.getStart()).line-1}function Z(t){let e=new Set,n=[];for(let r of t){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),n.push(r))}return n}function ee(t,e){let n=pr.relative(t||process.cwd(),e).replace(/\\/g,"/");return!n||n.startsWith("..")?null:n}function yr(t,e,n,r){let i=to(e,r);return i.size===0?new Map:no(t,n,i)}function to(t,e){let n=new Map;for(let r of q(t,e)){let i=$(r.symbol)??r.leaf;if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push(r)}return n}function no(t,e,n){let r=new Map,i=new Map;return e.forEachDescendant(s=>{for(let o of ro(t,s)){let a=n.get(o);if(!a)continue;let c=Mt(e,s);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let p=Math.abs(c-l.startLine),u=i.get(l.symbolId);u!==void 0&&u<=p||(i.set(l.symbolId,p),r.set(l.symbolId,s))}}}),r}function ro(t,e){let n=[],r=i=>{i&&!n.includes(i)&&n.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return t.Node.isIdentifier(e)&&r(e.getText()),n}var io=qt("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function gr(t,e,n,r){let i=Tt(t,e),s=Ct(i.get(r)??[],n);if(s)return s;let o=[];for(let a of i.values())for(let c of a)((c.leaf||$(c.symbol)||"").includes(r)||c.symbol.includes(r))&&o.push(c);return Ct(o,n)}function Dt(t,e,n,r){return Ct(Tt(t,e).get(r)??[],n)}function Sr(t,e){let n=new Map;for(let[r,i]of Tt(t,e)){let s=i[0];s&&n.set(r,s)}return n}function Tt(t,e){return io.get(t,e,()=>{let n=new Map;for(let r of q(t,e)){let i=r.leaf||$(r.symbol);if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push({...r,leaf:i})}for(let r of n.values())r.sort((i,s)=>i.startLine-s.startLine||i.endLine-s.endLine||i.symbolId-s.symbolId);return n})}function Ct(t,e){let n=null,r=Number.POSITIVE_INFINITY;for(let i of t){let s=Math.abs(i.startLine-e);(s<r||s===r&&n&&i.startLine<n.startLine)&&(n=i,r=s)}return n}import Pt from"path";var ce=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function j(t){let e=t.toLowerCase();return ce.some(n=>e.endsWith(n))}function Rr(t,e){let n=new Map,r=null,i=null,s=()=>(i??=Y(t,{extensions:ce}),i),o=()=>(r??=C("typescript.source-file-index",()=>so(t.config.projectRoot,e,s()),()=>({projects:e.length,indexedDocuments:s().length})),r),a=c=>j(c)?E(n,c,()=>{let l=le(Pt.resolve(t.config.projectRoot,c));for(let{project:p,sourceFiles:u}of o()){let f=u.get(l)??null;if(f||(f=p.addSourceFileAtPathIfExists(l)??null,f&&u.set(le(f.getFilePath()),f)),f)return{project:p,sourceFile:f}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:s}}function so(t,e,n){let r=e.map(({project:i})=>({project:i,sourceFiles:new Map(i.getSourceFiles().map(s=>[le(s.getFilePath()),s]))}));for(let i of n){let s=le(Pt.resolve(t,i));for(let o of r){if(o.sourceFiles.has(s))break;let a=o.project.addSourceFileAtPathIfExists(s)??null;if(a){o.sourceFiles.set(le(a.getFilePath()),a);break}}}return r}function le(t){return Pt.resolve(t)}function kt(t,e){for(let n of t)if(e===n.name||e.startsWith(`${n.name}/`))return n.name;return null}function hr(t){let e=`${t.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as ue,readFileSync as oo}from"fs";import T from"path";var Ft=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function wt(t,e){let r=e?T.dirname(T.join(t,e)):t,i=T.resolve(t);for(;r.startsWith(i);){for(let o of Ft){let a=T.join(r,o);if(ue(a))return a}let s=T.dirname(r);if(s===r)break;r=s}for(let s of Ft){let o=T.join(t,s);if(ue(o))return o}return null}function br(t){let e=t.config.projectRoot,n=new Set(ao(e,t.config.semantic?.typescript?.tsconfigs)),r=Y(t,{includeIgnored:!1,extensions:ce});for(let i of r){let s=wt(e,i);s&&n.add(T.resolve(s))}if(n.size===0){let i=wt(e);i&&n.add(T.resolve(i))}return[...n].filter(i=>!Ir(e,i)).sort((i,s)=>i.localeCompare(s))}function ao(t,e=[]){let n=new Set;for(let r of e){let i=T.isAbsolute(r)?r:T.join(t,r);ue(i)&&n.add(T.resolve(i))}for(let r of co(t))for(let i of Ft){let s=T.join(r,i);ue(s)&&n.add(T.resolve(s))}if(n.size===0){let r=wt(t);r&&n.add(T.resolve(r))}return[...n].filter(r=>!Ir(t,r)).sort((r,i)=>r.localeCompare(i))}function co(t){let e=T.join(t,"package.json");if(!ue(e))return[];let n;try{n=JSON.parse(oo(e,"utf8"))}catch{return[]}return(Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[]).flatMap(i=>Ht(t,i))}function Ir(t,e){let n=T.relative(t,e).replace(/\\/g,"/");return n.startsWith("..")||n.includes("/node_modules/")||n.startsWith("node_modules/")||n.includes("/dist/")||n.startsWith("dist/")}import{createRequire as lo}from"module";var vr=lo(import.meta.url),pe,je;function Et(){if(pe!==void 0)return pe;try{pe=vr("ts-morph")}catch{pe=null}return pe}function Le(){if(je)return je;let t=Et();if(!t)return"ts-morph:unavailable";let e="unknown";try{e=vr("ts-morph/package.json").version??"unknown"}catch{}return je=`ts-morph:${e}:typescript:${t.ts.version}`,je}function xr(t,e){return e.map(n=>({tsconfigPath:n,project:new t.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function Oe(t,e,n){return{language:"typescript",availability:()=>({available:!1,reason:t,tsconfigPath:e,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function Ue(t,e){let n=new Map(t.map(i=>[i.symbol,i])),r=new Map(t.map(i=>[i.symbolId,[]]));for(let i of e.values())for(let s of i){let o=n.get(s.targetSymbol);o&&r.get(o.symbolId).push(s.location)}for(let[i,s]of r)r.set(i,uo(s));return r}function Dr(t,e,n){let r=Cr(t,e),i=Cr(t,n),s=[...r].filter(u=>!i.has(u)).sort(),o=[...i].filter(u=>!r.has(u)).sort(),a=Mr(t,e),c=Mr(t,n),l=[...a].filter(u=>!c.has(u)).sort(),p=[...c].filter(u=>!a.has(u)).sort();return{passed:s.length===0&&o.length===0,expectedCount:r.size,actualCount:i.size,missing:s,extra:o,callerFiles:{passed:l.length===0&&p.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:p}}}function Mr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function Tr(t,e,n){let r=new Set(n),i=new Map(n.map(s=>[s,[]]));for(let s of t)for(let o of e.get(s.symbolId)??[])r.has(o.file)&&i.get(o.file).push({targetSymbol:s.symbol,location:o});for(let[s,o]of i)i.set(s,po(o));return i}function Cr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function uo(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort(Pr)}function po(t){let e=new Map;for(let n of t){let{location:r}=n;e.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...e.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||Pr(n.location,r.location))}function Pr(t,e){return t.file.localeCompare(e.file)||t.line-e.line||t.column-e.column}var fo=32;function Ar(t,e){let n=C("typescript.provider.load",()=>Et());if(!n)return Oe("ts-morph is not installed");let r=C("typescript.provider.tsconfig-discovery",()=>br(t));if(r.length===0)return Oe("no tsconfig found");try{let i=C("typescript.provider.project-bundles",()=>xr(n,r),()=>({tsconfigs:r.length}));return mo(t,n,i)}catch(i){return Oe(i instanceof Error?i.message:String(i),r[0],r)}}function mo(t,e,n,r={}){return C("typescript.provider.construct",()=>new At(t,e,n),()=>({tsconfigs:n.length,reusedProjects:r.reusedProjects===!0}))}var At=class{constructor(e,n,r){this.db=e;this.tsMorph=n;this.projects=r;this.workspacePackages=$t(e.config.projectRoot),this.sourceFiles=Rr(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return E(this.importUsageCache,e,()=>{let n=this.sourceFiles.sourceFile(e);if(!n)return[];let r=go();return C("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,n,r),()=>({file:e,...r}))})}referencesFor(e){return E(this.referencesCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,n)})}referencesForDefinitions(e,n={}){let r=new Map,i=W(),s=[];for(let p of e){let u=this.referencesCache.get(p.symbolId);u?r.set(p.symbolId,u):s.push(p)}if(s.length===0)return r;let o=s,a=n.exact?[]:s.filter(p=>!Fr(p));if(a.length>=fo){let p=this.referencesForDefinitionsBySymbolScan(a);for(let u of a){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}if(o=s.filter(u=>Fr(u)),o.length===0)return r}let c=new Map;for(let p of o){let u=c.get(p.relativePath);u?u.push(p):c.set(p.relativePath,[p])}let l=[];for(let[p,u]of c){let f=wr();C("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(p);for(let m of u){i&&(f.cacheMisses+=1);let h=d.get(m.symbolId)??null;i&&(h?f.nodeHits+=1:f.nodeMisses+=1);try{let y=this.referencesForDefinitionNode(m,h,i?f:void 0);this.referencesCache.set(m.symbolId,y),r.set(m.symbolId,y)}catch{f.preciseSearchFailures+=1,l.push(m)}}},()=>({relativePath:p,definitions:u.length,...Er(f)}))}if(l.length>0){let p=this.referencesForDefinitionsBySymbolScan(l);for(let u of l){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}}return r}referenceFragmentsForFiles(e){let n=Se(this.db).filter(s=>j(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(n,r);return Tr(n,i,r)}referencesForDefinitionsBySymbolScan(e,n){let r=W(),i=wr(),s=new Map,o=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)s.set(c.symbolId,[]);return C("typescript.references-map.inverted-scan",()=>{let c=r?b.now():0,l=n?this.packageImportReferencesForFiles(n):this.packageImportReferences();for(let y of e){let S=l.get(y.symbolId)??[];if(S.length>0){let v=s.get(y.symbolId)??[];v.push(...S),s.set(y.symbolId,v)}r&&(i.packageReferenceCount+=S.length)}r&&(i.packageRefsMs+=b.now()-c);let p=new Map,u=new Map,f=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(y=>y.leaf).filter(Boolean)),m=r?b.now():0;for(let y of n??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(y))continue;let S=this.sourceFiles.sourceFile(y);S&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(S,y,o,a,f,d,p,u,s,r?i:void 0))}r&&(i.scanMs+=b.now()-m);let h=r?b.now():0;this.addHierarchyMemberReferences(e,s,r?i:void 0),r&&(i.hierarchyMs+=b.now()-h);for(let[y,S]of s){let v=Z(S);s.set(y,v),r&&(i.referenceCount+=v.length)}},()=>({definitions:e.length,...Er(i)})),s}addReferencesFromSourceFileScan(e,n,r,i,s,o,a,c,l,p){let u=this.compilerCheckerForSourceFile(e),f=e.compilerNode,d=ho(e),m=h=>{if(this.tsMorph.ts.isIdentifier(h)){if(p&&(p.identifiers+=1),!o.has(h.text)&&!d.has(h.text)){this.tsMorph.ts.forEachChild(h,m);return}let y=this.compilerReferenceSymbol(u,h,p);if(y){let S;a.has(y)?S=a.get(y)??null:(S=this.referenceDefinitionFromCompilerSymbol(y),a.set(y,S)),p&&(S?p.targetHits+=1:p.targetMisses+=1);let v=E(c,y,()=>this.compilerSymbolKeys(y)),L=null,P=null,O=S&&r.has(S.symbolId)?i.get(S.symbolId):void 0;if(O&&(L=Nt(f,h),!kr(O,n,L))){let U=f.getLineAndCharacterOfPosition(h.getStart(f));P={file:n,line:U.line,column:U.character};let N=l.get(O.symbolId)??[];N.push(P),l.set(O.symbolId,N),p&&(p.requestedHits+=1)}for(let U of v)for(let N of s.get(U)?.values()??[]){if(L??=Nt(f,h),kr(N,n,L))continue;if(!P){let I=f.getLineAndCharacterOfPosition(h.getStart(f));P={file:n,line:I.line,column:I.character}}let g=l.get(N.symbolId)??[];g.push(P),l.set(N.symbolId,g),p&&(p.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(h,m)};m(f)}hierarchyTargetsForDefinitions(e){let n=new Map;for(let r of e){let i=this.nodeForDefinition(r),s=i?.compilerNode;if(!s||!this.isHierarchyMethod(s))continue;let o=s.parent;if(!this.isHierarchyContainer(o))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(s.name);if(c)for(let l of this.hierarchyMemberSymbols(a,o,c))for(let p of this.compilerSymbolKeys(l)){let u=n.get(p)??new Map;u.set(r.symbolId,r),n.set(p,u)}}return n}hierarchyMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(!s.has(a)){s.add(a),i.add(c);for(let p of l){let u=p.getProperty(r.name);u&&o(p,u,this.hierarchyAncestorTypesForType(e,p))}}};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}addHierarchyMemberReferences(e,n,r){let i=new Map;for(let s of e){let o=this.nodeForDefinition(s),a=o?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let l=this.compilerCheckerForSourceFile(o.getSourceFile()),p=l.getSymbolAtLocation(a.name);if(!p)continue;let u=a.getSourceFile(),f=u.getLineAndCharacterOfPosition(a.name.getStart(u)),d={definition:s,location:{file:s.relativePath,line:f.line,column:f.character}},m=n.get(s.symbolId)??[];for(let y of this.hierarchyMemberSymbols(l,c,p))if(y!==p)for(let S of this.compilerSymbolLocations(y))m.push(S),r&&(r.hierarchyReferences+=1);n.set(s.symbolId,m);let h=this.hierarchyRootMemberSymbols(l,c,p);for(let y of h){let S=i.get(y)??new Map;S.set(s.symbolId,d),i.set(y,S)}r&&(r.hierarchyDefinitions+=1)}for(let s of i.values())if(!(s.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:o}of s.values()){let a=n.get(o.symbolId)??[];for(let c of s.values())c.definition.symbolId!==o.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));n.set(o.symbolId,a)}}}hierarchyRootMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(s.has(a))return;s.add(a);let p=!1;for(let u of l){let f=u.getProperty(r.name);f&&(p=!0,o(u,f,this.hierarchyAncestorTypesForType(e,u)))}if(!p)for(let u of this.compilerSymbolKeys(c))i.add(u)};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(n=>{let r=n.getSourceFile();return`${r.fileName}\0${n.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let n=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),s=ee(this.db.config.projectRoot,i.fileName);if(!s)continue;let o=r.name,a=i.getLineAndCharacterOfPosition((o??r).getStart(i));n.push({file:s,line:a.line,column:a.character})}return n}baseTypes(e,n){try{return e.getBaseTypes(n)??[]}catch{return[]}}hierarchyAncestorTypes(e,n){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(n)));for(let i of n.heritageClauses??[])for(let s of i.types)r.add(e.getTypeAtLocation(s));return[...r]}hierarchyAncestorTypesForType(e,n){let r=new Set(this.baseTypes(e,n));for(let i of n.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let s of i.heritageClauses??[])for(let o of s.types)r.add(e.getTypeAtLocation(o));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,n,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(n);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return E(this.calleesCache,e.symbolId,()=>E(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let n=new Map,r=new Map;for(let i of e){let s=r.get(i.relativePath);s?s.push(i):r.set(i.relativePath,[i])}for(let[i,s]of r){let o=this.fileCalleesCache.get(i),a=new Set(s.map(l=>l.symbolId)),c=o??this.calleeMapForFile(i,a);for(let l of s){let p=c.get(l.symbolId)??[];this.calleesCache.set(l.symbolId,p),n.set(l.symbolId,p)}}return n}referencesForDefinitionNode(e,n,r){let i=r?b.now():0,s=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=b.now()-i,r.packageReferenceCount+=s.length),!n)return s;let o=r?b.now():0,a=fr(n,e,s,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=b.now()-o,r.referenceCount+=a.length),a}signatureFor(e){return E(this.signatureCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);if(!n||!this.tsMorph.Node.isFunctionDeclaration(n)&&!this.tsMorph.Node.isMethodDeclaration(n)&&!this.tsMorph.Node.isArrowFunction(n)&&!this.tsMorph.Node.isFunctionExpression(n)&&!this.tsMorph.Node.isConstructorDeclaration(n))return null;let r=n.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(o=>{let a=o.getDeclarations()[0],c=a?o.getTypeAtLocation(a).getText(a):o.getValueDeclaration()?.getType().getText()??"unknown";return Nr(c)}),s=r.getReturnType().getText(n);return`(${i.join(",")})=>${Nr(s)}`})}importUsageForSourceFile(e,n,r){let i=[],s=new Map;for(let o of n.getImportDeclarations()){r.declarations+=1;let a=Ge(this.db,e,o.getModuleSpecifierValue()),c=o.getImportClause()?.isTypeOnly()??!1;for(let l of _t(o)){r.entries+=1;let p=c?null:l.identifier?.getSymbol()?.compilerSymbol??null;!c&&l.identifier&&(p?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let u={sourcePath:a,entry:l,typeOnlyDeclaration:c,bindingSymbol:p,references:[]};if(i.push(u),c||!l.localName||!p)continue;let f=s.get(l.localName);f?f.push(u):s.set(l.localName,[u])}}return s.size>0&&n.forEachDescendant(o=>{if(o.getKindName()!=="Identifier")return;let a=s.get(o.getText());if(!a||So(o))return;r.scannedIdentifiers+=1;let c=o.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let l of a)if(l.bindingSymbol===c){l.references.push({location:_e(o,this.db.config.projectRoot),node:o}),r.matchedReferences+=1;break}}}),i.map(o=>o.typeOnlyDeclaration?yo(e,o.sourcePath,o.entry):o.entry.identifier&&!o.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,o.sourcePath,o.entry)):this.valueImportUsageFromLocations(e,o.sourcePath,o.entry,o.references))}valueImportUsageForEntry(e,n,r){let i=r.identifier?r.identifier.findReferences():[],s=[];for(let o of i)for(let a of dr(o,e,r.identifier,this.db.config.projectRoot))s.push(a);return this.valueImportUsageFromLocations(e,n,r,s)}valueImportUsageFromLocations(e,n,r,i){let s=i.some(c=>!xt(c.node)),o=i.some(c=>xt(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:n,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||o,isValueUsed:s,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let n=new Map,r=new Set;for(let s of e){let o=this.sourceFiles.sourceFile(s);if(o)for(let a of o.getImportDeclarations()){let c=kt(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return n;let i=this.packageExportsForNames(r);for(let s of e)this.addPackageImportReferencesForDocument(n,i,s);for(let[s,o]of n)n.set(s,Z(o));return n}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,n=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,n,r);for(let[r,i]of e)e.set(r,Z(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,n,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let s of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,n,r,s)}addPackageImportReferencesForDeclaration(e,n,r,i){let s=kt(this.workspacePackages,i.getModuleSpecifierValue());if(!s)return;let o=n.get(s);if(o)for(let a of _t(i)){if(a.kind!=="named"||!a.identifier)continue;let c=o.get(a.importedName);if(!c||c.size===0)continue;let l=mr(a.identifier,r,this.db.config.projectRoot);l.length>0&&xo(e,c,l)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let n=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let s of hr(r))this.collectPackageExports(r,s,i,new Set);i.size>0&&n.set(r.name,i)}return n}collectPackageExports(e,n,r,i){if(i.has(n))return;i.add(n);let s=this.sourceFiles.sourceFile(n);if(s)for(let o of s.getExportDeclarations()){let a=o.getModuleSpecifierValue(),c=a?Ge(this.db,n,a):n;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let l=o.getNamedExports();if(l.length===0){if(o.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let p of l){let u=p.getNameNode().getText(),f=p.getAliasNode()?.getText()??u,d=this.indexedDefinitionByLeaf(c,u);if(!d)continue;let m=r.get(f);m||(m=new Set,r.set(f,m)),m.add(d.symbolId)}}}indexedDefinitionByLeaf(e,n){return E(this.indexedDefinitionLeafCache,e,()=>Sr(this.db,e)).get(n)??null}nodeForDefinition(e){return E(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return E(this.fileDefinitionNodeCache,e,()=>{let n=this.sourceFiles.sourceFile(e);return n?yr(this.tsMorph,this.db,n,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,n,r=!1){let i=e.name,s=n?b.now():0,o=e.declarations??[];n&&(n.declarationsMs+=b.now()-s,n.declarationChecks+=o.length);for(let a of o){let c=n?b.now():0,l=a.getSourceFile(),p=ee(this.db.config.projectRoot,l.fileName),u=l.getLineAndCharacterOfPosition(a.getStart(l)).line;if(n&&(n.declarationLocationMs+=b.now()-c),!p||this.db.isIgnored(p))continue;let f=n?b.now():0,d=this.compilerDeclarationName(a),m=r?Dt(this.db,p,u,i)??(d&&d!==i?Dt(this.db,p,u,d):null):gr(this.db,p,u,i);if(n&&(n.indexedLookupMs+=b.now()-f),m)return{symbolId:m.symbolId,symbol:m.symbol,file:m.relativePath,line:m.startLine}}return null}compilerDeclarationName(e){let n=e.name;return n&&this.tsMorph.ts.isIdentifier(n)?n.text:null}calleeMapForFile(e,n){let r=W(),i=0,s=0,o=0,a=0,c=0,l=0,p=0,u=0,f=r?Io():void 0;return C("typescript.callee-map.file",()=>{let d=r?b.now():0,m=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(b.now()-d)),!m)return new Map;let h=r?b.now():0,y=q(this.db,e).sort((g,I)=>g.startLine-I.startLine||I.endLine-g.endLine);if(r&&(l=Math.round(b.now()-h)),i=y.length,y.length===0)return new Map;let S=new Map,v=r?b.now():0,L=this.compilerCheckerForSourceFile(m),P=m.compilerNode;r&&(p=Math.round(b.now()-v));let O=new Map,U=g=>{if(this.tsMorph.ts.isCallExpression(g)||this.tsMorph.ts.isNewExpression(g)){r&&(s+=1);let I=this.semanticCalleeForCallNode(L,P,y,g,O,n,f);I&&(r&&(o+=1),Ro(S,I.callerId,I.target))}this.tsMorph.ts.forEachChild(g,U)},N=r?b.now():0;U(P),r&&(u=Math.round(b.now()-N));for(let[g,I]of S)S.set(g,Mo(I));return a=S.size,S},()=>({relativePath:e,definitions:i,callNodes:s,resolvedCallees:o,outputRows:a,requestedDefinitions:n?.size??i,sourceFileLookupMs:c,definitionsLoadMs:l,checkerLookupMs:p,traversalMs:u,...f?vo(f):{}}))}semanticCalleeForCallNode(e,n,r,i,s,o,a){let c=a?b.now():0,l=bo(r,Nt(n,i));if(a&&(a.callerLookupMs+=b.now()-c),!l)return null;if(o&&!o.has(l.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let p=i.expression,u=this.compilerSymbolForExpression(e,p,a),f=null;if(u)if(a&&(a.targetSymbolHits+=1),s.has(u))a&&(a.compilerSymbolCacheHits+=1),f=s.get(u)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?b.now():0;f=this.definitionFromCompilerSymbol(u,a),a&&(a.targetLookupMs+=b.now()-d),s.set(u,f)}else a&&(a.targetMisses+=1);return f?{callerId:l.symbolId,target:{symbol:f.symbol,file:f.file,line:f.line}}:null}compilerSymbolForExpression(e,n,r){let i=r?b.now():0,s=e.getSymbolAtLocation(n);if(r&&(r.expressionSymbolMs+=b.now()-i),s)return s;r&&(r.typeFallbacks+=1);let o=r?b.now():0,a=e.getTypeAtLocation(n).getSymbol();return r&&(r.typeSymbolMs+=b.now()-o),a}compilerCheckerForSourceFile(e){let n=e.getProject(),r=this.compilerCheckerCache.get(n);return r||(r=n.getTypeChecker().compilerObject,this.compilerCheckerCache.set(n,r)),r}};function _t(t){let e=[],n=t.getDefaultImport();n&&e.push({identifier:n,importedName:"default",localName:n.getText(),kind:"default",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});let r=t.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});for(let i of t.getNamedImports()){let s=i.getNameNode(),a=i.getAliasNode()??(s.getKindName()==="Identifier"?s:null);e.push({identifier:a,importedName:s.getText(),localName:a?.getText()??s.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(t.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function yo(t,e,n){return{importer:t,sourcePath:e,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function go(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function So(t){for(let e=t;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function Ro(t,e,n){let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}function ho(t){let e=new Set;for(let n of t.getImportDeclarations())for(let r of _t(n))r.localName&&e.add(r.localName);return e}function bo(t,e){let n=null;for(let r of t)e<r.startLine||e>r.endLine||(!n||r.startLine>=n.startLine)&&(n=r);return n}function Nt(t,e){return t.getLineAndCharacterOfPosition(e.getStart(t)).line}function kr(t,e,n){return e===t.relativePath&&n>=t.startLine&&n<=t.endLine}function Fr(t){return t.symbol.includes("#")?ge(t.symbol)==="type"&&t.relativePath.endsWith(".d.ts"):!1}function Io(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function vo(t){return{...t,callerLookupMs:Math.round(t.callerLookupMs),expressionSymbolMs:Math.round(t.expressionSymbolMs),typeSymbolMs:Math.round(t.typeSymbolMs),targetLookupMs:Math.round(t.targetLookupMs),declarationsMs:Math.round(t.declarationsMs),declarationLocationMs:Math.round(t.declarationLocationMs),indexedLookupMs:Math.round(t.indexedLookupMs)}}function wr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function Er(t){return{...t,scanMs:Math.round(t.scanMs),packageRefsMs:Math.round(t.packageRefsMs),semanticRefsMs:Math.round(t.semanticRefsMs),hierarchyMs:Math.round(t.hierarchyMs)}}function xo(t,e,n){for(let r of e){let i=t.get(r)??[];i.push(...n),t.set(r,i)}}function Mo(t){let e=new Set,n=[];for(let r of t){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),n.push(r))}return n}function Nr(t){return t.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{createHash as Co}from"crypto";import{readFileSync as Do}from"fs";import{dirname as To,join as Be}from"path";var We=2,Po="typescript-semantic";function _r(t){let e=Be(t,Po);return{rootDir:e,requestDir:Be(e,"requests"),responseDir:Be(e,"responses")}}function jr(t){try{let e=JSON.parse(Do(Be(To(t),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:Co("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}var No=12e4,Ao=5;function qr(t,e,n={}){let r=new jt(t,n),i=null,s=null,o=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Ar(t,e),i),c=(u,f,d)=>{if(o)return d();try{return f(r.request(u))}catch{return o=!0,d()}},l=(u,f)=>c({kind:"references",definitions:[...u],...f?.exact?{exact:!0}:{}},d=>Wr(d),()=>a().referencesForDefinitions?.(u,f)??new Map(u.map(d=>[d.symbolId,a().referencesFor(d)]))),p=u=>c({kind:"callees",definitions:[...u]},f=>Wr(f),()=>a().calleesForDefinitions?.(u)??new Map(u.map(f=>[f.symbolId,a().calleesFor(f)])));return{language:"typescript",availability:()=>(s??=c({kind:"availability"},Lo,()=>a().availability()),s),importUsage:u=>c({kind:"import-usage",file:u},f=>f,()=>a().importUsage(u)),referencesFor:u=>l([u]).get(u.symbolId)??[],referencesForDefinitions:l,referenceFragmentsForFiles:u=>c({kind:"reference-fragments",files:[...u]},f=>jo(f),()=>a().referenceFragmentsForFiles?.(u)??new Map),calleesFor:u=>p([u]).get(u.symbolId)??[],calleesForDefinitions:p,signatureFor:u=>c({kind:"signature",definition:u},Oo,()=>a().signatureFor(u)),dispose:()=>i?.dispose?.()}}var jt=class{constructor(e,n={}){this.db=e;this.runtime=n.runtime??Bo,this.timeoutMs=n.timeoutMs??Uo(),this.cacheDir=Eo(e.config.dbPath),this.projectRoot=rn(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;request(e){let n=ur(this.cacheDir),r=_r(this.cacheDir),i=vt(n.statePath);if(!Br(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let s=jr(this.db.config.dbPath);if(!s)throw new Error("Published TypeScript generation identity is unavailable.");let o=this.runtime.randomId(),a=Ur(r.requestDir,`${o}.json`),c=Ur(r.responseDir,`${o}.json`),l=this.runtime.now()+this.timeoutMs;Lr(r.requestDir,{recursive:!0}),Lr(r.responseDir,{recursive:!0}),be(a,{protocolVersion:We,id:o,generation:s,deadlineAtMs:l,profileEnvironment:Kt(),request:e});try{for(;this.runtime.now()<=l;){if(Fo(c))return _o(wo(c,"utf8"),o,s);let p=vt(n.statePath);if(!Br(p,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Ao)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}finally{Or(a,{force:!0}),Or(c,{force:!0})}}};function Br(t,e,n){let r=t!==null&&n.now()-Date.parse(t.heartbeatAt)<=lr,i=t?.typescriptSemantic?.busyUntil!==void 0&&n.now()<=Date.parse(t.typescriptSemantic.busyUntil);return t!==null&&t.projectRoot===e&&t.typescriptSemantic?.protocolVersion===We&&n.isProcessAlive(t.pid)&&(r||i)}function _o(t,e,n){let r=JSON.parse(t);if(r.protocolVersion!==We||r.id!==e||r.ok===!0&&r.generation!==n)throw new Error("TypeScript semantic service wrote an incompatible response.");if(r.ok===!0)return r.response;throw new Error(typeof r.error=="string"?r.error:"TypeScript semantic service request failed.")}function Wr(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(t)}function jo(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(t)}function Lo(t){if(!t||typeof t!="object"||typeof t.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return t}function Oo(t){if(t!==null&&typeof t!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return t}function Uo(){let t=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(t)&&t>0?t:No}var Bo={now:Date.now,randomId:ko,sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)},isProcessAlive:he};var zr=new Ae;Wt({name:"semantic-provider",groups:["semantic-provider"],clearAll:t=>zr.clear(t)});function Lt(t,e){let n=Wo(e)??"typescript";return zr.getOrCreate(t,n,()=>n==="rust"?sr(t.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>Cn(t,r)},calleeSymbolResolver:Mn(t),sourceZeroCalleeOracle:r=>qo(t,r),scipOccurrenceCalleeOracle:r=>cr(t,r)}):qr(t,e))}function Wo(t){return t?Gt(t)==="rust"?"rust":j(t)?"typescript":null:"typescript"}function qo(t,e){let n=me(t,e.relativePath);if(!n||n.language!=="rust")return!1;let r=n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!n.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}import{readFileSync as Ko}from"fs";import{dirname as Vo,join as Jo}from"path";function ze(t){let e=qe(t.projectFiles),n=new Set(e),r=new Map(t.snapshot.files.map(u=>[u.path,u])),i=t.snapshot.files.filter(u=>{let f=nt(u.path,["typescript"]);return f==="config"||f==="ambient"}).map(u=>u.path),s=qe([...e,...i]),o=s.find(u=>!r.has(u)),a=new Set(t.snapshot.files.map(u=>u.path)).size!==t.snapshot.files.length,c=!o&&s.some(u=>$r(r.get(u))),l=Ye(JSON.stringify({pnpmWorkspaces:t.snapshot.pnpmWorkspaces,typescriptProjectMode:t.snapshot.typescriptProjectMode,typescriptProjects:qe(t.snapshot.typescriptProjects),membership:e})),p=new Map;return{identityFor(u,f){if(!n.has(u))return te("target-outside-project");if(a)return te("duplicate-input-path");if(o)return te("missing-input-fingerprint");if(c)return te("unreadable-input");let d=[],m,h;if(t.graph===null)d.push("dependency-graph-unavailable"),h="whole-project",m=s;else{let v=$o(u,t.graph,p);if(v.find(P=>!r.has(P)))return te("missing-input-fingerprint");if(m=qe([...v,...i]),m.some(P=>$r(r.get(P))))return te("unreadable-input");h="dependency-closure"}let y=m.map(v=>Ho(r.get(v)));return{version:1,key:Ye(JSON.stringify({version:1,engineIdentity:t.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:y})),mode:h,inputFiles:m,reasons:d}}}}function zo(t,e){let n=new Set,r=[t];for(let i=0;i<r.length;i+=1){let s=r[i];if(!(s===void 0||n.has(s))){n.add(s);for(let o of[...e.get(s)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function $o(t,e,n){let r=n.get(t);if(r)return r;let i=zo(t,e);return n.set(t,i),i}function Ho(t){return{path:t.path,size:t.size,hash:t.hash}}function $r(t){return t.size<0||t.hash==="unreadable"}function te(t){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[t]}}function qe(t){return[...new Set(t)].sort()}var Yo=zt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Ot(t,e,n){let r=Yo.get(t,()=>Go(t));if(!r)return null;let i=`${n}\0${e}`,s=r.identities.get(i);if(s)return s;let o=r.builder.identityFor(e,n);return r.identities.set(i,o),o}function fe(t){return Y(t,{includeIgnored:!1}).filter(j).sort()}function Go(t){try{let e=JSON.parse(Ko(Jo(Vo(t.config.dbPath),"meta.json"),"utf8")),n=Sn(e.fingerprint);return n?{builder:ze({projectFiles:fe(t),snapshot:n,graph:ye(t),engineIdentity:Le()}),identities:new Map}:null}catch{return null}}var Ut="typescript-reference-fragment-v2",He=Vt({kind:"typescript-reference-fragments",invalidation:Jt("typescript-reference-fragments"),serialize:t=>JSON.stringify(t),deserialize:Xo});function Nu(t,e,n,r=t){let i=fe(t),s=ze({projectFiles:i,snapshot:e,graph:ye(t),engineIdentity:Le()}),o=[...n].map(([a,c])=>({relativePath:a,contentHash:s.identityFor(a,Ut).key,value:[...c]}));if(o.some(a=>a.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return He.writeBatch(r,o.map(a=>({...a,contentHash:a.contentHash}))),o.length}function Au(t,e,n){let r=e.filter(s=>j(s.relativePath));if(r.length===0)return $e("no TypeScript definitions");let i=$e("shadow did not run");return C("typescript.reference-fragments.shadow",()=>{try{let s=Lt(t,r[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return i=$e("TypeScript reference fragment provider is unavailable"),i;let o=fe(t),a=new Set(o),c=s.referenceFragmentsForFiles(o),l=Ue(r,c),p=Dr(r,Qo(n,a),l);if(!p.passed)return i={state:"failing",files:o.length,keyedFiles:0,writtenFiles:0,...p},i;let u=[];for(let f of o){let d=Ot(t,f,Ut);d?.key&&u.push({relativePath:f,contentHash:d.key,value:c.get(f)??[]})}return He.writeBatch(t,u),i={state:"passing",files:o.length,keyedFiles:u.length,writtenFiles:u.length,...p},i}catch(s){return i=$e(s instanceof Error?s.message:String(s)),i}},()=>({...i}))}function Qo(t,e){return new Map([...t].map(([n,r])=>[n,r.filter(i=>e.has(i.file))]))}function _u(t,e){if(e.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let n="fallback",r=0,i=0,s=0,o=0;return C("typescript.reference-fragments.materialize",()=>{try{let a=fe(t);r=a.length;let c=new Map,l=new Map,p=[];for(let d of a){let m=Ot(t,d,Ut);if(!m?.key)return null;c.set(d,m.key);let h=He.read(t,d,m.key);h===null?(s+=1,p.push(d)):(i+=1,l.set(d,h))}if(s===0)return n="hit",{references:Ue(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o};let u=Lt(t,e[0].relativePath);if(!u.availability().available||!u.referenceFragmentsForFiles)return null;let f=u.referenceFragmentsForFiles(p);if(p.some(d=>!f.has(d)))return null;o=f.size,He.writeBatch(t,p.map(d=>({relativePath:d,contentHash:c.get(d),value:f.get(d)??[]})));for(let[d,m]of f)l.set(d,m);return n="computed",{references:Ue(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o}}catch{return null}},()=>({state:n,files:r,cacheHits:i,cacheMisses:s,computedFiles:o}))}function $e(t){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:t}}function Xo(t){try{let e=JSON.parse(t);return!Array.isArray(e)||!e.every(Zo)?null:e}catch{return null}}function Zo(t){if(!t||typeof t!="object")return!1;let e=t,n=e.location;return typeof e.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}export{cn as a,Jr as b,et as c,oa as d,Qr as e,aa as f,he as g,be as h,Tn as i,Va as j,Ja as k,Za as l,nt as m,Sn as n,da as o,yi as p,rt as q,ba as r,lr as s,ur as t,vt as u,j as v,Lt as w,Wo as x,ze as y,Ot as z,Nu as A,Au as B,_u as C};
|
|
5
|
+
//# sourceMappingURL=chunk-NLNZK7RL.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as I,f as Y,g as _}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as I,f as Y,g as _}from"./chunk-CAKPEQZB.js";import{a as M}from"./chunk-BGBBVSH4.js";import{b as X,e as Z,f as $,g as ee}from"./chunk-PLDIXTKR.js";import{a as z,f as J,g as Q,i as w,j as U,n as v}from"./chunk-YGBHQOB2.js";import{a as B}from"./chunk-AOSFSYEA.js";import{a as V,g as T,h as P,j as H,k as O,s as D,u as G,v as W,w as N}from"./chunk-AYRHVJXW.js";import{m as F}from"./chunk-GAE7WCBK.js";import{B as R,C as K,L as j}from"./chunk-WAU7HVDI.js";import{B as h,s as E,y as A}from"./chunk-FC5K7T35.js";import{a as q}from"./chunk-64MNV6AB.js";function ne(n,e,t){let r=e.identifierResolution==="strict"?w:U,l=e.candidateNames?J(e.candidateNames):null,o=0,f=0,m=0,p=0,y="";for(let a of e.paths)if(o+=1,y=a,!(!R(a)&&!(e.includeVueSfc&&K(a)))&&!n.isIgnored(a)&&!e.skipPath?.(a))try{if(l&&!Q(A(n,a),l))continue;f+=1;let S=(s,u,L,b)=>{if(e.candidateNames&&!e.candidateNames.has(s))return;m+=1;let g=e.resolveTargets?e.resolveTargets({sourceFile:a,name:s,kind:u,defaultTargets:b}):b();for(let k of g)p+=1,t({sourceFile:a,name:s,target:k,occurrences:L,kind:u})},C=z(n,a);for(let[s,u]of C)S(s,"identifier",u.length,()=>r(n,a,s));for(let s of F(n,a,{includeCrossLanguageDispatchNames:e.includeCrossLanguageDispatchNames,includeRustAttributeNames:e.includeRustAttributeNames})){let u=s.kind==="cross-language-dispatch"?()=>w(n,a,s.name):()=>r(n,a,s.name);S(s.name,s.kind,s.occurrences,u)}}finally{e.afterPath?.(a),o%10===0&&E("source-reference-scan.progress",()=>{},()=>({scannedPaths:o,currentPath:y,candidateMatchedPaths:f,visitedNames:m,visitedHits:p}))}}function te(n,e={}){let{scope:t,files:r,minLoc:l=1,maxLoc:o=Number.POSITIVE_INFINITY,excludeSymbol:f,excludeEntrySurfaces:m=!1,excludeTypesFiles:p=!1,excludeRootedSymbols:y=!1,requireFunctionLikeSymbol:a=!1,requireCallableSymbol:x=!1,excludeRustTraitImplMembers:S=!1,includeSuppressed:C=!1,sortByLocDesc:s=!1}=e,u=[],L=oe(n,{scope:t,files:r,requireFunctionLikeSymbol:a,requireCallableSymbol:x}),b=new Map,g=new Map,k=i=>{let c=b.get(i);if(c!==void 0)return c;let d=Y(n,i);return b.set(i,d),d},re=i=>{let c=g.get(i);if(c!==void 0)return c;let d=I(i);return g.set(i,d),d};for(let i of L){let c=i.relativePath;if(n.isIgnored(c)||m&&k(c)||!ae(i,{requireFunctionLikeSymbol:a,requireCallableSymbol:x})||f!==void 0&&i.symbol===f)continue;let d=M(i);d<l||d>o||p&&se(c)||y&&_(n,i.symbol,c)||S&&H(i.symbol)||re(c)!=="test"&&(O(i.symbol)||!C&&h(n,c,i.startLine)||u.push(i))}return s?u.sort((i,c)=>M(c)-M(i)):u}function oe(n,e){return e.files!==void 0?[...new Set(e.files.map(r=>r.replace(/\\/g,"/")))].sort().filter(r=>!e.scope||r.includes(e.scope)).flatMap(r=>D(n,r)):e.requireCallableSymbol?N(n,{scope:e.scope,symbolMatches:T,sqlPrefilter:"callable"}):e.requireFunctionLikeSymbol?N(n,{scope:e.scope,symbolMatches:P,sqlPrefilter:"function-like"}):W(n,e.scope)}function ae(n,e){return e.requireCallableSymbol?T(n.symbol):e.requireFunctionLikeSymbol?P(n.symbol):n.isFunctionLike}function se(n){return(n.split("/").pop()??"").includes("types")}var ie=class{constructor(e){this.db=e}db;scopedDefinitions(e){return G(this.db,e)}definitionsForFile(e){return D(this.db,e)}productionCallableDefinitions(e={}){return te(this.db,e)}calleeMap(e,t={}){return X(this.db,e,{...t,semanticEvidence:v})}crossFileCallerMap(e,t={}){return Z(this.db,e,{...t,semanticEvidence:v})}sourceFallbackCallerFiles(e,t={}){return $(this.db,e,t)}callerFileMap(e,t={}){return ee(this.db,e,{...t,semanticEvidence:v})}frameworkReferencedSymbolIds(e){let t=new Map;for(let l of e){if(!l.leaf)continue;let o=t.get(l.leaf)??[];o.push(l.symbolId),t.set(l.leaf,o)}let r=new Set;for(let l of q(this.db,{includeIgnored:!1}))if(R(l)==="rust")for(let{name:o}of F(this.db,l,{includeRustAttributeNames:!0}))for(let f of t.get(o)??[])r.add(f);return r}symbolsWithNonSelfCallees(e,t={}){if(e.length===0)return new Set;let r=new Map(e.map(o=>[o.symbolId,o.symbol])),l=this.calleeMap(e,t);return new Set([...l.entries()].filter(([o,f])=>{let m=r.get(o);return f.some(p=>p.symbol!==m)}).map(([o])=>o))}fileDependencyGraph(e){return B(this.db,e)}fileKind(e){return I(e)}hasSuppressionComment(e){return h(this.db,e.relativePath,e.startLine)}sourceFiles(){return j(this.db)}scanSourceReferences(e,t){ne(this.db,e,t)}callableSignature(e){let t=V(this.db).forFile(e.relativePath,{facts:!0}).facts?.callables.find(r=>r.startLine===e.startLine&&r.endLine===e.endLine);return t?{paramCount:t.paramCount}:null}};export{ie as a};
|
|
2
|
+
//# sourceMappingURL=chunk-OAM22BCR.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-SJ6XSCG7.js";function m(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d2.relative_path
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d1 ON c.document_id = d1.id
|
|
@@ -30,4 +30,4 @@ import{a as s}from"./chunk-DV6B262O.js";function m(e,d){let i=s(e,d);return i?e.
|
|
|
30
30
|
WHERE d2.relative_path = ?
|
|
31
31
|
AND d1.relative_path != ?
|
|
32
32
|
ORDER BY d1.relative_path`,i,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}export{m as a,o as b};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-OLG2YPLS.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as C,b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as C,b}from"./chunk-2WCXKANA.js";import{a as P,c as y,e as r,f}from"./chunk-B3X6KU75.js";import{a as g,b as h,c as k}from"./chunk-KMVGRIO2.js";import{N as v}from"./chunk-WAU7HVDI.js";function L(e,i={}){let{minSimilarity:o=.62,minTokens:n=8,limit:c=20,scope:l,scanLimit:u,filePattern:m,focusFiles:d}=i,s=B(e,{scope:l,minTokens:n,scanLimit:u}),p=C(s,t=>t.tokens);return b({profiles:s,limit:c,filePattern:m,focusFiles:d,candidateIndex:p,profile:{name:"vue-component-duplicates"},compare:(t,a)=>V(t,a,o),sort:(t,a)=>a.similarity-t.similarity||t.fileA.localeCompare(a.fileA)||t.fileB.localeCompare(a.fileB)})}function B(e,i){return v(e).vueProfiles({scope:i.scope,minTemplateTokens:i.minTokens,scanLimit:i.scanLimit}).map(o=>({file:o.file,tokens:o.templateTokens,loc:T(o)}))}function T(e){return e.totalLines}function V(e,i,o){let n=g(e.tokens,i.tokens);if(n.size<6||!R(n))return null;let c=k(e.tokens,i.tokens);if(c<o)return null;let l=r(n,"component:"),u=r(n,"prop:"),m=r(n,"event:"),d=r(n,"directive:"),s=r(n,"slot:"),p=r(n,"id:"),t=S({sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p});return{fileA:e.file,fileB:i.file,similarity:c,tokenCountA:e.tokens.size,tokenCountB:i.tokens.size,sharedTokens:f(n),sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p,evidenceClass:t.evidenceClass,actionTier:t.actionTier,evidenceClassReasons:t.reasons,recommendation:t.recommendation,uniqueToA:f(h(e.tokens,i.tokens)).slice(0,25),uniqueToB:f(h(i.tokens,e.tokens)).slice(0,25),locA:e.loc,locB:i.loc}}function R(e){let i=0,o=0;for(let n of e)n.startsWith("component:")&&(i+=1),(n.startsWith("prop:")||n.startsWith("event:")||n.startsWith("directive:")||n.startsWith("slot:"))&&(o+=1);return y([{name:"component",count:i},{name:"behavior",count:o}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function S(e){return P({genericWords:x,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:w})}function w(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var x=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);export{L as a};
|
|
2
|
+
//# sourceMappingURL=chunk-OQ6TCHBB.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as f}from"./chunk-OAM22BCR.js";import{a as L}from"./chunk-HFBNIIZX.js";import{d as i,e as b,f as u,l as c}from"./chunk-AYRHVJXW.js";import{f as l}from"./chunk-GAE7WCBK.js";import{B as a}from"./chunk-WAU7HVDI.js";function S(o,s){let t=L(o,s);if(!t)return[];let e=new f(o).definitionsForFile(t.relativePath).filter(r=>r.symbol!==t.symbol).filter(r=>c(t.symbol,r.symbol)).sort((r,m)=>r.startLine-m.startLine||r.endLine-m.endLine).map(r=>({symbol:r.symbol,shortName:i(r.symbol),startLine:r.startLine,endLine:r.endLine,kind:u(r.symbol)??"unknown"}));return a(t.relativePath)!=="clojure"?e:d(e,y(o,t))}function y(o,s){let t=b(s.symbol);if(!t)return[];let n=i(s.symbol);return(l(o,s.relativePath)?.clojureMembers??[]).filter(e=>e.ownerName===t).map(e=>({symbol:`${s.symbol}${e.memberName}().`,shortName:`${n}:${e.memberName}()`,startLine:e.startLine,endLine:e.endLine,kind:e.memberKind}))}function d(o,s){let t=new Map;for(let n of[...o,...s])t.set(`${n.shortName}:${n.startLine}:${n.endLine}`,n);return[...t.values()].sort((n,e)=>n.startLine-e.startLine||n.endLine-e.endLine)}export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PCIFZHWS.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as g}from"./chunk-FBUNGRKI.js";import{a as d}from"./chunk-OAM22BCR.js";import{a as c}from"./chunk-YGBHQOB2.js";import{d as p}from"./chunk-AYRHVJXW.js";import{f as o}from"./chunk-GAE7WCBK.js";import{B as u}from"./chunk-WAU7HVDI.js";function F(r,a={}){let{scope:l,limit:s=30,scanLimit:b}=a,f=new d(r);return g({candidates:()=>f.productionCallableDefinitions({scope:l,files:a.files,minLoc:2,excludeRootedSymbols:!0,requireFunctionLikeSymbol:!0}),filterCandidate:e=>y(e.relativePath),scanLimit:b,profile:{name:"unused-params"},evaluate:e=>{let n=o(r,e.relativePath)?.callables.find(t=>t.startLine===e.startLine&&t.endLine===e.endLine);if(!n||n.params.length===0||n.params.some(t=>!t.simple)||n.paramsEndLine>=n.endLine)return null;let L=c(r,e.relativePath),m=[];for(let t=n.params.length-1;t>=0;t--){let i=n.params[t];if(i.name===""||i.name.startsWith("_")||h(L.get(i.name),n.paramsEndLine,n.endLine))break;m.unshift(i.name)}return m.length===0?null:{symbol:e.symbol,shortName:p(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,paramCount:n.paramCount,unusedTrailing:m}},orderResults:(e,n)=>n.unusedTrailing.length-e.unusedTrailing.length||e.file.localeCompare(n.file)||e.startLine-n.startLine,limit:s})}function y(r){let a=u(r);return a==="typescript"||a==="tsx"||a==="javascript"}function h(r,a,l){return r?r.some(s=>s>a&&s<=l):!1}export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PJENL245.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as U,c as k,d as D,e as A,k as Y,l as Z}from"./chunk-
|
|
1
|
+
import{b as U,c as k,d as D,e as A,k as Y,l as Z}from"./chunk-YGBHQOB2.js";import{d as z}from"./chunk-XAMVIPE2.js";import{d as q,e as X}from"./chunk-MTDBHTSF.js";import{e as w,g as W,s as J,t as L,y as V,z as Q}from"./chunk-AYRHVJXW.js";import{k as R,m as G,p as B}from"./chunk-GAE7WCBK.js";import{B as C,c as K}from"./chunk-WAU7HVDI.js";import{d as $}from"./chunk-FC5K7T35.js";import{a as H}from"./chunk-64MNV6AB.js";function Ge(t,n,e={}){let o=te(t,[n],{additive:e.additive,semantic:e.semantic,semanticEvidence:e.semanticEvidence}),i=e.callableOnly?(o.get(n.symbolId)??[]).filter(a=>W(a.symbol)||a.source==="ast-callsite"):o.get(n.symbolId)??[];return typeof e.limit=="number"?i.slice(0,e.limit):i}function ne(t,n,e){return F(t,[n],e).get(n.symbolId)??[]}function F(t,n,e){let o=ce(t)?de(t,n,{semantic:e.semantic!==!1,semanticEvidence:e.semanticEvidence}):me(t,e.semanticEvidence);return typeof e.limit!="number"?new Map(n.map(i=>[i.symbolId,o.get(i.symbolId)??[]])):new Map(n.map(i=>[i.symbolId,(o.get(i.symbolId)??[]).slice(0,e.limit)]))}var se=$("caller-rows",{clearGroups:["whole-project"]}),re=2e4;function ce(t){return(t.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>re}function me(t,n){return se.get(t,()=>{let e=L(t),o=te(t,e,{semanticEvidence:n}),i=new Map;for(let s of e)i.set(s.symbol,s.symbolId);let a=new Map,l=new Map;for(let s of e){let m=o.get(s.symbolId);if(!(!m||m.length===0))for(let d of m){let c=i.get(d.symbol);if(c===void 0||c===s.symbolId)continue;let f=a.get(c);f||(f=[],a.set(c,f),l.set(c,new Set));let u=`${s.symbol}|${s.relativePath}`;l.get(c).has(u)||(l.get(c).add(u),f.push({symbol:s.symbol,file:s.relativePath,source:"caller-map-inversion"}))}}return a})}function de(t,n,e){let o=e.semantic&&e.semanticEvidence?n.flatMap(s=>{let m=ue(t,s);return m?[m]:[]}):[],i=new Map(o.map(s=>[s.symbolId,s])),a=e.semanticEvidence?.referenceMap(t,o)??new Map,l=new Map;for(let s of n){let m=[],d=new Set,c=u=>{if(u.symbol===s.symbol)return;let r=`${u.symbol}|${u.file}`;d.has(r)||(d.add(r),m.push(u))};for(let u of Z(t,s))u.file!==s.relativePath&&c({symbol:u.enclosingSymbol??u.file,file:u.file,source:"resolved-reference"});let f=i.get(s.symbolId);if(f)for(let u of a.get(f.symbolId)??[]){if(u.file===s.relativePath||t.isIgnored(u.file))continue;let r=Q(J(t,u.file),u.line);c({symbol:r?.symbol??u.file,file:u.file,source:"semantic-reference"})}l.set(s.symbolId,m)}return l}function ue(t,n){let e=q().join(", "),o=X().join(", ");return t.get(`SELECT
|
|
2
2
|
d.id AS documentId,
|
|
3
3
|
gs.id AS symbolId,
|
|
4
4
|
gs.symbol,
|
|
@@ -35,4 +35,4 @@ import{b as U,c as k,d as D,e as A,k as Y,l as Z}from"./chunk-UVMME4FI.js";impor
|
|
|
35
35
|
) def_chunk ON def_chunk.symbol_id = gs.id
|
|
36
36
|
WHERE gs.id IN (${r.map(()=>"?").join(",")})`,...r,...r)),s=P([...n.map(r=>r.documentId),...l.flatMap(r=>r.document_id===null?[]:[r.document_id])]),m=new Map(s.flatMap(r=>t.all(`SELECT id, relative_path FROM documents
|
|
37
37
|
WHERE id IN (${r.map(()=>"?").join(",")})`,...r).map(p=>[p.id,p.relative_path]))),d=new Map;for(let r of l)d.has(r.symbol_id)||d.set(r.symbol_id,{symbol:r.symbol,file:r.document_id!==null?m.get(r.document_id)??"":""});let c=new Map,f=m,u=ge(n);for(let[r,p]of u){let h=[...i.get(r)??[]].sort((b,S)=>b.start_line-S.start_line||b.end_line-S.end_line),ie=[...p].sort((b,S)=>b.startLine-S.startLine||b.endLine-S.endLine),_=new Set,v=0;for(let b of ie){for(;v<h.length&&h[v].start_line<=b.endLine;)_.add(h[v]),v+=1;for(let y of _)y.end_line<b.startLine&&_.delete(y);let S=new Set,T=[],N=null,ae=()=>{if(N)return N;let y=f.get(b.documentId)??"",g=new Set;if(y){let x=U(t,y),I=Math.max(0,b.startLine),j=Math.min(x.length-1,b.endLine);for(let M=I;M<=j;M+=1)for(let le of x[M])g.add(le)}return N=g,g};for(let y of _){if(y.symbol_id===b.symbolId)continue;let g=d.get(y.symbol_id);if(!g)continue;if(!(y.start_line>=b.startLine&&y.end_line<=b.endLine)){if(!(y.start_line<=b.endLine&&y.end_line>=b.startLine))continue;let M=w(g.symbol);if(!M||!ae().has(M))continue}let I=`${g.symbol}|${y.chunk_id}`;S.has(I)||(S.add(I),T.push({...g,chunkId:y.chunk_id,source:"scip-chunk"}))}c.set(b.symbolId,T)}}return c}var ee=500;function P(t){let n=[...new Set(t)],e=[];for(let o=0;o<n.length;o+=ee)e.push(n.slice(o,o+ee));return e}function ge(t){let n=new Map;for(let e of t){let o=n.get(e.documentId);o?o.push(e):n.set(e.documentId,[e])}return n}function he(t){let n=new Map;for(let[e,o]of t){let i=[];for(let a of o)i.push({symbol:a.symbol,file:a.file,chunkId:-1,source:"semantic-callee"});n.set(e,i)}return n}function oe(t,n,e={}){let o=new Map;if(n&&n.length===0)return o;let i=H(t,{includeIgnored:!1}),a=A(t),l=n??L(t),s=new Set(l.map(d=>d.symbolId)),m=Ie(l);return Me(t,o,i,a,s,m),Ce(t,o,l,s),ve(t,o,i,a,s,m),e.semantic!==!1&&e.semanticEvidence&&Le(o,e.semanticEvidence.callerMap(t,we(l))),o}function Me(t,n,e,o,i,a){for(let l of e){if(!C(l))continue;let s=R(t,l);if(s)for(let m of s){if(a&&!a.has(m.calleeLeaf))continue;let d=k(l,o.get(m.calleeLeaf)??[]);if(!d||d.length===0)continue;let c=D(t,l,d,m.memberAccess);c&&i.has(c.symbolId)&&c.file!==l&&O(n,c.symbolId,l)}}}function Ce(t,n,e,o){let i=Ee(e);for(let a of Re(t,o))t.isIgnored(a.relative_path)||_e(a,i.get(a.symbol_id))||O(n,a.symbol_id,a.relative_path)}function Re(t,n){return z(t,n?[...n]:void 0)}function Ee(t){let n=new Map;for(let e of t)n.set(e.symbolId,{docId:e.documentId,startLine:e.startLine,endLine:e.endLine});return n}function _e(t,n){return!!n&&n.docId===t.document_id&&t.chunk_start>=n.startLine&&t.chunk_end<=n.endLine}function ve(t,n,e,o,i,a){for(let l of e){if(C(l)!=="rust")continue;let s=G(t,l,{includeRustAttributeNames:!0});if(s.length!==0)for(let{name:m}of s){if(a&&!a.has(m))continue;let d=o.get(m);if(d)for(let c of d)i.has(c.symbolId)&&c.file!==l&&O(n,c.symbolId,l)}}}function O(t,n,e){let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(e)}function Ie(t){let n=new Set;for(let e of t){let o="leaf"in e&&typeof e.leaf=="string"?e.leaf:"symbol"in e&&typeof e.symbol=="string"?w(e.symbol):"";o&&n.add(o)}return n.size>0?n:null}function we(t){return t.filter(n=>"relativePath"in n&&"symbol"in n&&"leaf"in n)}function Le(t,n){for(let[e,o]of n){let i=t.get(e);i||(i=new Set,t.set(e,i));for(let a of o)i.add(a)}}function en(t,n,e){return ne(t,n,e)}function nn(t,n,e){return F(t,n,e)}function ke(t,n,e={}){return oe(t,n,e)}function De(t,n,e={}){return Y(t,n,e)}function tn(t,n,e={}){let o=ke(t,n,{semantic:e.semantic,semanticEvidence:e.semanticEvidence});return e.sourceFallback===!1?o:Ae(o,De(t,n))}function Ae(t,n){let e=new Map;for(let[o,i]of t)e.set(o,new Set(i));for(let[o,i]of n){let a=e.get(o)??new Set;for(let l of i)a.add(l);e.set(o,a)}return e}export{Ge as a,te as b,en as c,nn as d,ke as e,De as f,tn as g,Ae as h};
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
//# sourceMappingURL=chunk-PLDIXTKR.js.map
|