@@ -60,16 +60,6 @@ pub trait Db: DbInputs {
6060 /// (mirroring `.libPaths()`).
6161 fn package_by_name ( & self , name : & str ) -> Option < Package > ;
6262
63- /// Look up a `Package` by its `DESCRIPTION` URL.
64- ///
65- /// Walks workspace packages, then library packages, then falls back
66- /// to [`StaleRoot`]. Stale matches are intentional: scanner upserts
67- /// use this to find a `Package` entity whose live container was
68- /// dropped on a previous `set_*_paths` call, so the entity gets
69- /// reused on re-add. Analysis paths should not call this — they use
70- /// [`Db::package_by_name`] which is stale-blind.
71- fn package_by_url ( & self , url : & UrlId ) -> Option < Package > ;
72-
7363 /// Resolve the live `Root` that contains `pkg`, if any.
7464 ///
7565 /// Returns `None` when the package is only in [`StaleRoot`] (its live
@@ -147,19 +137,6 @@ pub fn package_by_name_query(db: &dyn Db, name: &str) -> Option<Package> {
147137 None
148138}
149139
150- /// Implementation of [`Db::package_by_url`]. Walks live roots' packages
151- /// by `description_url`, then falls back to the stale bucket.
152- pub fn package_by_url_query ( db : & dyn Db , url : & UrlId ) -> Option < Package > {
153- for & root in db. live_roots ( ) {
154- if let LiveRoot :: Workspace ( r) | LiveRoot :: Library ( r) = root {
155- if let Some ( & pkg) = root_package_url_index ( db, r) . get ( url) {
156- return Some ( pkg) ;
157- }
158- }
159- }
160- stale_package_url_index ( db) . get ( url) . copied ( )
161- }
162-
163140/// Implementation of [`Db::root_by_package`]. Walks all live roots looking for
164141/// `pkg` in their `packages` vec, picking the longest-path root on ties.
165142pub fn root_by_package_query ( db : & dyn Db , pkg : Package ) -> Option < Root > {
@@ -232,45 +209,3 @@ fn root_package_index(db: &dyn Db, root: Root) -> FxHashMap<String, Package> {
232209 }
233210 map
234211}
235-
236- /// Per-root DESCRIPTION URL -> Package index. Used by
237- /// [`package_by_url_query`] for entity-reuse lookups across rescans;
238- /// salsa cache invalidates only when this root's packages change.
239- #[ salsa:: tracked( returns( ref) ) ]
240- fn root_package_url_index ( db : & dyn Db , root : Root ) -> FxHashMap < UrlId , Package > {
241- let mut map = FxHashMap :: default ( ) ;
242- for & pkg in root. packages ( db) {
243- map. insert ( pkg. description_url ( db) . clone ( ) , pkg) ;
244- }
245- map
246- }
247-
248- /// Stale file URL -> File index. Reads only `stale_root().files`. Not
249- /// consulted by [`file_by_url_query`] — analysis is stale-blind by
250- /// design. Scanner upserts use [`stale_file_by_url`] when re-adding a
251- /// path.
252- #[ salsa:: tracked( returns( ref) ) ]
253- fn stale_url_index ( db : & dyn Db ) -> FxHashMap < UrlId , File > {
254- let mut map = FxHashMap :: default ( ) ;
255- for & file in db. stale_root ( ) . files ( db) {
256- map. insert ( file. url ( db) . clone ( ) , file) ;
257- }
258- map
259- }
260-
261- /// Look up a stale `File` by URL. Public so scanner upsert helpers in
262- /// `oak_scan` can fall back to stale after [`Db::file_by_url`] misses.
263- pub fn stale_file_by_url ( db : & dyn Db , url : & UrlId ) -> Option < File > {
264- stale_url_index ( db) . get ( url) . copied ( )
265- }
266-
267- /// Stale DESCRIPTION URL -> Package index. Same role as
268- /// [`stale_url_index`] for packages.
269- #[ salsa:: tracked( returns( ref) ) ]
270- fn stale_package_url_index ( db : & dyn Db ) -> FxHashMap < UrlId , Package > {
271- let mut map = FxHashMap :: default ( ) ;
272- for & pkg in db. stale_root ( ) . packages ( db) {
273- map. insert ( pkg. description_url ( db) . clone ( ) , pkg) ;
274- }
275- map
276- }
0 commit comments