mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
index libraies off the main thread
This commit is contained in:
parent
47cbaeba6f
commit
5ba645c009
5 changed files with 39 additions and 13 deletions
|
@ -6,7 +6,7 @@ use std::{
|
|||
};
|
||||
|
||||
use languageserver_types::Url;
|
||||
use libanalysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId};
|
||||
use libanalysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId, LibraryData};
|
||||
|
||||
use {
|
||||
Result,
|
||||
|
@ -64,17 +64,20 @@ impl ServerWorldState {
|
|||
|
||||
self.analysis_host.change_files(changes);
|
||||
}
|
||||
pub fn add_library(&mut self, events: Vec<FileEvent>) {
|
||||
pub fn events_to_files(&mut self, events: Vec<FileEvent>) -> Vec<(FileId, String)> {
|
||||
let pm = &mut self.path_map;
|
||||
let files = events.into_iter()
|
||||
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);
|
||||
.map(|(path, text)| (pm.get_or_insert(path), text))
|
||||
.collect()
|
||||
}
|
||||
pub fn add_lib(&mut self, data: LibraryData) {
|
||||
self.analysis_host.add_library(data);
|
||||
}
|
||||
|
||||
pub fn add_mem_file(&mut self, path: PathBuf, text: String) -> FileId {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue