1818 suggest_spec /1 ,
1919 extract_function /1 ,
2020 extract_function_case /1 ,
21- extract_function_tuple /1
21+ extract_function_tuple /1 ,
22+ extract_function_list_comp /1
2223]).
2324
2425% %==============================================================================
@@ -57,7 +58,8 @@ init_per_testcase(TestCase, Config0) when
5758 TestCase =:= ct_run_test ;
5859 TestCase =:= extract_function ;
5960 TestCase =:= extract_function_case ;
60- TestCase =:= extract_function_tuple
61+ TestCase =:= extract_function_tuple ;
62+ TestCase =:= extract_function_list_comp
6163->
6264 Config = els_test_utils :init_per_testcase (TestCase , Config0 ),
6365 setup_mocks (),
@@ -82,7 +84,8 @@ end_per_testcase(TestCase, Config) when
8284 TestCase =:= ct_run_test ;
8385 TestCase =:= extract_function ;
8486 TestCase =:= extract_function_case ;
85- TestCase =:= extract_function_tuple
87+ TestCase =:= extract_function_tuple ;
88+ TestCase =:= extract_function_list_comp
8689->
8790 teardown_mocks (),
8891 els_test_utils :end_per_testcase (TestCase , Config );
@@ -285,8 +288,8 @@ extract_function(Config) ->
285288 " A + B + C.\n\n "
286289 >>,
287290 range := #{
288- 'end' := #{character := 0 , line := 14 },
289- start := #{character := 0 , line := 14 }
291+ 'end' := #{character := 0 , line := 15 },
292+ start := #{character := 0 , line := 15 }
290293 }
291294 }
292295 ] = Changes .
@@ -315,12 +318,40 @@ extract_function_case(Config) ->
315318 >>,
316319 range :=
317320 #{
318- 'end' := #{character := 0 , line := 14 },
319- start := #{character := 0 , line := 14 }
321+ 'end' := #{character := 0 , line := 15 },
322+ start := #{character := 0 , line := 15 }
320323 }
321324 }
322325 ] = Changes .
323326
327+ -spec extract_function_list_comp (config ()) -> ok .
328+ extract_function_list_comp (Config ) ->
329+ Uri = ? config (extract_function_uri , Config ),
330+ execute_command_refactor_extract (Uri , {13 , 4 }, {13 , 32 }),
331+ [#{edit := #{changes := #{Uri := Changes }}}] = get_edits_from_meck_history (),
332+ [
333+ #{
334+ range :=
335+ #{
336+ start := #{line := 13 , character := 4 },
337+ 'end' := #{line := 13 , character := 32 }
338+ },
339+ newText := <<" new_function(A, B, C)" >>
340+ },
341+ #{
342+ range :=
343+ #{
344+ start := #{line := 15 , character := 0 },
345+ 'end' := #{line := 15 , character := 0 }
346+ },
347+ newText :=
348+ <<
349+ " new_function(A, B, C) ->\n "
350+ " [X || X <- [A, B, C], X > 1].\n\n "
351+ >>
352+ }
353+ ] = Changes .
354+
324355-spec extract_function_tuple (config ()) -> ok .
325356extract_function_tuple (Config ) ->
326357 Uri = ? config (extract_function_uri , Config ),
@@ -343,8 +374,8 @@ extract_function_tuple(Config) ->
343374 >>,
344375 range :=
345376 #{
346- 'end' := #{character := 0 , line := 14 },
347- start := #{character := 0 , line := 14 }
377+ 'end' := #{character := 0 , line := 15 },
378+ start := #{character := 0 , line := 15 }
348379 }
349380 }
350381 ] = Changes .
0 commit comments