Cross-file `ClassName.staticMethod()` calls resolved to the class, not the method: the import resolver matched the receiver `Foo` to the named class import but dropped the `.bar` member, and createEdges then mis-promoted the `calls` edge to `instantiates`. So callers/impact for the static method came back empty. Descend from the resolved class into its `Container::member` so the call links to the method; fall back to the class when no such member exists (non-`::` languages and genuine class references are unaffected). Also normalize `codegraph affected` inputs to the project-relative, forward-slash form the index stores, so `./src/x.ts`, an absolute path, and a Windows back-slash path all match (previously silently returned 0). Validated on luxon (24 files): node/edge totals identical (no explosion), 69 mis-promoted `instantiates` edges become `calls`, and real static factories (DateTime.fromISO, etc.) resolve their callers. Full suite: 1534 passed. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
fb974552b0
commit
f7441f2124
@@ -1198,6 +1198,23 @@ program
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Normalize a user-supplied file path to the project-relative, forward-slash
|
||||
* form CodeGraph stores in the index. Accepts an absolute path, a `./`-prefixed
|
||||
* path, or Windows back-slashes; an empty string when the input is blank. Used
|
||||
* by `codegraph affected` so `./src/x.ts`, `/abs/repo/src/x.ts`, and
|
||||
* `src/x.ts` all match the same indexed file. (#825)
|
||||
*/
|
||||
function normalizeIndexPath(filePath: string, projectPath: string): string {
|
||||
let f = filePath.trim();
|
||||
if (!f) return '';
|
||||
if (path.isAbsolute(f)) f = path.relative(projectPath, f);
|
||||
// Collapse `.`/`..` segments, then force forward slashes and drop a leading
|
||||
// `./` (path.normalize already strips it on POSIX; explicit for Windows).
|
||||
f = path.normalize(f).replace(/\\/g, '/').replace(/^\.\//, '');
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert glob pattern to regex
|
||||
*/
|
||||
@@ -1710,6 +1727,14 @@ program
|
||||
changedFiles.push(...stdinFiles);
|
||||
}
|
||||
|
||||
// Normalize inputs to the project-relative, forward-slash form the index
|
||||
// stores. Without this, `affected ./src/x.ts`, an absolute path (what a
|
||||
// wrapping script often passes), or a Windows back-slash path silently
|
||||
// matches nothing and reports 0 affected tests. (#825)
|
||||
changedFiles = changedFiles
|
||||
.map((f) => normalizeIndexPath(f, projectPath))
|
||||
.filter(Boolean);
|
||||
|
||||
if (changedFiles.length === 0) {
|
||||
if (!options.quiet) info('No files provided. Use file arguments or --stdin.');
|
||||
process.exit(0);
|
||||
|
||||
Reference in New Issue
Block a user