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

Function isSimpleOperand

src/graph/branch-guards.ts:137–154  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

135}
136
137function isSimpleOperand(text: string): boolean {
138 // A name, a member chain, or one call on it — `Objects.equals(owner.getId(), id)`
139 // included: the parens must balance and nothing may sit outside them.
140 if (/[=<>]/.test(text) || /\s(?:&&|\|\||and|or)\s/.test(text)) return false;
141 const m = /^([\w$.?!]+)(\(.*\))?$/s.exec(text);
142 if (!m) return false;
143 if (!m[2]) return true;
144 let depth = 0;
145 for (let i = 0; i < m[2].length; i++) {
146 const ch = m[2][i]!;
147 if (ch === '(') depth++;
148 else if (ch === ')') {
149 depth--;
150 if (depth === 0 && i < m[2].length - 1) return false;
151 }
152 }
153 return depth === 0;
154}
155
156// =============================================================================
157// Trees, cached per file version

Callers 1

renderGuardFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected