Skip to content

Commit 4d3e842

Browse files
author
Paul van Brenk
committed
Add assert to make sure getOccurences at position only returns results for the file we request the occurences for.
1 parent 85cf761 commit 4d3e842

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/services/services.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3571,8 +3571,22 @@ module ts {
35713571
}
35723572
}
35733573

3574-
/// References and Occurrences
35753574
function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
3575+
let results = getOccurrencesAtPositionCore(fileName, position);
3576+
3577+
let sourceFile = getCanonicalFileName(normalizeSlashes(fileName));
3578+
3579+
// ensure the results are in the file we're interested in
3580+
results.forEach((value) => {
3581+
let targetFile = getCanonicalFileName(normalizeSlashes(value.fileName));
3582+
Debug.assert(sourceFile == targetFile, `Unexpected file in results. Found results in ${targetFile} expected only results in ${sourceFile}.`);
3583+
});
3584+
3585+
return results;
3586+
}
3587+
3588+
/// References and Occurrences
3589+
function getOccurrencesAtPositionCore(fileName: string, position: number): ReferenceEntry[] {
35763590
synchronizeHostData();
35773591

35783592
let sourceFile = getValidSourceFile(fileName);

0 commit comments

Comments
 (0)