diff options
author | Aleksey Kladov <[email protected]> | 2018-12-22 09:13:20 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-22 09:38:24 +0000 |
commit | 90f20f8c539843f53a7a2b1cfb83b3673ec78534 (patch) | |
tree | 57e252955404bba9978f3a3a3c288a0636a87173 /crates | |
parent | 94241cec04f0dfa4aa725f114abc0405f65b00b9 (diff) |
less verbose debug
Diffstat (limited to 'crates')
-rw-r--r-- | crates/gen_lsp_server/src/msg.rs | 8 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 45 |
2 files changed, 45 insertions, 8 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_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 { |