···10264 find_position_of("let").select_until(find_position_of("* b\n").under_char('\n'))
10265 );
10266}
10267+10268+#[test]
10269+fn extract_function_which_use_variables_defined_in_the_extracted_span() {
10270+ assert_code_action!(
10271+ EXTRACT_FUNCTION,
10272+ "
10273+pub fn do_things(a, b) {
10274+ let new_a = 10 + a
10275+ let new_b = 10 + b
10276+ let result = new_a * new_b
10277+ result + 3
10278+}
10279+",
10280+ find_position_of("let").select_until(find_position_of("* new_b\n").under_char('\n'))
10281+ );
10282+}
10283+10284+#[test]
10285+fn extract_function_which_use_variables_shadowed_in_an_inner_scope() {
10286+ assert_code_action!(
10287+ EXTRACT_FUNCTION,
10288+ "
10289+pub fn do_things(a, b) {
10290+ let first_part = {
10291+ let a = a + 10
10292+ let b = b + 10
10293+ a * b
10294+ }
10295+ let result = first_part + a * b
10296+ result + 3
10297+}
10298+",
10299+ find_position_of("let").select_until(find_position_of("+ a * b\n").under_char('\n'))
10300+ );
10301+}
···1+---
2+source: compiler-core/src/language_server/tests/action.rs
3+expression: "\npub fn do_things(a, b) {\n let new_a = 10 + a\n let new_b = 10 + b\n let result = new_a * new_b\n result + 3\n}\n"
4+---
5+----- BEFORE ACTION
6+7+pub fn do_things(a, b) {
8+ let new_a = 10 + a
9+ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
10+ let new_b = 10 + b
11+▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
12+ let result = new_a * new_b
13+▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
14+ result + 3
15+}
16+17+18+----- AFTER ACTION
19+20+pub fn do_things(a, b) {
21+ function(a, b)
22+ result + 3
23+}
24+25+fn function(a: Int, b: Int) -> Int {
26+ let new_a = 10 + a
27+ let new_b = 10 + b
28+ let result = new_a * new_b
29+}
···1+---
2+source: compiler-core/src/language_server/tests/action.rs
3+expression: "\npub fn do_things(a, b) {\n let first_part = {\n let a = a + 10\n let b = b + 10\n a * b\n }\n let result = first_part + a * b\n result + 3\n}\n"
4+---
5+----- BEFORE ACTION
6+7+pub fn do_things(a, b) {
8+ let first_part = {
9+ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
10+ let a = a + 10
11+▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
12+ let b = b + 10
13+▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
14+ a * b
15+▔▔▔▔▔▔▔▔▔
16+ }
17+▔▔▔
18+ let result = first_part + a * b
19+▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
20+ result + 3
21+}
22+23+24+----- AFTER ACTION
25+26+pub fn do_things(a, b) {
27+ function(a, b)
28+ result + 3
29+}
30+31+fn function(a: Int, b: Int) -> Int {
32+ let first_part = {
33+ let a = a + 10
34+ let b = b + 10
35+ a * b
36+ }
37+ let result = first_part + a * b
38+}