@@ -5453,21 +5453,26 @@ module ts {
54535453 if ( symbol ) {
54545454 var declarations = symbol . getDeclarations ( ) ;
54555455 if ( declarations && declarations . length > 0 ) {
5456-
54575456 // Disallow rename for elements that are defined in the standard TypeScript library.
54585457 var defaultLibFile = getDefaultLibFileName ( host . getCompilationSettings ( ) ) ;
54595458 for ( var i = 0 ; i < declarations . length ; i ++ ) {
54605459 var sourceFile = declarations [ i ] . getSourceFile ( ) ;
54615460 if ( sourceFile && endsWith ( sourceFile . fileName , defaultLibFile ) ) {
54625461 return getRenameInfoError ( getLocaleSpecificMessage ( Diagnostics . You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library . key ) ) ;
54635462 }
5464- }
5463+ }
54655464
54665465 var kind = getSymbolKind ( symbol , typeInfoResolver , node ) ;
54675466 if ( kind ) {
5468- return getRenameInfo ( symbol . name , typeInfoResolver . getFullyQualifiedName ( symbol ) , kind ,
5469- getSymbolModifiers ( symbol ) ,
5470- createTextSpan ( node . getStart ( ) , node . getWidth ( ) ) ) ;
5467+ return {
5468+ canRename : true ,
5469+ localizedErrorMessage : undefined ,
5470+ displayName : symbol . name ,
5471+ fullDisplayName : typeInfoResolver . getFullyQualifiedName ( symbol ) ,
5472+ kind : kind ,
5473+ kindModifiers : getSymbolModifiers ( symbol ) ,
5474+ triggerSpan : createTextSpan ( node . getStart ( ) , node . getWidth ( ) )
5475+ } ;
54715476 }
54725477 }
54735478 }
@@ -5476,7 +5481,7 @@ module ts {
54765481 return getRenameInfoError ( getLocaleSpecificMessage ( Diagnostics . You_cannot_rename_this_element . key ) ) ;
54775482
54785483 function endsWith ( string : string , value : string ) : boolean {
5479- return string . substring ( string . length - value . length , string . length ) === value ;
5484+ return string . lastIndexOf ( value ) + value . length === string . length ;
54805485 }
54815486
54825487 function getRenameInfoError ( localizedErrorMessage : string ) : RenameInfo {
@@ -5490,18 +5495,6 @@ module ts {
54905495 triggerSpan : undefined
54915496 } ;
54925497 }
5493-
5494- function getRenameInfo ( displayName : string , fullDisplayName : string , kind : string , kindModifiers : string , triggerSpan : TextSpan ) : RenameInfo {
5495- return {
5496- canRename : true ,
5497- localizedErrorMessage : undefined ,
5498- displayName,
5499- fullDisplayName,
5500- kind,
5501- kindModifiers,
5502- triggerSpan
5503- } ;
5504- }
55055498 }
55065499
55075500 return {
0 commit comments