(rootNode: Node)
| 129 | } |
| 130 | |
| 131 | function extractRedirectionNodes(rootNode: Node): RedirectionNode[] { |
| 132 | const redirections: RedirectionNode[] = [] |
| 133 | visitNodes(rootNode, node => { |
| 134 | if (node.type === 'file_redirect') { |
| 135 | const children = node.children |
| 136 | const op = children.find(c => c.type === '>' || c.type === '>>') |
| 137 | const target = children.find(c => c.type === 'word') |
| 138 | if (op && target) { |
| 139 | redirections.push({ |
| 140 | startIndex: node.startIndex, |
| 141 | endIndex: node.endIndex, |
| 142 | target: target.text, |
| 143 | operator: op.type as '>' | '>>', |
| 144 | }) |
| 145 | } |
| 146 | } |
| 147 | }) |
| 148 | return redirections |
| 149 | } |
| 150 | |
| 151 | class TreeSitterParsedCommand implements IParsedCommand { |
| 152 | readonly originalCommand: string |
no test coverage detected