@@ -6,7 +6,7 @@ use hir::setup_tracing;
6
6
use ide_db:: {
7
7
LineIndexDatabase , RootDatabase ,
8
8
assists:: { AssistResolveStrategy , ExprFillDefaultMode } ,
9
- base_db:: SourceDatabase ,
9
+ base_db:: { SourceDatabase , salsa } ,
10
10
} ;
11
11
use itertools:: Itertools ;
12
12
use stdx:: trim_indent;
@@ -74,14 +74,16 @@ fn check_nth_fix_with_config(
74
74
let after = trim_indent ( ra_fixture_after) ;
75
75
76
76
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
+ } ) ;
85
87
let fix = & diagnostic
86
88
. fixes
87
89
. unwrap_or_else ( || panic ! ( "{:?} diagnostic misses fixes" , diagnostic. code) ) [ nth] ;
@@ -127,12 +129,14 @@ pub(crate) fn check_has_fix(
127
129
let ( db, file_position) = RootDatabase :: with_position ( ra_fixture_before) ;
128
130
let mut conf = DiagnosticsConfig :: test_sample ( ) ;
129
131
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
+ } )
136
140
. into_iter ( )
137
141
. find ( |d| {
138
142
d. fixes
@@ -166,12 +170,14 @@ pub(crate) fn check_has_fix(
166
170
/// Checks that there's a diagnostic *without* fix at `$0`.
167
171
pub ( crate ) fn check_no_fix ( #[ rust_analyzer:: rust_fixture] ra_fixture : & str ) {
168
172
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
+ } )
175
181
. pop ( )
176
182
. unwrap ( ) ;
177
183
assert ! ( diagnostic. fixes. is_none( ) , "got a fix when none was expected: {diagnostic:?}" ) ;
@@ -206,7 +212,13 @@ pub(crate) fn check_diagnostics_with_config(
206
212
. iter ( )
207
213
. copied ( )
208
214
. 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
+ )
210
222
. into_iter ( )
211
223
. map ( |d| {
212
224
let mut annotation = String :: new ( ) ;
@@ -224,6 +236,7 @@ pub(crate) fn check_diagnostics_with_config(
224
236
annotation. push_str ( & d. message ) ;
225
237
( d. range , annotation)
226
238
} )
239
+ } )
227
240
} )
228
241
. map ( |( diagnostic, annotation) | ( diagnostic. file_id , ( diagnostic. range , annotation) ) )
229
242
. into_group_map ( ) ;
@@ -275,15 +288,19 @@ fn test_disabled_diagnostics() {
275
288
let ( db, file_id) = RootDatabase :: with_single_file ( r#"mod foo;"# ) ;
276
289
let file_id = file_id. file_id ( & db) ;
277
290
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
+ } ) ;
279
294
assert ! ( diagnostics. is_empty( ) ) ;
280
295
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
+ } ) ;
287
304
assert ! ( !diagnostics. is_empty( ) ) ;
288
305
}
289
306
0 commit comments