Repository navigation
fix: keep same-named functions of different files apart in the stack view - #55
Arthurvroum wants to merge 1 commit into
Conversation
…view Merging the stack reports of a workspace indexed functions by name: two files each defining a static helper became one row, mixing the location of one with the stack size of the other. The CodeLens and the sidebar lookups used the name too. - A function is identified by its name and the file defining it. Names defined in a single file keep their name as id; the others get name@file. Functions without a known file are still merged by name. - Calls are resolved within the file that made them, then to the only definition of that name elsewhere; an ambiguous name is not linked. - The CodeLens shows and focuses the definition of its own file, and the sidebar shows the file next to names that several functions share. Fixes #42
| return match[0] ?? null; | ||
| const all = [...model.nodes.values()]; | ||
| const exact = all.filter(node => node.name === name); | ||
| const candidates = (exact.length > 0 ? exact : all.filter(node => node.name.endsWith(suffix))) |
There was a problem hiding this comment.
[P2] Prefer the requested file before exact-name matches elsewhere
With run in a.c and Worker::run in b.cpp, clicking the unqualified run CodeLens in b.cpp resolves to a.c: the exact match discards all qualified candidates before the file filter runs. Match exact or qualified names in the requested file first, or pass the resolved function ID from the CodeLens.
| public getFunction(name: string, file?: string): StackFunction | undefined { | ||
| const candidates = this._functionMap.get(name) ?? []; | ||
| if (file) { | ||
| const inFile = candidates.find(fn => fn.file === file); |
There was a problem hiding this comment.
[P2] Normalize analyzer and editor paths before CodeLens lookup
A WSL report can name /mnt/c/project/a.c while the editor supplies C:\project\a.c. parseStackReport() keeps the report’s file or meta.inputFile, so this strict comparison discards even a unique definition and removes its stack CodeLens. Normalize both paths to the same source identity before indexing and lookup.
| const node = model.nodes.get(id); | ||
| if (!node) { return id; } | ||
| if (!model.duplicateNames.has(node.name) || !node.file) { return node.name; } | ||
| return `${node.name} · ${String(node.file).split(/[\\/]/).pop()}`; |
There was a problem hiding this comment.
[P3] Disambiguate functions whose source files share a basename
src/util.c and tests/util.c can each define helper. Both rows and call links then read helper · util.c; the call links’ titles are identical too. Use enough of the workspace-relative path to distinguish the two files.
Merging the stack reports of a workspace indexed functions by name: two files each defining a static helper became one row, mixing the location of one with the stack size of the other. The CodeLens and the sidebar lookups used the name too.
Fixes #42