@@ -2093,6 +2093,26 @@ module ts {
2093
2093
}
2094
2094
2095
2095
/// Find references
2096
+ function getOccurrencesAtPosition ( filename : string , position : number ) : ReferenceEntry [ ] {
2097
+ synchronizeHostData ( ) ;
2098
+
2099
+ filename = TypeScript . switchToForwardSlashes ( filename ) ;
2100
+ var sourceFile = getSourceFile ( filename ) ;
2101
+
2102
+ var node = getNodeAtPosition ( sourceFile , position ) ;
2103
+ if ( ! node ) {
2104
+ return undefined ;
2105
+ }
2106
+
2107
+ if ( node . kind !== SyntaxKind . Identifier &&
2108
+ ! isLiteralNameOfPropertyDeclarationOrIndexAccess ( node ) &&
2109
+ ! isNameOfExternalModuleImportOrDeclaration ( node ) ) {
2110
+ return undefined ;
2111
+ }
2112
+
2113
+ return getReferencesForNode ( node , [ sourceFile ] ) ;
2114
+ }
2115
+
2096
2116
function getReferencesAtPosition ( filename : string , position : number ) : ReferenceEntry [ ] {
2097
2117
synchronizeHostData ( ) ;
2098
2118
@@ -2105,11 +2125,15 @@ module ts {
2105
2125
}
2106
2126
2107
2127
if ( node . kind !== SyntaxKind . Identifier &&
2108
- ! isLiteralNameOfPropertyDeclarationOrIndexAccess ( node ) &&
2128
+ ! isLiteralNameOfPropertyDeclarationOrIndexAccess ( node ) &&
2109
2129
! isNameOfExternalModuleImportOrDeclaration ( node ) ) {
2110
2130
return undefined ;
2111
2131
}
2112
2132
2133
+ return getReferencesForNode ( node , program . getSourceFiles ( ) ) ;
2134
+ }
2135
+
2136
+ function getReferencesForNode ( node : Node , sourceFiles : SourceFile [ ] ) : ReferenceEntry [ ] {
2113
2137
// Labels
2114
2138
if ( isLabelName ( node ) ) {
2115
2139
if ( isJumpStatementTarget ( node ) ) {
@@ -2153,7 +2177,7 @@ module ts {
2153
2177
getReferencesInNode ( scope , symbol , symbolName , node , searchMeaning , result ) ;
2154
2178
}
2155
2179
else {
2156
- forEach ( program . getSourceFiles ( ) , sourceFile => {
2180
+ forEach ( sourceFiles , sourceFile => {
2157
2181
cancellationToken . throwIfCancellationRequested ( ) ;
2158
2182
2159
2183
if ( lookUp ( sourceFile . identifiers , symbolName ) ) {
@@ -2789,7 +2813,7 @@ module ts {
2789
2813
getSignatureAtPosition : ( filename , position ) : SignatureInfo => undefined ,
2790
2814
getDefinitionAtPosition : getDefinitionAtPosition ,
2791
2815
getReferencesAtPosition : getReferencesAtPosition ,
2792
- getOccurrencesAtPosition : ( filename , position ) => [ ] ,
2816
+ getOccurrencesAtPosition : getOccurrencesAtPosition ,
2793
2817
getImplementorsAtPosition : ( filename , position ) => [ ] ,
2794
2818
getNameOrDottedNameSpan : getNameOrDottedNameSpan ,
2795
2819
getBreakpointStatementAtPosition : getBreakpointStatementAtPosition ,
0 commit comments