mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +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>)>) {
|
||||
let data = self.data_mut();
|
||||
data.root = Arc::new(data.root.apply_changes(changes, None));
|
||||
self.data_mut()
|
||||
.root.apply_changes(changes, None);
|
||||
}
|
||||
pub fn set_file_resolver(&mut self, resolver: FileResolverImp) {
|
||||
let data = self.data_mut();
|
||||
data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver)));
|
||||
self.data_mut()
|
||||
.root.apply_changes(&mut iter::empty(), Some(resolver));
|
||||
}
|
||||
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
||||
let mut visited = FxHashSet::default();
|
||||
|
@ -141,7 +141,7 @@ impl Clone for AnalysisImpl {
|
|||
impl AnalysisImpl {
|
||||
fn root(&self, file_id: FileId) -> &SourceRoot {
|
||||
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()
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ impl AnalysisImpl {
|
|||
#[derive(Default, Clone, Debug)]
|
||||
struct WorldData {
|
||||
crate_graph: CrateGraph,
|
||||
root: Arc<WritableSourceRoot>,
|
||||
root: WritableSourceRoot,
|
||||
libs: Vec<Arc<ReadonlySourceRoot>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ pub(crate) struct WritableSourceRoot {
|
|||
|
||||
impl WritableSourceRoot {
|
||||
pub fn apply_changes(
|
||||
&self,
|
||||
&mut self,
|
||||
changes: &mut dyn Iterator<Item=(FileId, Option<String>)>,
|
||||
file_resolver: Option<FileResolverImp>,
|
||||
) -> WritableSourceRoot {
|
||||
) {
|
||||
let db = self.db.write();
|
||||
let mut changed = FxHashSet::default();
|
||||
let mut removed = FxHashSet::default();
|
||||
|
@ -65,9 +65,6 @@ impl WritableSourceRoot {
|
|||
let resolver = file_resolver.unwrap_or_else(|| file_set.resolver.clone());
|
||||
db.query(db::FileSetQuery)
|
||||
.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…
Reference in a new issue