@@ -75,12 +75,12 @@ pub(super) fn hints(
75
75
76
76
#[ cfg( test) ]
77
77
mod tests {
78
- use expect_test:: expect;
78
+ use expect_test:: { expect, Expect } ;
79
+ use text_edit:: { TextRange , TextSize } ;
79
80
80
81
use crate :: {
81
- inlay_hints:: tests:: {
82
- check_expect, check_expect_clear_loc, check_with_config, DISABLED_CONFIG , TEST_CONFIG ,
83
- } ,
82
+ fixture,
83
+ inlay_hints:: tests:: { check_with_config, DISABLED_CONFIG , TEST_CONFIG } ,
84
84
InlayHintsConfig ,
85
85
} ;
86
86
@@ -89,6 +89,33 @@ mod tests {
89
89
check_with_config ( InlayHintsConfig { chaining_hints : true , ..DISABLED_CONFIG } , ra_fixture) ;
90
90
}
91
91
92
+ #[ track_caller]
93
+ pub ( super ) fn check_expect ( config : InlayHintsConfig , ra_fixture : & str , expect : Expect ) {
94
+ let ( analysis, file_id) = fixture:: file ( ra_fixture) ;
95
+ let inlay_hints = analysis. inlay_hints ( & config, file_id, None ) . unwrap ( ) ;
96
+ let filtered =
97
+ inlay_hints. into_iter ( ) . map ( |hint| ( hint. range , hint. label ) ) . collect :: < Vec < _ > > ( ) ;
98
+ expect. assert_debug_eq ( & filtered)
99
+ }
100
+
101
+ #[ track_caller]
102
+ pub ( super ) fn check_expect_clear_loc (
103
+ config : InlayHintsConfig ,
104
+ ra_fixture : & str ,
105
+ expect : Expect ,
106
+ ) {
107
+ let ( analysis, file_id) = fixture:: file ( ra_fixture) ;
108
+ let mut inlay_hints = analysis. inlay_hints ( & config, file_id, None ) . unwrap ( ) ;
109
+ inlay_hints. iter_mut ( ) . flat_map ( |hint| & mut hint. label . parts ) . for_each ( |hint| {
110
+ if let Some ( loc) = & mut hint. linked_location {
111
+ loc. range = TextRange :: empty ( TextSize :: from ( 0 ) ) ;
112
+ }
113
+ } ) ;
114
+ let filtered =
115
+ inlay_hints. into_iter ( ) . map ( |hint| ( hint. range , hint. label ) ) . collect :: < Vec < _ > > ( ) ;
116
+ expect. assert_debug_eq ( & filtered)
117
+ }
118
+
92
119
#[ test]
93
120
fn chaining_hints_ignore_comments ( ) {
94
121
check_expect (
0 commit comments