mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +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
|
@ -57,9 +57,8 @@ impl AnalysisHostImpl {
|
|||
}
|
||||
self.data_mut().crate_graph = graph;
|
||||
}
|
||||
pub fn add_library(&mut self, files: impl Iterator<Item=(FileId, String)>) {
|
||||
let libs = ReadonlySourceRoot::new(files);
|
||||
self.data_mut().libs.push(Arc::new(libs));
|
||||
pub fn add_library(&mut self, root: ReadonlySourceRoot) {
|
||||
self.data_mut().libs.push(Arc::new(root));
|
||||
}
|
||||
fn data_mut(&mut self) -> &mut WorldData {
|
||||
Arc::make_mut(&mut self.data)
|
||||
|
|
|
@ -68,8 +68,8 @@ impl AnalysisHost {
|
|||
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
||||
self.imp.set_crate_graph(graph)
|
||||
}
|
||||
pub fn add_library(&mut self, files: impl Iterator<Item=(FileId, String)>) {
|
||||
self.imp.add_library(files)
|
||||
pub fn add_library(&mut self, data: LibraryData) {
|
||||
self.imp.add_library(data.root)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,3 +216,15 @@ impl Analysis {
|
|||
self.imp.diagnostics(file_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LibraryData {
|
||||
root: roots::ReadonlySourceRoot
|
||||
}
|
||||
|
||||
impl LibraryData {
|
||||
pub fn prepare(files: Vec<(FileId, String)>) -> LibraryData {
|
||||
let root = roots::ReadonlySourceRoot::new(files);
|
||||
LibraryData { root }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,9 +136,10 @@ pub(crate) struct ReadonlySourceRoot {
|
|||
}
|
||||
|
||||
impl ReadonlySourceRoot {
|
||||
pub fn new(files: impl Iterator<Item=(FileId, String)>) -> ReadonlySourceRoot {
|
||||
pub fn new(files: Vec<(FileId, String)>) -> ReadonlySourceRoot {
|
||||
let mut module_map = ModuleMap::new();
|
||||
let file_map: HashMap<FileId, FileData> = files
|
||||
.into_iter()
|
||||
.map(|(id, text)| {
|
||||
module_map.update_file(id, ChangeKind::Insert);
|
||||
(id, FileData::new(text))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue