MCPcopy
hub / github.com/claude-code-best/claude-code / doParse

Function doParse

src/utils/bash/ParsedCommand.ts:270–290  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

268}
269
270async 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

Callers 1

parseFunction · 0.85

Calls 2

parseCommandFunction · 0.70

Tested by

no test coverage detected