diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 49 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 1 |
2 files changed, 41 insertions, 9 deletions
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; | |||
2 | mod subscriptions; | 2 | mod subscriptions; |
3 | 3 | ||
4 | use std::{ | 4 | use 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 | ||
113 | enum Event { | ||
114 | Msg(RawMessage), | ||
115 | Task(Task), | ||
116 | Vfs(VfsTask), | ||
117 | Lib(LibraryData), | ||
118 | } | ||
119 | |||
120 | impl 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", ¬.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 | |||
112 | fn main_loop_inner( | 150 | fn 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); |