| 155 | } |
| 156 | |
| 157 | export function getLabel(node: SyntaxNodeRef) { |
| 158 | if (node.type.is(qt.Group) || node.type.isTop) return undefined |
| 159 | if (!node.type.is(qt.Label)) node = node.node.parent! // "if not label, set node to its parent". Note that we reassign `node`. |
| 160 | let child = node.node.firstChild |
| 161 | while (child != null && !stringLabels.includes(child.type.name)) { |
| 162 | child = child.nextSibling |
| 163 | } |
| 164 | const label = child?.name |
| 165 | console.assert( |
| 166 | labels.includes(label as never), |
| 167 | `Expected Label but got ${label}.`, |
| 168 | ) |
| 169 | return label as Label |
| 170 | } |
| 171 | |
| 172 | function buildContent(node: SyntaxNodeRef, input: string, negate: boolean) { |
| 173 | let valueFrom |