@@ -59,10 +59,14 @@ fn check_nth_fix_with_config(
59
59
let after = trim_indent ( ra_fixture_after) ;
60
60
61
61
let ( db, file_position) = RootDatabase :: with_position ( ra_fixture_before) ;
62
- let diagnostic =
63
- super :: diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_position. file_id . into ( ) )
64
- . pop ( )
65
- . expect ( "no diagnostics" ) ;
62
+ let diagnostic = super :: full_diagnostics (
63
+ & db,
64
+ & config,
65
+ & AssistResolveStrategy :: All ,
66
+ file_position. file_id . into ( ) ,
67
+ )
68
+ . pop ( )
69
+ . expect ( "no diagnostics" ) ;
66
70
let fix = & diagnostic
67
71
. fixes
68
72
. unwrap_or_else ( || panic ! ( "{:?} diagnostic misses fixes" , diagnostic. code) ) [ nth] ;
@@ -102,37 +106,39 @@ pub(crate) fn check_has_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
102
106
let ( db, file_position) = RootDatabase :: with_position ( ra_fixture_before) ;
103
107
let mut conf = DiagnosticsConfig :: test_sample ( ) ;
104
108
conf. expr_fill_default = ExprFillDefaultMode :: Default ;
105
- let fix =
106
- super :: diagnostics ( & db, & conf, & AssistResolveStrategy :: All , file_position. file_id . into ( ) )
107
- . into_iter ( )
108
- . find ( |d| {
109
- d. fixes
110
- . as_ref ( )
111
- . and_then ( |fixes| {
112
- fixes. iter ( ) . find ( |fix| {
113
- if !fix. target . contains_inclusive ( file_position. offset ) {
114
- return false ;
115
- }
116
- let actual = {
117
- let source_change = fix. source_change . as_ref ( ) . unwrap ( ) ;
118
- let file_id =
119
- * source_change. source_file_edits . keys ( ) . next ( ) . unwrap ( ) ;
120
- let mut actual = db. file_text ( file_id) . to_string ( ) ;
109
+ let fix = super :: full_diagnostics (
110
+ & db,
111
+ & conf,
112
+ & AssistResolveStrategy :: All ,
113
+ file_position. file_id . into ( ) ,
114
+ )
115
+ . into_iter ( )
116
+ . find ( |d| {
117
+ d. fixes
118
+ . as_ref ( )
119
+ . and_then ( |fixes| {
120
+ fixes. iter ( ) . find ( |fix| {
121
+ if !fix. target . contains_inclusive ( file_position. offset ) {
122
+ return false ;
123
+ }
124
+ let actual = {
125
+ let source_change = fix. source_change . as_ref ( ) . unwrap ( ) ;
126
+ let file_id = * source_change. source_file_edits . keys ( ) . next ( ) . unwrap ( ) ;
127
+ let mut actual = db. file_text ( file_id) . to_string ( ) ;
121
128
122
- for ( edit, snippet_edit) in source_change. source_file_edits . values ( )
123
- {
124
- edit. apply ( & mut actual) ;
125
- if let Some ( snippet_edit) = snippet_edit {
126
- snippet_edit. apply ( & mut actual) ;
127
- }
128
- }
129
- actual
130
- } ;
131
- after == actual
132
- } )
133
- } )
134
- . is_some ( )
135
- } ) ;
129
+ for ( edit, snippet_edit) in source_change. source_file_edits . values ( ) {
130
+ edit. apply ( & mut actual) ;
131
+ if let Some ( snippet_edit) = snippet_edit {
132
+ snippet_edit. apply ( & mut actual) ;
133
+ }
134
+ }
135
+ actual
136
+ } ;
137
+ after == actual
138
+ } )
139
+ } )
140
+ . is_some ( )
141
+ } ) ;
136
142
assert ! ( fix. is_some( ) , "no diagnostic with desired fix" ) ;
137
143
}
138
144
@@ -144,46 +150,48 @@ pub(crate) fn check_has_single_fix(ra_fixture_before: &str, ra_fixture_after: &s
144
150
let mut conf = DiagnosticsConfig :: test_sample ( ) ;
145
151
conf. expr_fill_default = ExprFillDefaultMode :: Default ;
146
152
let mut n_fixes = 0 ;
147
- let fix =
148
- super :: diagnostics ( & db, & conf, & AssistResolveStrategy :: All , file_position. file_id . into ( ) )
149
- . into_iter ( )
150
- . find ( |d| {
151
- d. fixes
152
- . as_ref ( )
153
- . and_then ( |fixes| {
154
- n_fixes += fixes. len ( ) ;
155
- fixes. iter ( ) . find ( |fix| {
156
- if !fix. target . contains_inclusive ( file_position. offset ) {
157
- return false ;
158
- }
159
- let actual = {
160
- let source_change = fix. source_change . as_ref ( ) . unwrap ( ) ;
161
- let file_id =
162
- * source_change. source_file_edits . keys ( ) . next ( ) . unwrap ( ) ;
163
- let mut actual = db. file_text ( file_id) . to_string ( ) ;
153
+ let fix = super :: full_diagnostics (
154
+ & db,
155
+ & conf,
156
+ & AssistResolveStrategy :: All ,
157
+ file_position. file_id . into ( ) ,
158
+ )
159
+ . into_iter ( )
160
+ . find ( |d| {
161
+ d. fixes
162
+ . as_ref ( )
163
+ . and_then ( |fixes| {
164
+ n_fixes += fixes. len ( ) ;
165
+ fixes. iter ( ) . find ( |fix| {
166
+ if !fix. target . contains_inclusive ( file_position. offset ) {
167
+ return false ;
168
+ }
169
+ let actual = {
170
+ let source_change = fix. source_change . as_ref ( ) . unwrap ( ) ;
171
+ let file_id = * source_change. source_file_edits . keys ( ) . next ( ) . unwrap ( ) ;
172
+ let mut actual = db. file_text ( file_id) . to_string ( ) ;
164
173
165
- for ( edit, snippet_edit) in source_change. source_file_edits . values ( )
166
- {
167
- edit. apply ( & mut actual) ;
168
- if let Some ( snippet_edit) = snippet_edit {
169
- snippet_edit. apply ( & mut actual) ;
170
- }
171
- }
172
- actual
173
- } ;
174
- after == actual
175
- } )
176
- } )
177
- . is_some ( )
178
- } ) ;
174
+ for ( edit, snippet_edit) in source_change. source_file_edits . values ( ) {
175
+ edit. apply ( & mut actual) ;
176
+ if let Some ( snippet_edit) = snippet_edit {
177
+ snippet_edit. apply ( & mut actual) ;
178
+ }
179
+ }
180
+ actual
181
+ } ;
182
+ after == actual
183
+ } )
184
+ } )
185
+ . is_some ( )
186
+ } ) ;
179
187
assert ! ( fix. is_some( ) , "no diagnostic with desired fix" ) ;
180
188
assert ! ( n_fixes == 1 , "Too many fixes suggested" ) ;
181
189
}
182
190
183
191
/// Checks that there's a diagnostic *without* fix at `$0`.
184
192
pub ( crate ) fn check_no_fix ( ra_fixture : & str ) {
185
193
let ( db, file_position) = RootDatabase :: with_position ( ra_fixture) ;
186
- let diagnostic = super :: diagnostics (
194
+ let diagnostic = super :: full_diagnostics (
187
195
& db,
188
196
& DiagnosticsConfig :: test_sample ( ) ,
189
197
& AssistResolveStrategy :: All ,
@@ -215,7 +223,7 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
215
223
. iter ( )
216
224
. copied ( )
217
225
. flat_map ( |file_id| {
218
- super :: diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id. into ( ) )
226
+ super :: full_diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id. into ( ) )
219
227
. into_iter ( )
220
228
. map ( |d| {
221
229
let mut annotation = String :: new ( ) ;
@@ -277,10 +285,10 @@ fn test_disabled_diagnostics() {
277
285
let ( db, file_id) = RootDatabase :: with_single_file ( r#"mod foo;"# ) ;
278
286
let file_id = file_id. into ( ) ;
279
287
280
- let diagnostics = super :: diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id) ;
288
+ let diagnostics = super :: full_diagnostics ( & db, & config, & AssistResolveStrategy :: All , file_id) ;
281
289
assert ! ( diagnostics. is_empty( ) ) ;
282
290
283
- let diagnostics = super :: diagnostics (
291
+ let diagnostics = super :: full_diagnostics (
284
292
& db,
285
293
& DiagnosticsConfig :: test_sample ( ) ,
286
294
& AssistResolveStrategy :: All ,
0 commit comments