diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 11e7803e4..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 { |