diff --git a/gitnexus/src/core/ingestion/symbol-table.ts b/gitnexus/src/core/ingestion/symbol-table.ts index 2135c7db4..96d0948db 100644 --- a/gitnexus/src/core/ingestion/symbol-table.ts +++ b/gitnexus/src/core/ingestion/symbol-table.ts @@ -216,8 +216,9 @@ export const createSymbolTable = (): SymbolTable => { } globalIndex.get(name)!.push(def); - // C2. Methods with ownerId go to methodByOwner index (in addition to globalIndex). - if (type === 'Method' && metadata?.ownerId) { + // C2. Methods and constructors with ownerId go to methodByOwner index + // (in addition to globalIndex). + if ((type === 'Method' || type === 'Constructor') && metadata?.ownerId) { const key = `${metadata.ownerId}\0${name}`; const existing = methodByOwner.get(key); if (existing) { diff --git a/gitnexus/test/unit/symbol-table.test.ts b/gitnexus/test/unit/symbol-table.test.ts index a7d6a9ea1..95f79cfb8 100644 --- a/gitnexus/test/unit/symbol-table.test.ts +++ b/gitnexus/test/unit/symbol-table.test.ts @@ -383,12 +383,18 @@ describe('SymbolTable', () => { expect(table.lookupMethodByOwner('class:Handler', 'process')).toBeUndefined(); }); - it('does NOT index Constructor in methodByOwner', () => { + it('indexes Constructor in methodByOwner', () => { table.add('src/models.ts', 'User', 'ctor:User', 'Constructor', { parameterCount: 0, ownerId: 'class:User', }); - expect(table.lookupMethodByOwner('class:User', 'User')).toBeUndefined(); + expect(table.lookupMethodByOwner('class:User', 'User')).toEqual({ + nodeId: 'ctor:User', + filePath: 'src/models.ts', + type: 'Constructor', + parameterCount: 0, + ownerId: 'class:User', + }); // But it should be in lookupFuzzyCallable expect(table.lookupFuzzyCallable('User')).toHaveLength(1); });