aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/hover.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-01-06 10:54:28 +0000
committerAleksey Kladov <[email protected]>2021-01-06 12:39:28 +0000
commitf7a15b5cd1df58e46066bbd27c90cb1ad7f9c316 (patch)
treedf2caa99c4558b9f2550420896ec9998566e1d5d /crates/ide/src/hover.rs
parentc3104466596e85d7fa43b8e3ac015bcabd08fcce (diff)
More maintainable config
Rather than eagerly converting JSON, we losslessly keep it as is, and change the shape of user-submitted data at the last moment. This also allows us to remove a bunch of wrong Defaults
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r--crates/ide/src/hover.rs29
1 files changed, 7 insertions, 22 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index f2ad95cb6..72c9c66fe 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -17,7 +17,7 @@ use crate::{
17 doc_links::{remove_links, rewrite_links}, 17 doc_links::{remove_links, rewrite_links},
18 markdown_remove::remove_markdown, 18 markdown_remove::remove_markdown,
19 markup::Markup, 19 markup::Markup,
20 runnables::runnable, 20 runnables::{runnable, runnable_fn},
21 FileId, FilePosition, NavigationTarget, RangeInfo, Runnable, 21 FileId, FilePosition, NavigationTarget, RangeInfo, Runnable,
22}; 22};
23 23
@@ -31,19 +31,6 @@ pub struct HoverConfig {
31 pub markdown: bool, 31 pub markdown: bool,
32} 32}
33 33
34impl Default for HoverConfig {
35 fn default() -> Self {
36 Self {
37 implementations: true,
38 run: true,
39 debug: true,
40 goto_type_def: true,
41 links_in_hover: true,
42 markdown: true,
43 }
44 }
45}
46
47impl HoverConfig { 34impl HoverConfig {
48 pub const NO_ACTIONS: Self = Self { 35 pub const NO_ACTIONS: Self = Self {
49 implementations: false, 36 implementations: false,
@@ -204,22 +191,20 @@ fn runnable_action(
204 match def { 191 match def {
205 Definition::ModuleDef(it) => match it { 192 Definition::ModuleDef(it) => match it {
206 ModuleDef::Module(it) => match it.definition_source(sema.db).value { 193 ModuleDef::Module(it) => match it.definition_source(sema.db).value {
207 ModuleSource::Module(it) => runnable(&sema, it.syntax().clone(), file_id) 194 ModuleSource::Module(it) => {
208 .map(|it| HoverAction::Runnable(it)), 195 runnable(&sema, it.syntax().clone()).map(|it| HoverAction::Runnable(it))
196 }
209 _ => None, 197 _ => None,
210 }, 198 },
211 ModuleDef::Function(it) => { 199 ModuleDef::Function(func) => {
212 #[allow(deprecated)] 200 let src = func.source(sema.db)?;
213 let src = it.source(sema.db)?;
214 if src.file_id != file_id.into() { 201 if src.file_id != file_id.into() {
215 mark::hit!(hover_macro_generated_struct_fn_doc_comment); 202 mark::hit!(hover_macro_generated_struct_fn_doc_comment);
216 mark::hit!(hover_macro_generated_struct_fn_doc_attr); 203 mark::hit!(hover_macro_generated_struct_fn_doc_attr);
217
218 return None; 204 return None;
219 } 205 }
220 206
221 runnable(&sema, src.value.syntax().clone(), file_id) 207 runnable_fn(&sema, func).map(HoverAction::Runnable)
222 .map(|it| HoverAction::Runnable(it))
223 } 208 }
224 _ => None, 209 _ => None,
225 }, 210 },