(rootNode: Node)
| 111 | } |
| 112 | |
| 113 | function extractPipePositions(rootNode: Node): number[] { |
| 114 | const pipePositions: number[] = [] |
| 115 | visitNodes(rootNode, node => { |
| 116 | if (node.type === 'pipeline') { |
| 117 | for (const child of node.children) { |
| 118 | if (child.type === '|') { |
| 119 | pipePositions.push(child.startIndex) |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | }) |
| 124 | // visitNodes is depth-first. For `a | b && c | d`, the outer `list` nests |
| 125 | // the second pipeline as a sibling of the first, so the outer `|` is |
| 126 | // visited before the inner one — positions arrive out of order. |
| 127 | // getPipeSegments iterates them to slice left-to-right, so sort here. |
| 128 | return pipePositions.sort((a, b) => a - b) |
| 129 | } |
| 130 | |
| 131 | function extractRedirectionNodes(rootNode: Node): RedirectionNode[] { |
| 132 | const redirections: RedirectionNode[] = [] |
no test coverage detected