(command: string)
| 268 | } |
| 269 | |
| 270 | async function doParse(command: string): Promise<IParsedCommand | null> { |
| 271 | if (!command) return null |
| 272 | |
| 273 | const treeSitterAvailable = await getTreeSitterAvailable() |
| 274 | if (treeSitterAvailable) { |
| 275 | try { |
| 276 | const { parseCommand } = await import('./parser.js') |
| 277 | const data = await parseCommand(command) |
| 278 | if (data) { |
| 279 | // Native NAPI parser returns plain JS objects (no WASM handles); |
| 280 | // nothing to free — extract directly. |
| 281 | return buildParsedCommandFromRoot(command, data.rootNode) |
| 282 | } |
| 283 | } catch { |
| 284 | // Fall through to regex implementation |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | // Fallback to regex implementation |
| 289 | return new RegexParsedCommand_DEPRECATED(command) |
| 290 | } |
| 291 | |
| 292 | // Single-entry cache: legacy callers (bashCommandIsSafeAsync, |
| 293 | // buildSegmentWithoutRedirections) may call ParsedCommand.parse repeatedly |
no test coverage detected