Index deps

This commit is contained in:
Aleksey Kladov 2018-09-03 21:03:37 +03:00
parent b04c14d4ad
commit 47cbaeba6f
7 changed files with 128 additions and 84 deletions

View file

@ -47,7 +47,6 @@ impl ServerWorldState {
.map(|event| {
let text = match event.kind {
FileEventKind::Add(text) => Some(text),
FileEventKind::Remove => None,
};
(event.path, text)
})
@ -65,6 +64,18 @@ impl ServerWorldState {
self.analysis_host.change_files(changes);
}
pub fn add_library(&mut self, events: Vec<FileEvent>) {
let pm = &mut self.path_map;
let files = events.into_iter()
.map(|event| {
let text = match event.kind {
FileEventKind::Add(text) => text,
};
(event.path, text)
})
.map(|(path, text)| (pm.get_or_insert(path), text));
self.analysis_host.add_library(files);
}
pub fn add_mem_file(&mut self, path: PathBuf, text: String) -> FileId {
let file_id = self.path_map.get_or_insert(path);