@@ -1697,23 +1697,33 @@ namespace ts {
1697
1697
}
1698
1698
1699
1699
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
+ }
1702
1711
}
1703
1712
1704
1713
function getReferencesAtPosition ( fileName : string , position : number ) : ReferenceEntry [ ] | undefined {
1705
- return getReferences ( fileName , position ) ! ;
1714
+ synchronizeHostData ( ) ;
1715
+ return getReferences ( getTouchingPropertyName ( getValidSourceFile ( fileName ) , position ) , position ) ;
1706
1716
}
1707
1717
1708
- function getReferences ( fileName : string , position : number , options ?: FindAllReferences . Options ) : ReferenceEntry [ ] | undefined {
1718
+ function getReferences ( node : Node , position : number , options ?: FindAllReferences . Options ) : ReferenceEntry [ ] | undefined {
1709
1719
synchronizeHostData ( ) ;
1710
1720
1711
1721
// Exclude default library when renaming as commonly user don't want to change that file.
1712
1722
const sourceFiles = options && options . isForRename
1713
1723
? program . getSourceFiles ( ) . filter ( sourceFile => ! program . isSourceFileDefaultLibrary ( sourceFile ) )
1714
1724
: program . getSourceFiles ( ) ;
1715
1725
1716
- return FindAllReferences . findReferencedEntries ( program , cancellationToken , sourceFiles , getValidSourceFile ( fileName ) , position , options ) ;
1726
+ return FindAllReferences . findReferencedEntries ( program , cancellationToken , sourceFiles , node , position , options ) ;
1717
1727
}
1718
1728
1719
1729
function findReferences ( fileName : string , position : number ) : ReferencedSymbol [ ] | undefined {
0 commit comments