Skip to content

(Sources-2) oak_db::workspace_dependencies()#1287

Open
DavisVaughan wants to merge 5 commits into
sources/1-namespaced-accessesfrom
sources/2-workspace-dependencies
Open

(Sources-2) oak_db::workspace_dependencies()#1287
DavisVaughan wants to merge 5 commits into
sources/1-namespaced-accessesfrom
sources/2-workspace-dependencies

Conversation

@DavisVaughan

Copy link
Copy Markdown
Contributor

Progress towards #1234
Branched from #1286

Two new things here:

  • File::used_packages() is a tracked query that returns the Names of all packages used by this file

    • library() and require() are included (reusing the existing attached_packages())
    • :: and ::: are included (using the new namespaced_accesses() from (Sources-1) Teach SemanticIndex about NamespacedAccesses #1286)
    • The result is sorted and unique, maximizing the chance of backdating after small file edits (a reorder of library() or :: calls should not affect this query result, unlike attached_packages())
  • oak_db::workspace_dependencies() is a tracked query that returns a Vec<Package> of every installed package used by this workspace.

    • It collects from File::used_packages() on each workspace_file()
    • It collects from DESCRIPTION if you have a workspace package open. In particular, it collects Imports and Depends. I have omitted Suggests because typically they are referenced by :: already if they are used, so they probably aren't worth it to also include here?

Two notes about oak_db::workspace_dependencies():

  • Any not installed package returned by File::used_packages() is thrown out. The user can't actually use this, and we won't have a package version to look up anyways.
  • If you have a workspace package open, it is also removed from the list (the workspace package itself isn't really a workspace dependency). We assume that you already have package sources for that in your local R/ folder.

oak_db::workspace_dependencies() will be used in a future PR to detect the set of changed packages after each revision change.

Comment thread crates/oak_db/src/file.rs Outdated
Comment thread crates/oak_db/src/file.rs
Comment thread crates/oak_db/src/workspace.rs Outdated
Comment thread crates/oak_db/src/workspace.rs
We are guessing there won't ever be more than 100-200 namespace accesses within a single R file, so this is likely to never be a performance or memory issue, and the Vec impl is simpler to reason about.
@DavisVaughan DavisVaughan force-pushed the sources/2-workspace-dependencies branch from a1a4bce to 8fb644d Compare June 24, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants