From fd3ece2b739b2e8d97626d6c5a6cb91b70df1071 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 12 Mar 2020 17:38:48 +0100 Subject: Make naming more uniform --- crates/ra_ide/src/inlay_hints.rs | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'crates/ra_ide/src/inlay_hints.rs') diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 59922e14c..ecd615cf4 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -11,13 +11,13 @@ use ra_syntax::{ use crate::{FileId, FunctionSignature}; #[derive(Clone, Debug, PartialEq, Eq)] -pub struct InlayConfig { +pub struct InlayHintsOptions { pub type_hints: bool, pub parameter_hints: bool, pub max_length: Option, } -impl Default for InlayConfig { +impl Default for InlayHintsOptions { fn default() -> Self { Self { type_hints: true, parameter_hints: true, max_length: None } } @@ -39,7 +39,7 @@ pub struct InlayHint { pub(crate) fn inlay_hints( db: &RootDatabase, file_id: FileId, - inlay_hint_opts: &InlayConfig, + options: &InlayHintsOptions, ) -> Vec { let _p = profile("inlay_hints"); let sema = Semantics::new(db); @@ -49,9 +49,9 @@ pub(crate) fn inlay_hints( for node in file.syntax().descendants() { match_ast! { match node { - ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, inlay_hint_opts, ast::Expr::from(it)); }, - ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, inlay_hint_opts, ast::Expr::from(it)); }, - ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, inlay_hint_opts, it); }, + ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); }, + ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); }, + ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, options, it); }, _ => (), } } @@ -62,10 +62,10 @@ pub(crate) fn inlay_hints( fn get_param_name_hints( acc: &mut Vec, sema: &Semantics, - inlay_hint_opts: &InlayConfig, + options: &InlayHintsOptions, expr: ast::Expr, ) -> Option<()> { - if !inlay_hint_opts.parameter_hints { + if !options.parameter_hints { return None; } @@ -102,10 +102,10 @@ fn get_param_name_hints( fn get_bind_pat_hints( acc: &mut Vec, sema: &Semantics, - inlay_hint_opts: &InlayConfig, + options: &InlayHintsOptions, pat: ast::BindPat, ) -> Option<()> { - if !inlay_hint_opts.type_hints { + if !options.type_hints { return None; } @@ -118,7 +118,7 @@ fn get_bind_pat_hints( acc.push(InlayHint { range: pat.syntax().text_range(), kind: InlayKind::TypeHint, - label: ty.display_truncated(sema.db, inlay_hint_opts.max_length).to_string().into(), + label: ty.display_truncated(sema.db, options.max_length).to_string().into(), }); Some(()) } @@ -224,7 +224,7 @@ fn get_fn_signature(sema: &Semantics, expr: &ast::Expr) -> Option< #[cfg(test)] mod tests { - use crate::inlay_hints::InlayConfig; + use crate::inlay_hints::InlayHintsOptions; use insta::assert_debug_snapshot; use crate::mock_analysis::single_file; @@ -238,7 +238,7 @@ mod tests { let _x = foo(4, 4); }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ parameter_hints: true, type_hints: false, max_length: None}).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: true, type_hints: false, max_length: None}).unwrap(), @r###" [ InlayHint { range: [106; 107), @@ -262,7 +262,7 @@ mod tests { let _x = foo(4, 4); }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ type_hints: false, parameter_hints: false, max_length: None}).unwrap(), @r###"[]"###); + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: false, parameter_hints: false, max_length: None}).unwrap(), @r###"[]"###); } #[test] @@ -274,7 +274,7 @@ mod tests { let _x = foo(4, 4); }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ type_hints: true, parameter_hints: false, max_length: None}).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: true, parameter_hints: false, max_length: None}).unwrap(), @r###" [ InlayHint { range: [97; 99), @@ -298,7 +298,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [69; 71), @@ -355,7 +355,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [193; 197), @@ -435,7 +435,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [21; 30), @@ -499,7 +499,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [21; 30), @@ -549,7 +549,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [188; 192), @@ -644,7 +644,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [188; 192), @@ -739,7 +739,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [252; 256), @@ -811,7 +811,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" [ InlayHint { range: [74; 75), @@ -899,7 +899,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" [ InlayHint { range: [798; 809), @@ -1021,7 +1021,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" [] "### ); @@ -1047,7 +1047,7 @@ fn main() { }"#, ); - assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" + assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" [] "### ); -- cgit v1.2.3