mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Merge #1382
1382: use salsa's LRU for syntax trees r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
03645c5576
13 changed files with 63 additions and 15 deletions
|
@ -225,7 +225,6 @@ impl RootDatabase {
|
|||
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
|
||||
|
||||
self.query(ra_db::ParseQuery).sweep(sweep);
|
||||
|
||||
self.query(hir::db::ParseMacroQuery).sweep(sweep);
|
||||
self.query(hir::db::MacroDefQuery).sweep(sweep);
|
||||
self.query(hir::db::MacroArgQuery).sweep(sweep);
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
|
||||
use ra_db::{
|
||||
CheckCanceled, FileId, Canceled, SourceDatabase,
|
||||
salsa,
|
||||
salsa::{self, Database},
|
||||
};
|
||||
|
||||
use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}};
|
||||
|
@ -41,6 +41,12 @@ impl salsa::Database for RootDatabase {
|
|||
|
||||
impl Default for RootDatabase {
|
||||
fn default() -> RootDatabase {
|
||||
RootDatabase::new(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl RootDatabase {
|
||||
pub fn new(lru_capacity: Option<usize>) -> RootDatabase {
|
||||
let mut db = RootDatabase {
|
||||
runtime: salsa::Runtime::default(),
|
||||
last_gc: time::Instant::now(),
|
||||
|
@ -49,6 +55,9 @@ impl Default for RootDatabase {
|
|||
db.set_crate_graph(Default::default());
|
||||
db.set_local_roots(Default::default());
|
||||
db.set_library_roots(Default::default());
|
||||
let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP);
|
||||
db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity);
|
||||
db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity);
|
||||
db
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,12 +242,21 @@ pub struct CallInfo {
|
|||
}
|
||||
|
||||
/// `AnalysisHost` stores the current state of the world.
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct AnalysisHost {
|
||||
db: db::RootDatabase,
|
||||
}
|
||||
|
||||
impl Default for AnalysisHost {
|
||||
fn default() -> AnalysisHost {
|
||||
AnalysisHost::new(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl AnalysisHost {
|
||||
pub fn new(lru_capcity: Option<usize>) -> AnalysisHost {
|
||||
AnalysisHost { db: db::RootDatabase::new(lru_capcity) }
|
||||
}
|
||||
/// Returns a snapshot of the current state, which you can query for
|
||||
/// semantic information.
|
||||
pub fn analysis(&self) -> Analysis {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue