The class a method belongs to: its qualified name's owner, declared in the method's own file.
(routine: Node, context: ResolutionContext)
| 1902 | |
| 1903 | /** The class a method belongs to: its qualified name's owner, declared in the method's own file. */ |
| 1904 | function classOfRoutine(routine: Node, context: ResolutionContext): Node | null { |
| 1905 | if (routine.kind !== 'method') return null; |
| 1906 | const memo = memos(context).classOfRoutine; |
| 1907 | if (memo.has(routine.id)) return memo.get(routine.id)!; |
| 1908 | const owner = routine.qualifiedName.slice(0, Math.max(0, routine.qualifiedName.lastIndexOf('::'))); |
| 1909 | const candidates = owner ? context.getNodesByQualifiedName(owner).filter((n) => n.language === 'pascal' && CLASS_KINDS.has(n.kind)) : []; |
| 1910 | const cls = declarationOf(candidates.filter((n) => n.filePath === routine.filePath)) ?? declarationOf(candidates); |
| 1911 | memo.set(routine.id, cls); |
| 1912 | return cls; |
| 1913 | } |
| 1914 | |
| 1915 | /** |
| 1916 | * A class and its ancestors the project declares, nearest first. A helper's |
no test coverage detected