mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 12:25:05 +00:00
correctly setup path-map for fs-changes
This commit is contained in:
parent
e240360ee2
commit
ccc75675b6
1 changed files with 24 additions and 23 deletions
|
@ -39,30 +39,31 @@ impl ServerWorldState {
|
||||||
mem_map: HashMap::new(),
|
mem_map: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_fs_changes(&mut self, events: Vec<FileEvent>) {
|
pub fn apply_fs_changes(&mut self, events: Vec<FileEvent>) {
|
||||||
let pm = &mut self.path_map;
|
{
|
||||||
let mm = &mut self.mem_map;
|
let pm = &mut self.path_map;
|
||||||
let changes = events.into_iter()
|
let mm = &mut self.mem_map;
|
||||||
.map(|event| {
|
let changes = events.into_iter()
|
||||||
let text = match event.kind {
|
.map(|event| {
|
||||||
FileEventKind::Add(text) => Some(text),
|
let text = match event.kind {
|
||||||
};
|
FileEventKind::Add(text) => Some(text),
|
||||||
(event.path, text)
|
};
|
||||||
})
|
(event.path, text)
|
||||||
.map(|(path, text)| {
|
})
|
||||||
(pm.get_or_insert(path, Root::Workspace), text)
|
.map(|(path, text)| {
|
||||||
})
|
(pm.get_or_insert(path, Root::Workspace), text)
|
||||||
.filter_map(|(id, text)| {
|
})
|
||||||
if mm.contains_key(&id) {
|
.filter_map(|(id, text)| {
|
||||||
mm.insert(id, text);
|
if mm.contains_key(&id) {
|
||||||
None
|
mm.insert(id, text);
|
||||||
} else {
|
None
|
||||||
Some((id, text))
|
} else {
|
||||||
}
|
Some((id, text))
|
||||||
});
|
}
|
||||||
|
});
|
||||||
self.analysis_host.change_files(changes);
|
self.analysis_host.change_files(changes);
|
||||||
|
}
|
||||||
|
self.analysis_host.set_file_resolver(Arc::new(self.path_map.clone()));
|
||||||
}
|
}
|
||||||
pub fn events_to_files(&mut self, events: Vec<FileEvent>) -> (Vec<(FileId, String)>, Arc<FileResolver>) {
|
pub fn events_to_files(&mut self, events: Vec<FileEvent>) -> (Vec<(FileId, String)>, Arc<FileResolver>) {
|
||||||
let files = {
|
let files = {
|
||||||
|
|
Loading…
Reference in a new issue