]> git.lizzy.rs Git - rust.git/commitdiff
minor: simplify
authorAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 28 Jul 2021 09:25:14 +0000 (12:25 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 28 Jul 2021 09:35:21 +0000 (12:35 +0300)
crates/rust-analyzer/src/config.rs
crates/rust-analyzer/src/handlers.rs

index a4caccbe63c6e7266224a0bf33196e5a7c784beb..99a29b43d20419189d4eeb0a604d8adcc0970606 100644 (file)
@@ -582,9 +582,6 @@ fn experimental(&self, index: &'static str) -> bool {
     pub fn code_action_group(&self) -> bool {
         self.experimental("codeActionGroup")
     }
-    pub fn experimental_hover_actions(&self) -> bool {
-        self.experimental("hoverActions")
-    }
     pub fn server_status_notification(&self) -> bool {
         self.experimental("serverStatusNotification")
     }
@@ -790,13 +787,13 @@ pub fn lens(&self) -> LensConfig {
         }
     }
     pub fn hover_actions(&self) -> HoverActionsConfig {
+        let enable = self.experimental("hoverActions") && self.data.hoverActions_enable;
         HoverActionsConfig {
-            implementations: self.data.hoverActions_enable
-                && self.data.hoverActions_implementations,
-            references: self.data.hoverActions_enable && self.data.hoverActions_references,
-            run: self.data.hoverActions_enable && self.data.hoverActions_run,
-            debug: self.data.hoverActions_enable && self.data.hoverActions_debug,
-            goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef,
+            implementations: enable && self.data.hoverActions_implementations,
+            references: enable && self.data.hoverActions_references,
+            run: enable && self.data.hoverActions_run,
+            debug: enable && self.data.hoverActions_debug,
+            goto_type_def: enable && self.data.hoverActions_gotoTypeDef,
         }
     }
     pub fn highlighting_strings(&self) -> bool {
index 52b557f156886c2b3cfd7883ca6b67269fa35d11..129b35999d0d3661c5a6cf441bdb7d9c542a9cdd 100644 (file)
@@ -882,7 +882,11 @@ pub(crate) fn handle_hover(
             contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)),
             range: Some(range),
         },
-        actions: prepare_hover_actions(&snap, &info.info.actions),
+        actions: if snap.config.hover_actions().none() {
+            Vec::new()
+        } else {
+            prepare_hover_actions(&snap, &info.info.actions)
+        },
     };
 
     Ok(Some(hover))
@@ -1594,10 +1598,6 @@ fn prepare_hover_actions(
     snap: &GlobalStateSnapshot,
     actions: &[HoverAction],
 ) -> Vec<lsp_ext::CommandLinkGroup> {
-    if snap.config.hover_actions().none() || !snap.config.experimental_hover_actions() {
-        return Vec::new();
-    }
-
     actions
         .iter()
         .filter_map(|it| match it {