@@ -48,24 +48,25 @@ fn check_doc_test(assist_id: &str, before: &str, after: &str) {
4848 let before = db. file_text ( file_id) . to_string ( ) ;
4949 let frange = FileRange { file_id, range : selection. into ( ) } ;
5050
51- let assist = Assist :: resolved ( & db, & AssistConfig :: default ( ) , frange)
51+ let assist = Assist :: get ( & db, & AssistConfig :: default ( ) , true , frange)
5252 . into_iter ( )
53- . find ( |assist| assist. assist . id . 0 == assist_id)
53+ . find ( |assist| assist. id . 0 == assist_id)
5454 . unwrap_or_else ( || {
5555 panic ! (
5656 "\n \n Assist is not applicable: {}\n Available assists: {}" ,
5757 assist_id,
58- Assist :: resolved ( & db, & AssistConfig :: default ( ) , frange)
58+ Assist :: get ( & db, & AssistConfig :: default ( ) , false , frange)
5959 . into_iter( )
60- . map( |assist| assist. assist . id. 0 )
60+ . map( |assist| assist. id. 0 )
6161 . collect:: <Vec <_>>( )
6262 . join( ", " )
6363 )
6464 } ) ;
6565
6666 let actual = {
67+ let source_change = assist. source_change . unwrap ( ) ;
6768 let mut actual = before;
68- for source_file_edit in assist . source_change . source_file_edits {
69+ for source_file_edit in source_change. source_file_edits {
6970 if source_file_edit. file_id == file_id {
7071 source_file_edit. edit . apply ( & mut actual)
7172 }
@@ -90,18 +91,18 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label:
9091 let sema = Semantics :: new ( & db) ;
9192 let config = AssistConfig :: default ( ) ;
9293 let ctx = AssistContext :: new ( sema, & config, frange) ;
93- let mut acc = Assists :: new_resolved ( & ctx) ;
94+ let mut acc = Assists :: new ( & ctx, true ) ;
9495 handler ( & mut acc, & ctx) ;
95- let mut res = acc. finish_resolved ( ) ;
96+ let mut res = acc. finish ( ) ;
9697
9798 let assist = match assist_label {
98- Some ( label) => res. into_iter ( ) . find ( |resolved| resolved. assist . label == label) ,
99+ Some ( label) => res. into_iter ( ) . find ( |resolved| resolved. label == label) ,
99100 None => res. pop ( ) ,
100101 } ;
101102
102103 match ( assist, expected) {
103104 ( Some ( assist) , ExpectedResult :: After ( after) ) => {
104- let mut source_change = assist. source_change ;
105+ let mut source_change = assist. source_change . unwrap ( ) ;
105106 assert ! ( !source_change. source_file_edits. is_empty( ) ) ;
106107 let skip_header = source_change. source_file_edits . len ( ) == 1
107108 && source_change. file_system_edits . len ( ) == 0 ;
@@ -138,7 +139,7 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label:
138139 assert_eq_text ! ( after, & buf) ;
139140 }
140141 ( Some ( assist) , ExpectedResult :: Target ( target) ) => {
141- let range = assist. assist . target ;
142+ let range = assist. target ;
142143 assert_eq_text ! ( & text_without_caret[ range] , target) ;
143144 }
144145 ( Some ( _) , ExpectedResult :: NotApplicable ) => panic ! ( "assist should not be applicable!" ) ,
@@ -155,14 +156,11 @@ fn assist_order_field_struct() {
155156 let ( before_cursor_pos, before) = extract_offset ( before) ;
156157 let ( db, file_id) = with_single_file ( & before) ;
157158 let frange = FileRange { file_id, range : TextRange :: empty ( before_cursor_pos) } ;
158- let assists = Assist :: resolved ( & db, & AssistConfig :: default ( ) , frange) ;
159+ let assists = Assist :: get ( & db, & AssistConfig :: default ( ) , false , frange) ;
159160 let mut assists = assists. iter ( ) ;
160161
161- assert_eq ! (
162- assists. next( ) . expect( "expected assist" ) . assist. label,
163- "Change visibility to pub(crate)"
164- ) ;
165- assert_eq ! ( assists. next( ) . expect( "expected assist" ) . assist. label, "Add `#[derive]`" ) ;
162+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Change visibility to pub(crate)" ) ;
163+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Add `#[derive]`" ) ;
166164}
167165
168166#[ test]
@@ -178,11 +176,11 @@ fn assist_order_if_expr() {
178176 let ( range, before) = extract_range ( before) ;
179177 let ( db, file_id) = with_single_file ( & before) ;
180178 let frange = FileRange { file_id, range } ;
181- let assists = Assist :: resolved ( & db, & AssistConfig :: default ( ) , frange) ;
179+ let assists = Assist :: get ( & db, & AssistConfig :: default ( ) , false , frange) ;
182180 let mut assists = assists. iter ( ) ;
183181
184- assert_eq ! ( assists. next( ) . expect( "expected assist" ) . assist . label, "Extract into variable" ) ;
185- assert_eq ! ( assists. next( ) . expect( "expected assist" ) . assist . label, "Replace with match" ) ;
182+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Extract into variable" ) ;
183+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Replace with match" ) ;
186184}
187185
188186#[ test]
@@ -203,27 +201,27 @@ fn assist_filter_works() {
203201 let mut cfg = AssistConfig :: default ( ) ;
204202 cfg. allowed = Some ( vec ! [ AssistKind :: Refactor ] ) ;
205203
206- let assists = Assist :: resolved ( & db, & cfg, frange) ;
204+ let assists = Assist :: get ( & db, & cfg, false , frange) ;
207205 let mut assists = assists. iter ( ) ;
208206
209- assert_eq ! ( assists. next( ) . expect( "expected assist" ) . assist . label, "Extract into variable" ) ;
210- assert_eq ! ( assists. next( ) . expect( "expected assist" ) . assist . label, "Replace with match" ) ;
207+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Extract into variable" ) ;
208+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Replace with match" ) ;
211209 }
212210
213211 {
214212 let mut cfg = AssistConfig :: default ( ) ;
215213 cfg. allowed = Some ( vec ! [ AssistKind :: RefactorExtract ] ) ;
216- let assists = Assist :: resolved ( & db, & cfg, frange) ;
214+ let assists = Assist :: get ( & db, & cfg, false , frange) ;
217215 assert_eq ! ( assists. len( ) , 1 ) ;
218216
219217 let mut assists = assists. iter ( ) ;
220- assert_eq ! ( assists. next( ) . expect( "expected assist" ) . assist . label, "Extract into variable" ) ;
218+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Extract into variable" ) ;
221219 }
222220
223221 {
224222 let mut cfg = AssistConfig :: default ( ) ;
225223 cfg. allowed = Some ( vec ! [ AssistKind :: QuickFix ] ) ;
226- let assists = Assist :: resolved ( & db, & cfg, frange) ;
224+ let assists = Assist :: get ( & db, & cfg, false , frange) ;
227225 assert ! ( assists. is_empty( ) , "All asserts but quickfixes should be filtered out" ) ;
228226 }
229227}
0 commit comments