@@ -1697,23 +1697,33 @@ namespace ts {
16971697 }
16981698
16991699 function findRenameLocations ( fileName : string , position : number , findInStrings : boolean , findInComments : boolean ) : RenameLocation [ ] | undefined {
1700- const refs = getReferences ( fileName , position , { findInStrings, findInComments, isForRename : true } ) ;
1701- return refs && refs . map ( ( { fileName, textSpan } ) : RenameLocation => ( { fileName, textSpan } ) ) ;
1700+ synchronizeHostData ( ) ;
1701+ const sourceFile = getValidSourceFile ( fileName ) ;
1702+ const node = getTouchingPropertyName ( sourceFile , position ) ;
1703+ if ( isIdentifier ( node ) && isJsxOpeningElement ( node . parent ) || isJsxClosingElement ( node . parent ) ) {
1704+ const { openingElement, closingElement } = node . parent . parent ;
1705+ return [ openingElement , closingElement ] . map ( ( node ) : RenameLocation => ( { fileName : sourceFile . fileName , textSpan : createTextSpanFromNode ( node . tagName , sourceFile ) } ) ) ;
1706+ }
1707+ else {
1708+ const refs = getReferences ( node , position , { findInStrings, findInComments, isForRename : true } ) ;
1709+ return refs && refs . map ( ( { fileName, textSpan } ) : RenameLocation => ( { fileName, textSpan } ) ) ;
1710+ }
17021711 }
17031712
17041713 function getReferencesAtPosition ( fileName : string , position : number ) : ReferenceEntry [ ] | undefined {
1705- return getReferences ( fileName , position ) ! ;
1714+ synchronizeHostData ( ) ;
1715+ return getReferences ( getTouchingPropertyName ( getValidSourceFile ( fileName ) , position ) , position ) ;
17061716 }
17071717
1708- function getReferences ( fileName : string , position : number , options ?: FindAllReferences . Options ) : ReferenceEntry [ ] | undefined {
1718+ function getReferences ( node : Node , position : number , options ?: FindAllReferences . Options ) : ReferenceEntry [ ] | undefined {
17091719 synchronizeHostData ( ) ;
17101720
17111721 // Exclude default library when renaming as commonly user don't want to change that file.
17121722 const sourceFiles = options && options . isForRename
17131723 ? program . getSourceFiles ( ) . filter ( sourceFile => ! program . isSourceFileDefaultLibrary ( sourceFile ) )
17141724 : program . getSourceFiles ( ) ;
17151725
1716- return FindAllReferences . findReferencedEntries ( program , cancellationToken , sourceFiles , getValidSourceFile ( fileName ) , position , options ) ;
1726+ return FindAllReferences . findReferencedEntries ( program , cancellationToken , sourceFiles , node , position , options ) ;
17171727 }
17181728
17191729 function findReferences ( fileName : string , position : number ) : ReferencedSymbol [ ] | undefined {
0 commit comments