Skip to content

Finish off WorldState::root and WorldState::library removal! #1306

Open
DavisVaughan wants to merge 3 commits into
mainfrom
feature/no-semantic-package
Open

Finish off WorldState::root and WorldState::library removal! #1306
DavisVaughan wants to merge 3 commits into
mainfrom
feature/no-semantic-package

Conversation

@DavisVaughan

Copy link
Copy Markdown
Contributor

Cleans up a loooooooot of outdated things now that Salsa is pretty well integrated and fully featured

Support:

  • oak_db::Package now has a depends() query (DESCRIPTION Depends:) and an index() query (for INDEX). This also requires an index_revision field on Package, which I thought we could avoid, but the 2nd commit shows that we cannot.

Tweaks:

  • Diagnostics now look at file.package() for namespace imports instead of the old SourceRoot
  • Diagnostics now use the new package.index() in insert_package_exports() to layer in the documented dataset symbols (that was our stopgap to avoid false positives)
  • roxygen2 completions were tweaked again to directly use the OakDatabase rather than the old oak_semantic::Library
  • temp_palmerpenguin() moved to oak_package_metadata since oak_semantic::package.rs is gone now. It is still useful for a test.

Removed:

  • WorldState drops root and library fields, yay!
  • oak_semantic drops library.rs and package.rs, both of which were "old style" features that we now access through OakDatabase directly

- `oak_db::Package` now has a `depends()` query and an `index()` (for `INDEX`) query
- Diagnostics now look at `file.package()` for namespace imports
- Diagnostics now use the new `package.index()` in `insert_package_exports()` to layer in the documented dataset symbols (that was our stopgap to avoid false positives)
- roxygen2 completions were tweaked again to directly use the `OakDatabase` rather than the old `oak_semantic::Library`
- `WorldState` drops `root` and `library` fields, yay!
- `oak_semantic` drops `library.rs` and `package.rs`, both of which were "old style" features that we now access through `OakDatabase` directly
- `temp_palmerpenguin()` moved to `oak_package_metadata` since `oak_semantic::package.rs` is gone now
In theory the following can happen:
- We scan the user's library
- We run diagnostics and trigger an `index()` load
- The user does `install.packages()` and overwrites the package we loaded the index for

We don't currently watch the installed package library, but we plan to! So no need to do this wrong to begin with.
Comment on lines +89 to +93
// When you're actively working on roxygen2 itself, pull the tags from `inst/`
let tags = match root.kind(db) {
RootKind::Workspace => dir.join("inst").join("roxygen2-tags.yml"),
RootKind::Library => dir.join("roxygen2-tags.yml"),
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A neat little change

Comment on lines -60 to -65
/// The root of the source tree (e.g., a package).
pub(crate) root: Option<SourceRoot>,

/// Map of package name to package metadata and package sources for installed
/// libraries. Lazily populated.
pub(crate) library: Library,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo!

Comment on lines +151 to +159
/// The package's `Depends:`, parsed lazily from `DESCRIPTION`. `None` when the file
/// is missing. Narrow query over [`Package::description`], same backdating story as
/// [`Package::version`].
#[salsa::tracked(returns(ref))]
pub fn depends(self, db: &dyn Db) -> Option<Vec<String>> {
self.description(db)
.as_ref()
.map(|description| description.depends.clone())
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New query

Comment on lines +203 to +210
/// The package's parsed `INDEX`
///
/// Returns `None` for workspace packages, which never have an `INDEX`.
///
/// Returns an empty `Index` for installed packages with missing or unreadable
/// indexes.
#[salsa::tracked(returns(ref))]
pub fn index(self, db: &dyn Db) -> Option<Index> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New query + index_revision field

@DavisVaughan DavisVaughan requested a review from lionel- June 30, 2026 16:37
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.

1 participant