MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / declaredUnderCondition

Function declaredUnderCondition

src/resolution/pascal-scope.ts:733–748  ·  view source on GitHub ↗

* Whether a declaration is inside an `{$IFDEF}`, `{$IFNDEF}`, `{$IF}` or * `{$IFOPT}` block, or its `{$ELSE}`.

(node: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

731 * `{$IFOPT}` block, or its `{$ELSE}`.
732 */
733function 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). */
751function conditionDepthAfter(text: string, depth: number): number {

Callers 1

matchPascalSystemCallFunction · 0.85

Calls 6

memosFunction · 0.85
fileLinesFunction · 0.85
conditionDepthAfterFunction · 0.85
pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected