Skip to content

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

Merged
DavisVaughan merged 3 commits into
mainfrom
feature/no-semantic-package
Jul 9, 2026
Merged

Finish off WorldState::root and WorldState::library removal! #1306
DavisVaughan merged 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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yep nice

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

@lionel- lionel- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How did I forget to do this very satisfying consolidation/cleanup!

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

Choose a reason for hiding this comment

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

yep nice

};

// Start from explicit `NAMESPACE` exports
let mut exports = package.namespace(context.db).exports.clone().into_vec();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a Package::exports() query mirroring File::exports(). I thought I had implemented it already, but can't find it (maybe it was abandoned at some point).

There will be some complex resolution in the future (e.g. for regex exportPattern), so we should call a single method everywhere exports are needed.

It'd return a vector of names that you can then resolve with top-level Package::resolve().

Comment thread crates/oak_db/src/package.rs
- `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.
@DavisVaughan DavisVaughan force-pushed the feature/no-semantic-package branch from 6619964 to 9a2e636 Compare July 9, 2026 16:51
@DavisVaughan DavisVaughan merged commit 59ba153 into main Jul 9, 2026
17 checks passed
@DavisVaughan DavisVaughan deleted the feature/no-semantic-package branch July 9, 2026 17:07
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants