The class a method belongs to: its qualified name's owner, declared in the method's own file.
(routine: Node, context: ResolutionContext)
| 724 | |
| 725 | /** The class a method belongs to: its qualified name's owner, declared in the method's own file. */ |
| 726 | function classOfRoutine(routine: Node, context: ResolutionContext): Node | null { |
| 727 | if (routine.kind !== 'method') return null; |
| 728 | const memo = memos(context).classOfRoutine; |
| 729 | if (memo.has(routine.id)) return memo.get(routine.id)!; |
| 730 | const owner = routine.qualifiedName.slice(0, Math.max(0, routine.qualifiedName.lastIndexOf('::'))); |
| 731 | const candidates = owner ? context.getNodesByQualifiedName(owner).filter((n) => n.language === 'pascal' && CLASS_KINDS.has(n.kind)) : []; |
| 732 | const cls = declarationOf(candidates.filter((n) => n.filePath === routine.filePath)) ?? declarationOf(candidates); |
| 733 | memo.set(routine.id, cls); |
| 734 | return cls; |
| 735 | } |
| 736 | |
| 737 | /** A class and its ancestors the project declares, nearest first. */ |
| 738 | function ancestorsOf(cls: Node, context: ResolutionContext): Node[] { |
no test coverage detected