@@ -3299,7 +3299,6 @@ export class TestState {
32993299 ts . Debug . fail ( `Did not expect a change in ${ change . fileName } ` ) ;
33003300 }
33013301 const oldText = this . tryGetFileContent ( change . fileName ) ;
3302- ts . Debug . assert ( ! ! change . isNewFile === ( oldText === undefined ) ) ;
33033302 const newContent = change . isNewFile ? ts . first ( change . textChanges ) . newText : ts . textChanges . applyChanges ( oldText ! , change . textChanges ) ;
33043303 this . verifyTextMatches ( newContent , /*includeWhitespace*/ true , expectedNewContent ) ;
33053304 }
@@ -3912,6 +3911,18 @@ export class TestState {
39123911 this . verifyNewContent ( { newFileContent : options . newFileContents } , editInfo . edits ) ;
39133912 }
39143913
3914+ public moveToFile ( options : FourSlashInterface . MoveToFileOptions ) : void {
3915+ assert ( this . getRanges ( ) . length === 1 , "Must have exactly one fourslash range (source enclosed between '[|' and '|]' delimiters) in the source file" ) ;
3916+ const range = this . getRanges ( ) [ 0 ] ;
3917+ const refactor = ts . find ( this . getApplicableRefactors ( range , { allowTextChangesInNewFiles : true } , /*triggerReason*/ undefined , /*kind*/ undefined , /*includeInteractiveActions*/ true ) , r => r . name === "Move to file" ) ! ;
3918+ assert ( refactor . actions . length === 1 ) ;
3919+ const action = ts . first ( refactor . actions ) ;
3920+ assert ( action . name === "Move to file" && action . description === "Move to file" ) ;
3921+
3922+ const editInfo = this . languageService . getEditsForRefactor ( range . fileName , this . formatCodeSettings , range , refactor . name , action . name , options . preferences || ts . emptyOptions , options . interactiveRefactorArguments ) ! ;
3923+ this . verifyNewContent ( { newFileContent : options . newFileContents } , editInfo . edits ) ;
3924+ }
3925+
39153926 private testNewFileContents ( edits : readonly ts . FileTextChanges [ ] , newFileContents : { [ fileName : string ] : string } , description : string ) : void {
39163927 for ( const { fileName, textChanges } of edits ) {
39173928 const newContent = newFileContents [ fileName ] ;
@@ -4217,11 +4228,11 @@ export class TestState {
42174228 private getApplicableRefactorsAtSelection ( triggerReason : ts . RefactorTriggerReason = "implicit" , kind ?: string , preferences = ts . emptyOptions ) {
42184229 return this . getApplicableRefactorsWorker ( this . getSelection ( ) , this . activeFile . fileName , preferences , triggerReason , kind ) ;
42194230 }
4220- private getApplicableRefactors ( rangeOrMarker : Range | Marker , preferences = ts . emptyOptions , triggerReason : ts . RefactorTriggerReason = "implicit" , kind ?: string ) : readonly ts . ApplicableRefactorInfo [ ] {
4221- return this . getApplicableRefactorsWorker ( "position" in rangeOrMarker ? rangeOrMarker . position : rangeOrMarker , rangeOrMarker . fileName , preferences , triggerReason , kind ) ; // eslint-disable-line local/no-in-operator
4231+ private getApplicableRefactors ( rangeOrMarker : Range | Marker , preferences = ts . emptyOptions , triggerReason : ts . RefactorTriggerReason = "implicit" , kind ?: string , includeInteractiveActions ?: boolean ) : readonly ts . ApplicableRefactorInfo [ ] {
4232+ return this . getApplicableRefactorsWorker ( "position" in rangeOrMarker ? rangeOrMarker . position : rangeOrMarker , rangeOrMarker . fileName , preferences , triggerReason , kind , includeInteractiveActions ) ; // eslint-disable-line local/no-in-operator
42224233 }
4223- private getApplicableRefactorsWorker ( positionOrRange : number | ts . TextRange , fileName : string , preferences = ts . emptyOptions , triggerReason : ts . RefactorTriggerReason , kind ?: string ) : readonly ts . ApplicableRefactorInfo [ ] {
4224- return this . languageService . getApplicableRefactors ( fileName , positionOrRange , preferences , triggerReason , kind ) || ts . emptyArray ;
4234+ private getApplicableRefactorsWorker ( positionOrRange : number | ts . TextRange , fileName : string , preferences = ts . emptyOptions , triggerReason : ts . RefactorTriggerReason , kind ?: string , includeInteractiveActions ?: boolean ) : readonly ts . ApplicableRefactorInfo [ ] {
4235+ return this . languageService . getApplicableRefactors ( fileName , positionOrRange , preferences , triggerReason , kind , includeInteractiveActions ) || ts . emptyArray ;
42254236 }
42264237
42274238 public configurePlugin ( pluginName : string , configuration : any ) : void {
0 commit comments