mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-08 03:08:13 +00:00
fix(symbol-table): index constructors in methodByOwner (#694)
This commit is contained in:
parent
be2401061e
commit
fe87ff8f74
2 changed files with 11 additions and 4 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue