* Whether a declaration is inside an `{$IFDEF}`, `{$IFNDEF}`, `{$IF}` or * `{$IFOPT}` block, or its `{$ELSE}`.
(node: Node, context: ResolutionContext)
| 731 | * `{$IFOPT}` block, or its `{$ELSE}`. |
| 732 | */ |
| 733 | function declaredUnderCondition(node: Node, context: ResolutionContext): boolean { |
| 734 | const memo = memos(context).conditionDepths; |
| 735 | let depths = memo.get(node.filePath); |
| 736 | const lines = fileLines(node.filePath, context); |
| 737 | if (!depths) { |
| 738 | depths = []; |
| 739 | let depth = 0; |
| 740 | for (const text of lines) { |
| 741 | depths.push(depth); |
| 742 | if (text.includes('{$')) depth = conditionDepthAfter(text, depth); |
| 743 | } |
| 744 | memo.set(node.filePath, depths); |
| 745 | } |
| 746 | const line = lines[node.startLine - 1] ?? ''; |
| 747 | return conditionDepthAfter(line.slice(0, node.startColumn), depths[node.startLine - 1] ?? 0) > 0; |
| 748 | } |
| 749 | |
| 750 | /** The depth of conditional blocks after a line's directives (`{$IFDEF X}` opens one, `{$ENDIF}` closes it). */ |
| 751 | function conditionDepthAfter(text: string, depth: number): number { |
no test coverage detected