From fed52706def9a9f5d33edc7dd9848a02ae475ba5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 7 Jun 2019 20:49:29 +0300 Subject: make LRU cache configurable --- crates/ra_lsp_server/src/init.rs | 14 +++++++++++--- crates/ra_lsp_server/src/main_loop.rs | 2 +- crates/ra_lsp_server/src/world.rs | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/init.rs b/crates/ra_lsp_server/src/init.rs index 1b77e0312..b894b449d 100644 --- a/crates/ra_lsp_server/src/init.rs +++ b/crates/ra_lsp_server/src/init.rs @@ -17,11 +17,17 @@ pub struct InitializationOptions { /// Defaults to `true` #[serde(deserialize_with = "nullable_bool_true")] pub show_workspace_loaded: bool, + + pub lru_capacity: Option, } impl Default for InitializationOptions { fn default() -> InitializationOptions { - InitializationOptions { publish_decorations: false, show_workspace_loaded: true } + InitializationOptions { + publish_decorations: false, + show_workspace_loaded: true, + lru_capacity: None, + } } } @@ -54,8 +60,10 @@ mod test { assert_eq!(default, serde_json::from_str(r#"{}"#).unwrap()); assert_eq!( default, - serde_json::from_str(r#"{"publishDecorations":null, "showWorkspaceLoaded":null}"#) - .unwrap() + serde_json::from_str( + r#"{"publishDecorations":null, "showWorkspaceLoaded":null, "lruCapacity":null}"# + ) + .unwrap() ); } } diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 090fb9b1b..0790ea472 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -73,7 +73,7 @@ pub fn main_loop( loaded_workspaces }; - let mut state = WorldState::new(ws_roots, workspaces); + let mut state = WorldState::new(ws_roots, workspaces, options.lru_capacity); let pool = ThreadPool::new(THREADPOOL_SIZE); let (task_sender, task_receiver) = unbounded::(); diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index cd8df4fdb..f9ce570ca 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -46,7 +46,11 @@ pub struct WorldSnapshot { } impl WorldState { - pub fn new(folder_roots: Vec, workspaces: Vec) -> WorldState { + pub fn new( + folder_roots: Vec, + workspaces: Vec, + lru_capacity: Option, + ) -> WorldState { let mut change = AnalysisChange::new(); let mut roots = Vec::new(); @@ -74,7 +78,7 @@ impl WorldState { } change.set_crate_graph(crate_graph); - let mut analysis_host = AnalysisHost::default(); + let mut analysis_host = AnalysisHost::new(lru_capacity); analysis_host.apply_change(change); WorldState { roots_to_scan, -- cgit v1.2.3