diff options
author | Aleksey Kladov <[email protected]> | 2018-09-04 02:13:22 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-04 02:13:22 +0100 |
commit | 4df965a002b5296fc728f1bc2fb9312fe421ea5d (patch) | |
tree | 989dfb2bbc2751d97959b4ca320cc5301b2ec4f5 | |
parent | c3e28f06463854e4711c4c49a49c77d1e136969f (diff) |
work
-rw-r--r-- | crates/libanalysis/src/roots.rs | 10 | ||||
-rw-r--r-- | crates/server/src/main_loop/mod.rs | 9 | ||||
-rw-r--r-- | crates/server/src/vfs.rs | 6 | ||||
-rw-r--r-- | crates/server/tests/heavy_tests/main.rs | 2 |
4 files changed, 15 insertions, 12 deletions
diff --git a/crates/libanalysis/src/roots.rs b/crates/libanalysis/src/roots.rs index f1bc72e33..6d1375f88 100644 --- a/crates/libanalysis/src/roots.rs +++ b/crates/libanalysis/src/roots.rs | |||
@@ -138,6 +138,11 @@ pub(crate) struct ReadonlySourceRoot { | |||
138 | impl ReadonlySourceRoot { | 138 | impl ReadonlySourceRoot { |
139 | pub fn new(files: Vec<(FileId, String)>) -> ReadonlySourceRoot { | 139 | pub fn new(files: Vec<(FileId, String)>) -> ReadonlySourceRoot { |
140 | let mut module_map = ModuleMap::new(); | 140 | let mut module_map = ModuleMap::new(); |
141 | let symbol_index = SymbolIndex::for_files( | ||
142 | files.par_iter().map(|(file_id, text)| { | ||
143 | (*file_id, File::parse(text)) | ||
144 | }) | ||
145 | ); | ||
141 | let file_map: HashMap<FileId, FileData> = files | 146 | let file_map: HashMap<FileId, FileData> = files |
142 | .into_iter() | 147 | .into_iter() |
143 | .map(|(id, text)| { | 148 | .map(|(id, text)| { |
@@ -145,11 +150,6 @@ impl ReadonlySourceRoot { | |||
145 | (id, FileData::new(text)) | 150 | (id, FileData::new(text)) |
146 | }) | 151 | }) |
147 | .collect(); | 152 | .collect(); |
148 | let symbol_index = SymbolIndex::for_files( | ||
149 | file_map.par_iter().map(|(&file_id, file_data)| { | ||
150 | (file_id, file_data.syntax_transient()) | ||
151 | }) | ||
152 | ); | ||
153 | 153 | ||
154 | ReadonlySourceRoot { | 154 | ReadonlySourceRoot { |
155 | symbol_index, | 155 | symbol_index, |
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index 58f6f88a7..52e3b661d 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs | |||
@@ -8,7 +8,7 @@ use std::{ | |||
8 | 8 | ||
9 | use threadpool::ThreadPool; | 9 | use threadpool::ThreadPool; |
10 | use serde::{Serialize, de::DeserializeOwned}; | 10 | use serde::{Serialize, de::DeserializeOwned}; |
11 | use crossbeam_channel::{bounded, Sender, Receiver}; | 11 | use crossbeam_channel::{unbounded, Sender, Receiver}; |
12 | use languageserver_types::{NumberOrString}; | 12 | use languageserver_types::{NumberOrString}; |
13 | use libanalysis::{FileId, JobHandle, JobToken, LibraryData}; | 13 | use libanalysis::{FileId, JobHandle, JobToken, LibraryData}; |
14 | use gen_lsp_server::{ | 14 | use gen_lsp_server::{ |
@@ -38,7 +38,7 @@ pub fn main_loop( | |||
38 | msg_sender: &mut Sender<RawMessage>, | 38 | msg_sender: &mut Sender<RawMessage>, |
39 | ) -> Result<()> { | 39 | ) -> Result<()> { |
40 | let pool = ThreadPool::new(4); | 40 | let pool = ThreadPool::new(4); |
41 | let (task_sender, task_receiver) = bounded::<Task>(16); | 41 | let (task_sender, task_receiver) = unbounded::<Task>(); |
42 | let (fs_sender, fs_receiver, fs_watcher) = vfs::roots_loader(); | 42 | let (fs_sender, fs_receiver, fs_watcher) = vfs::roots_loader(); |
43 | let (ws_sender, ws_receiver, ws_watcher) = workspace_loader(); | 43 | let (ws_sender, ws_receiver, ws_watcher) = workspace_loader(); |
44 | 44 | ||
@@ -97,7 +97,7 @@ fn main_loop_inner( | |||
97 | pending_requests: &mut HashMap<u64, JobHandle>, | 97 | pending_requests: &mut HashMap<u64, JobHandle>, |
98 | subs: &mut Subscriptions, | 98 | subs: &mut Subscriptions, |
99 | ) -> Result<()> { | 99 | ) -> Result<()> { |
100 | let (libdata_sender, libdata_receiver) = bounded(1024); | 100 | let (libdata_sender, libdata_receiver) = unbounded(); |
101 | ws_sender.send(ws_root.clone()); | 101 | ws_sender.send(ws_root.clone()); |
102 | fs_sender.send(ws_root.clone()); | 102 | fs_sender.send(ws_root.clone()); |
103 | loop { | 103 | loop { |
@@ -137,7 +137,10 @@ fn main_loop_inner( | |||
137 | let files = state.events_to_files(events); | 137 | let files = state.events_to_files(events); |
138 | let sender = libdata_sender.clone(); | 138 | let sender = libdata_sender.clone(); |
139 | pool.execute(move || { | 139 | pool.execute(move || { |
140 | let start = ::std::time::Instant::now(); | ||
141 | info!("indexing {} ... ", root.display()); | ||
140 | let data = LibraryData::prepare(files); | 142 | let data = LibraryData::prepare(files); |
143 | info!("indexed {:?} {}", start.elapsed(), root.display()); | ||
141 | sender.send(data); | 144 | sender.send(data); |
142 | }); | 145 | }); |
143 | } | 146 | } |
diff --git a/crates/server/src/vfs.rs b/crates/server/src/vfs.rs index 69a7654af..2699fc21e 100644 --- a/crates/server/src/vfs.rs +++ b/crates/server/src/vfs.rs | |||
@@ -3,7 +3,7 @@ use std::{ | |||
3 | fs, | 3 | fs, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use crossbeam_channel::{Sender, Receiver, bounded}; | 6 | use crossbeam_channel::{Sender, Receiver, unbounded}; |
7 | use walkdir::WalkDir; | 7 | use walkdir::WalkDir; |
8 | 8 | ||
9 | use { | 9 | use { |
@@ -23,8 +23,8 @@ pub enum FileEventKind { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | pub fn roots_loader() -> (Sender<PathBuf>, Receiver<(PathBuf, Vec<FileEvent>)>, ThreadWatcher) { | 25 | pub fn roots_loader() -> (Sender<PathBuf>, Receiver<(PathBuf, Vec<FileEvent>)>, ThreadWatcher) { |
26 | let (path_sender, path_receiver) = bounded::<PathBuf>(2048); | 26 | let (path_sender, path_receiver) = unbounded::<PathBuf>(); |
27 | let (event_sender, event_receiver) = bounded::<(PathBuf, Vec<FileEvent>)>(1); | 27 | let (event_sender, event_receiver) = unbounded::<(PathBuf, Vec<FileEvent>)>(); |
28 | let thread = ThreadWatcher::spawn("roots loader", move || { | 28 | let thread = ThreadWatcher::spawn("roots loader", move || { |
29 | path_receiver | 29 | path_receiver |
30 | .into_iter() | 30 | .into_iter() |
diff --git a/crates/server/tests/heavy_tests/main.rs b/crates/server/tests/heavy_tests/main.rs index 66620ac62..50529f453 100644 --- a/crates/server/tests/heavy_tests/main.rs +++ b/crates/server/tests/heavy_tests/main.rs | |||
@@ -95,5 +95,5 @@ fn test_eggs() {} | |||
95 | // extern crate regex; | 95 | // extern crate regex; |
96 | // "#); | 96 | // "#); |
97 | // server.wait_for_feedback("workspace loaded"); | 97 | // server.wait_for_feedback("workspace loaded"); |
98 | // server.wait_for_feedback_n("library loaded", 1); | 98 | // server.wait_for_feedback_n("library loaded", 9); |
99 | // } | 99 | // } |