@@ -105,7 +105,7 @@ namespace ts {
105
105
if ( ! selectionRange ) {
106
106
throw new Error ( `Test ${ s } does not specify selection range` ) ;
107
107
}
108
- const result = refactor . extractMethod . getRangeToExtract ( file , createTextSpanFromBounds ( selectionRange . start , selectionRange . end ) ) ;
108
+ const result = refactor . extractSymbol . getRangeToExtract ( file , createTextSpanFromBounds ( selectionRange . start , selectionRange . end ) ) ;
109
109
assert ( result . targetRange === undefined , "failure expected" ) ;
110
110
const sortedErrors = result . errors . map ( e => < string > e . messageText ) . sort ( ) ;
111
111
assert . deepEqual ( sortedErrors , expectedErrors . sort ( ) , "unexpected errors" ) ;
@@ -119,7 +119,7 @@ namespace ts {
119
119
if ( ! selectionRange ) {
120
120
throw new Error ( `Test ${ s } does not specify selection range` ) ;
121
121
}
122
- const result = refactor . extractMethod . getRangeToExtract ( f , createTextSpanFromBounds ( selectionRange . start , selectionRange . end ) ) ;
122
+ const result = refactor . extractSymbol . getRangeToExtract ( f , createTextSpanFromBounds ( selectionRange . start , selectionRange . end ) ) ;
123
123
const expectedRange = t . ranges . get ( "extracted" ) ;
124
124
if ( expectedRange ) {
125
125
let start : number , end : number ;
@@ -407,7 +407,7 @@ function test(x: number) {
407
407
testExtractRangeFailed ( "extractRangeFailed9" ,
408
408
`var x = ([#||]1 + 2);` ,
409
409
[
410
- "Statement or expression expected ."
410
+ "Cannot extract empty range ."
411
411
] ) ;
412
412
413
413
testExtractRangeFailed ( "extract-method-not-for-token-expression-statement" , `[#|a|]` , [ "Select more than a single identifier." ] ) ;
@@ -604,15 +604,15 @@ function test(x: number) {
604
604
// doesn't handle type parameter shadowing.
605
605
testExtractMethod ( "extractMethod14" ,
606
606
`function F<T>(t1: T) {
607
- function F <T>(t2: T) {
607
+ function G <T>(t2: T) {
608
608
[#|t1.toString();
609
609
t2.toString();|]
610
610
}
611
611
}` ) ;
612
612
// Confirm that the constraint is preserved.
613
613
testExtractMethod ( "extractMethod15" ,
614
614
`function F<T>(t1: T) {
615
- function F <U extends T[]>(t2: U) {
615
+ function G <U extends T[]>(t2: U) {
616
616
[#|t2.toString();|]
617
617
}
618
618
}` ) ;
@@ -799,19 +799,20 @@ function parsePrimaryExpression(): any {
799
799
newLineCharacter,
800
800
program,
801
801
file : sourceFile ,
802
- startPosition : - 1 ,
802
+ startPosition : selectionRange . start ,
803
+ endPosition : selectionRange . end ,
803
804
rulesProvider : getRuleProvider ( )
804
805
} ;
805
- const result = refactor . extractMethod . getRangeToExtract ( sourceFile , createTextSpanFromBounds ( selectionRange . start , selectionRange . end ) ) ;
806
- assert . equal ( result . errors , undefined , "expect no errors" ) ;
807
- const results = refactor . extractMethod . getPossibleExtractions ( result . targetRange , context ) ;
806
+ const rangeToExtract = refactor . extractSymbol . getRangeToExtract ( sourceFile , createTextSpanFromBounds ( selectionRange . start , selectionRange . end ) ) ;
807
+ assert . equal ( rangeToExtract . errors , undefined , "expect no errors" ) ;
808
+ const actions = refactor . extractSymbol . getAvailableActions ( context ) [ 0 ] . actions ; // TODO (acasey): smarter index
808
809
const data : string [ ] = [ ] ;
809
810
data . push ( `// ==ORIGINAL==` ) ;
810
811
data . push ( sourceFile . text ) ;
811
- for ( const r of results ) {
812
- const { renameLocation, edits } = refactor . extractMethod . getExtractionAtIndex ( result . targetRange , context , results . indexOf ( r ) ) ;
812
+ for ( const action of actions ) {
813
+ const { renameLocation, edits } = refactor . extractSymbol . getEditsForAction ( context , action . name ) ;
813
814
assert . lengthOf ( edits , 1 ) ;
814
- data . push ( `// ==SCOPE::${ r . scopeDescription } ==` ) ;
815
+ data . push ( `// ==SCOPE::${ action . description } ==` ) ;
815
816
const newText = textChanges . applyChanges ( sourceFile . text , edits [ 0 ] . textChanges ) ;
816
817
const newTextWithRename = newText . slice ( 0 , renameLocation ) + "/*RENAME*/" + newText . slice ( renameLocation ) ;
817
818
data . push ( newTextWithRename ) ;
0 commit comments