(name: string, ref: UnresolvedRef, context: ResolutionContext)
| 325 | } |
| 326 | |
| 327 | function 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 | |
| 339 | function pythonBases(cls: Node, ref: UnresolvedRef, context: ResolutionContext): Node[] { |
| 340 | const line = context.getFileLines?.(cls.filePath)?.[cls.startLine - 1] |
no test coverage detected