@@ -11,13 +11,13 @@ use ra_syntax::{
1111use crate :: { FileId , FunctionSignature } ;
1212
1313#[ derive( Clone , Debug , PartialEq , Eq ) ]
14- pub struct InlayConfig {
14+ pub struct InlayHintsOptions {
1515 pub type_hints : bool ,
1616 pub parameter_hints : bool ,
1717 pub max_length : Option < usize > ,
1818}
1919
20- impl Default for InlayConfig {
20+ impl Default for InlayHintsOptions {
2121 fn default ( ) -> Self {
2222 Self { type_hints : true , parameter_hints : true , max_length : None }
2323 }
@@ -39,7 +39,7 @@ pub struct InlayHint {
3939pub ( crate ) fn inlay_hints (
4040 db : & RootDatabase ,
4141 file_id : FileId ,
42- inlay_hint_opts : & InlayConfig ,
42+ options : & InlayHintsOptions ,
4343) -> Vec < InlayHint > {
4444 let _p = profile ( "inlay_hints" ) ;
4545 let sema = Semantics :: new ( db) ;
@@ -49,9 +49,9 @@ pub(crate) fn inlay_hints(
4949 for node in file. syntax ( ) . descendants ( ) {
5050 match_ast ! {
5151 match node {
52- ast:: CallExpr ( it) => { get_param_name_hints( & mut res, & sema, inlay_hint_opts , ast:: Expr :: from( it) ) ; } ,
53- ast:: MethodCallExpr ( it) => { get_param_name_hints( & mut res, & sema, inlay_hint_opts , ast:: Expr :: from( it) ) ; } ,
54- ast:: BindPat ( it) => { get_bind_pat_hints( & mut res, & sema, inlay_hint_opts , it) ; } ,
52+ ast:: CallExpr ( it) => { get_param_name_hints( & mut res, & sema, options , ast:: Expr :: from( it) ) ; } ,
53+ ast:: MethodCallExpr ( it) => { get_param_name_hints( & mut res, & sema, options , ast:: Expr :: from( it) ) ; } ,
54+ ast:: BindPat ( it) => { get_bind_pat_hints( & mut res, & sema, options , it) ; } ,
5555 _ => ( ) ,
5656 }
5757 }
@@ -62,10 +62,10 @@ pub(crate) fn inlay_hints(
6262fn get_param_name_hints (
6363 acc : & mut Vec < InlayHint > ,
6464 sema : & Semantics < RootDatabase > ,
65- inlay_hint_opts : & InlayConfig ,
65+ options : & InlayHintsOptions ,
6666 expr : ast:: Expr ,
6767) -> Option < ( ) > {
68- if !inlay_hint_opts . parameter_hints {
68+ if !options . parameter_hints {
6969 return None ;
7070 }
7171
@@ -102,10 +102,10 @@ fn get_param_name_hints(
102102fn get_bind_pat_hints (
103103 acc : & mut Vec < InlayHint > ,
104104 sema : & Semantics < RootDatabase > ,
105- inlay_hint_opts : & InlayConfig ,
105+ options : & InlayHintsOptions ,
106106 pat : ast:: BindPat ,
107107) -> Option < ( ) > {
108- if !inlay_hint_opts . type_hints {
108+ if !options . type_hints {
109109 return None ;
110110 }
111111
@@ -118,7 +118,7 @@ fn get_bind_pat_hints(
118118 acc. push ( InlayHint {
119119 range : pat. syntax ( ) . text_range ( ) ,
120120 kind : InlayKind :: TypeHint ,
121- label : ty. display_truncated ( sema. db , inlay_hint_opts . max_length ) . to_string ( ) . into ( ) ,
121+ label : ty. display_truncated ( sema. db , options . max_length ) . to_string ( ) . into ( ) ,
122122 } ) ;
123123 Some ( ( ) )
124124}
@@ -224,7 +224,7 @@ fn get_fn_signature(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
224224
225225#[ cfg( test) ]
226226mod tests {
227- use crate :: inlay_hints:: InlayConfig ;
227+ use crate :: inlay_hints:: InlayHintsOptions ;
228228 use insta:: assert_debug_snapshot;
229229
230230 use crate :: mock_analysis:: single_file;
@@ -238,7 +238,7 @@ mod tests {
238238 let _x = foo(4, 4);
239239 }"# ,
240240 ) ;
241- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { parameter_hints: true , type_hints: false , max_length: None } ) . unwrap( ) , @r###"
241+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions { parameter_hints: true , type_hints: false , max_length: None } ) . unwrap( ) , @r###"
242242 [
243243 InlayHint {
244244 range: [106; 107),
@@ -262,7 +262,7 @@ mod tests {
262262 let _x = foo(4, 4);
263263 }"# ,
264264 ) ;
265- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { type_hints: false , parameter_hints: false , max_length: None } ) . unwrap( ) , @r###"[]"### ) ;
265+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions { type_hints: false , parameter_hints: false , max_length: None } ) . unwrap( ) , @r###"[]"### ) ;
266266 }
267267
268268 #[ test]
@@ -274,7 +274,7 @@ mod tests {
274274 let _x = foo(4, 4);
275275 }"# ,
276276 ) ;
277- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { type_hints: true , parameter_hints: false , max_length: None } ) . unwrap( ) , @r###"
277+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions { type_hints: true , parameter_hints: false , max_length: None } ) . unwrap( ) , @r###"
278278 [
279279 InlayHint {
280280 range: [97; 99),
@@ -298,7 +298,7 @@ fn main() {
298298}"# ,
299299 ) ;
300300
301- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
301+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
302302 [
303303 InlayHint {
304304 range: [69; 71),
@@ -355,7 +355,7 @@ fn main() {
355355}"# ,
356356 ) ;
357357
358- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
358+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
359359 [
360360 InlayHint {
361361 range: [193; 197),
@@ -435,7 +435,7 @@ fn main() {
435435}"# ,
436436 ) ;
437437
438- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
438+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
439439 [
440440 InlayHint {
441441 range: [21; 30),
@@ -499,7 +499,7 @@ fn main() {
499499}"# ,
500500 ) ;
501501
502- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
502+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
503503 [
504504 InlayHint {
505505 range: [21; 30),
@@ -549,7 +549,7 @@ fn main() {
549549}"# ,
550550 ) ;
551551
552- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
552+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
553553 [
554554 InlayHint {
555555 range: [188; 192),
@@ -644,7 +644,7 @@ fn main() {
644644}"# ,
645645 ) ;
646646
647- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
647+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
648648 [
649649 InlayHint {
650650 range: [188; 192),
@@ -739,7 +739,7 @@ fn main() {
739739}"# ,
740740 ) ;
741741
742- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
742+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
743743 [
744744 InlayHint {
745745 range: [252; 256),
@@ -811,7 +811,7 @@ fn main() {
811811}"# ,
812812 ) ;
813813
814- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { max_length: Some ( 8 ) , ..Default :: default ( ) } ) . unwrap( ) , @r###"
814+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions { max_length: Some ( 8 ) , ..Default :: default ( ) } ) . unwrap( ) , @r###"
815815 [
816816 InlayHint {
817817 range: [74; 75),
@@ -899,7 +899,7 @@ fn main() {
899899}"# ,
900900 ) ;
901901
902- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig :: default ( ) ) . unwrap( ) , @r###"
902+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions :: default ( ) ) . unwrap( ) , @r###"
903903 [
904904 InlayHint {
905905 range: [798; 809),
@@ -1021,7 +1021,7 @@ fn main() {
10211021}"# ,
10221022 ) ;
10231023
1024- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { max_length: Some ( 8 ) , ..Default :: default ( ) } ) . unwrap( ) , @r###"
1024+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions { max_length: Some ( 8 ) , ..Default :: default ( ) } ) . unwrap( ) , @r###"
10251025 []
10261026 "###
10271027 ) ;
@@ -1047,7 +1047,7 @@ fn main() {
10471047}"# ,
10481048 ) ;
10491049
1050- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { max_length: Some ( 8 ) , ..Default :: default ( ) } ) . unwrap( ) , @r###"
1050+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayHintsOptions { max_length: Some ( 8 ) , ..Default :: default ( ) } ) . unwrap( ) , @r###"
10511051 []
10521052 "###
10531053 ) ;
0 commit comments