aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/gen_lsp_server/src/msg.rs8
-rw-r--r--crates/ra_analysis/src/lib.rs11
-rw-r--r--crates/ra_analysis/src/symbol_index.rs4
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs49
-rw-r--r--crates/ra_lsp_server/src/server_world.rs1
5 files changed, 62 insertions, 11 deletions
diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs
index af901d0d2..f68cbc541 100644
--- a/crates/gen_lsp_server/src/msg.rs
+++ b/crates/gen_lsp_server/src/msg.rs
@@ -152,12 +152,18 @@ impl RawNotification {
152 params: to_value(params).unwrap(), 152 params: to_value(params).unwrap(),
153 } 153 }
154 } 154 }
155 pub fn is<N>(&self) -> bool
156 where
157 N: Notification,
158 {
159 self.method == N::METHOD
160 }
155 pub fn cast<N>(self) -> ::std::result::Result<N::Params, RawNotification> 161 pub fn cast<N>(self) -> ::std::result::Result<N::Params, RawNotification>
156 where 162 where
157 N: Notification, 163 N: Notification,
158 N::Params: serde::de::DeserializeOwned, 164 N::Params: serde::de::DeserializeOwned,
159 { 165 {
160 if self.method != N::METHOD { 166 if !self.is::<N>() {
161 return Err(self); 167 return Err(self);
162 } 168 }
163 Ok(from_value(self.params).unwrap()) 169 Ok(from_value(self.params).unwrap())
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 6fd157880..85df9c089 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -368,13 +368,22 @@ impl Analysis {
368 } 368 }
369} 369}
370 370
371#[derive(Debug)]
372pub struct LibraryData { 371pub struct LibraryData {
373 root_id: SourceRootId, 372 root_id: SourceRootId,
374 root_change: RootChange, 373 root_change: RootChange,
375 symbol_index: SymbolIndex, 374 symbol_index: SymbolIndex,
376} 375}
377 376
377impl fmt::Debug for LibraryData {
378 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
379 f.debug_struct("LibraryData")
380 .field("root_id", &self.root_id)
381 .field("root_change", &self.root_change)
382 .field("n_symbols", &self.symbol_index.len())
383 .finish()
384 }
385}
386
378impl LibraryData { 387impl LibraryData {
379 pub fn prepare( 388 pub fn prepare(
380 root_id: SourceRootId, 389 root_id: SourceRootId,
diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs
index b48a37229..e5bdf0aa1 100644
--- a/crates/ra_analysis/src/symbol_index.rs
+++ b/crates/ra_analysis/src/symbol_index.rs
@@ -56,6 +56,10 @@ impl Hash for SymbolIndex {
56} 56}
57 57
58impl SymbolIndex { 58impl SymbolIndex {
59 pub(crate) fn len(&self) -> usize {
60 self.symbols.len()
61 }
62
59 pub(crate) fn for_files( 63 pub(crate) fn for_files(
60 files: impl ParallelIterator<Item = (FileId, SourceFileNode)>, 64 files: impl ParallelIterator<Item = (FileId, SourceFileNode)>,
61 ) -> SymbolIndex { 65 ) -> SymbolIndex {
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index afe0fec89..84f88eeff 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -2,6 +2,7 @@ mod handlers;
2mod subscriptions; 2mod subscriptions;
3 3
4use std::{ 4use std::{
5 fmt,
5 path::PathBuf, 6 path::PathBuf,
6 sync::Arc, 7 sync::Arc,
7}; 8};
@@ -109,6 +110,43 @@ pub fn main_loop(
109 Ok(()) 110 Ok(())
110} 111}
111 112
113enum Event {
114 Msg(RawMessage),
115 Task(Task),
116 Vfs(VfsTask),
117 Lib(LibraryData),
118}
119
120impl fmt::Debug for Event {
121 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
122 let debug_verbose_not = |not: &RawNotification, f: &mut fmt::Formatter| {
123 f.debug_struct("RawNotification")
124 .field("method", &not.method)
125 .finish()
126 };
127
128 match self {
129 Event::Msg(RawMessage::Notification(not)) => {
130 if not.is::<req::DidOpenTextDocument>() || not.is::<req::DidChangeTextDocument>() {
131 return debug_verbose_not(not, f);
132 }
133 }
134 Event::Task(Task::Notify(not)) => {
135 if not.is::<req::PublishDecorations>() || not.is::<req::PublishDiagnostics>() {
136 return debug_verbose_not(not, f);
137 }
138 }
139 _ => (),
140 }
141 match self {
142 Event::Msg(it) => fmt::Debug::fmt(it, f),
143 Event::Task(it) => fmt::Debug::fmt(it, f),
144 Event::Vfs(it) => fmt::Debug::fmt(it, f),
145 Event::Lib(it) => fmt::Debug::fmt(it, f),
146 }
147 }
148}
149
112fn main_loop_inner( 150fn main_loop_inner(
113 internal_mode: bool, 151 internal_mode: bool,
114 publish_decorations: bool, 152 publish_decorations: bool,
@@ -123,13 +161,6 @@ fn main_loop_inner(
123) -> Result<()> { 161) -> Result<()> {
124 let (libdata_sender, libdata_receiver) = unbounded(); 162 let (libdata_sender, libdata_receiver) = unbounded();
125 loop { 163 loop {
126 #[derive(Debug)]
127 enum Event {
128 Msg(RawMessage),
129 Task(Task),
130 Vfs(VfsTask),
131 Lib(LibraryData),
132 }
133 log::trace!("selecting"); 164 log::trace!("selecting");
134 let event = select! { 165 let event = select! {
135 recv(msg_receiver, msg) => match msg { 166 recv(msg_receiver, msg) => match msg {
@@ -143,7 +174,8 @@ fn main_loop_inner(
143 } 174 }
144 recv(libdata_receiver, data) => Event::Lib(data.unwrap()) 175 recv(libdata_receiver, data) => Event::Lib(data.unwrap())
145 }; 176 };
146 log::info!("{:?}", event); 177 log::info!("loop_turn = {:?}", event);
178 let start = std::time::Instant::now();
147 let mut state_changed = false; 179 let mut state_changed = false;
148 match event { 180 match event {
149 Event::Task(task) => on_task(task, msg_sender, pending_requests), 181 Event::Task(task) => on_task(task, msg_sender, pending_requests),
@@ -206,6 +238,7 @@ fn main_loop_inner(
206 subs.subscriptions(), 238 subs.subscriptions(),
207 ) 239 )
208 } 240 }
241 log::info!("loop_turn = {:?}", start.elapsed());
209 } 242 }
210} 243}
211 244
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index 73cccc9dd..c183c25af 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -107,7 +107,6 @@ impl ServerWorldState {
107 let mut libs = Vec::new(); 107 let mut libs = Vec::new();
108 let mut change = AnalysisChange::new(); 108 let mut change = AnalysisChange::new();
109 for c in changes { 109 for c in changes {
110 log::info!("vfs change {:?}", c);
111 match c { 110 match c {
112 VfsChange::AddRoot { root, files } => { 111 VfsChange::AddRoot { root, files } => {
113 let root_path = self.vfs.read().root2path(root); 112 let root_path = self.vfs.read().root2path(root);