@@ -1319,6 +1319,37 @@ namespace FourSlash {
13191319 }
13201320 }
13211321
1322+ public baselineRename ( marker : string , options : FourSlashInterface . RenameOptions ) {
1323+ const position = this . getMarkerByName ( marker ) . position ;
1324+ const locations = this . languageService . findRenameLocations (
1325+ this . activeFile . fileName ,
1326+ position ,
1327+ options . findInStrings ?? false ,
1328+ options . findInComments ?? false ,
1329+ options . providePrefixAndSuffixTextForRename ) ;
1330+
1331+ if ( ! locations ) {
1332+ this . raiseError ( `baselineRename failed. Could not rename at the provided position.` ) ;
1333+ }
1334+
1335+ const renamesByFile = ts . group ( locations , l => l . fileName ) ;
1336+ const baselineContent = renamesByFile . map ( renames => {
1337+ const { fileName } = renames [ 0 ] ;
1338+ const sortedRenames = ts . sort ( renames , ( a , b ) => b . textSpan . start - a . textSpan . start ) ;
1339+ let baselineFileContent = this . getFileContent ( fileName ) ;
1340+ for ( const { textSpan } of sortedRenames ) {
1341+ const isOriginalSpan = fileName === this . activeFile . fileName && ts . textSpanIntersectsWithPosition ( textSpan , position ) ;
1342+ baselineFileContent =
1343+ baselineFileContent . slice ( 0 , textSpan . start ) +
1344+ ( isOriginalSpan ? "[|RENAME|]" : "RENAME" ) +
1345+ baselineFileContent . slice ( textSpan . start + textSpan . length ) ;
1346+ }
1347+ return `/*====== ${ fileName } ======*/\n\n${ baselineFileContent } ` ;
1348+ } ) . join ( "\n\n" ) + "\n" ;
1349+
1350+ Harness . Baseline . runBaseline ( this . getBaselineFileNameForContainingTestFile ( ) , baselineContent ) ;
1351+ }
1352+
13221353 public verifyQuickInfoExists ( negative : boolean ) {
13231354 const actualQuickInfo = this . languageService . getQuickInfoAtPosition ( this . activeFile . fileName , this . currentCaretPosition ) ;
13241355 if ( negative ) {
0 commit comments