Whether a VB.NET owner (by qualified name) is a `Module`, whose members are reached without a qualifier.
(ownerQn: string, context: ResolutionContext)
| 494 | |
| 495 | /** Whether a VB.NET owner (by qualified name) is a `Module`, whose members are reached without a qualifier. */ |
| 496 | function isModule(ownerQn: string, context: ResolutionContext): boolean { |
| 497 | let memo = VB_MODULES.get(context); |
| 498 | if (!memo) VB_MODULES.set(context, (memo = new Map())); |
| 499 | const hit = memo.get(ownerQn); |
| 500 | if (hit !== undefined) return hit; |
| 501 | // Its own head line or the two after it (attributes may come first); the raw |
| 502 | // lines, as the whole file need not be read as code for this. |
| 503 | const module = context.getNodesByQualifiedName(ownerQn).some((n) => n.language === 'vbnet' && n.kind === 'class' && |
| 504 | (context.getFileLines?.(n.filePath) ?? context.readFile(n.filePath)?.split(/\r?\n/) ?? []).slice(n.startLine - 1, n.startLine + 2) |
| 505 | .some((l) => /^\s*(?:<[^>]*>\s*)*(?:(?:Public|Friend|Private|Partial)\s+)*Module\s/i.test(l))); |
| 506 | memo.set(ownerQn, module); |
| 507 | return module; |
| 508 | } |
| 509 | |
| 510 | /** The members named `name` of the project's Modules, which code reaches without a qualifier — the caller's project's first. */ |
| 511 | function moduleMembersNamed(name: string, ref: UnresolvedRef, context: ResolutionContext): Node[] { |
no test coverage detected