Skip to content

Commit 9be5c71

Browse files
committed
fix(build-edges): use lastIndexOf for namespace-aware class extraction in same-class fallbacks
Both the this.method() fallback and the bare-call same-class fallback were using indexOf('.') which takes the first dot segment. For a caller named MyNS.Validators.ValidateUser this yields MyNS instead of Validators, causing the sibling edge lookup to miss. Align with call-resolver.ts which uses lastIndexOf + prevDot to isolate only the segment immediately before the method name.
1 parent 08b0702 commit 9be5c71

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/domain/graph/builder/stages/build-edges.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,9 +1340,10 @@ function buildFileCallEdges(
13401340
// not the enclosing class, so qualifying with the child class name would
13411341
// produce a false edge when the child also defines a same-named method.
13421342
if (targets.length === 0 && call.receiver === 'this' && caller.callerName != null) {
1343-
const dotIdx = caller.callerName.indexOf('.');
1344-
if (dotIdx > 0) {
1345-
const className = caller.callerName.slice(0, dotIdx);
1343+
const lastDot = caller.callerName.lastIndexOf('.');
1344+
if (lastDot > 0) {
1345+
const prevDot = caller.callerName.lastIndexOf('.', lastDot - 1);
1346+
const className = caller.callerName.slice(prevDot + 1, lastDot);
13461347
const qualifiedName = `${className}.${call.name}`;
13471348
const qualified = lookup
13481349
.byNameAndFile(qualifiedName, relPath)
@@ -1359,9 +1360,10 @@ function buildFileCallEdges(
13591360
// to `Validators.IsValidEmail`. Safe for JS/TS: only fires when byName()
13601361
// already returned nothing (so module-level functions are found first).
13611362
if (targets.length === 0 && !call.receiver && caller.callerName != null) {
1362-
const dotIdx = caller.callerName.indexOf('.');
1363-
if (dotIdx > 0) {
1364-
const className = caller.callerName.slice(0, dotIdx);
1363+
const lastDot = caller.callerName.lastIndexOf('.');
1364+
if (lastDot > 0) {
1365+
const prevDot = caller.callerName.lastIndexOf('.', lastDot - 1);
1366+
const className = caller.callerName.slice(prevDot + 1, lastDot);
13651367
const qualifiedName = `${className}.${call.name}`;
13661368
const qualified = lookup
13671369
.byNameAndFile(qualifiedName, relPath)

0 commit comments

Comments
 (0)