mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Prime open files on load
This commit is contained in:
parent
94c48980bb
commit
fc970d188e
3 changed files with 25 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
pub mod mock_analysis;
|
pub mod mock_analysis;
|
||||||
mod source_change;
|
mod source_change;
|
||||||
|
|
||||||
|
mod prime_caches;
|
||||||
mod status;
|
mod status;
|
||||||
mod completion;
|
mod completion;
|
||||||
mod runnables;
|
mod runnables;
|
||||||
|
@ -227,6 +228,10 @@ impl Analysis {
|
||||||
self.with_db(|db| status::status(&*db))
|
self.with_db(|db| status::status(&*db))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn prime_caches(&self, files: Vec<FileId>) -> Cancelable<()> {
|
||||||
|
self.with_db(|db| prime_caches::prime_caches(db, files))
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets the text of the source file.
|
/// Gets the text of the source file.
|
||||||
pub fn file_text(&self, file_id: FileId) -> Cancelable<Arc<String>> {
|
pub fn file_text(&self, file_id: FileId) -> Cancelable<Arc<String>> {
|
||||||
self.with_db(|db| db.file_text(file_id))
|
self.with_db(|db| db.file_text(file_id))
|
||||||
|
|
15
crates/ra_ide/src/prime_caches.rs
Normal file
15
crates/ra_ide/src/prime_caches.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
//! rust-analyzer is lazy and doesn't not compute anything unless asked. This
|
||||||
|
//! sometimes is counter productive when, for example, the first goto definition
|
||||||
|
//! request takes longer to compute. This modules implemented prepopulating of
|
||||||
|
//! various caches, it's not really advanced at the moment.
|
||||||
|
|
||||||
|
use hir::Semantics;
|
||||||
|
|
||||||
|
use crate::{FileId, RootDatabase};
|
||||||
|
|
||||||
|
pub(crate) fn prime_caches(db: &RootDatabase, files: Vec<FileId>) {
|
||||||
|
let sema = Semantics::new(db);
|
||||||
|
for file in files {
|
||||||
|
let _ = sema.to_module_def(file);
|
||||||
|
}
|
||||||
|
}
|
|
@ -426,6 +426,11 @@ fn loop_turn(
|
||||||
show_message(req::MessageType::Info, msg, &connection.sender);
|
show_message(req::MessageType::Info, msg, &connection.sender);
|
||||||
}
|
}
|
||||||
world_state.check_watcher.update();
|
world_state.check_watcher.update();
|
||||||
|
pool.execute({
|
||||||
|
let subs = loop_state.subscriptions.subscriptions();
|
||||||
|
let snap = world_state.snapshot();
|
||||||
|
move || snap.analysis().prime_caches(subs).unwrap_or_else(|_: Canceled| ())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if state_changed {
|
if state_changed {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue