| 135 | } |
| 136 | |
| 137 | function 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 |