File tree Expand file tree Collapse file tree 7 files changed +267
-2
lines changed Expand file tree Collapse file tree 7 files changed +267
-2
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ namespace ts {
224
224
testExtractRange ( `
225
225
function f() {
226
226
while (true) {
227
- [#|
227
+ [#|
228
228
if (x) {
229
229
return;
230
230
} |]
@@ -234,7 +234,7 @@ namespace ts {
234
234
testExtractRange ( `
235
235
function f() {
236
236
while (true) {
237
- [#|
237
+ [#|
238
238
[$|if (x) {
239
239
}
240
240
return;|]
@@ -655,6 +655,60 @@ function test(x: number) {
655
655
finally {
656
656
[#|return 1;|]
657
657
}
658
+ }` ) ;
659
+ // Extraction position - namespace
660
+ testExtractMethod ( "extractMethod23" ,
661
+ `namespace NS {
662
+ function M1() { }
663
+ function M2() {
664
+ [#|return 1;|]
665
+ }
666
+ function M3() { }
667
+ }` ) ;
668
+ // Extraction position - function
669
+ testExtractMethod ( "extractMethod24" ,
670
+ `function Outer() {
671
+ function M1() { }
672
+ function M2() {
673
+ [#|return 1;|]
674
+ }
675
+ function M3() { }
676
+ }` ) ;
677
+ // Extraction position - file
678
+ testExtractMethod ( "extractMethod25" ,
679
+ `function M1() { }
680
+ function M2() {
681
+ [#|return 1;|]
682
+ }
683
+ function M3() { }` ) ;
684
+ // Extraction position - class without ctor
685
+ testExtractMethod ( "extractMethod26" ,
686
+ `class C {
687
+ M1() { }
688
+ M2() {
689
+ [#|return 1;|]
690
+ }
691
+ M3() { }
692
+ }` ) ;
693
+ // Extraction position - class with ctor in middle
694
+ testExtractMethod ( "extractMethod27" ,
695
+ `class C {
696
+ M1() { }
697
+ M2() {
698
+ [#|return 1;|]
699
+ }
700
+ constructor() { }
701
+ M3() { }
702
+ }` ) ;
703
+ // Extraction position - class with ctor at end
704
+ testExtractMethod ( "extractMethod28" ,
705
+ `class C {
706
+ M1() { }
707
+ M2() {
708
+ [#|return 1;|]
709
+ }
710
+ M3() { }
711
+ constructor() { }
658
712
}` ) ;
659
713
} ) ;
660
714
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ namespace NS {
3
+ function M1 ( ) { }
4
+ function M2 ( ) {
5
+ return 1 ;
6
+ }
7
+ function M3 ( ) { }
8
+ }
9
+ // ==SCOPE::function 'M2'==
10
+ namespace NS {
11
+ function M1 ( ) { }
12
+ function M2 ( ) {
13
+ return newFunction ( ) ;
14
+
15
+ function newFunction ( ) {
16
+ return 1 ;
17
+ }
18
+ }
19
+ function M3 ( ) { }
20
+ }
21
+ // ==SCOPE::namespace 'NS'==
22
+ namespace NS {
23
+ function M1 ( ) { }
24
+ function M2 ( ) {
25
+ return newFunction ( ) ;
26
+ }
27
+ function newFunction ( ) {
28
+ return 1 ;
29
+ }
30
+
31
+ function M3 ( ) { }
32
+ }
33
+ // ==SCOPE::global scope==
34
+ namespace NS {
35
+ function M1 ( ) { }
36
+ function M2 ( ) {
37
+ return newFunction ( ) ;
38
+ }
39
+ function M3 ( ) { }
40
+ }
41
+ function newFunction ( ) {
42
+ return 1 ;
43
+ }
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ function Outer ( ) {
3
+ function M1 ( ) { }
4
+ function M2 ( ) {
5
+ return 1 ;
6
+ }
7
+ function M3 ( ) { }
8
+ }
9
+ // ==SCOPE::function 'M2'==
10
+ function Outer ( ) {
11
+ function M1 ( ) { }
12
+ function M2 ( ) {
13
+ return newFunction ( ) ;
14
+
15
+ function newFunction ( ) {
16
+ return 1 ;
17
+ }
18
+ }
19
+ function M3 ( ) { }
20
+ }
21
+ // ==SCOPE::function 'Outer'==
22
+ function Outer ( ) {
23
+ function M1 ( ) { }
24
+ function M2 ( ) {
25
+ return newFunction ( ) ;
26
+ }
27
+ function newFunction ( ) {
28
+ return 1 ;
29
+ }
30
+
31
+ function M3 ( ) { }
32
+ }
33
+ // ==SCOPE::global scope==
34
+ function Outer ( ) {
35
+ function M1 ( ) { }
36
+ function M2 ( ) {
37
+ return newFunction ( ) ;
38
+ }
39
+ function M3 ( ) { }
40
+ }
41
+ function newFunction ( ) {
42
+ return 1 ;
43
+ }
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ function M1 ( ) { }
3
+ function M2 ( ) {
4
+ return 1 ;
5
+ }
6
+ function M3 ( ) { }
7
+ // ==SCOPE::function 'M2'==
8
+ function M1 ( ) { }
9
+ function M2 ( ) {
10
+ return newFunction ( ) ;
11
+
12
+ function newFunction ( ) {
13
+ return 1 ;
14
+ }
15
+ }
16
+ function M3 ( ) { }
17
+ // ==SCOPE::global scope==
18
+ function M1 ( ) { }
19
+ function M2 ( ) {
20
+ return newFunction ( ) ;
21
+ }
22
+ function newFunction ( ) {
23
+ return 1 ;
24
+ }
25
+
26
+ function M3 ( ) { }
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ class C {
3
+ M1 ( ) { }
4
+ M2 ( ) {
5
+ return 1 ;
6
+ }
7
+ M3 ( ) { }
8
+ }
9
+ // ==SCOPE::class 'C'==
10
+ class C {
11
+ M1 ( ) { }
12
+ M2 ( ) {
13
+ return this . newFunction ( ) ;
14
+ }
15
+ private newFunction ( ) {
16
+ return 1 ;
17
+ }
18
+
19
+ M3 ( ) { }
20
+ }
21
+ // ==SCOPE::global scope==
22
+ class C {
23
+ M1 ( ) { }
24
+ M2 ( ) {
25
+ return newFunction ( ) ;
26
+ }
27
+ M3 ( ) { }
28
+ }
29
+ function newFunction ( ) {
30
+ return 1 ;
31
+ }
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ class C {
3
+ M1 ( ) { }
4
+ M2 ( ) {
5
+ return 1 ;
6
+ }
7
+ constructor ( ) { }
8
+ M3 ( ) { }
9
+ }
10
+ // ==SCOPE::class 'C'==
11
+ class C {
12
+ M1 ( ) { }
13
+ M2 ( ) {
14
+ return this . newFunction ( ) ;
15
+ }
16
+ constructor ( ) { }
17
+ private newFunction ( ) {
18
+ return 1 ;
19
+ }
20
+
21
+ M3 ( ) { }
22
+ }
23
+ // ==SCOPE::global scope==
24
+ class C {
25
+ M1 ( ) { }
26
+ M2 ( ) {
27
+ return newFunction ( ) ;
28
+ }
29
+ constructor ( ) { }
30
+ M3 ( ) { }
31
+ }
32
+ function newFunction ( ) {
33
+ return 1 ;
34
+ }
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ class C {
3
+ M1 ( ) { }
4
+ M2 ( ) {
5
+ return 1 ;
6
+ }
7
+ M3 ( ) { }
8
+ constructor ( ) { }
9
+ }
10
+ // ==SCOPE::class 'C'==
11
+ class C {
12
+ M1 ( ) { }
13
+ M2 ( ) {
14
+ return this . newFunction ( ) ;
15
+ }
16
+ private newFunction ( ) {
17
+ return 1 ;
18
+ }
19
+
20
+ M3 ( ) { }
21
+ constructor ( ) { }
22
+ }
23
+ // ==SCOPE::global scope==
24
+ class C {
25
+ M1 ( ) { }
26
+ M2 ( ) {
27
+ return newFunction ( ) ;
28
+ }
29
+ M3 ( ) { }
30
+ constructor ( ) { }
31
+ }
32
+ function newFunction ( ) {
33
+ return 1 ;
34
+ }
You can’t perform that action at this time.
0 commit comments