MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / pythonRefClass

Function pythonRefClass

src/resolution/name-matcher.ts:327–337  ·  view source on GitHub ↗
(name: string, ref: UnresolvedRef, context: ResolutionContext)

Source from the content-addressed store, hash-verified

325}
326
327function pythonRefClass(name: string, ref: UnresolvedRef, context: ResolutionContext): Node | null {
328 const imports = context.getImportMappings(ref.filePath, 'python');
329 if (imports.some(i => i.localName === name.split('.')[0])) {
330 const hit = context.resolveImport?.({ ...ref, referenceName: name, referenceKind: 'references' });
331 const node = hit && context.getNodeById?.(hit.targetNodeId);
332 return node?.kind === 'class' && context.getNodesByQualifiedName(node.qualifiedName)
333 .filter(n => n.kind === 'class' && n.filePath === node.filePath).length === 1 ? node : null;
334 }
335 const classes = context.getNodesByName(name).filter(n => n.kind === 'class' && n.filePath === ref.filePath);
336 return classes.length === 1 ? classes[0]! : null;
337}
338
339function pythonBases(cls: Node, ref: UnresolvedRef, context: ResolutionContext): Node[] {
340 const line = context.getFileLines?.(cls.filePath)?.[cls.startLine - 1]

Callers 2

matchMemberFunctionRefFunction · 0.85
pythonBasesFunction · 0.85

Calls 5

getImportMappingsMethod · 0.80
resolveImportMethod · 0.80
getNodeByIdMethod · 0.65
getNodesByNameMethod · 0.65

Tested by

no test coverage detected