mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Tweak writable root API
This commit is contained in:
parent
8c88900fa9
commit
76c51fae77
2 changed files with 8 additions and 11 deletions
|
@ -94,12 +94,12 @@ impl AnalysisHostImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn change_files(&mut self, changes: &mut dyn Iterator<Item=(FileId, Option<String>)>) {
|
pub fn change_files(&mut self, changes: &mut dyn Iterator<Item=(FileId, Option<String>)>) {
|
||||||
let data = self.data_mut();
|
self.data_mut()
|
||||||
data.root = Arc::new(data.root.apply_changes(changes, None));
|
.root.apply_changes(changes, None);
|
||||||
}
|
}
|
||||||
pub fn set_file_resolver(&mut self, resolver: FileResolverImp) {
|
pub fn set_file_resolver(&mut self, resolver: FileResolverImp) {
|
||||||
let data = self.data_mut();
|
self.data_mut()
|
||||||
data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver)));
|
.root.apply_changes(&mut iter::empty(), Some(resolver));
|
||||||
}
|
}
|
||||||
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
||||||
let mut visited = FxHashSet::default();
|
let mut visited = FxHashSet::default();
|
||||||
|
@ -141,7 +141,7 @@ impl Clone for AnalysisImpl {
|
||||||
impl AnalysisImpl {
|
impl AnalysisImpl {
|
||||||
fn root(&self, file_id: FileId) -> &SourceRoot {
|
fn root(&self, file_id: FileId) -> &SourceRoot {
|
||||||
if self.data.root.contains(file_id) {
|
if self.data.root.contains(file_id) {
|
||||||
return &*self.data.root;
|
return &self.data.root;
|
||||||
}
|
}
|
||||||
&**self.data.libs.iter().find(|it| it.contains(file_id)).unwrap()
|
&**self.data.libs.iter().find(|it| it.contains(file_id)).unwrap()
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ impl AnalysisImpl {
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
struct WorldData {
|
struct WorldData {
|
||||||
crate_graph: CrateGraph,
|
crate_graph: CrateGraph,
|
||||||
root: Arc<WritableSourceRoot>,
|
root: WritableSourceRoot,
|
||||||
libs: Vec<Arc<ReadonlySourceRoot>>,
|
libs: Vec<Arc<ReadonlySourceRoot>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,10 @@ pub(crate) struct WritableSourceRoot {
|
||||||
|
|
||||||
impl WritableSourceRoot {
|
impl WritableSourceRoot {
|
||||||
pub fn apply_changes(
|
pub fn apply_changes(
|
||||||
&self,
|
&mut self,
|
||||||
changes: &mut dyn Iterator<Item=(FileId, Option<String>)>,
|
changes: &mut dyn Iterator<Item=(FileId, Option<String>)>,
|
||||||
file_resolver: Option<FileResolverImp>,
|
file_resolver: Option<FileResolverImp>,
|
||||||
) -> WritableSourceRoot {
|
) {
|
||||||
let db = self.db.write();
|
let db = self.db.write();
|
||||||
let mut changed = FxHashSet::default();
|
let mut changed = FxHashSet::default();
|
||||||
let mut removed = FxHashSet::default();
|
let mut removed = FxHashSet::default();
|
||||||
|
@ -65,9 +65,6 @@ impl WritableSourceRoot {
|
||||||
let resolver = file_resolver.unwrap_or_else(|| file_set.resolver.clone());
|
let resolver = file_resolver.unwrap_or_else(|| file_set.resolver.clone());
|
||||||
db.query(db::FileSetQuery)
|
db.query(db::FileSetQuery)
|
||||||
.set((), Arc::new(db::FileSet { files, resolver }));
|
.set((), Arc::new(db::FileSet { files, resolver }));
|
||||||
// TODO: reconcile sasla's API with our needs
|
|
||||||
// https://github.com/salsa-rs/salsa/issues/12
|
|
||||||
self.clone()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue