Skip to content

Finish migrating off Document to ArkFile#1267

Open
lionel- wants to merge 3 commits into
oak/salsa-25-rewire-indexerfrom
oak/salsa-26-remove-document
Open

Finish migrating off Document to ArkFile#1267
lionel- wants to merge 3 commits into
oak/salsa-25-rewire-indexerfrom
oak/salsa-26-remove-document

Conversation

@lionel-

@lionel- lionel- commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Branched from #1266
Progress towards #1212

With this PR everything now goes through Oak's DB.

  • Remove Ark's Document structure, along with its copy of the tree-sitter tree, source code, and line index. These are now all accessed via Oak queries on File.

  • WorldState's documents field becomes open_files: HashMap<FilePath, ArkFile>. (Maybe we should rename to ArkOpenFile?)

@lionel- lionel- force-pushed the oak/salsa-26-remove-document branch from 79aae40 to 0b199bf Compare June 12, 2026 10:27

@DavisVaughan DavisVaughan 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.

woooooooo

@@ -18,10 +17,10 @@ fn test_diagnostics_published_through_refresh_snapshot() {
// a `Document` plus its matching `oak_db::File`.

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.

Update comment

Comment on lines +39 to +43
// TODO: this is a stopgap that goes away with `ArkFile`. Once handlers are
// pure Oak, they return `File`-keyed results (diagnostics, the edit targets
// in a `WorkspaceEdit`) and the wire URL gets attached at the transport
// boundary from a map of open editor URLs owned by the LSP layer. In that
// design the verbatim URL never travels through the analysis layer.

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.

👍

Comment on lines +996 to 999
for document in state.open_files.values() {
if !ExtUrl::should_diagnose(&document.url) {
continue;
}

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.

Remove usage of ark_file() in here, you already have one!

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.

Could also change document to file

pub(crate) fn get_document_mut(&mut self, path: &FilePath) -> anyhow::Result<&mut Document> {
if let Some(doc) = self.documents.get_mut(path) {
Ok(doc)
pub(crate) fn ark_file_mut(&mut self, uri: &Url) -> anyhow::Result<&mut ArkFile> {

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.

Looks like we only still need this for updating DocumentConfig. I wonder what that will end up being a part of

url: document.url.clone(),
encoding: self.config.position_encoding,
})
Ok(ark_file.clone())

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.

I would generally disagree with this on principle but ill allow it since ark_file is supposed to go away anyways 😛

Comment on lines 142 to +144
pub(crate) fn workspace_uris(state: &WorldState) -> Vec<Url> {
state
.documents
.open_files

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.

Suggested change
pub(crate) fn workspace_uris(state: &WorldState) -> Vec<Url> {
state
.documents
.open_files
pub(crate) fn open_file_uris(state: &WorldState) -> Vec<Url> {
state
.open_files

?

Seems nicer

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.

I imagine this helper may go away eventually too. I guess it depends on how we end up handling config in update_config(), which is currently the only consumer of this

// origin = "https://github.com/rust-lang/rust-analyzer/blob/master/crates/rust-analyzer/src/lsp/utils.rs"
// ---
/// Apply a batch of LSP content changes to `contents`, returning the new text.
fn apply_content_changes(

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.

I feeeel like maybe this and its newly added tests at the bottom should just go in its own standalone file. Maybe content.rs or changes.rs or something?

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