* What a dotted name's last link is declared as: a member of what the links * before it are declared to be — a field's or a property's type, a * function's result — from its head (see headOf), or, with `unit`, the * routine or variable a unit's name qualifies (`Utils.Helper`). A constructor * ca
(path: string[], cls: Node | null, ref: UnresolvedRef, context: ResolutionContext)
| 533 | * (`TLog.Create.Write('x')`, `Logs.TLog.Create().Write('x')`). |
| 534 | */ |
| 535 | function memberAtPath(path: string[], cls: Node | null, ref: UnresolvedRef, context: ResolutionContext): { node: Node; unit: boolean } | null { |
| 536 | let head = headOf(path[0]!, cls, ref, context); |
| 537 | let rest = path.slice(1); |
| 538 | // A dotted unit name, the longest the links make (`mormot.core.os.GetTickCount64`). |
| 539 | for (let k = path.length - 1; !head && k >= 2; k--) { |
| 540 | const unitFile = unitFileNamed(path.slice(0, k).join('.').toLowerCase(), ref.filePath!, context); |
| 541 | if (unitFile) { |
| 542 | head = { type: null, unitFile }; |
| 543 | rest = path.slice(k); |
| 544 | } |
| 545 | } |
| 546 | if (!head) return null; |
| 547 | let type = head.type; |
| 548 | let classRef = head.classRef === true; |
| 549 | if (head.unitFile) { |
| 550 | // `UnitName.Routine`, `UnitName.GlobalVar.Method`, `UnitName.TFoo.Create.Method`. |
| 551 | const decl = unitDeclaration(head.unitFile, rest[0]!.toLowerCase(), context, ref.filePath!); |
| 552 | if (!decl) return null; |
| 553 | if (rest.length === 1) return { node: decl, unit: true }; |
| 554 | classRef = CLASS_KINDS.has(decl.kind); |
| 555 | type = classRef ? decl : typeOfMember(decl, context); |
| 556 | rest = rest.slice(1); |
| 557 | } |
| 558 | for (let i = 0; i < rest.length && type; i++) { |
| 559 | const lower = rest[i]!.toLowerCase(); |
| 560 | const member = memberInHierarchy(type, lower, context); |
| 561 | if (i === rest.length - 1) return member ? { node: member, unit: false } : null; |
| 562 | if (classRef && (member ? routineKeyword(member, context) === 'constructor' : lower === 'create')) { |
| 563 | classRef = false; |
| 564 | continue; |
| 565 | } |
| 566 | if (!member) return null; |
| 567 | type = typeOfMember(member, context); |
| 568 | classRef = false; |
| 569 | } |
| 570 | return null; |
| 571 | } |
| 572 | |
| 573 | /** |
| 574 | * What a dotted name's first link is: a value of a known class (a local's |
no test coverage detected