@@ -1567,17 +1567,17 @@ namespace ts {
1567
1567
1568
1568
/// References and Occurrences
1569
1569
function getOccurrencesAtPosition ( fileName : string , position : number ) : ReferenceEntry [ ] {
1570
- let results = getOccurrencesAtPositionCore ( fileName , position ) ;
1571
-
1572
- if ( results ) {
1573
- const sourceFile = getCanonicalFileName ( normalizeSlashes ( fileName ) ) ;
1574
-
1575
- // Get occurrences only supports reporting occurrences for the file queried. So
1576
- // filter down to that list.
1577
- results = filter ( results , r => getCanonicalFileName ( ts . normalizeSlashes ( r . fileName ) ) === sourceFile ) ;
1578
- }
1579
-
1580
- return results ;
1570
+ const canonicalFileName = getCanonicalFileName ( normalizeSlashes ( fileName ) ) ;
1571
+ return flatMap ( getDocumentHighlights ( fileName , position , [ fileName ] ) , entry => entry . highlightSpans . map < ReferenceEntry > ( highlightSpan => {
1572
+ Debug . assert ( getCanonicalFileName ( normalizeSlashes ( entry . fileName ) ) === canonicalFileName ) ; // Get occurrences only supports reporting occurrences for the file queried.
1573
+ return {
1574
+ fileName : entry . fileName ,
1575
+ textSpan : highlightSpan . textSpan ,
1576
+ isWriteAccess : highlightSpan . kind === HighlightSpanKind . writtenReference ,
1577
+ isDefinition : false ,
1578
+ isInString : highlightSpan . isInString ,
1579
+ } ;
1580
+ } ) ) ;
1581
1581
}
1582
1582
1583
1583
function getDocumentHighlights ( fileName : string , position : number , filesToSearch : ReadonlyArray < string > ) : DocumentHighlights [ ] {
@@ -1587,31 +1587,6 @@ namespace ts {
1587
1587
return DocumentHighlights . getDocumentHighlights ( program , cancellationToken , sourceFile , position , sourceFilesToSearch ) ;
1588
1588
}
1589
1589
1590
- function getOccurrencesAtPositionCore ( fileName : string , position : number ) : ReferenceEntry [ ] {
1591
- return convertDocumentHighlights ( getDocumentHighlights ( fileName , position , [ fileName ] ) ) ;
1592
-
1593
- function convertDocumentHighlights ( documentHighlights : DocumentHighlights [ ] ) : ReferenceEntry [ ] {
1594
- if ( ! documentHighlights ) {
1595
- return undefined ;
1596
- }
1597
-
1598
- const result : ReferenceEntry [ ] = [ ] ;
1599
- for ( const entry of documentHighlights ) {
1600
- for ( const highlightSpan of entry . highlightSpans ) {
1601
- result . push ( {
1602
- fileName : entry . fileName ,
1603
- textSpan : highlightSpan . textSpan ,
1604
- isWriteAccess : highlightSpan . kind === HighlightSpanKind . writtenReference ,
1605
- isDefinition : false ,
1606
- isInString : highlightSpan . isInString ,
1607
- } ) ;
1608
- }
1609
- }
1610
-
1611
- return result ;
1612
- }
1613
- }
1614
-
1615
1590
function findRenameLocations ( fileName : string , position : number , findInStrings : boolean , findInComments : boolean ) : RenameLocation [ ] {
1616
1591
return getReferences ( fileName , position , { findInStrings, findInComments, isForRename : true } ) ;
1617
1592
}
0 commit comments