(node: SyntaxNode | null | undefined)
| 1167 | } |
| 1168 | |
| 1169 | function 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 |
no outgoing calls
no test coverage detected