scip-query 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2DSS2NGF.js +10 -0
- package/dist/chunk-2RLP74AO.js +2 -0
- package/dist/chunk-4QJ7LVW5.js +2 -0
- package/dist/chunk-4TYGGOLO.js +5 -0
- package/dist/chunk-5IADAU5B.js +7 -0
- package/dist/chunk-7754WFFV.js +18 -0
- package/dist/chunk-7VOF4ZG6.js +2 -0
- package/dist/chunk-7Z4COVMC.js +2 -0
- package/dist/chunk-AJ5PWKD4.js +2 -0
- package/dist/chunk-BDBRZPX3.js +7 -0
- package/dist/chunk-BE6EQIWY.js +2 -0
- package/dist/chunk-BQ3INTYT.js +8 -0
- package/dist/chunk-D7KLLMPB.js +2 -0
- package/dist/chunk-D7YBWSON.js +29 -0
- package/dist/chunk-DE5ZBHMK.js +39 -0
- package/dist/chunk-DHYIJHXZ.js +33 -0
- package/dist/chunk-EEF3YEHW.js +2 -0
- package/dist/chunk-F2LLHRRZ.js +2 -0
- package/dist/chunk-FCC3XJTI.js +2 -0
- package/dist/chunk-GNXRLK5G.js +2 -0
- package/dist/chunk-GXVB36TG.js +62 -0
- package/dist/chunk-HMKJTAZD.js +2 -0
- package/dist/chunk-IBGBI3VU.js +2 -0
- package/dist/chunk-IYFZS4PV.js +84 -0
- package/dist/chunk-JH3A7HTU.js +2 -0
- package/dist/chunk-JS2RNIC7.js +2 -0
- package/dist/chunk-K5FQFCSN.js +41 -0
- package/dist/chunk-K6GBKEQE.js +6 -0
- package/dist/chunk-KO7YJRWP.js +12 -0
- package/dist/chunk-KYT47WU2.js +4 -0
- package/dist/chunk-LORWXBOO.js +2 -0
- package/dist/chunk-LX4H4LLG.js +89 -0
- package/dist/chunk-N3Z2SJCR.js +2 -0
- package/dist/chunk-NTDA4A2D.js +25 -0
- package/dist/chunk-NXMYYHDO.js +24 -0
- package/dist/chunk-PZ6ESKRH.js +7 -0
- package/dist/chunk-QXE6EDY2.js +6 -0
- package/dist/chunk-RJ7SPBJ5.js +5 -0
- package/dist/chunk-RWE6FHG3.js +3 -0
- package/dist/chunk-SDX6MDBL.js +2 -0
- package/dist/chunk-SG35Y7J2.js +2 -0
- package/dist/chunk-STOGKRJH.js +4 -0
- package/dist/chunk-TINPMWJK.js +2 -0
- package/dist/chunk-UJB62HV3.js +2 -0
- package/dist/chunk-VEUMRDHW.js +2 -0
- package/dist/chunk-WCDXJGYT.js +65 -0
- package/dist/chunk-WTSTDJZ7.js +6 -0
- package/dist/chunk-XAZTIDST.js +2 -0
- package/dist/chunk-XVDASCN7.js +35 -0
- package/dist/chunk-Y7H6D2EV.js +2 -0
- package/dist/chunk-Y7LOQSWY.js +2 -0
- package/dist/chunk-YIPCV7M7.js +70 -0
- package/dist/chunk-ZSRXMNMK.js +5 -0
- package/dist/chunk-ZXKURFVB.js +56 -0
- package/dist/cli.js +509 -8758
- package/dist/{db-6F9R9e_t.d.ts → db-BSTtBG_H.d.ts} +146 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +13 -1616
- package/dist/postinstall.js +4 -100
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +1 -8
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +1 -8
- package/dist/queries/by-kind.d.ts +1 -4
- package/dist/queries/by-kind.js +1 -10
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -8
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +1 -8
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -8
- package/dist/queries/complexity-hotspots.d.ts +5 -10
- package/dist/queries/complexity-hotspots.js +1 -8
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +1 -8
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +1 -8
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +1 -10
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +1 -8
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +1 -8
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +1 -9
- package/dist/queries/deep-chains.d.ts +9 -1
- package/dist/queries/deep-chains.js +1 -8
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +1 -10
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +1 -7
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -8
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +1 -8
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +1 -14
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -6
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -20
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +1 -8
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -8
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +1 -12
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +1 -197
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +1 -9
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +1 -8
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +1 -8
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +1 -8
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +1 -8
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +1 -9
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +1 -8
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +1 -8
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +1 -8
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +1 -8
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +1 -10
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +1 -8
- package/dist/queries/stale-abstractions.d.ts +15 -5
- package/dist/queries/stale-abstractions.js +1 -8
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/stats.js +1 -6
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +1 -8
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +1 -9
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +1 -9
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +1 -9
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +1 -8
- package/dist/reindex-worker.js +7 -672
- package/package.json +20 -2
- package/dist/chunk-2MQ5DPY6.js +0 -61
- package/dist/chunk-2QTYIOJ5.js +0 -165
- package/dist/chunk-3VI4YXCL.js +0 -172
- package/dist/chunk-3VV2G6U7.js +0 -34
- package/dist/chunk-44PFXVXG.js +0 -76
- package/dist/chunk-6SLFQR36.js +0 -64
- package/dist/chunk-74RFWB5T.js +0 -24
- package/dist/chunk-7DBPRGMS.js +0 -221
- package/dist/chunk-DTB724R3.js +0 -110
- package/dist/chunk-FLOYI6I4.js +0 -185
- package/dist/chunk-FO2CBB7U.js +0 -23
- package/dist/chunk-GJT3MO2T.js +0 -17
- package/dist/chunk-HAP4LJKX.js +0 -66
- package/dist/chunk-JCOJQ4I6.js +0 -93
- package/dist/chunk-JGQMOS4V.js +0 -59
- package/dist/chunk-JMD4WJ2Q.js +0 -213
- package/dist/chunk-JSQPZOPO.js +0 -64
- package/dist/chunk-JSXGC2EH.js +0 -151
- package/dist/chunk-JZN3DRCT.js +0 -59
- package/dist/chunk-KMWYB3CX.js +0 -71
- package/dist/chunk-MRM755FU.js +0 -37
- package/dist/chunk-N2XO3Z5F.js +0 -69
- package/dist/chunk-OLW5UL36.js +0 -76
- package/dist/chunk-OMCRXXDX.js +0 -2600
- package/dist/chunk-OWJOHUZE.js +0 -44
- package/dist/chunk-P3VCDYMJ.js +0 -269
- package/dist/chunk-PEDH3D4G.js +0 -53
- package/dist/chunk-POAN4SCR.js +0 -46
- package/dist/chunk-PTMGEBU3.js +0 -101
- package/dist/chunk-PU44HK7P.js +0 -87
- package/dist/chunk-QJI7EECA.js +0 -327
- package/dist/chunk-R5HICGMB.js +0 -110
- package/dist/chunk-RJ2D6YWQ.js +0 -49
- package/dist/chunk-RZ5GYPBP.js +0 -79
- package/dist/chunk-SRLQNO6O.js +0 -101
- package/dist/chunk-UGS7HJI4.js +0 -84
- package/dist/chunk-VKUUXOE7.js +0 -105
- package/dist/chunk-VPUJSJCI.js +0 -84
- package/dist/chunk-VRWVV3EP.js +0 -72
- package/dist/chunk-WJWQEU4A.js +0 -162
- package/dist/chunk-WJZHDUSB.js +0 -40
- package/dist/chunk-WWOCQ5W4.js +0 -34
- package/dist/chunk-X3Q2OVRL.js +0 -77
- package/dist/chunk-Y3P7QKKN.js +0 -27
- package/dist/chunk-Y6FAHY4N.js +0 -81
- package/dist/chunk-YMSJCSRG.js +0 -213
- package/dist/chunk-ZDL3U4W2.js +0 -124
- package/dist/chunk-ZXNX5JRE.js +0 -216
- package/dist/queries/clean-signature.d.ts +0 -17
- package/dist/queries/clean-signature.js +0 -9
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as u}from"./chunk-WTSTDJZ7.js";import{p as c}from"./chunk-IYFZS4PV.js";import{b as a}from"./chunk-TINPMWJK.js";function _(t,d){let s=u(t,d);if(!s)return null;let n=t.get(`SELECT id, relative_path FROM documents
|
|
2
|
+
WHERE relative_path = ?
|
|
3
|
+
${t.pathExclusionsFor("documents")}
|
|
4
|
+
LIMIT 1`,s);if(!n||t.isIgnored(n.relative_path))return null;let f=c(t,n.relative_path).sort((e,i)=>e.startLine-i.startLine||e.endLine-i.endLine),m=[],l=0;for(let e of f){let o=t.get(`SELECT COUNT(DISTINCT c.document_id) AS consumer_count
|
|
5
|
+
FROM mentions m
|
|
6
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
7
|
+
WHERE m.symbol_id = ?
|
|
8
|
+
AND m.role != 1
|
|
9
|
+
AND c.document_id != ?`,e.symbolId,n.id)?.consumer_count??0,r;o>10?r="high":o>0?r="medium":r="low",l+=o,m.push({symbol:e.symbol,shortName:a(e.symbol),startLine:e.startLine,endLine:e.endLine,externalConsumers:o,riskLevel:r})}return{file:n.relative_path,symbols:m,totalExternalConsumers:l}}export{_ as a};
|
|
10
|
+
//# sourceMappingURL=chunk-2DSS2NGF.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as p}from"./chunk-WTSTDJZ7.js";import{s as u}from"./chunk-IYFZS4PV.js";import{i as f}from"./chunk-TINPMWJK.js";function S(a,b){let y=p(a,b),o=u(a,y,{sort:!0});if(o.length===0)return[];let i=o.map(e=>({symbol:e.symbol,shortName:e.shortName,startLine:e.startLine,endLine:e.endLine,children:[]})),s=new Map;for(let e of i)s.set(e.symbol,e);let c=[];for(let e=0;e<o.length;e++){let r=o[e],n=i[e];if(r.enclosingSymbol&&s.has(r.enclosingSymbol)){s.get(r.enclosingSymbol).children.push(n);continue}let l=null,m=1/0;for(let t of i)if(t!==n&&t.startLine<=n.startLine&&t.endLine>=n.endLine){if(t.startLine===n.startLine&&t.endLine===n.endLine&&!f(t.symbol,n.symbol))continue;let d=t.endLine-t.startLine;d<m&&(m=d,l=t)}l?l.children.push(n):c.push(n)}return c}export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2RLP74AO.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as d}from"./chunk-LORWXBOO.js";import{d as a}from"./chunk-WCDXJGYT.js";function F(t,i={}){let{minSimilarity:f=.5,limit:n=20,scope:o,filePattern:s}=i,u=i.minDeps??(s?1:3),e=g(t,{scope:o,minDeps:u}),p=[];if(s){let r=e.find(l=>l.file.includes(s));if(!r)return[];for(let l of e){if(l.file===r.file)continue;let c=m(r,l,f);c&&p.push(c)}}else for(let r=0;r<e.length;r++){for(let l=r+1;l<e.length;l++){let c=m(e[r],e[l],f);c&&p.push(c)}if(p.length>n*5)break}return p.sort((r,l)=>l.similarity-r.similarity),p.slice(0,n)}function g(t,i){let{scope:f,minDeps:n}=i,o=a(t,f),s=h(o),u=[];for(let[e,p]of o)p.size>=n&&u.push({file:e,deps:new Set([...p].filter(r=>!s.has(r)))});return u}function h(t){let i=new Set,f=t.size;if(f===0)return i;let n=new Map;for(let o of t.values())for(let s of o)n.set(s,(n.get(s)??0)+1);for(let[o,s]of n)s>=5&&s/f>.3&&i.add(o);return i}function m(t,i,f){let n=new Set;for(let e of t.deps)i.deps.has(e)&&n.add(e);if(n.size<3||t.deps.size<4||i.deps.size<4)return null;let o=d(t.deps,i.deps);if(o<f)return null;let s=[];for(let e of t.deps)i.deps.has(e)||s.push(e);let u=[];for(let e of i.deps)t.deps.has(e)||u.push(e);return{fileA:t.file,fileB:i.file,similarity:o,sharedDeps:[...n],uniqueToA:s,uniqueToB:u}}export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4QJ7LVW5.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{execFileSync as n}from"child_process";import{platform as o,arch as p}from"os";var a=o()==="win32",u="v0.7.0";function t(e){let r=a?"where":"which";try{return n(r,[e],{stdio:"pipe"}),!0}catch{return!1}}function h(){try{return n(a?"where":"which",["scip"],{stdio:"pipe"}),!0}catch{return!1}}function w(){try{return n("scip",["--version"],{stdio:"pipe"}).toString().trim()}catch{return null}}function g(){let e=o(),r=p(),i,l,s;switch(e){case"darwin":i="darwin",s="tar.gz";break;case"linux":i="linux",s="tar.gz";break;case"win32":i="windows",s="zip";break;default:return null}switch(r){case"arm64":l="arm64";break;case"x64":l="amd64";break;default:return null}let c=`scip-${i}-${l}.${s}`;return{url:`https://github.com/sourcegraph/scip/releases/download/${u}/${c}`,filename:c}}function b(){let e=g();console.log("\nThe `scip` CLI is required but not found on PATH.\n"),o()==="darwin"?(console.log("Install via Homebrew:"),console.log(` brew install sourcegraph/scip/scip
|
|
2
|
+
`),console.log("Or download manually:")):console.log("Download from:"),console.log(e?` ${e.url}
|
|
3
|
+
`:` https://github.com/sourcegraph/scip/releases/tag/${u}
|
|
4
|
+
`),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function I(e){if(o()==="darwin"&&t("brew")){e("Installing scip CLI via Homebrew...");try{if(n("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),t("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(r){let i=r instanceof Error?r.message:String(r);e(`Homebrew install failed: ${i}`)}}if(t("go")){e("Installing scip CLI via go install...");try{if(n("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),t("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(r){let i=r instanceof Error?r.message:String(r);e(`go install failed: ${i}`)}}return e("Could not auto-install scip CLI."),e("Install manually from: https://github.com/sourcegraph/scip/releases"),!1}export{h as a,w as b,b as c,I as d};
|
|
5
|
+
//# sourceMappingURL=chunk-4TYGGOLO.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as k}from"./chunk-VEUMRDHW.js";import{c as _,d as N,j as P}from"./chunk-WCDXJGYT.js";import{e as C,p as D,r as M,t as v}from"./chunk-IYFZS4PV.js";import{b as F,c as L,f as I}from"./chunk-TINPMWJK.js";import{basename as u,extname as d}from"path";function V(e,n){let{scope:i,maxLoc:t=15,limit:s=30}=n??{},o=J(N(e,i)),l=T(e,i,t),c=j(P(e,l),k(e,l)),g=[];for(let r of l){if(C(e,r.relativePath,r.startLine))continue;let p=u(r.relativePath,d(r.relativePath)),h=[...c.get(r.symbolId)??[]].filter(m=>m!==r.relativePath).filter(m=>u(m,d(m))!==p);if(h.length!==1)continue;let f=h[0],y=e.get(`SELECT c.start_line, c.end_line
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d ON c.document_id = d.id
|
|
5
|
+
WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
|
|
6
|
+
LIMIT 1`,r.symbolId,f);if(!y)continue;let R=D(e,f),w=A(e,f,r.symbol,y.start_line,y.end_line),a=v(R,w),b,E=a?.symbol??"",O=a?.isFunctionLike?F(a.symbol):u(f);if(a?.isFunctionLike&&a.symbolId!==r.symbolId){let m=[...c.get(a.symbolId)??[]].filter(W=>W!==a.relativePath);b=m.length>0?m.length:x(o,f)}else b=x(o,f);b<=3||g.push({symbol:r.symbol,shortName:F(r.symbol),file:r.relativePath,startLine:r.startLine,endLine:r.endLine,loc:S(r),singleCaller:E,singleCallerShort:O,callerFanIn:b})}return g.sort((r,p)=>p.callerFanIn-r.callerFanIn||p.loc-r.loc),g.slice(0,s)}function S(e){return e.endLine-e.startLine+1}function T(e,n,i){return M(e,n).filter(t=>!e.isIgnored(t.relativePath)).filter(t=>I(t.symbol)).filter(t=>S(t)<=i&&S(t)>=2)}function A(e,n,i,t,s){let o=L(i);if(!o)return t;let l=_(e,n).get(o);if(!l||l.length===0)return t;for(let c of l)if(c>=t&&c<=s)return c;return t}function j(...e){let n=new Map;for(let i of e)for(let[t,s]of i){let o=n.get(t);o||(o=new Set,n.set(t,o));for(let l of s)o.add(l)}return n}function J(e){let n=new Map;for(let[i,t]of e){n.has(i)||n.set(i,n.get(i)??0);for(let s of t)n.set(s,(n.get(s)??0)+1)}return n}function x(e,n){let i=e.get(n)??0;if(i>0)return i;let t=u(n,d(n)),s=0;for(let[o,l]of e)o!==n&&u(o,d(o))===t&&l>s&&(s=l);return s}export{V as a};
|
|
7
|
+
//# sourceMappingURL=chunk-5IADAU5B.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{d as y}from"./chunk-WCDXJGYT.js";import{e as h}from"./chunk-BQ3INTYT.js";import m from"path";function E(t,r){let{scope:i}=r??{},f=y(t,i),n=_(t,i),o=[];for(let[e,c]of f){if(d(e))continue;let u=n.get(e)??new Set;for(let s of c)if(!d(s)&&!u.has(s)){if(k(s)||b(t,e,s))continue;o.push({file:e,kind:"unused-import",description:`Depends on ${s} but references none of its symbols`,dep:s})}}let p=S(f);for(let[e,c]of f){if(d(e))continue;let u=g(e);for(let s of c){if(d(s))continue;let l=g(s);if(u===l)continue;p.get(`${u}->${l}`)==="violation"&&o.push({file:e,kind:"layer-violation",description:`Imports from ${l}/ (${s}) \u2014 may cross architectural boundary`,dep:s,detail:`${u}/ should not depend on ${l}/`})}}let a=new Map;for(let e of f.keys()){let c=m.dirname(e);a.has(c)||a.set(c,[]),a.get(c).push(e)}for(let[e,c]of a){if(c.length<3)continue;let u=new Map;for(let s of c)if(!d(s))for(let l of f.get(s)??[])d(l)||u.set(l,(u.get(l)??0)+1);for(let s of c)if(!d(s)){for(let l of f.get(s)??[])if(!d(l)&&(u.get(l)??0)===1){if(m.dirname(l)===e)continue;o.push({file:s,kind:"pattern-deviation",description:`Only file in ${e}/ that depends on ${l}`,dep:l})}}}return{results:o,unusedImports:o.filter(e=>e.kind==="unused-import").length,layerViolations:o.filter(e=>e.kind==="layer-violation").length,patternDeviations:o.filter(e=>e.kind==="pattern-deviation").length}}function _(t,r){let i=r?`AND d1.relative_path LIKE '%${r}%'`:"",f=t.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
5
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
6
|
+
JOIN (
|
|
7
|
+
SELECT m2.symbol_id, c2.document_id
|
|
8
|
+
FROM mentions m2
|
|
9
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
10
|
+
WHERE m2.role = 1
|
|
11
|
+
GROUP BY m2.symbol_id
|
|
12
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
13
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
14
|
+
WHERE d1.id != d2.id
|
|
15
|
+
AND m.role != 1
|
|
16
|
+
${t.pathExclusionsFor("d1","d2")}
|
|
17
|
+
${i}`),n=new Map;for(let o of f)t.isIgnored(o.from_file)||t.isIgnored(o.to_file)||(n.has(o.from_file)||n.set(o.from_file,new Set),n.get(o.from_file).add(o.to_file));return n}function S(t){let r=new Map,i=new Set;for(let[n,o]of t){if(d(n))continue;let p=g(n);i.add(p);for(let a of o){if(d(a))continue;let e=g(a);if(p===e)continue;i.add(e);let c=`${p}->${e}`;r.set(c,(r.get(c)??0)+1)}}let f=new Map;for(let[n,o]of r)f.set(n,o<=2?"violation":"ok");return f}function g(t){let i=t.replace(/\\/g,"/").split("/").filter(Boolean);return i.length<=1?"(root)":i.length>=3&&["src","lib","app","server","client"].includes(i[0])?`${i[0]}/${i[1]}`:i[0]}function k(t){return t.includes("types")||t.endsWith(".d.ts")}function b(t,r,i){let f=h(t,r).filter(n=>n.sourcePath===i);return f.length===0?!1:f.every(n=>n.kind==="side-effect"||n.kind==="namespace"&&n.usedMembers.length===0&&!n.used)}function d(t){return $(m.basename(t))||v(t)}function $(t){return!!(t==="index.ts"||t==="index.js"||t==="cli.ts"||t==="main.ts"||t==="main.rs"||t.includes("worker.")||t.includes("postinstall.")||t==="health.ts"||t==="health.js")}function v(t){let r=t.replace(/\\/g,"/"),i=m.basename(r);return r.includes("/__tests__/")||r.includes("/tests/")||r.includes("/test/")||/\.(test|spec)\.[A-Za-z0-9]+$/.test(i)||/_(test|spec)\.[A-Za-z0-9]+$/.test(i)||/^test[_-]/.test(i)||/^test\./.test(i)}export{E as a};
|
|
18
|
+
//# sourceMappingURL=chunk-7754WFFV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h as L}from"./chunk-WCDXJGYT.js";import{e as g,f as b,h as C,r as S}from"./chunk-IYFZS4PV.js";import{b as y,f as d}from"./chunk-TINPMWJK.js";function x(o,s,a,i){let r=b(s);if(!r)return!0;let t=C(o,s);if(!t)return!0;let l=_.get(t);return l||(l=w(t,r),_.set(t,l)),l.get(`${a}:${i}`)??!0}var _=new WeakMap;function w(o,s){let a=s==="rust"?new Set(["function_item","function_signature_item"]):s==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),i=new Map,r=t=>{a.has(t.type)&&i.set(`${t.startPosition.row}:${t.endPosition.row}`,P(t,s));for(let l of t.children)r(l)};return r(o.rootNode),i}function P(o,s){let a=o.namedChildren.find(e=>e.type==="block"||e.type==="statement_block");if(!a)return!1;let i=a.namedChildren.filter(e=>e.type!=="comment"&&e.type!=="line_comment"&&e.type!=="block_comment");if(i.length!==1)return!1;let r=i[0],t=null;if(r.type==="return_statement"||r.type==="expression_statement"?t=r.namedChild(0)??null:s==="rust"&&(r.type==="call_expression"||r.type==="macro_invocation")&&(t=r),!t)return!1;let l=s==="python"?"call":"call_expression";if(t.type!==l)return!1;let u=t.namedChildren.find(e=>e.type==="arguments"||e.type==="argument_list");if(!u)return!1;let n=u.namedChildren.filter(e=>e.type!=="comment"),f=o.namedChildren.find(e=>e.type==="parameters"||e.type==="formal_parameters");if(!f)return!1;let p=[];for(let e of f.namedChildren)if(e.type==="identifier")p.push(e.text);else{let m=e.namedChildren.find(c=>c.type==="identifier");m&&p.push(m.text)}if(n.length!==p.length)return!1;for(let e=0;e<p.length;e+=1){let m=n[e];if(m.type!=="identifier"||m.text!==p[e])return!1}return!0}function j(o,s){let{scope:a,maxLoc:i=15,limit:r=30}=s??{},t=T(o,a,i),l=L(o,t),u=[];for(let n of t){if(g(o,n.relativePath,n.startLine))continue;let f=l.get(n.symbolId)??[],p=f.some(c=>d(c.symbol))?f.filter(c=>d(c.symbol)):f,e=new Map;for(let c of p)e.has(c.symbol)||e.set(c.symbol,c);if(e.size!==1||!x(o,n.relativePath,n.startLine,n.endLine))continue;let[,m]=[...e.entries()][0];u.push({symbol:n.symbol,shortName:y(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:h(n),forwardsTo:m.symbol,forwardsToShort:y(m.symbol),forwardsToFile:m.file})}return u.sort((n,f)=>n.loc-f.loc||n.file.localeCompare(f.file)),u.slice(0,r)}function T(o,s,a){return S(o,s).filter(i=>!o.isIgnored(i.relativePath)).filter(i=>d(i.symbol)).filter(i=>h(i)>=3&&h(i)<=a)}function h(o){return o.endLine-o.startLine+1}export{j as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7VOF4ZG6.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as i}from"./chunk-GNXRLK5G.js";import{c as n}from"./chunk-VEUMRDHW.js";import{h as o,j as m}from"./chunk-WCDXJGYT.js";import{r}from"./chunk-IYFZS4PV.js";import{b as l}from"./chunk-TINPMWJK.js";function F(t,c={}){let{scope:p,minLoc:y=3}=c,a=r(t,p).filter(e=>!t.isIgnored(e.relativePath)).filter(e=>!i(t,e.relativePath)).filter(e=>e.isFunctionLike).filter(e=>e.endLine-e.startLine+1>=y),b=m(t,a),L=n(t,a),u=new Set([...b.keys(),...L.keys()]),d=new Map(a.map(e=>[e.symbolId,e.symbol])),f=o(t,a,{additive:!0}),S=new Set([...f.entries()].filter(([e,s])=>{let h=d.get(e);return s.some(C=>C.symbol!==h)}).map(([e])=>e));return a.filter(e=>!u.has(e.symbolId)).filter(e=>!S.has(e.symbolId)).sort((e,s)=>s.endLine-s.startLine-(e.endLine-e.startLine)||e.relativePath.localeCompare(s.relativePath)||e.startLine-s.startLine).map(e=>({symbol:e.symbol,shortName:l(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1}))}export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7Z4COVMC.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as g}from"./chunk-VEUMRDHW.js";import{e as u,g as h}from"./chunk-WCDXJGYT.js";import{a as d,b as y}from"./chunk-LX4H4LLG.js";import{p as S,t as p}from"./chunk-IYFZS4PV.js";import{b as m}from"./chunk-TINPMWJK.js";function N(e,o,r={}){let{direction:c="backward",maxDepth:s=3}=r,t=d(e,o);return t?c==="backward"?w(e,t,s):R(e,t):null}function w(e,o,r){let c=[],s=new Set([o.symbol]),t=[o];for(let n=1;n<=r&&t.length!==0;n++){let l=[];for(let a of t){let i=u(e,a);for(let f of i){if(s.has(f.symbol))continue;s.add(f.symbol),c.push({symbol:f.symbol,shortName:m(f.symbol),file:f.file,relationship:n===1?"referenced within definition (callee)":`depth ${n} callee`});let b=y(e,f.symbol);b&&!e.isIgnored(b.relativePath)&&l.push(b)}}t=l}return{symbol:o.symbol,shortName:m(o.symbol),direction:"backward",connectedSymbols:c}}function R(e,o){let r=g(e,o),c=r.length>0?r:h(e,o),s=new Set,t=[];for(let n of c){if(t.length>=30)break;if(e.isIgnored(n.file))continue;let l=n.enclosingSymbol??p(S(e,n.file),n.line)?.symbol??null;if(!l||l===o.symbol)continue;let a=y(e,l);if(a){for(let i of u(e,a))if(i.symbol!==o.symbol&&i.symbol!==l&&i.file!==n.file&&!e.isIgnored(i.file)&&!s.has(i.symbol)&&(s.add(i.symbol),t.push({symbol:i.symbol,shortName:m(i.symbol),file:i.file,relationship:`used alongside target in ${m(l)}`}),t.length>=30))break}}return t.sort((n,l)=>n.file.localeCompare(l.file)),{symbol:o.symbol,shortName:m(o.symbol),direction:"forward",connectedSymbols:t}}export{N as a};
|
|
2
|
+
//# sourceMappingURL=chunk-AJ5PWKD4.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{h as g}from"./chunk-WCDXJGYT.js";import{a as b}from"./chunk-LX4H4LLG.js";import{b as m}from"./chunk-TINPMWJK.js";import{readFileSync as y}from"fs";import{join as d}from"path";function I(o,i){let t=b(o,i);if(!t)return null;let l=o.get("SELECT language FROM documents WHERE relative_path = ?",t.relativePath)?.language??"unknown",s=d(o.config.projectRoot,t.relativePath),n="";try{n=y(s,"utf-8").split(`
|
|
2
|
+
`).slice(t.startLine,t.endLine+1).join(`
|
|
3
|
+
`)}catch{}let e=S(n,l),f=t.endLine-t.startLine+1,a=g(o,[t],{additive:!0}).get(t.symbolId)??[],p=new Set(a.map(r=>r.symbol)),u=o.get(`SELECT COUNT(DISTINCT c.document_id) AS c
|
|
4
|
+
FROM mentions m
|
|
5
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
6
|
+
WHERE m.symbol_id = ? AND m.role != 1`,t.symbolId),h=new Set(a.filter(r=>r.file!==t.relativePath).map(r=>r.symbol)).size;return{symbol:t.symbol,shortName:m(t.symbol),relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:f,branches:e,cyclomaticEstimate:e+1,calleeCount:p.size,fanIn:u?.c??0,fanOut:h}}function S(o,i){let t=P(o),c=0,l=[/\bif\b/g,/\belse\s+if\b/g,/\belse\b/g,/\bfor\b/g,/\bwhile\b/g,/\bswitch\b/g,/\bcase\b/g,/\bcatch\b/g,/\?\s*[^?]/g,/&&/g,/\|\|/g];for(let s of l){let n=t.match(s);n&&(c+=n.length)}if(i==="python"){let s=[/\belif\b/g,/\bexcept\b/g,/\bfinally\b/g];for(let n of s){let e=t.match(n);e&&(c+=e.length)}}else if(i==="rust"){let s=[/\bmatch\b/g,/=>/g,/\bloop\b/g];for(let n of s){let e=t.match(n);e&&(c+=e.length)}}else if(i==="ruby"){let s=[/\belsif\b/g,/\bunless\b/g,/\brescue\b/g,/\bwhen\b/g];for(let n of s){let e=t.match(n);e&&(c+=e.length)}}else if(i==="go"){let s=[/\bselect\b/g,/\bdefer\b/g];for(let n of s){let e=t.match(n);e&&(c+=e.length)}}return c}function P(o){return o.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"").replace(/#.*/g,"").replace(/"(?:[^"\\]|\\.)*"/g,'""').replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/`(?:[^`\\]|\\.)*`/g,"``")}export{I as a};
|
|
7
|
+
//# sourceMappingURL=chunk-BDBRZPX3.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as n}from"./chunk-LX4H4LLG.js";import{p as l}from"./chunk-IYFZS4PV.js";import{b as m,d as o,h as i}from"./chunk-TINPMWJK.js";function f(r,a){let t=n(r,a);return t?l(r,t.relativePath).filter(e=>e.symbol!==t.symbol).filter(e=>i(t.symbol,e.symbol)).sort((e,s)=>e.startLine-s.startLine||e.endLine-s.endLine).map(e=>({symbol:e.symbol,shortName:m(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:o(e.symbol)??"unknown"})):[]}export{f as a};
|
|
2
|
+
//# sourceMappingURL=chunk-BE6EQIWY.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as B,b as ie,c as ae,d as G,f as F,g as ce,h as S}from"./chunk-IYFZS4PV.js";import{existsSync as ve,readFileSync as Ae}from"fs";import{join as Oe}from"path";import{existsSync as w}from"fs";import{basename as Le,dirname as j,extname as R,join as E,relative as A,resolve as P}from"path";var qe=ie("indexed-paths"),H=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],K=[".py",".pyi"],C=[".java",".scala",".kt",".kts"],Z=[".rs"],ee=[".rb"],pe=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],L=[".cs",".vb"],te=[".dart"],X=[".php"],Ue=[H,K,C,Z,ee,pe,L,te,X];function $(e,r){return r.includes(R(e).toLowerCase())}function We(e){return $(e,K)}function Be(e){return $(e,C)}function Xe(e){return $(e,Z)}function Je(e){return $(e,ee)}function Fe(e){return $(e,pe)}function He(e){return $(e,L)}function le(e){return R(e).toLowerCase()===".vb"}function ze(e){return $(e,te)}function Ve(e){return $(e,X)}function re(e){let r=R(e).toLowerCase();for(let t of Ue)if(t.includes(r))return t;return H}function Qe(e){return Be(e)||He(e)||Ve(e)}function O(e,r,t){return We(r)?q(e,r,t):Xe(r)?T(e,r,t):Je(r)?z(e,r,t):Fe(r)?V(e,r,t):Qe(r)?g(e,t.replace(/\\/g,"."),re(r)):ze(r)?Q(e,r,t):Ye(e,r,t)}function Ye(e,r,t){if(!t.startsWith(".")&&!t.startsWith("/"))return null;let n=j(E(e.config.projectRoot,r)),s=P(n,t),o=M(e);for(let i of tt(s)){let a=b(A(e.config.projectRoot,i));if(o.has(a)||w(i))return a}return b(A(e.config.projectRoot,s))}function q(e,r,t){let n=M(e),s;if(t.startsWith(".")){let o=t.match(/^(\.+)(.*)$/);if(!o)return null;let i=o[1].length,a=o[2].replace(/^\./,""),c=j(E(e.config.projectRoot,r));for(let p=1;p<i;p++)c=j(c);s=a?P(c,a.replace(/\./g,"/")):c}else s=P(e.config.projectRoot,t.replace(/\./g,"/"));for(let o of Ge(s)){let i=b(A(e.config.projectRoot,o));if(n.has(i)||w(o))return i}return null}function T(e,r,t){if(!t)return null;let n=t.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let s=j(E(e.config.projectRoot,r)),o;n.startsWith("crate::")?o=P(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=P(s,n.slice(6).replace(/::/g,"/")):o=P(j(s),n.slice(7).replace(/::/g,"/"));for(let i of Ke(o)){let a=b(A(e.config.projectRoot,i));if(M(e).has(a)||w(i))return a}return null}function z(e,r,t){let n=j(E(e.config.projectRoot,r)),s=P(n,t);for(let o of Ze(s)){let i=b(A(e.config.projectRoot,o));if(M(e).has(i)||w(o))return i}return null}function V(e,r,t){let n=M(e),s=j(E(e.config.projectRoot,r)),o=[P(s,t),P(e.config.projectRoot,t),P(e.config.projectRoot,"include",t),P(e.config.projectRoot,"src",t)];for(let i of o){let a=b(A(e.config.projectRoot,i));if(n.has(a)||w(i))return a}return null}function g(e,r,t){let n=M(e),s=r.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=s.replace(/\./g,"/"),i=s.split(".").pop()??s;for(let c of t){let p=`${o}${c}`,l=[...n].find(u=>u.endsWith(p));if(l)return l}for(let c of t){let p=[...n].find(l=>Le(l)===`${i}${c}`);if(p)return p}let a=[...n].filter(c=>t.includes(R(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${i}/`)).sort((c,p)=>c.localeCompare(p));return a.length===1?a[0]:null}function Q(e,r,t){let n=M(e);if(t.startsWith("package:")){let i=t.slice(8),a=i.indexOf("/");if(a<0)return null;let c=i.slice(a+1),p=b(c.startsWith("lib/")?c:`lib/${c}`);return n.has(p)?p:null}let s=j(E(e.config.projectRoot,r)),o=P(s,t);for(let i of et(o)){let a=b(A(e.config.projectRoot,i));if(n.has(a)||w(i))return a}return null}function Ge(e){let r=R(e);return K.includes(r)?[e]:[`${e}.py`,`${e}.pyi`,E(e,"__init__.py"),E(e,"__init__.pyi")]}function Ke(e){let r=R(e);return Z.includes(r)?[e]:[`${e}.rs`,E(e,"mod.rs")]}function Ze(e){let r=R(e);return ee.includes(r)?[e]:[`${e}.rb`,E(e,"index.rb")]}function et(e){let r=R(e);return te.includes(r)?[e]:[`${e}.dart`,e]}function tt(e){let r=R(e),t=new Set;if(r){t.add(e);for(let n of H)t.add(e.slice(0,-r.length)+n)}else for(let n of H)t.add(`${e}${n}`),t.add(E(e,`index${n}`));return[...t]}function M(e){return qe.get(e,()=>new Set(e.all(`SELECT relative_path
|
|
2
|
+
FROM documents
|
|
3
|
+
WHERE 1 = 1
|
|
4
|
+
${e.pathExclusionsFor("documents")}`).map(r=>b(r.relative_path)).filter(r=>!e.isIgnored(r))))}function b(e){return e.replace(/\\/g,"/")}function me(e){return e.replace(/'''[\s\S]*?'''/g,v).replace(/"""[\s\S]*?"""/g,v).replace(/#.*$/gm,v).replace(/\/\/.*$/gm,v).replace(/\/\*[\s\S]*?\*\//g,v).replace(/`(?:\\[\s\S]|[^`])*`/g,v).replace(/'(?:\\.|[^'\\\r\n])*'/g,v).replace(/"(?:\\.|[^"\\\r\n])*"/g,v)}function v(e){return e.replace(/[^\r\n]/g," ")}var rt=ae("stripped-lines");function er(e,r,t){return rt.get(e,r,t,()=>me(t).split(`
|
|
5
|
+
`))}var ue=null,ne="";function nt(e){return ue===e||(ue=e,ne=me(e)),ne}function x(e,r,t){let n=nt(e);return`${n.slice(0,r)}${" ".repeat(t-r)}${n.slice(t)}`}function y(e,r){return new RegExp(`\\b${de(r)}\\b`,"m").test(e)}function U(e,r){let t=new Set,n=new RegExp(`\\b${de(r)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let s of e.matchAll(n)){let o=s[1];o&&t.add(o)}return[...t]}function de(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function I(e){let r=[],t=0,n=0;for(let s=0;s<e.length;s++){let o=e[s];(o==="{"||o==="["||o==="(")&&t++,(o==="}"||o==="]"||o===")")&&t--,o===","&&t===0&&(r.push(e.slice(n,s)),n=s+1)}return r.push(e.slice(n)),r}function _(e,r){for(let t of e.namedChildren)if(t.type===r)return t;return null}function h(e,r){let t=new Set,n=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]),s=(o,i)=>{let a=i||r.has(o.type);!a&&n.has(o.type)&&t.add(o.text);for(let c of o.children)s(c,a)};return s(e.rootNode,!1),t}function D(e,r,t,n,s,o,i){return{importedName:s,localName:o,sourcePath:i??g(e,n,re(r)),kind:"named",used:y(t,o),usedMembers:[]}}function ge(e,r,t){let n=S(e,r);return n?st(e,r,n):at(t).flatMap(s=>ct(e,r,s.clause,s.specifier,s.start,s.end,t))}function st(e,r,t){let n=h(t,new Set(["import_statement"]));if(ce(r))for(let o of ht(e,r))n.add(o);let s=[];for(let o of t.rootNode.descendantsOfType("import_statement")){let i=ot(o);if(!i)continue;let a=O(e,r,i),c=_(o,"import_clause");if(!c){s.push({importedName:"*",localName:null,sourcePath:a,kind:"side-effect",used:!0,usedMembers:[]});continue}for(let p of c.namedChildren)switch(p.type){case"identifier":{let l=p.text;s.push({importedName:"default",localName:l,sourcePath:a,kind:"default",used:n.has(l),usedMembers:[]});break}case"namespace_import":{let u=_(p,"identifier")?.text??"";if(!u)break;let m=it(t,u);s.push({importedName:"*",localName:u,sourcePath:a,kind:"namespace",used:m.length>0||n.has(u),usedMembers:m});break}case"named_imports":{for(let l of p.namedChildren){if(l.type!=="import_specifier")continue;let u=l.namedChild(0),m=l.namedChild(1);if(!u)continue;let d=u.text,f=m?.text??d;s.push({importedName:d,localName:f,sourcePath:a,kind:"named",used:n.has(f),usedMembers:[]})}break}}}return s}function ot(e){let r=_(e,"string");if(!r)return null;let t=_(r,"string_fragment");return t?t.text:null}function it(e,r){let t=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let s=n.namedChild(0),o=n.namedChild(1);!s||!o||s.type!=="identifier"||s.text!==r||(o.type==="property_identifier"||o.type==="identifier")&&t.add(o.text)}return[...t]}function at(e){let r=[],t=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let s of e.matchAll(t)){let o=s[0],i=s[1],a=s[2];!o||!a||typeof s.index!="number"||r.push({clause:i,specifier:a,start:s.index,end:s.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let s of e.matchAll(n)){let o=s[0],i=s[1];!o||!i||typeof s.index!="number"||r.push({clause:null,specifier:i,start:s.index,end:s.index+o.length})}return r.sort((s,o)=>s.start-o.start)}function ct(e,r,t,n,s,o,i){let a=O(e,r,n),c=x(i,s,o);return t?pt(t).map(l=>({...l,sourcePath:a})).map(l=>{if(l.kind==="namespace"){let u=U(c,l.localName);return{...l,used:u.length>0||y(c,l.localName),usedMembers:u}}return l.kind==="side-effect"?{...l,used:!0,usedMembers:[]}:{...l,used:l.localName?y(c,l.localName):!1,usedMembers:[]}}):[{importedName:"*",localName:null,sourcePath:a,kind:"side-effect",used:!0,usedMembers:[]}]}function pt(e){let r=e.trim().replace(/^type\s+/,""),[t,n]=lt(r),s=[];return t&&s.push(...fe(t)),n&&s.push(...fe(n)),s}function fe(e){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let t=r.slice(1,-1).trim();return t?I(t).map(n=>{let s=n.trim().replace(/^type\s+/,""),[o,i]=s.split(/\s+as\s+/);return{importedName:o.trim(),localName:(i??o).trim(),kind:"named"}}):[]}return r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace"}]:[{importedName:"default",localName:r,kind:"default"}]}function lt(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];if(n==="{"&&r++,n==="}"&&r--,n===","&&r===0)return[e.slice(0,t).trim(),e.slice(t+1).trim()]}return[e.trim(),null]}function he(e,r){let t=S(e,r);if(t)return mt(e,r,t);let n=G(e,r);if(!n)return[];let s=[],o=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let c of n.matchAll(o)){if(typeof c.index!="number")continue;let p=c[1]??"",l=c[2]??"",u=I(p).map(f=>ut(f.trim())).filter(f=>!!f),m=W(n,c.index),d=W(n,c.index+c[0].length-1);s.push({kind:"named",sourcePath:O(e,r,l),names:u,startLine:m,endLine:d})}let i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let c of n.matchAll(i)){if(typeof c.index!="number")continue;let p=c[2]??"",l=W(n,c.index),u=W(n,c.index+c[0].length-1);s.push({kind:"star-as",sourcePath:O(e,r,p),names:[],startLine:l,endLine:u})}let a=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let c of n.matchAll(a)){if(typeof c.index!="number")continue;let p=c[1]??"",l=W(n,c.index),u=W(n,c.index+c[0].length-1);s.push({kind:"star",sourcePath:O(e,r,p),names:[],startLine:l,endLine:u})}return s}function ut(e){if(!e)return null;let r=e.replace(/^type\s+/,"").trim();if(!r)return null;let t=r.match(/^(\w+)\s+as\s+(\w+)$/);if(t)return t[2]??null;let n=r.match(/^(\w+)$/);return n?n[1]??null:null}function W(e,r){let t=0;for(let n=0;n<r&&n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function mt(e,r,t){let n=[];for(let s of t.rootNode.descendantsOfType("export_statement")){let o=dt(e,r,s);if(o===void 0)continue;let i=s.startPosition.row,a=s.endPosition.row,c=ft(s,o,i,a);n.push(c)}return n}function dt(e,r,t){let n=_(t,"string");if(!n)return;let s=_(n,"string_fragment");if(s)return O(e,r,s.text)}function ft(e,r,t,n){let s=_(e,"export_clause");if(s){let i=[];for(let a of s.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),p=a.namedChild(1);c&&i.push((p??c).text)}return{kind:"named",sourcePath:r,names:i,startLine:t,endLine:n}}return _(e,"namespace_export")?{kind:"star-as",sourcePath:r,names:[],startLine:t,endLine:n}:{kind:"star",sourcePath:r,names:[],startLine:t,endLine:n}}var gt=B("vue-non-script-identifiers");function ht(e,r){return gt.get(e,r,()=>{let t=new Set,n=G(e,r);if(!n)return t;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,i=>i.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,i=>i.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\r\n]/g," "));for(let i of o.matchAll(/[A-Za-z_$][\w$]*/g))t.add(i[0]);return t})}import{basename as Se}from"path";function xe(e,r,t){let n=S(e,r);if(n)return St(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm)){let i=o[1]?.trim(),a=o[0];if(!i||!a||typeof o.index!="number")continue;let c=x(t,o.index,o.index+a.length),p=Se(i).replace(/\.[^.]+$/,"");s.push({importedName:i,localName:p,sourcePath:V(e,r,i),kind:"named",used:y(c,p),usedMembers:[]})}return s}function St(e,r,t){let n=h(t,new Set(["preproc_include"])),s=[];for(let o of t.rootNode.descendantsOfType("preproc_include")){let i=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){i=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){i=c.namedChildren.find(l=>l.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!i)continue;let a=Se(i).replace(/\.[^.]+$/,"");s.push({importedName:i,localName:a,sourcePath:V(e,r,i),kind:"named",used:n.has(a),usedMembers:[]})}return s}function ye(e,r,t){let n=[];for(let s of t.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=s[1]?.trim(),i=s[2]?.trim()??null,a=s[0];if(!o||!a||typeof s.index!="number")continue;let c=x(t,s.index,s.index+a.length);n.push({importedName:o,localName:i,sourcePath:Q(e,r,o),kind:i?"namespace":"side-effect",used:i?y(c,i):!0,usedMembers:i?U(c,i):[]})}return n}function Ne(e,r,t){let n=[];for(let s of t.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=s[1]?.trim();o&&n.push({specifier:o,sourcePath:Q(e,r,o)})}return n}function Ie(e,r,t){let n=S(e,r),s=F(r);if(n&&s==="csharp")return yt(e,r,n);if(n&&s==="vb")return xt(e,r,n);let o=[],i=le(r)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;for(let a of t.matchAll(i)){let c=a[1]?.trim(),p=a[0];if(!c||!p||typeof a.index!="number")continue;let l=x(t,a.index,a.index+p.length),[u,m]=c.split(/\s*=\s*/),d=!!m,f=(d?m:u)?.trim()??c,N=f.split(".").pop()??f,k=d?u?.trim()??N:N;o.push(D(e,r,l,f,N,k,g(e,f,L)))}return o}function xt(e,r,t){let n=h(t,new Set(["imports_statement"])),s=[];for(let o of t.rootNode.descendantsOfType("imports_statement")){let i=o.namedChildren.filter(m=>m.type==="namespace_name");if(i.length===0)continue;let a=i[i.length-1],c=i.length>1?i[0]:null,p=a.text,l=p.split(".").pop()??p,u=c?.text??l;s.push({importedName:l,localName:u,sourcePath:g(e,p,L),kind:c?"namespace":"named",used:n.has(u),usedMembers:[]})}return s}function yt(e,r,t){let n=h(t,new Set(["using_directive"])),s=[];for(let o of t.rootNode.descendantsOfType("using_directive")){let i=o.namedChildren;if(i.length===0)continue;let a=null,c=null;if(i.length>=2&&i[0].type==="identifier"&&(i[1].type==="qualified_name"||i[1].type==="identifier")?(a=i[0],c=i[1]):c=i[i.length-1],!c)continue;let p=c.text,l=p.split(".").pop()??p,u=a?.text??l;s.push({importedName:l,localName:u,sourcePath:g(e,p,L),kind:a?"namespace":"named",used:n.has(u),usedMembers:[]})}return s}function Pe(e,r,t){let n=S(e,r),s=F(r);if(n&&s==="java")return Nt(e,r,n);if(n&&s==="kotlin")return It(e,r,n);if(n&&s==="scala")return Pt(e,r,n);let o=[];for(let i of t.matchAll(/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm)){let a=i[1]?.trim(),c=i[0];if(!a||!c||typeof i.index!="number")continue;let p=x(t,i.index,i.index+c.length);o.push(...bt(e,r,a,p))}return o}function Nt(e,r,t){let n=h(t,new Set(["import_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let i=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let p=c.text;if(i){s.push({importedName:"*",localName:null,sourcePath:g(e,p,C),kind:"namespace",used:!0,usedMembers:[]});continue}let l=p.split(".").pop()??p;s.push({importedName:l,localName:l,sourcePath:g(e,p,C),kind:"named",used:n.has(l),usedMembers:[]})}return s}function It(e,r,t){let n=h(t,new Set(["import_header","import_list"])),s=[];for(let o of t.rootNode.descendantsOfType("import_header")){let i=o.namedChildren.find(d=>d.type==="identifier");if(!i)continue;let a=o.namedChildren.some(d=>d.type==="wildcard_import"),c=o.namedChildren.find(d=>d.type==="import_alias");if(a){s.push({importedName:"*",localName:null,sourcePath:g(e,i.text,C),kind:"namespace",used:!0,usedMembers:[]});continue}let p=i.text,l=p.split(".").pop()??p,m=c?.namedChild(0)?.text??l;s.push({importedName:l,localName:m,sourcePath:g(e,p,C),kind:"named",used:n.has(m),usedMembers:[]})}return s}function Pt(e,r,t){let n=h(t,new Set(["import_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let i=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==i&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(i?.type==="namespace_wildcard"){s.push({importedName:"*",localName:null,sourcePath:g(e,c,C),kind:"namespace",used:!0,usedMembers:[]});continue}if(i?.type==="namespace_selectors"){for(let u of i.namedChildren)if(u.type==="arrow_renamed_identifier"){let[m,d]=u.namedChildren;if(!m)continue;let f=m.text,N=d?.text??f;if(f==="_")continue;s.push({importedName:f,localName:N,sourcePath:g(e,`${c}.${f}`,C),kind:"named",used:n.has(N),usedMembers:[]})}else if(u.type==="identifier"){let m=u.text;s.push({importedName:m,localName:m,sourcePath:g(e,`${c}.${m}`,C),kind:"named",used:n.has(m),usedMembers:[]})}continue}let p=a[a.length-1]?.text??c,l=a.slice(0,-1).map(u=>u.text).join(".")||c;s.push({importedName:p,localName:p,sourcePath:g(e,l&&a.length>1?`${l}.${p}`:c,C),kind:"named",used:n.has(p),usedMembers:[]})}return s}function bt(e,r,t,n){if(t.includes("{")&&t.includes("}")){let s=t.slice(0,t.indexOf("{")).replace(/\.$/,"").trim(),o=t.slice(t.indexOf("{")+1,t.lastIndexOf("}")).trim();return I(o).flatMap(i=>{let a=i.trim();if(!a)return[];let[c,p]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),l=c?.trim();if(!l||l==="_")return[];let u=(p??l.split(".").pop()??l).trim(),m=l==="_"?s:`${s}.${l}`.replace(/\.\./g,".");return[D(e,r,n,m,l,u)]})}return[D(e,r,n,t,t.split(".").pop()??t,t.split(".").pop()??t)]}function _e(e,r,t){let n=S(e,r);if(n)return _t(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*use\s+(.+?)\s*;$/gm)){let i=o[1]?.trim(),a=o[0];if(!i||!a||typeof o.index!="number")continue;let c=x(t,o.index,o.index+a.length);for(let p of I(i)){let l=p.trim();if(!l)continue;let[u,m]=l.split(/\s+as\s+/i),d=u?.trim()??l,f=d.split("\\").pop()??d,N=(m??f).trim();s.push(D(e,r,c,d,f,N,g(e,d.replace(/\\/g,"."),X)))}}return s}function _t(e,r,t){let n=h(t,new Set(["namespace_use_declaration"])),s=[],o=(i,a,c)=>{s.push({importedName:a,localName:c,sourcePath:g(e,i.replace(/\\/g,"."),X),kind:"named",used:n.has(c),usedMembers:[]})};for(let i of t.rootNode.descendantsOfType("namespace_use_declaration")){let a=i.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=i.namedChildren.find(p=>p.type==="namespace_name")?.text??"";for(let p of a.namedChildren){if(p.type!=="namespace_use_clause")continue;let{importedName:l,localName:u,qualified:m}=be(p,c);l&&o(m,l,u)}continue}for(let c of i.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:p,localName:l,qualified:u}=be(c,"");p&&o(u,p,l)}}return s}function be(e,r){let t=e.namedChildren.find(p=>p.type==="qualified_name"),n=e.namedChildren.filter(p=>p.type==="name"),s="";t?s=t.text:n.length>=1&&(s=n[0].text);let o=t&&n.length>0?n[n.length-1]:null,i=s.split("\\").pop()??s,a=o?.text??i,c=r?`${r}\\${s}`:s;return{importedName:i,localName:a,qualified:c}}function De(e,r,t){let n=S(e,r);return n?Et(e,r,n):Dt(t).flatMap(s=>Tt(e,r,s,t))}function Et(e,r,t){let n=h(t,new Set(["import_statement","import_from_statement"])),s=[];for(let o of t.rootNode.descendantsOfType("import_statement"))for(let i of o.namedChildren){let a=Ee(i);if(!a)continue;let c=q(e,r,a.qualifiedName);s.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of t.rootNode.descendantsOfType("import_from_statement")){let i=o.namedChild(0);if(!i)continue;let a=Ct(i);if(a===null)continue;let c=q(e,r,a);for(let p=1;p<o.namedChildCount;p+=1){let l=o.namedChild(p);if(l.type==="wildcard_import"){s.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=Ee(l);u&&s.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return s}function Ee(e){if(e.type==="aliased_import"){let r=e.namedChild(0),t=e.namedChild(1);return!r||!t?null:{qualifiedName:r.text,localName:t.text}}if(e.type==="dotted_name"){let r=e.text;return{qualifiedName:r,localName:r.split(".")[0]??r}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function Ct(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let r=_(e,"import_prefix")?.text??"",t=_(e,"dotted_name")?.text??"";return`${r}${t}`}return null}function Dt(e){let r=e.split(`
|
|
6
|
+
`),t=[],n=0;for(let s=0;s<r.length;s++){let o=r[s],i=o.trimStart(),a=n;if(n+=o.length+1,!i.startsWith("import ")&&!i.startsWith("from "))continue;let c=o,p=a+o.length,l=Ce(o);for(;s+1<r.length&&(l>0||c.trimEnd().endsWith("\\"));){s++;let m=r[s];c+=`
|
|
7
|
+
${m}`,p+=1+m.length,l+=Ce(m),n+=m.length+1}let u=Rt(c);u&&t.push({...u,start:a,end:p})}return t}function Rt(e){let r=e.replace(/\\\s*\n/g," ").trim();if(r.startsWith("import "))return{kind:"import",module:null,clause:r.slice(7).trim()};let t=r.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!t)return null;let n=t[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:t[1],clause:n}}function Tt(e,r,t,n){let s=x(n,t.start,t.end),o=t.clause.replace(/\n/g," ").trim();if(t.kind==="import")return I(o).flatMap(c=>{let p=c.trim().replace(/,$/,"");if(!p)return[];let[l,u]=p.split(/\s+as\s+/),m=l.trim(),d=(u??m.split(".")[0]??m).trim(),f=q(e,r,m),N=U(s,d);return[{importedName:m,localName:d,sourcePath:f,kind:"namespace",used:y(s,d)||N.length>0,usedMembers:N}]});let i=t.module?q(e,r,t.module):null,a=[];for(let c of I(o)){let p=c.trim().replace(/,$/,"");if(!p)continue;if(p==="*"){a.push({importedName:"*",localName:null,sourcePath:i,kind:"side-effect",used:!0,usedMembers:[]});continue}let[l,u]=p.split(/\s+as\s+/),m=(u??l).trim();a.push({importedName:l.trim(),localName:m,sourcePath:i,kind:"named",used:y(s,m),usedMembers:[]})}return a}function Ce(e){let r=0;for(let t of e)t==="("&&r++,t===")"&&r--;return r}import{basename as kt}from"path";function Re(e,r,t){let n=S(e,r);if(n)return jt(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm)){let i=o[1],a=o[2],c=o[0];if(!i||!a||!c||typeof o.index!="number")continue;let p=x(t,o.index,o.index+c.length),l=i==="require_relative"?z(e,r,a):null;if(l){let u=Te(a);s.push({importedName:u,localName:u,sourcePath:l,kind:"named",used:y(p,u),usedMembers:[]});continue}s.push({importedName:a,localName:null,sourcePath:l,kind:"side-effect",used:!0,usedMembers:[]})}return s}function jt(e,r,t){let n=h(t,new Set([])),s=[],o=new Set(["require","require_relative","load"]);for(let i of t.rootNode.descendantsOfType("call")){let a=i.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let p=i.namedChildren.find(d=>d.type==="argument_list")?.namedChild(0);if(!p||p.type!=="string")continue;let u=p.namedChildren.find(d=>d.type==="string_content")?.text;if(!u)continue;let m=a.text==="require_relative"?z(e,r,u):null;if(m){let d=Te(u);s.push({importedName:d,localName:d,sourcePath:m,kind:"named",used:n.has(d),usedMembers:[]})}else s.push({importedName:u,localName:null,sourcePath:m,kind:"side-effect",used:!0,usedMembers:[]})}return s}function Te(e){return kt(e).replace(/\.[^.]+$/,"").split("_").filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}function ke(e,r,t){let n=S(e,r);if(n)return $t(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*use\s+(.+?)\s*;$/gm)){let i=o[1]?.trim(),a=o[0];if(!i||!a||typeof o.index!="number")continue;let c=x(t,o.index,o.index+a.length);s.push(...vt(e,r,i,c))}return s}function $t(e,r,t){let n=h(t,new Set(["use_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("use_declaration")){let i=o.namedChild(0);if(i)for(let a of J(i,"")){if(!a.importedName||a.importedName==="*")continue;let c=T(e,r,a.qualifiedName)??T(e,r,a.qualifiedName.split("::").slice(0,-1).join("::"));s.push({importedName:a.importedName,localName:a.localName,sourcePath:c,kind:"named",used:n.has(a.localName),usedMembers:[]})}}return s}function J(e,r){switch(e.type){case"identifier":case"super":case"self":case"crate":{let t=e.text;return[{qualifiedName:Y(r,t),importedName:t,localName:t}]}case"scoped_identifier":{let t=e.text,n=t.split("::").pop()??t;return[{qualifiedName:Y(r,t),importedName:n,localName:n}]}case"scoped_use_list":{let t=e.namedChild(0),n=e.namedChild(1);if(!t||!n)return[];let s=Y(r,t.text),o=[];for(let i of n.namedChildren)o.push(...J(i,s));return o}case"use_list":{let t=[];for(let n of e.namedChildren)t.push(...J(n,r));return t}case"use_as_clause":{let t=e.namedChild(0),n=e.namedChild(1);if(!t||!n)return[];let s=J(t,r),o=n.text;return s.map(i=>({...i,localName:o}))}case"use_wildcard":{let t=e.namedChild(0),n=t?t.text:"";return[{qualifiedName:Y(r,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Y(e,r){return e?r?`${e}::${r}`:e:r}function vt(e,r,t,n){let s=t.trim();if(s.includes("{")&&s.includes("}")){let l=s.slice(0,s.indexOf("{")).replace(/::$/,"").trim(),u=s.slice(s.indexOf("{")+1,s.lastIndexOf("}")).trim();return I(u).flatMap(m=>{let d=m.trim();if(!d||d==="self")return[];let[f,N]=d.split(/\s+as\s+/),k=f?.trim();if(!k)return[];let Me=(N??k.split("::").pop()??k).trim(),we=`${l}::${k}`.replace(/::::/g,"::");return[D(e,r,n,we,k.split("::").pop()??k,Me,T(e,r,l))]})}let[o,i]=s.split(/\s+as\s+/),a=o?.trim()??s,c=(i??a.split("::").pop()??a).trim(),p=T(e,r,a)??T(e,r,a.split("::").slice(0,-1).join("::"));return[D(e,r,n,a,a.split("::").pop()??a,c,p)]}function je(e,r,t){let n=S(e,r);if(n)return At(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let i=o[1]?.trim();i&&s.push(...Mt(e,r,i))}return s}function At(e,r,t){let n=[];for(let s of t.rootNode.descendantsOfType("use_declaration")){if(!Ot(s))continue;let o=s.namedChildren.find(i=>i.type!=="visibility_modifier");if(o)for(let i of J(o,""))i.importedName&&n.push(se(e,r,i.qualifiedName))}return n}function Ot(e){for(let r of e.children)if(r.type==="visibility_modifier"&&r.text.startsWith("pub"))return!0;return!1}function Mt(e,r,t){let n=t.trim();if(n.includes("{")&&n.includes("}")){let s=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return I(o).flatMap(i=>{let a=i.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),p=`${s}::${c?.trim()??a}`.replace(/::::/g,"::");return[se(e,r,p)]})}return[se(e,r,n)]}function se(e,r,t){return{specifier:t,sourcePath:T(e,r,t)??T(e,r,t.split("::").slice(0,-1).join("::"))}}function $e(e,r){let t=r.toLowerCase();for(let n of e)for(let s of n.extensions)if(t.endsWith(s))return n;return null}var wt={language:"javascript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],parseImports:ge},Lt={language:"python",extensions:[".py",".pyi"],parseImports:De},qt={language:"jvm",extensions:[".java",".scala",".kt",".kts"],parseImports:Pe},Ut={language:"rust",extensions:[".rs"],parseImports:ke,parseExports:je},Wt={language:"ruby",extensions:[".rb"],parseImports:Re},Bt={language:"c/cpp",extensions:[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],parseImports:xe},Xt={language:"dotnet",extensions:[".cs",".vb"],parseImports:Ie},Jt={language:"dart",extensions:[".dart"],parseImports:ye,parseExports:Ne},Ft={language:"php",extensions:[".php"],parseImports:_e},Ht=[wt,Lt,qt,Ut,Wt,Bt,Xt,Jt,Ft];function oe(e){return $e(Ht,e)}function Sn(e,r){return he(e,r)}var zt=B("source-imports"),Vt=B("source-exports");function xn(e,r){let t=b(r);return zt.get(e,t,()=>{let n=oe(t);if(!n)return[];let s=Oe(e.config.projectRoot,t);if(!ve(s))return[];let o=Ae(s,"utf-8");return n.parseImports(e,t,o)})}function yn(e,r){let t=b(r);return Vt.get(e,t,()=>{let n=oe(t);if(!n?.parseExports)return[];let s=Oe(e.config.projectRoot,t);if(!ve(s))return[];let o=Ae(s,"utf-8");return n.parseExports(e,t,o)})}export{me as a,er as b,de as c,Sn as d,xn as e,yn as f};
|
|
8
|
+
//# sourceMappingURL=chunk-BQ3INTYT.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as S,j as M}from"./chunk-WCDXJGYT.js";import{a as g,b as I}from"./chunk-LX4H4LLG.js";import{p as d,t as p}from"./chunk-IYFZS4PV.js";import{b as u}from"./chunk-TINPMWJK.js";function N(s,f,n={}){let{maxDepth:a=5,scope:b}=n,c=g(s,f);if(!c)return[];let i=[],y=new Set([c.symbolId]),r=new Set,l=[c];for(let e=1;e<=a&&l.length!==0;e++){let t=[];for(let m of l)for(let o of w(s,m,b)){let h=`${o.file}|${o.shortName}`;if(o.symbolId!==null){if(y.has(o.symbolId))continue;y.add(o.symbolId)}else if(r.has(h))continue;r.add(h),i.push({symbol:o.symbol,shortName:o.shortName,file:o.file,depth:e}),o.symbolId!==null&&o.symbolMatch&&t.push(o.symbolMatch)}l=t}return i.sort((e,t)=>e.depth-t.depth||e.file.localeCompare(t.file)),i}function w(s,f,n){let a=S(s,f,{limit:500}).filter(e=>!s.isIgnored(e.file)).filter(e=>!n||e.file.includes(n)),b=new Set(a.map(e=>e.file)),c=M(s).get(f.symbolId)??new Set,i=[];for(let e of c){if(b.has(e)||s.isIgnored(e)||n&&!e.includes(n))continue;let t=d(s,e),m=t.length>0?p(t,t[0].startLine):null;i.push({symbol:m?.symbol??e,file:e})}let y=[...a,...i],r=[],l=new Set;for(let e of y){let t=I(s,e.symbol);if(!t){let o=`${e.file}|${e.symbol}`;if(l.has(o))continue;l.add(o),r.push({symbolId:null,symbol:e.symbol,shortName:u(e.symbol),file:e.file,symbolMatch:null});continue}if(t.symbolId===f.symbolId||s.isIgnored(t.relativePath))continue;let m=`${t.symbolId}|${t.relativePath}`;l.has(m)||(l.add(m),r.push({symbolId:t.symbolId,symbol:t.symbol,shortName:u(t.symbol),file:t.relativePath,symbolMatch:t}))}return r}export{N as a};
|
|
2
|
+
//# sourceMappingURL=chunk-D7KLLMPB.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{b as m}from"./chunk-WTSTDJZ7.js";import{p as a}from"./chunk-IYFZS4PV.js";import{b as d,e as l}from"./chunk-TINPMWJK.js";function u(t,n){let s=m(t,n);if(s.length===0)return[];let i=s.map(()=>"?").join(", "),c=t.all(`SELECT DISTINCT d1.relative_path, gs.symbol
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
5
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
6
|
+
WHERE d1.relative_path NOT IN (${i})
|
|
7
|
+
AND (
|
|
8
|
+
EXISTS (
|
|
9
|
+
SELECT 1
|
|
10
|
+
FROM defn_enclosing_ranges der
|
|
11
|
+
JOIN documents d2 ON der.document_id = d2.id
|
|
12
|
+
WHERE der.symbol_id = gs.id
|
|
13
|
+
AND d2.relative_path IN (${i})
|
|
14
|
+
)
|
|
15
|
+
OR EXISTS (
|
|
16
|
+
SELECT 1
|
|
17
|
+
FROM mentions def_m
|
|
18
|
+
JOIN chunks def_c ON def_m.chunk_id = def_c.id
|
|
19
|
+
JOIN documents d2 ON def_c.document_id = d2.id
|
|
20
|
+
WHERE def_m.symbol_id = gs.id
|
|
21
|
+
AND def_m.role = 1
|
|
22
|
+
AND d2.relative_path IN (${i})
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
AND m.role != 1
|
|
26
|
+
AND ${t.localSymbolPredicate}
|
|
27
|
+
${t.pathExclusionsFor("d1")}
|
|
28
|
+
ORDER BY d1.relative_path`,...s,...s,...s),p=s.flatMap(e=>a(t,e).filter(o=>l(o.symbol)).map(o=>({relative_path:e,symbol:o.symbol}))),r=new Set;return[...c,...p].filter(e=>!t.isIgnored(e.relative_path)).filter(e=>{let o=`${e.relative_path}|${e.symbol}`;return r.has(o)?!1:(r.add(o),!0)}).map(e=>({consumer:e.relative_path,symbol:e.symbol,shortName:d(e.symbol)}))}export{u as a};
|
|
29
|
+
//# sourceMappingURL=chunk-D7YBWSON.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{a as h}from"./chunk-WTSTDJZ7.js";import{e as p}from"./chunk-BQ3INTYT.js";import{a as _}from"./chunk-LX4H4LLG.js";import{b as d,c,g as f}from"./chunk-TINPMWJK.js";function v(e,i){return b(e,i)?.map(t=>({symbol:t.symbol,shortName:t.shortName,fromFile:t.fromFile}))??[]}function F(e,i){let a=e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d ON c.document_id = d.id
|
|
5
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
6
|
+
WHERE gs.symbol LIKE ?
|
|
7
|
+
AND m.role = 2
|
|
8
|
+
ORDER BY d.relative_path`,`%${i}%`).filter(s=>!e.isIgnored(s.importer)).map(s=>({symbol:s.symbol,shortName:d(s.symbol),fromFile:s.importer}));if(a.length>0)return a;let o=_(e,i),r=o?.relativePath??null,m=o?c(o.symbol):i.replace(/\(\)$/,""),u=o?f(o.symbol):!1,y=e.all(`SELECT relative_path
|
|
9
|
+
FROM documents
|
|
10
|
+
WHERE 1 = 1
|
|
11
|
+
${e.pathExclusionsFor("documents")}
|
|
12
|
+
ORDER BY relative_path`),l=new Set;for(let s of y)if(!e.isIgnored(s.relative_path)){for(let n of p(e,s.relative_path))if(n.sourcePath&&!(r&&g(n.sourcePath)!==g(r))){if(n.kind==="side-effect"){l.add(s.relative_path);continue}if(r&&E(s.relative_path)){l.add(s.relative_path);continue}if(u){l.add(s.relative_path);continue}if(n.kind==="named"&&n.importedName===m){l.add(s.relative_path);continue}n.kind==="namespace"&&n.usedMembers.includes(m)&&l.add(s.relative_path)}}return[...l].sort().map(s=>({symbol:o?.symbol??m,shortName:o?d(o.symbol):m,fromFile:s}))}function D(e,i){return b(e,i)?.filter(t=>!t.used).map(t=>({symbol:t.symbol,shortName:t.shortName,importedIn:t.importer}))??[]}function b(e,i){let t=h(e,i);if(!t)return null;let o=e.all(`SELECT DISTINCT
|
|
13
|
+
gs.symbol,
|
|
14
|
+
def_d.relative_path AS from_file,
|
|
15
|
+
imp_d.relative_path AS importer,
|
|
16
|
+
EXISTS (
|
|
17
|
+
SELECT 1
|
|
18
|
+
FROM mentions ref_m
|
|
19
|
+
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
20
|
+
WHERE ref_m.symbol_id = gs.id
|
|
21
|
+
AND ref_m.role != 1
|
|
22
|
+
AND ref_c.document_id = imp_d.id
|
|
23
|
+
) AS used
|
|
24
|
+
FROM mentions m
|
|
25
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
26
|
+
JOIN documents imp_d ON c.document_id = imp_d.id
|
|
27
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
28
|
+
LEFT JOIN (
|
|
29
|
+
SELECT m2.symbol_id, c2.document_id
|
|
30
|
+
FROM mentions m2
|
|
31
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
32
|
+
WHERE m2.role = 1
|
|
33
|
+
GROUP BY m2.symbol_id
|
|
34
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
35
|
+
LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
36
|
+
WHERE imp_d.relative_path = ?
|
|
37
|
+
AND m.role = 2
|
|
38
|
+
ORDER BY def_d.relative_path, gs.symbol`,t).filter(r=>!e.isIgnored(r.importer));return o.length>0?o.map(r=>({symbol:r.symbol,shortName:d(r.symbol),fromFile:r.from_file??"(external)",importer:r.importer,used:r.used!==0})):p(e,t).map(r=>{let m=I(r.importedName,r.localName,r.kind),u=r.kind==="side-effect"?!0:r.used;return{symbol:m,shortName:m,fromFile:r.sourcePath??"(external)",importer:t,used:u}})}function I(e,i,t){return t==="namespace"&&e==="*"&&i?`* as ${i}`:t==="default"&&i?`default as ${i}`:t==="side-effect"?"(side effect import)":i&&i!==e?`${e} as ${i}`:e}function g(e){return e.replace(/\\/g,"/")}function E(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{v as a,F as b,D as c};
|
|
39
|
+
//# sourceMappingURL=chunk-DE5ZBHMK.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import{a as s}from"./chunk-WTSTDJZ7.js";function r(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d2.relative_path
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
5
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
6
|
+
JOIN (
|
|
7
|
+
SELECT m2.symbol_id, c2.document_id
|
|
8
|
+
FROM mentions m2
|
|
9
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
10
|
+
WHERE m2.role = 1
|
|
11
|
+
GROUP BY m2.symbol_id
|
|
12
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
13
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
14
|
+
WHERE d1.relative_path = ?
|
|
15
|
+
AND d2.relative_path <> d1.relative_path
|
|
16
|
+
AND ${e.localSymbolPredicate}
|
|
17
|
+
ORDER BY d2.relative_path`,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}function a(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d1.relative_path
|
|
18
|
+
FROM mentions m
|
|
19
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
20
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
21
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
22
|
+
JOIN (
|
|
23
|
+
SELECT m2.symbol_id, c2.document_id
|
|
24
|
+
FROM mentions m2
|
|
25
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
26
|
+
WHERE m2.role = 1
|
|
27
|
+
GROUP BY m2.symbol_id
|
|
28
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
29
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
30
|
+
WHERE d2.relative_path = ?
|
|
31
|
+
AND d1.relative_path != ?
|
|
32
|
+
ORDER BY d1.relative_path`,i,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}export{r as a,a as b};
|
|
33
|
+
//# sourceMappingURL=chunk-DHYIJHXZ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as h}from"./chunk-GNXRLK5G.js";import{d as x}from"./chunk-WCDXJGYT.js";function R(s,n={}){let{scope:i,maxDepth:C=10}=n,y=x(s,i),a=[],l=new Set,f=new Set,c=[];function m(e,t){if(t>C)return;if(f.has(e)){let o=c.indexOf(e);if(o!==-1){let r=c.slice(o).concat(e),u=r.indexOf(r.reduce((b,S)=>b<S?b:S)),p=[...r.slice(u,-1),...r.slice(0,u),r[u]],k=p.join(" -> ");d.has(k)||(d.add(k),a.push({path:p,kind:D(p)}))}return}if(l.has(e))return;l.add(e),f.add(e),c.push(e);let g=y.get(e);if(g)for(let o of g)m(o,t+1);c.pop(),f.delete(e)}let d=new Set;for(let e of y.keys())l.has(e)||m(e,0);return a.sort((e,t)=>e.kind!==t.kind?e.kind==="real"?-1:1:e.path.length-t.path.length),a}function D(s){if(s.length!==3)return"real";let[n,i]=s;return!n||!i?"real":h(n)||h(i)?"module-hierarchy":"real"}export{R as a};
|
|
2
|
+
//# sourceMappingURL=chunk-EEF3YEHW.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h as v}from"./chunk-WCDXJGYT.js";import{e as L,r as w}from"./chunk-IYFZS4PV.js";import{b,f as C}from"./chunk-TINPMWJK.js";function q(i,k={}){let{scope:x,minLoc:z=10,minCallees:D=6,limit:E=20}=k,y=w(i,x).filter(t=>!i.isIgnored(t.relativePath)).filter(t=>h(t)>=z&&C(t.symbol)).filter(t=>!(t.relativePath.split("/").pop()??"").includes("types")).filter(t=>!L(i,t.relativePath,t.startLine)).sort((t,r)=>h(r)-h(t)),F=v(i,y),d=[];for(let t of y){let r=F.get(t.symbolId)??[],c=new Set(r.map(e=>e.symbol));if(c.size<D)continue;let l=new Map;for(let e of c)l.set(e,new Set);let a=new Map;for(let e of r)a.has(e.chunkId)||a.set(e.chunkId,new Set),a.get(e.chunkId).add(e.symbol);for(let e of a.values()){let s=[...e];for(let o=0;o<s.length;o++)for(let n=o+1;n<s.length;n++)l.get(s[o]).add(s[n]),l.get(s[n]).add(s[o])}let f=new Set,m=[];for(let e of c){if(f.has(e))continue;let s=new Set,o=[e];for(;o.length>0;){let n=o.pop();if(!f.has(n)){f.add(n),s.add(n);for(let u of l.get(n)??[])f.has(u)||o.push(u)}}m.push(s)}if(m.length<2)continue;let S=m.filter(e=>e.size>=3).map(e=>{let s=new Set;for(let p of m)if(p!==e)for(let g of p)s.add(g);let o=0;for(let p of e)for(let g of l.get(p)??[])s.has(g)&&o++;let n=e.size*s.size,u=n>0?1-o/n:1;return{callees:[...e].map(b),isolation:u}}).filter(e=>e.isolation>.5).sort((e,s)=>s.isolation-e.isolation);S.length>0&&d.push({symbol:t.symbol,shortName:b(t.symbol),relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:h(t),totalCallees:c.size,clusters:S})}return d.sort((t,r)=>r.clusters.length-t.clusters.length||r.loc-t.loc),d.slice(0,E)}function h(i){return i.endLine-i.startLine+1}export{q as a};
|
|
2
|
+
//# sourceMappingURL=chunk-F2LLHRRZ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as n,f as a}from"./chunk-WCDXJGYT.js";import{a as i}from"./chunk-LX4H4LLG.js";import{b as m}from"./chunk-TINPMWJK.js";function b(s,e){let o=i(s,e);if(!o)return null;let t=a(s,o,{limit:50}),r=y(n(s,o,{limit:50}));return{symbol:o.symbol,shortName:m(o.symbol),callers:t.map(l=>({symbol:l.symbol,shortName:m(l.symbol),file:l.file})),callees:r.map(l=>({symbol:l.symbol,shortName:m(l.symbol),file:l.file}))}}function y(s){let e=new Set,o=[];for(let t of s){let r=`${t.symbol}|${t.file}`;e.has(r)||(e.add(r),o.push(t))}return o}export{b as a};
|
|
2
|
+
//# sourceMappingURL=chunk-FCC3XJTI.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as c}from"./chunk-ZSRXMNMK.js";import{d as f}from"./chunk-WCDXJGYT.js";import{b as a}from"./chunk-IYFZS4PV.js";function i(t){let r=_(t);return b(r)?"test":x(r)?"worker":S(r)?"entry":P(r)?"barrel":"source"}function l(t){return i(t)==="barrel"}function p(t){return g.get(t,()=>{let r=f(t),e=c(t).filter(s=>{let n=i(s);return n==="entry"||n==="worker"}),u=new Set,o=new Set;for(;e.length>0;){let s=e.shift();if(!u.has(s)){u.add(s),i(s)==="barrel"&&o.add(s);for(let n of r.get(s)??[])u.has(n)||e.push(n)}}return o})}var g=a("live-barrels");function h(t,r){return p(t).has(_(r))}function $(t){let r=p(t);return c(t).filter(e=>l(e)&&!r.has(e))}function k(t,r){let e=i(r);return e==="entry"||e==="worker"||h(t,r)}var v=["%/__tests__/%","%.test.%","%.spec.%","%/test/%","%/tests/%","%_test.%","%_spec.%","%/test_%.%","%/spec_%.%"],w=["%/test-utils/%"];function b(t){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(t)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(t)||/(?:^|\/)spec_[^/]+$/i.test(t)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(t)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(t)||/(?:^|\/)__tests__\//i.test(t)||/(?:^|\/)test\//i.test(t)||/(?:^|\/)tests\//i.test(t)||/(?:^|\/)__fixtures__\//i.test(t)||/(?:^|\/)__mocks__\//i.test(t)||/(?:^|\/)test-support\//i.test(t)||/(?:^|\/)test-utils\//i.test(t)||/(?:^|\/)testing\//i.test(t))}function x(t){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(t)}function S(t){let r=t.split("/"),e=r[r.length-1]??t;return e==="cli.ts"||e==="cli.js"||e==="postinstall.ts"||e==="postinstall.js"||e==="main.ts"||e==="main.js"||e==="main.rs"||e==="main.go"||e==="main.py"||e==="build.rs"||e==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(t)||/(?:^|\/)examples\/[^/]+\.rs$/.test(t)||/(?:^|\/)tests\/[^/]+\.rs$/.test(t)||/(?:^|\/)benches\/[^/]+\.rs$/.test(t)?!0:e==="index.ts"||e==="index.js"?r.length<=2:!1}function P(t){return t==="index.ts"||t==="index.js"||t.endsWith("/index.ts")||t.endsWith("/index.js")||t.endsWith("/mod.rs")||t.endsWith("/__init__.py")}function _(t){return t.replace(/\\/g,"/")}export{l as a,h as b,$ as c,k as d,v as e,w as f};
|
|
2
|
+
//# sourceMappingURL=chunk-GNXRLK5G.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import{a as l}from"./chunk-WTSTDJZ7.js";import{d as r}from"./chunk-WCDXJGYT.js";import{a as c}from"./chunk-LX4H4LLG.js";import{b as d}from"./chunk-TINPMWJK.js";function f(e,t){let o=c(e,t);if(!o)return[];let i=e.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
WHERE m.symbol_id = ?
|
|
5
|
+
AND m.role != 1`,o.symbolId);return[{name:d(o.symbol),count:i?.file_count??0}]}function y(e,t){let o=l(e,t);if(!o)return[];let n=e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
|
|
6
|
+
FROM mentions m
|
|
7
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
8
|
+
JOIN documents d ON c.document_id = d.id
|
|
9
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
10
|
+
JOIN (
|
|
11
|
+
SELECT m2.symbol_id, c2.document_id
|
|
12
|
+
FROM mentions m2
|
|
13
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
14
|
+
WHERE m2.role = 1
|
|
15
|
+
GROUP BY m2.symbol_id
|
|
16
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
17
|
+
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
18
|
+
WHERE d.relative_path = ?
|
|
19
|
+
AND m.role != 1
|
|
20
|
+
AND def_d.id != d.id
|
|
21
|
+
GROUP BY d.id
|
|
22
|
+
ORDER BY symbol_count DESC`,o).filter(m=>!e.isIgnored(m.relative_path)).map(m=>({name:m.relative_path,count:m.symbol_count}));if(n.length>0)return n;let s=r(e).get(o);return!s||s.size===0?[]:[{name:o,count:s.size}]}function b(e,t={}){return _(e,t).map(o=>({name:d(o.symbol),count:o.file_count}))}function _(e,t){let{limit:o=30,scope:i}=t,n=i?`AND def_d.relative_path LIKE '%${i}%'`:"";return e.all(`SELECT gs.symbol, COUNT(DISTINCT c.document_id) AS file_count
|
|
23
|
+
FROM mentions m
|
|
24
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
25
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
26
|
+
JOIN (
|
|
27
|
+
SELECT m2.symbol_id, c2.document_id
|
|
28
|
+
FROM mentions m2
|
|
29
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
30
|
+
WHERE m2.role = 1
|
|
31
|
+
GROUP BY m2.symbol_id
|
|
32
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
33
|
+
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
34
|
+
WHERE m.role != 1
|
|
35
|
+
${e.pathExclusionsFor("def_d")}
|
|
36
|
+
${e.symbolNoiseFor("gs")}
|
|
37
|
+
${n}
|
|
38
|
+
GROUP BY gs.id
|
|
39
|
+
HAVING file_count > 1
|
|
40
|
+
ORDER BY file_count DESC
|
|
41
|
+
LIMIT ?`,o)}function I(e,t={}){let{limit:o=30,scope:i}=t,n=i?`AND d.relative_path LIKE '%${i}%'`:"";return e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
|
|
42
|
+
FROM mentions m
|
|
43
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
44
|
+
JOIN documents d ON c.document_id = d.id
|
|
45
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
46
|
+
JOIN (
|
|
47
|
+
SELECT m2.symbol_id, c2.document_id
|
|
48
|
+
FROM mentions m2
|
|
49
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
50
|
+
WHERE m2.role = 1
|
|
51
|
+
GROUP BY m2.symbol_id
|
|
52
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
53
|
+
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
54
|
+
WHERE m.role != 1
|
|
55
|
+
AND def_d.id != d.id
|
|
56
|
+
${e.pathExclusionsFor("d")}
|
|
57
|
+
${e.symbolNoiseFor("gs")}
|
|
58
|
+
${n}
|
|
59
|
+
GROUP BY d.id
|
|
60
|
+
ORDER BY symbol_count DESC
|
|
61
|
+
LIMIT ?`,o).filter(s=>!e.isIgnored(s.relative_path)).map(s=>({name:s.relative_path,count:s.symbol_count}))}export{f as a,y as b,b as c,I as d};
|
|
62
|
+
//# sourceMappingURL=chunk-GXVB36TG.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as f}from"./chunk-WCDXJGYT.js";import{a as m}from"./chunk-LX4H4LLG.js";import{b as r}from"./chunk-TINPMWJK.js";function w(i,g,p){let s=m(i,g),n=m(i,p);if(!s||!n)return null;let c=new Set(f(i,s).map(e=>e.symbol)),h=new Set(f(i,n).map(e=>e.symbol)),a=[];for(let e of c)h.has(e)&&a.push(e);let o=[];for(let e of c)h.has(e)||o.push(e);let l=[];for(let e of h)c.has(e)||l.push(e);let u=new Set([...c,...h]),d=u.size>0?a.length/u.size:0,t;u.size===0?t="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":a.length===0?t="These functions do not share any callees. They are not a callee-based consolidation candidate.":o.length===0&&l.length===0?t="These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.":o.length===0?t="A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.":l.length===0?t="B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.":o.length<=2&&l.length<=2?t=`Create a shared function with the ${a.length} common callees. Pass the ${o.length+l.length} divergent callees as parameters or strategy callbacks.`:t=`Extract the ${a.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${o.length} callees in A, ${l.length} in B).`;let y=s.endLine-s.startLine+1,b=n.endLine-n.startLine+1;return{symbolA:{symbol:s.symbol,shortName:r(s.symbol),file:s.relativePath,loc:y},symbolB:{symbol:n.symbol,shortName:r(n.symbol),file:n.relativePath,loc:b},similarity:d,sharedCallees:a.map(r),uniqueToA:o.map(r),uniqueToB:l.map(r),consolidationStrategy:t}}export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-HMKJTAZD.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as y}from"./chunk-WCDXJGYT.js";function L(D,k={}){let{limit:x=10,scope:M,minDepth:j=3}=k,g=y(D,M),u=new Map,o=[],l=new Map,r=new Map,a=new Set,f=[],d=0;for(let t of g.keys()){if(l.has(t))continue;let n=[],s=(g.get(t)??new Set).values();for(l.set(t,d),r.set(t,d),d+=1,f.push(t),a.add(t),n.push({node:t,iter:s,pendingChild:null});n.length>0;){let e=n[n.length-1];if(e.pendingChild!==null){let h=e.pendingChild;e.pendingChild=null,r.set(e.node,Math.min(r.get(e.node),r.get(h)))}let c=e.iter.next();if(c.done){if(r.get(e.node)===l.get(e.node)){let h=[];for(;;){let p=f.pop();if(a.delete(p),h.push(p),u.set(p,o.length),p===e.node)break}o.push(h)}n.pop();continue}let i=c.value;if(l.has(i))a.has(i)&&r.set(e.node,Math.min(r.get(e.node),l.get(i)));else{l.set(i,d),r.set(i,d),d+=1,f.push(i),a.add(i);let h=(g.get(i)??new Set).values();e.pendingChild=i,n.push({node:i,iter:h,pendingChild:null})}}}let m=new Map,b=new Array(o.length);for(let t=0;t<o.length;t++)b[t]=o[t].length,m.set(t,new Set);for(let[t,n]of g){let s=u.get(t);for(let e of n){let c=u.get(e);c!==s&&m.get(s).add(c)}}let S=new Array(o.length),I=new Array(o.length);for(let t=0;t<o.length;t++){let n=[],s=0;for(let e of m.get(t)){let c=I[e];c>s&&(s=c,n=S[e])}S[t]=[t,...n],I[t]=b[t]+s}function v(t){return S[t]}let A=o.map(t=>[...t].sort()),C=new Set,w=[];for(let t=0;t<o.length;t++){let n=v(t),s=[];for(let c of n)s.push(...A[c]);if(s.length<j)continue;let e=s.join(" ");C.has(e)||(C.add(e),w.push({chain:s,depth:s.length}))}return w.sort((t,n)=>n.depth-t.depth),w.slice(0,x)}export{L as a};
|
|
2
|
+
//# sourceMappingURL=chunk-IBGBI3VU.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{a as D,b as v,c as k,d as A,f as M}from"./chunk-TINPMWJK.js";function b(a){let n=new WeakMap,e=t=>{let r=n.get(t);return r||(r=new Map,n.set(t,r)),r};return{get(t,r,i){let o=e(t);if(o.has(r))return o.get(r);let l=i();return o.set(r,l),l},invalidate(t,r){n.get(t)?.delete(r)},invalidateAll(t){n.delete(t)},size(t){return n.get(t)?.size??0}}}function he(a){let n=new WeakMap;return{get(e,t){let r=n.get(e);if(r)return r.value;let i=t();return n.set(e,{value:i}),i},invalidate(e){n.delete(e)},has(e){return n.has(e)}}}function I(a){let n=new WeakMap,e=t=>{let r=n.get(t);return r||(r=new Map,n.set(t,r)),r};return{get(t,r,i,o){let l=e(t),s=l.get(r);if(s&&s.source===i)return s.value;let u=o();return l.set(r,{source:i,value:u}),u},invalidate(t,r){n.get(t)?.delete(r)},invalidateAll(t){n.delete(t)}}}import{existsSync as H,readFileSync as Y}from"fs";import{join as K}from"path";var U=b("source-text");function m(a,n){let e=n.replace(/\\/g,"/");return U.get(a,e,()=>{let t=K(a.config.projectRoot,e);return H(t)?Y(t,"utf-8"):""})}var z=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale|wrapper|passthrough|drift)?/i;function Ce(a,n,e){if(e<=0)return!1;let t=m(a,n);if(!t)return!1;let r=t.split(`
|
|
2
|
+
`);for(let i=e-1;i>=0&&i>=e-5;i-=1){let o=(r[i]??"").trim();if(o!==""){if(z.test(o))return!0;if(!o.startsWith("//")&&!o.startsWith("*")&&!o.startsWith("/*")&&!o.startsWith("@")&&!o.startsWith("#"))return!1}}return!1}import{extname as R}from"path";import{createRequire as G}from"module";var p=G(import.meta.url),y=null,N=!1;function P(){if(N)return null;if(y)return y;try{return y=p("tree-sitter"),y}catch{return N=!0,null}}var q={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb"},w=new Map,x=new Set;function O(a){if(x.has(a))return null;let n=w.get(a);if(n)return n;let e;try{switch(a){case"rust":e=p("tree-sitter-rust");break;case"typescript":e=p("tree-sitter-typescript").typescript;break;case"tsx":e=p("tree-sitter-typescript").tsx;break;case"javascript":e=p("tree-sitter-javascript");break;case"python":e=p("tree-sitter-python");break;case"java":e=p("tree-sitter-java");break;case"kotlin":e=p("tree-sitter-kotlin");break;case"scala":e=p("tree-sitter-scala");break;case"ruby":e=p("tree-sitter-ruby");break;case"c":e=p("tree-sitter-c");break;case"cpp":e=p("tree-sitter-cpp");break;case"csharp":e=p("tree-sitter-c-sharp");break;case"php":e=p("tree-sitter-php").php;break;case"vb":{let t=p("tree-sitter-vb-dotnet");e=t.language??t;break}}}catch{return x.add(a),null}return w.set(a,e),e}var T=new Map;function V(a){let n=T.get(a);if(n)return n;let e=O(a);if(!e)return null;let t=P();if(!t)return null;let r=new t;try{r.setLanguage(e)}catch{return x.add(a),null}return T.set(a,r),r}function h(a){return q[R(a).toLowerCase()]??null}function J(a){return R(a).toLowerCase()===".vue"}var j=I("ast-trees");function L(a,n){if(J(n))return Z(a,n);let e=h(n);if(!e)return null;let t=m(a,n);return t?j.get(a,n,t,()=>{let r=V(e);return r?r.parse(t):null}):null}function Z(a,n){let e=m(a,n);return e?j.get(a,n,e,()=>{let t=X(e);if(!t)return null;let r=V(t.language);if(!r)return null;let i=`
|
|
3
|
+
`.repeat(t.startLine)+t.body;return r.parse(i)}):null}function X(a){let n=[],e=/<script\b([^>]*)>([\s\S]*?)<\/script>/g;for(let s of a.matchAll(e))typeof s.index=="number"&&n.push({tagOpen:s[1]??"",body:s[2]??"",openIdx:s.index+(s[0].length-(s[2]?.length??0)-9)});if(n.length===0)return null;let t=n.find(s=>/\bsetup\b/.test(s.tagOpen))??n[0],i=t.tagOpen.match(/\blang\s*=\s*["']?([\w-]+)/)?.[1]?.toLowerCase(),o=i==="ts"||i==="typescript"?"typescript":i==="tsx"?"tsx":"javascript",l=ee(a,t.openIdx);return{body:t.body,startLine:l,language:o}}function ee(a,n){let e=0;for(let t=0;t<n&&t<a.length;t++)a.charCodeAt(t)===10&&e++;return e}var g=new Map;function te(a,n){let e=`${a}::${n}`;if(g.has(e))return g.get(e)??null;let t=O(a);if(!t)return g.set(e,null),null;let r=P();if(!r)return g.set(e,null),null;let i=null;try{i=new r.Query(t,n)}catch{i=null}return g.set(e,i),i}var ne={rust:`
|
|
4
|
+
(function_item name: (identifier) @name) @def
|
|
5
|
+
(function_signature_item name: (identifier) @name) @def
|
|
6
|
+
`,typescript:`
|
|
7
|
+
(function_declaration name: (identifier) @name) @def
|
|
8
|
+
(method_definition name: (property_identifier) @name) @def
|
|
9
|
+
(method_signature name: (property_identifier) @name) @def
|
|
10
|
+
(function_signature name: (identifier) @name) @def
|
|
11
|
+
(variable_declarator name: (identifier) @name value: (arrow_function)) @def
|
|
12
|
+
(variable_declarator name: (identifier) @name value: (function_expression)) @def
|
|
13
|
+
(public_field_definition name: (property_identifier) @name value: (arrow_function)) @def
|
|
14
|
+
`,tsx:`
|
|
15
|
+
(function_declaration name: (identifier) @name) @def
|
|
16
|
+
(method_definition name: (property_identifier) @name) @def
|
|
17
|
+
(method_signature name: (property_identifier) @name) @def
|
|
18
|
+
(function_signature name: (identifier) @name) @def
|
|
19
|
+
(variable_declarator name: (identifier) @name value: (arrow_function)) @def
|
|
20
|
+
(variable_declarator name: (identifier) @name value: (function_expression)) @def
|
|
21
|
+
(public_field_definition name: (property_identifier) @name value: (arrow_function)) @def
|
|
22
|
+
`,javascript:`
|
|
23
|
+
(function_declaration name: (identifier) @name) @def
|
|
24
|
+
(method_definition name: (property_identifier) @name) @def
|
|
25
|
+
(variable_declarator name: (identifier) @name value: (arrow_function)) @def
|
|
26
|
+
(variable_declarator name: (identifier) @name value: (function_expression)) @def
|
|
27
|
+
`,python:`
|
|
28
|
+
(function_definition name: (identifier) @name) @def
|
|
29
|
+
`},re=new WeakMap;function F(a,n){return Q(a,n,re,ne,e=>{let t=[];for(let r of e){let i=null,o=null;for(let l of r.captures)l.name==="name"?i=l.node.text:l.name==="def"&&(o={startLine:l.node.startPosition.row,endLine:l.node.endPosition.row});i&&o&&t.push({name:i,startLine:o.startLine,endLine:o.endLine})}return t})}var ae={rust:`
|
|
30
|
+
(call_expression function: (_) @target) @call
|
|
31
|
+
(macro_invocation macro: (_) @target) @call
|
|
32
|
+
`,typescript:`
|
|
33
|
+
(call_expression function: (_) @target) @call
|
|
34
|
+
(new_expression constructor: (_) @target) @call
|
|
35
|
+
`,tsx:`
|
|
36
|
+
(call_expression function: (_) @target) @call
|
|
37
|
+
(new_expression constructor: (_) @target) @call
|
|
38
|
+
`,javascript:`
|
|
39
|
+
(call_expression function: (_) @target) @call
|
|
40
|
+
(new_expression constructor: (_) @target) @call
|
|
41
|
+
`,python:`
|
|
42
|
+
(call function: (_) @target) @call
|
|
43
|
+
`},ie=new WeakMap;function Ie(a,n){return Q(a,n,ie,ae,e=>{let t=[];for(let r of e){let i=null,o=null;for(let s of r.captures)s.name==="target"?i=s.node:s.name==="call"&&(o=s.node);if(!i||!o)continue;let l=S(i);l&&t.push({calleeLeaf:l,line:o.startPosition.row})}return t})}function Ne(a,n){return se(a,n,oe,()=>new Map,(e,t,r)=>{let i=(s,u)=>{if(s===u)return;let c=r.get(s);c||(c=new Set,r.set(s,c)),c.add(u)},o=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),l=(s,u)=>{let c=d=>{o.has(d.type)&&d.text!==u&&i(d.text,u);for(let f of d.children)c(f)};for(let d of s.children)c(d)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let u=s.namedChildren.find(d=>d.type==="type_identifier")?.text;if(!u)continue;let c=s.namedChildren.find(d=>d.type==="field_declaration_list"||d.type==="enum_variant_list"||d.type==="ordered_field_declaration_list");c&&l(c,u),s.type==="type_item"&&l(s,u)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let u=s.namedChildren.find(d=>d.type==="identifier")?.text;if(!u)continue;let c=s.namedChildren.find(d=>d.type==="block");if(c)for(let d of c.descendantsOfType("type"))for(let f of d.descendantsOfType("identifier"))f.text!==u&&i(f.text,u)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let u=s.namedChildren.find(c=>c.type==="type_identifier")?.text;u&&l(s,u)}})??new Map}function se(a,n,e,t,r){let i=h(n);if(!i)return null;let o=L(a,n);if(!o)return null;let l=e.get(o);if(l)return l;let s=t();return r(o,i,s),e.set(o,s),s}function Q(a,n,e,t,r){let i=h(n);if(!i)return null;let o=t[i];if(!o)return null;let l=L(a,n);if(!l)return null;let s=e.get(l);if(s)return s;let u=te(i,o);if(!u)return null;let c=r(u.matches(l.rootNode));return e.set(l,c),c}var oe=new WeakMap,E=new WeakMap;function we(a,n,e,t){let r=h(n);if(!r)return null;let i=L(a,n);if(!i)return null;let o=E.get(i);return o||(o=le(i,r),E.set(i,o)),o.get(`${e}:${t}`)??null}function le(a,n){let e=n==="rust"?new Set(["function_item","function_signature_item"]):n==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),t=new Map,r=i=>{if(e.has(i.type)){let o=i.namedChildren.find(s=>s.type==="parameters"||s.type==="formal_parameters"),l=0;if(o)for(let s of o.namedChildren)s.type==="comment"||s.type==="line_comment"||s.type==="block_comment"||(l+=1);t.set(`${i.startPosition.row}:${i.endPosition.row}`,{paramCount:l})}for(let o of i.children)r(o)};return r(a.rootNode),t}function S(a){switch(a.type){case"identifier":case"type_identifier":case"property_identifier":case"shorthand_property_identifier":return a.text;case"field_expression":case"member_expression":case"attribute":{let n=a.namedChild(a.namedChildCount-1);return n?S(n):null}case"scoped_identifier":{let n=a.childForFieldName("name")??a.namedChild(a.namedChildCount-1);return n?S(n):null}case"super":case"self":case"this":return null;default:return null}}function $(a){return!a||!a.trim()?null:a.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function W(a){if(!a)return null;let n=a.indexOf("|");return n===-1?a.replace(/\n/g," "):a.slice(n+1).replace(/\n/g," ")}var ce=b("file-definitions");function C(a,n){return ce.get(a,n,()=>{let e=a.all(`SELECT
|
|
44
|
+
gs.id,
|
|
45
|
+
gs.symbol,
|
|
46
|
+
der.document_id,
|
|
47
|
+
der.start_line,
|
|
48
|
+
der.end_line,
|
|
49
|
+
d.relative_path,
|
|
50
|
+
gs.display_name,
|
|
51
|
+
gs.kind,
|
|
52
|
+
gs.documentation,
|
|
53
|
+
gs.enclosing_symbol
|
|
54
|
+
FROM global_symbols gs
|
|
55
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
56
|
+
JOIN documents d ON der.document_id = d.id
|
|
57
|
+
WHERE d.relative_path = ?
|
|
58
|
+
${a.symbolNoiseFor("gs")}
|
|
59
|
+
ORDER BY der.start_line, der.end_line`,n),t=e.length>0?[]:a.all(`SELECT
|
|
60
|
+
gs.id,
|
|
61
|
+
gs.symbol,
|
|
62
|
+
c.document_id,
|
|
63
|
+
MIN(c.start_line) AS start_line,
|
|
64
|
+
MAX(c.end_line) AS end_line,
|
|
65
|
+
d.relative_path,
|
|
66
|
+
gs.display_name,
|
|
67
|
+
gs.kind,
|
|
68
|
+
gs.documentation,
|
|
69
|
+
gs.enclosing_symbol
|
|
70
|
+
FROM global_symbols gs
|
|
71
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
72
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
73
|
+
JOIN documents d ON c.document_id = d.id
|
|
74
|
+
WHERE d.relative_path = ?
|
|
75
|
+
AND m.role = 1
|
|
76
|
+
${a.symbolNoiseFor("gs")}
|
|
77
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
78
|
+
ORDER BY start_line, end_line`,n);return de(a,n,(e.length>0?e:t).map(r=>({symbolId:r.id,symbol:r.symbol,documentId:r.document_id,startLine:r.start_line,endLine:r.end_line,relativePath:r.relative_path,leaf:k(r.symbol),parentTypeName:ye(r.symbol),isFunctionLike:M(r.symbol),isTypeLike:A(r.symbol)==="type",kind:r.kind??null,documentation:r.documentation??null,enclosingSymbol:r.enclosing_symbol??null})))})}function Fe(a,n={}){return ue(a,n.scope)}function ue(a,n){let e=n?`AND relative_path LIKE '%${n}%'`:"";return a.all(`SELECT relative_path
|
|
79
|
+
FROM documents
|
|
80
|
+
WHERE 1 = 1
|
|
81
|
+
${a.pathExclusionsFor("documents")}
|
|
82
|
+
${e}
|
|
83
|
+
ORDER BY relative_path`).flatMap(t=>C(a,t.relative_path)).filter(t=>!a.isIgnored(t.relativePath))}function Qe(a,n,e={}){if(n.length===0)return[];let t=n.flatMap(r=>C(a,r)).filter(r=>!a.isIgnored(r.relativePath));return e.onlyDocumented&&(t=t.filter(r=>r.documentation!==null&&r.documentation!=="")),e.sort&&(t=t.sort((r,i)=>r.relativePath.localeCompare(i.relativePath)||r.startLine-i.startLine||r.endLine-i.endLine)),t.map(r=>({startLine:r.startLine,endLine:r.endLine,symbol:r.symbol,shortName:v(r.symbol),signature:$(W(r.documentation)),relativePath:r.relativePath,enclosingSymbol:r.enclosingSymbol}))}function $e(a,n){let e=null;for(let t of a)t.startLine>n||t.endLine<n||(!e||t.endLine-t.startLine<e.endLine-e.startLine)&&(e=t);return e}function We(a,n){let e=C(a,n.relative_path).find(t=>t.symbolId===n.id);return e?{symbolId:e.symbolId,symbol:e.symbol,documentId:e.documentId,startLine:e.startLine,endLine:e.endLine,relativePath:e.relativePath}:{symbolId:n.id,symbol:n.symbol,documentId:n.document_id,startLine:n.start_line,endLine:n.end_line,relativePath:n.relative_path}}function de(a,n,e){let t=F(a,n);if(t)return pe(e,t);let r=m(a,n);if(!r)return e;let i=r.split(/\r?\n/),o=e.some(c=>_(c.symbol))?me(i):null,l=new Map;for(let c of e)l.set(c.symbolId,fe(i,o,c));let s=new Map,u=e.filter(c=>_(c.symbol)).map(c=>({definition:c,startLine:l.get(c.symbolId)??c.startLine})).sort((c,d)=>c.startLine-d.startLine||c.definition.startLine-d.definition.startLine||c.definition.symbol.localeCompare(d.definition.symbol));for(let c=0;c<u.length;c+=1){let d=u[c],f=u[c+1],B=f?Math.max(d.startLine,f.startLine-1):i.length-1;s.set(d.definition.symbolId,{startLine:d.startLine,endLine:ge(i,d.definition,d.startLine,B)})}return e.map(c=>{let d=s.get(c.symbolId);return d?{...c,startLine:d.startLine,endLine:d.endLine}:c})}function pe(a,n){let e=new Map;for(let t of n){let r=e.get(t.name);r?r.push(t):e.set(t.name,[t])}return a.map(t=>{if(!_(t.symbol)||!t.leaf)return t;let r=e.get(t.leaf);if(!r||r.length===0)return t;let i=r[0],o=Math.abs(i.startLine-t.startLine);for(let l=1;l<r.length;l+=1){let s=r[l],u=Math.abs(s.startLine-t.startLine);u<o&&(i=s,o=u)}return{...t,startLine:i.startLine,endLine:i.endLine}})}function fe(a,n,e){if(!_(e.symbol))return e.startLine;let t=Math.max(0,Math.min(e.startLine,a.length-1));if(!n)return t;let r=n.get(e.leaf);if(!r||r.length===0)return t;let i=null;for(let o of r){let l=Math.abs(o-e.startLine);(!i||l<i.distance)&&(i={line:o,distance:l})}return i?.line??t}function me(a){let n=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,e=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,t=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,r=/\b([A-Za-z_$][\w$]*)\s*\(/g,i=new Map,o=(l,s)=>{let u=i.get(l);if(!u){i.set(l,[s]);return}u[u.length-1]!==s&&u.push(s)};for(let l=0;l<a.length;l+=1){let s=a[l]??"";for(let c of s.matchAll(n))c[1]&&o(c[1],l);for(let c of s.matchAll(e))c[1]&&o(c[1],l);let u=s.match(t);u?.[1]&&o(u[1],l);for(let c of s.matchAll(r))c[1]&&o(c[1],l)}return i}function ge(a,n,e,t){let r=Math.max(e,Math.min(a.length-1,t)),i=Math.max(e,Math.min(r,n.endLine)),o=0,l=0,s=!1;for(let u=e;u<=r;u+=1){let c=be(a[u]??"");for(let d of c)d==="{"?(o+=1,s=!0):d==="}"?o=Math.max(0,o-1):d==="("?l+=1:d===")"&&(l=Math.max(0,l-1));if(s&&o===0||!s&&l===0&&u>=i)return u}return i}function be(a){let n="",e=null,t=!1;for(let r=0;r<a.length;r+=1){let i=a[r],o=a[r+1];if(!e&&i==="/"&&o==="/"){n+=" ".repeat(a.length-r);break}if(e){if(t){t=!1,n+=" ";continue}if(i==="\\"){t=!0,n+=" ";continue}i===e&&(e=null),n+=" ";continue}if(i==='"'||i==="'"||i==="`"){e=i,n+=" ";continue}n+=i}return n}function _(a){return a.includes("().")}function ye(a){let n=D(a);if("kind"in n)return null;for(let e=n.descriptors.length-2;e>=0;e--){let t=n.descriptors[e];if(t?.suffix==="type")return t.name}return null}export{b as a,he as b,I as c,m as d,Ce as e,h as f,J as g,L as h,Ie as i,Ne as j,se as k,we as l,S as m,$ as n,W as o,C as p,Fe as q,ue as r,Qe as s,$e as t,We as u};
|
|
84
|
+
//# sourceMappingURL=chunk-IYFZS4PV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as m}from"./chunk-LX4H4LLG.js";import{p as l}from"./chunk-IYFZS4PV.js";import{c as r,e as a}from"./chunk-TINPMWJK.js";import{basename as p}from"path";function M(t,c){let o=m(t,c);if(!o)return[];let s=r(o.symbol),i=l(t,o.relativePath).filter(e=>a(e.symbol)),n=i.filter(e=>e.parentTypeName===s||e.symbol.includes(s));return(n.length>0?n:f(p(o.relativePath))===s?i.filter(e=>e.symbol.includes("<invalid-global-code>")):[]).map(e=>({startLine:e.startLine,endLine:e.endLine,name:r(e.symbol)}))}function f(t){return t.replace(/\.[^.]+$/,"")}export{M as a};
|
|
2
|
+
//# sourceMappingURL=chunk-JS2RNIC7.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{e as a,f as c}from"./chunk-WCDXJGYT.js";import{q as d}from"./chunk-IYFZS4PV.js";import{b as l}from"./chunk-TINPMWJK.js";function E(e,t={}){let{limit:m=20,scope:s,minFanIn:n=2,minFanOut:f=2}=t,_=s?`AND def_d.relative_path LIKE '%${s}%'`:"",r=e.all(`SELECT * FROM (
|
|
2
|
+
SELECT
|
|
3
|
+
gs.symbol,
|
|
4
|
+
def_d.relative_path AS defined_in,
|
|
5
|
+
(SELECT COUNT(DISTINCT ref_c.document_id)
|
|
6
|
+
FROM mentions ref_m
|
|
7
|
+
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
8
|
+
WHERE ref_m.symbol_id = gs.id AND ref_m.role != 1
|
|
9
|
+
) AS fan_in,
|
|
10
|
+
(SELECT COUNT(DISTINCT ref_gs.id)
|
|
11
|
+
FROM mentions ref_m
|
|
12
|
+
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
13
|
+
JOIN global_symbols ref_gs ON ref_m.symbol_id = ref_gs.id
|
|
14
|
+
JOIN (
|
|
15
|
+
SELECT m3.symbol_id, c3.document_id
|
|
16
|
+
FROM mentions m3
|
|
17
|
+
JOIN chunks c3 ON m3.chunk_id = c3.id
|
|
18
|
+
WHERE m3.role = 1
|
|
19
|
+
GROUP BY m3.symbol_id
|
|
20
|
+
) ref_sym_def ON ref_sym_def.symbol_id = ref_gs.id
|
|
21
|
+
WHERE ref_c.document_id = def_d.id
|
|
22
|
+
AND ref_m.role != 1
|
|
23
|
+
AND ref_sym_def.document_id != def_d.id
|
|
24
|
+
) AS fan_out
|
|
25
|
+
FROM global_symbols gs
|
|
26
|
+
JOIN (
|
|
27
|
+
SELECT m2.symbol_id, c2.document_id
|
|
28
|
+
FROM mentions m2
|
|
29
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
30
|
+
WHERE m2.role = 1
|
|
31
|
+
GROUP BY m2.symbol_id
|
|
32
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
33
|
+
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
34
|
+
WHERE 1 = 1
|
|
35
|
+
${e.pathExclusionsFor("def_d")}
|
|
36
|
+
${e.symbolNoiseFor("gs")}
|
|
37
|
+
${_}
|
|
38
|
+
) WHERE fan_in >= ? AND fan_out >= ?
|
|
39
|
+
ORDER BY (fan_in * fan_out) DESC
|
|
40
|
+
LIMIT ?`,n,f,m).filter(o=>!e.isIgnored(o.defined_in)).map(o=>({symbol:o.symbol,shortName:l(o.symbol),fanIn:o.fan_in,fanOut:o.fan_out,score:o.fan_in*o.fan_out,definedIn:o.defined_in}));return r.length>0?r:u(e,s,{minFanIn:n,minFanOut:f,limit:m})}function u(e,t,m){let{minFanIn:s,minFanOut:n,limit:f}=m;return d(e,{scope:t}).filter(i=>!e.isIgnored(i.relativePath)).map(i=>b(e,i)).filter(i=>i.fanIn>=s&&i.fanOut>=n).sort((i,r)=>r.score-i.score||r.fanIn-i.fanIn).slice(0,f)}function b(e,t){let m=new Set(c(e,t,{limit:500}).map(n=>n.file)).size,s=new Set(a(e,t,{limit:500}).filter(n=>n.file!==t.relativePath).map(n=>`${n.symbol}|${n.file}`)).size;return{symbol:t.symbol,shortName:l(t.symbol),fanIn:m,fanOut:s,score:m*s,definedIn:t.relativePath}}export{E as a};
|
|
41
|
+
//# sourceMappingURL=chunk-K5FQFCSN.js.map
|