This commit is contained in:
Aleksey Kladov 2018-09-04 04:13:22 +03:00
parent c3e28f0646
commit 4df965a002
4 changed files with 15 additions and 12 deletions

View file

@ -138,6 +138,11 @@ pub(crate) struct ReadonlySourceRoot {
impl ReadonlySourceRoot {
pub fn new(files: Vec<(FileId, String)>) -> ReadonlySourceRoot {
let mut module_map = ModuleMap::new();
let symbol_index = SymbolIndex::for_files(
files.par_iter().map(|(file_id, text)| {
(*file_id, File::parse(text))
})
);
let file_map: HashMap<FileId, FileData> = files
.into_iter()
.map(|(id, text)| {
@ -145,11 +150,6 @@ impl ReadonlySourceRoot {
(id, FileData::new(text))
})
.collect();
let symbol_index = SymbolIndex::for_files(
file_map.par_iter().map(|(&file_id, file_data)| {
(file_id, file_data.syntax_transient())
})
);
ReadonlySourceRoot {
symbol_index,

View file

@ -8,7 +8,7 @@ use std::{
use threadpool::ThreadPool;
use serde::{Serialize, de::DeserializeOwned};
use crossbeam_channel::{bounded, Sender, Receiver};
use crossbeam_channel::{unbounded, Sender, Receiver};
use languageserver_types::{NumberOrString};
use libanalysis::{FileId, JobHandle, JobToken, LibraryData};
use gen_lsp_server::{
@ -38,7 +38,7 @@ pub fn main_loop(
msg_sender: &mut Sender<RawMessage>,
) -> Result<()> {
let pool = ThreadPool::new(4);
let (task_sender, task_receiver) = bounded::<Task>(16);
let (task_sender, task_receiver) = unbounded::<Task>();
let (fs_sender, fs_receiver, fs_watcher) = vfs::roots_loader();
let (ws_sender, ws_receiver, ws_watcher) = workspace_loader();
@ -97,7 +97,7 @@ fn main_loop_inner(
pending_requests: &mut HashMap<u64, JobHandle>,
subs: &mut Subscriptions,
) -> Result<()> {
let (libdata_sender, libdata_receiver) = bounded(1024);
let (libdata_sender, libdata_receiver) = unbounded();
ws_sender.send(ws_root.clone());
fs_sender.send(ws_root.clone());
loop {
@ -137,7 +137,10 @@ fn main_loop_inner(
let files = state.events_to_files(events);
let sender = libdata_sender.clone();
pool.execute(move || {
let start = ::std::time::Instant::now();
info!("indexing {} ... ", root.display());
let data = LibraryData::prepare(files);
info!("indexed {:?} {}", start.elapsed(), root.display());
sender.send(data);
});
}

View file

@ -3,7 +3,7 @@ use std::{
fs,
};
use crossbeam_channel::{Sender, Receiver, bounded};
use crossbeam_channel::{Sender, Receiver, unbounded};
use walkdir::WalkDir;
use {
@ -23,8 +23,8 @@ pub enum FileEventKind {
}
pub fn roots_loader() -> (Sender<PathBuf>, Receiver<(PathBuf, Vec<FileEvent>)>, ThreadWatcher) {
let (path_sender, path_receiver) = bounded::<PathBuf>(2048);
let (event_sender, event_receiver) = bounded::<(PathBuf, Vec<FileEvent>)>(1);
let (path_sender, path_receiver) = unbounded::<PathBuf>();
let (event_sender, event_receiver) = unbounded::<(PathBuf, Vec<FileEvent>)>();
let thread = ThreadWatcher::spawn("roots loader", move || {
path_receiver
.into_iter()

View file

@ -95,5 +95,5 @@ fn test_eggs() {}
// extern crate regex;
// "#);
// server.wait_for_feedback("workspace loaded");
// server.wait_for_feedback_n("library loaded", 1);
// server.wait_for_feedback_n("library loaded", 9);
// }