Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 2c2873f

Browse files
authored
Skip test directories during caller analysis (#16)
1 parent 1740bd6 commit 2c2873f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/callStackExplorer.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ interface CallStackCache {
6868
lastUpdated: string;
6969
}
7070

71+
/**
72+
* Helper function to check if a file path is a test file
73+
*/
74+
function isTestPath(filePath: string): boolean {
75+
const normalizedPath = filePath.toLowerCase();
76+
return normalizedPath.includes('/test/') ||
77+
normalizedPath.includes('/tests/') ||
78+
normalizedPath.includes('/__tests__/') ||
79+
normalizedPath.includes('/__test__/') ||
80+
normalizedPath.includes('.test.') ||
81+
normalizedPath.includes('.spec.') ||
82+
normalizedPath.includes('_test.') ||
83+
normalizedPath.includes('_spec.');
84+
}
85+
7186
/**
7287
* TreeItem for call stack entries in the Call Stack Explorer
7388
*/
@@ -334,6 +349,11 @@ export class CallStackExplorerProvider implements vscode.TreeDataProvider<CallSt
334349

335350
if (locations) {
336351
for (const location of locations) {
352+
// Skip test files
353+
if (isTestPath(location.uri.fsPath)) {
354+
continue;
355+
}
356+
337357
// Skip self-references (the function definition itself)
338358
if (location.uri.fsPath === sourceFile &&
339359
location.range.start.line === selectionRange.start.line) {

0 commit comments

Comments
 (0)