Skip to content

Commit

Permalink
Merge pull request #18964 from davidbarsky/davidbarsky/port-rust-anal…
Browse files Browse the repository at this point in the history
…yzer-to-new-salsa

internal: port rust-analyzer to new Salsa
  • Loading branch information
davidbarsky authored Mar 10, 2025
2 parents 7368212 + 74620e6 commit 44f18c3
Show file tree
Hide file tree
Showing 163 changed files with 3,072 additions and 2,323 deletions.
857 changes: 580 additions & 277 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
profile = { path = "./crates/profile", version = "0.0.0" }
project-model = { path = "./crates/project-model", version = "0.0.0" }
ra-salsa = { path = "./crates/ra-salsa", package = "salsa", version = "0.0.0" }
query-group = { package = "query-group-macro", path = "./crates/query-group-macro", version = "0.0.0" }
span = { path = "./crates/span", version = "0.0.0" }
stdx = { path = "./crates/stdx", version = "0.0.0" }
syntax = { path = "./crates/syntax", version = "0.0.0" }
Expand Down Expand Up @@ -117,7 +117,7 @@ expect-test = "1.4.0"
hashbrown = { version = "0.14", features = [
"inline-more",
], default-features = false }
indexmap = "2.1.0"
indexmap = { version = "2.1.0", features = ["serde"] }
itertools = "0.12.0"
libc = "0.2.150"
libloading = "0.8.0"
Expand All @@ -135,6 +135,7 @@ process-wrap = { version = "8.0.2", features = ["std"] }
pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.0", default-features = false }
rayon = "1.8.0"
salsa = "0.19"
rustc-hash = "2.0.0"
semver = "1.0.14"
serde = { version = "1.0.192" }
Expand Down
4 changes: 3 additions & 1 deletion crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ rust-version.workspace = true
lz4_flex = { version = "0.11", default-features = false }

la-arena.workspace = true
ra-salsa.workspace = true
dashmap.workspace = true
salsa.workspace = true
query-group.workspace = true
rustc-hash.workspace = true
triomphe.workspace = true
semver.workspace = true
Expand Down
15 changes: 7 additions & 8 deletions crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
use std::fmt;

use ra_salsa::Durability;
use rustc_hash::FxHashMap;
use salsa::Durability;
use triomphe::Arc;
use vfs::FileId;

use crate::{
CrateGraph, CrateId, CrateWorkspaceData, SourceDatabaseFileInputExt, SourceRoot,
SourceRootDatabase, SourceRootId,
};
use crate::{CrateGraph, CrateId, CrateWorkspaceData, RootQueryDb, SourceRoot, SourceRootId};

/// Encapsulate a bunch of raw `.set` calls on the database.
#[derive(Default)]
Expand Down Expand Up @@ -59,7 +56,7 @@ impl FileChange {
self.ws_data = Some(data);
}

pub fn apply(self, db: &mut dyn SourceRootDatabase) {
pub fn apply(self, db: &mut dyn RootQueryDb) {
let _p = tracing::info_span!("FileChange::apply").entered();
if let Some(roots) = self.roots {
for (idx, root) in roots.into_iter().enumerate() {
Expand All @@ -68,14 +65,16 @@ impl FileChange {
for file_id in root.iter() {
db.set_file_source_root_with_durability(file_id, root_id, durability);
}

db.set_source_root_with_durability(root_id, Arc::new(root), durability);
}
}

for (file_id, text) in self.files_changed {
let source_root_id = db.file_source_root(file_id);
let source_root = db.source_root(source_root_id);
let durability = durability(&source_root);
let source_root = db.source_root(source_root_id.source_root_id(db));

let durability = durability(&source_root.source_root(db));
// XXX: can't actually remove the file, just reset the text
let text = text.unwrap_or_default();
db.set_file_text_with_durability(file_id, &text, durability)
Expand Down
Loading

0 comments on commit 44f18c3

Please sign in to comment.