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

Function condText

src/graph/branch-guards.ts:1169–1179  ·  view source on GitHub ↗
(node: SyntaxNode | null | undefined)

Source from the content-addressed store, hash-verified

1167}
1168
1169function condText(node: SyntaxNode | null | undefined): string {
1170 if (!node) return '';
1171 let n: SyntaxNode = node;
1172 // `(x)` — the parens are the statement's, not the condition's.
1173 while (n.type === 'parenthesized_expression' && n.namedChildCount === 1) n = n.namedChild(0)!;
1174 const text = n.text.replace(/\s+/g, ' ').trim();
1175 // A bare keyword is a grammar's error recovery (`let` from an `if let` it
1176 // could not parse), never a condition a reader can use.
1177 if (/^(?:let|var|case|try|await|guard|if|else|some|any)$/.test(text)) return '';
1178 return text.length > MAX_TEXT ? text.slice(0, MAX_TEXT - 1) + '…' : text;
1179}
1180
1181/**
1182 * One guard. `branch` names the construct the arm belongs to: by default the

Callers 4

guardFunction · 0.85
enclosingFunction · 0.85
earlyExitsFunction · 0.85
javaCaseTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected