* The function a C or C++ class is local to: the one of the scope its * qualified name is in whose lines hold it. Null for a class of a namespace * or of another class.
(cls: Node, context: ResolutionContext)
| 123 | * or of another class. |
| 124 | */ |
| 125 | function cppFunctionAround(cls: Node, context: ResolutionContext): Node | null { |
| 126 | let memo = LOCAL_TO.get(context); |
| 127 | if (!memo) LOCAL_TO.set(context, (memo = new Map())); |
| 128 | const hit = memo.get(cls.id); |
| 129 | if (hit !== undefined) return hit; |
| 130 | const scope = cppParentScope(cls.qualifiedName); |
| 131 | const fn = (scope ? context.getNodesByQualifiedName(scope) : []).find((f) => |
| 132 | (f.kind === 'function' || f.kind === 'method') && f.filePath === cls.filePath && |
| 133 | f.startLine <= cls.startLine && f.endLine >= cls.startLine) ?? null; |
| 134 | memo.set(cls.id, fn); |
| 135 | return fn; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * The declarations code in `file` can see: a header's, and the file's own — |
no test coverage detected