From f7a15b5cd1df58e46066bbd27c90cb1ad7f9c316 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 6 Jan 2021 13:54:28 +0300 Subject: 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 --- crates/ide/src/hover.rs | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'crates/ide/src/hover.rs') 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::{ doc_links::{remove_links, rewrite_links}, markdown_remove::remove_markdown, markup::Markup, - runnables::runnable, + runnables::{runnable, runnable_fn}, FileId, FilePosition, NavigationTarget, RangeInfo, Runnable, }; @@ -31,19 +31,6 @@ pub struct HoverConfig { pub markdown: bool, } -impl Default for HoverConfig { - fn default() -> Self { - Self { - implementations: true, - run: true, - debug: true, - goto_type_def: true, - links_in_hover: true, - markdown: true, - } - } -} - impl HoverConfig { pub const NO_ACTIONS: Self = Self { implementations: false, @@ -204,22 +191,20 @@ fn runnable_action( match def { Definition::ModuleDef(it) => match it { ModuleDef::Module(it) => match it.definition_source(sema.db).value { - ModuleSource::Module(it) => runnable(&sema, it.syntax().clone(), file_id) - .map(|it| HoverAction::Runnable(it)), + ModuleSource::Module(it) => { + runnable(&sema, it.syntax().clone()).map(|it| HoverAction::Runnable(it)) + } _ => None, }, - ModuleDef::Function(it) => { - #[allow(deprecated)] - let src = it.source(sema.db)?; + ModuleDef::Function(func) => { + let src = func.source(sema.db)?; if src.file_id != file_id.into() { mark::hit!(hover_macro_generated_struct_fn_doc_comment); mark::hit!(hover_macro_generated_struct_fn_doc_attr); - return None; } - runnable(&sema, src.value.syntax().clone(), file_id) - .map(|it| HoverAction::Runnable(it)) + runnable_fn(&sema, func).map(HoverAction::Runnable) } _ => None, }, -- cgit v1.2.3