@@ -6,7 +6,7 @@ use hir::setup_tracing;
66use ide_db:: {
77 LineIndexDatabase , RootDatabase ,
88 assists:: { AssistResolveStrategy , ExprFillDefaultMode } ,
9- base_db:: SourceDatabase ,
9+ base_db:: { SourceDatabase , salsa } ,
1010} ;
1111use itertools:: Itertools ;
1212use stdx:: trim_indent;
@@ -74,14 +74,16 @@ fn check_nth_fix_with_config(
7474 let after = trim_indent ( ra_fixture_after) ;
7575
7676 let ( db, file_position) = RootDatabase :: with_position ( ra_fixture_before) ;
77- let diagnostic = super :: full_diagnostics (
78- & db,
79- & config,
80- & AssistResolveStrategy :: All ,
81- file_position. file_id . file_id ( & db) ,
82- )
83- . pop ( )
84- . expect ( "no diagnostics" ) ;
77+ let diagnostic = salsa:: attach ( & db, || {
78+ super :: full_diagnostics (
79+ & db,
80+ & config,
81+ & AssistResolveStrategy :: All ,
82+ file_position. file_id . file_id ( & db) ,
83+ )
84+ . pop ( )
85+ . expect ( "no diagnostics" )
86+ } ) ;
8587 let fix = & diagnostic
8688 . fixes
8789 . unwrap_or_else ( || panic ! ( "{:?} diagnostic misses fixes" , diagnostic. code) ) [ nth] ;
@@ -127,12 +129,14 @@ pub(crate) fn check_has_fix(
127129 let ( db, file_position) = RootDatabase :: with_position ( ra_fixture_before) ;
128130 let mut conf = DiagnosticsConfig :: test_sample ( ) ;
129131 conf. expr_fill_default = ExprFillDefaultMode :: Default ;
130- let fix = super :: full_diagnostics (
131- & db,
132- & conf,
133- & AssistResolveStrategy :: All ,
134- file_position. file_id . file_id ( & db) ,
135- )
132+ let fix = salsa:: attach ( & db, || {
133+ super :: full_diagnostics (
134+ & db,
135+ & conf,
136+ & AssistResolveStrategy :: All ,
137+ file_position. file_id . file_id ( & db) ,
138+ )
139+ } )
136140 . into_iter ( )
137141 . find ( |d| {
138142 d. fixes
@@ -166,12 +170,14 @@ pub(crate) fn check_has_fix(
166170/// Checks that there's a diagnostic *without* fix at `$0`.
167171pub ( crate ) fn check_no_fix ( #[ rust_analyzer:: rust_fixture] ra_fixture : & str ) {
168172 let ( db, file_position) = RootDatabase :: with_position ( ra_fixture) ;
169- let diagnostic = super :: full_diagnostics (
170- & db,
171- & DiagnosticsConfig :: test_sample ( ) ,
172- & AssistResolveStrategy :: All ,
173- file_position. file_id . file_id ( & db) ,
174- )
173+ let diagnostic = salsa:: attach ( & db, || {
174+ super :: full_diagnostics (
175+ & db,
176+ & DiagnosticsConfig :: test_sample ( ) ,
177+ & AssistResolveStrategy :: All ,
178+ file_position. file_id . file_id ( & db) ,
179+ )
180+ } )
175181 . pop ( )
176182 . unwrap ( ) ;
177183 assert ! ( diagnostic. fixes. is_none( ) , "got a fix when none was expected: {diagnostic:?}" ) ;
@@ -206,7 +212,13 @@ pub(crate) fn check_diagnostics_with_config(
206212 . iter ( )
207213 . copied ( )
208214 . flat_map ( |file_id| {
209- super :: full_diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id. file_id ( & db) )
215+ salsa:: attach ( & db, || {
216+ super :: full_diagnostics (
217+ & db,
218+ & config,
219+ & AssistResolveStrategy :: All ,
220+ file_id. file_id ( & db) ,
221+ )
210222 . into_iter ( )
211223 . map ( |d| {
212224 let mut annotation = String :: new ( ) ;
@@ -224,6 +236,7 @@ pub(crate) fn check_diagnostics_with_config(
224236 annotation. push_str ( & d. message ) ;
225237 ( d. range , annotation)
226238 } )
239+ } )
227240 } )
228241 . map ( |( diagnostic, annotation) | ( diagnostic. file_id , ( diagnostic. range , annotation) ) )
229242 . into_group_map ( ) ;
@@ -275,15 +288,19 @@ fn test_disabled_diagnostics() {
275288 let ( db, file_id) = RootDatabase :: with_single_file ( r#"mod foo;"# ) ;
276289 let file_id = file_id. file_id ( & db) ;
277290
278- let diagnostics = super :: full_diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id) ;
291+ let diagnostics = salsa:: attach ( & db, || {
292+ super :: full_diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id)
293+ } ) ;
279294 assert ! ( diagnostics. is_empty( ) ) ;
280295
281- let diagnostics = super :: full_diagnostics (
282- & db,
283- & DiagnosticsConfig :: test_sample ( ) ,
284- & AssistResolveStrategy :: All ,
285- file_id,
286- ) ;
296+ let diagnostics = salsa:: attach ( & db, || {
297+ super :: full_diagnostics (
298+ & db,
299+ & DiagnosticsConfig :: test_sample ( ) ,
300+ & AssistResolveStrategy :: All ,
301+ file_id,
302+ )
303+ } ) ;
287304 assert ! ( !diagnostics. is_empty( ) ) ;
288305}
289306
0 commit comments