MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseFile

Function parseFile

packages/code-map/src/parse.ts:354–379  ·  view source on GitHub ↗
(
  parser: Parser,
  query: Query,
  sourceCode: string,
)

Source from the content-addressed store, hash-verified

352}
353
354function parseFile(
355 parser: Parser,
356 query: Query,
357 sourceCode: string,
358): { [key: string]: string[] } {
359 const tree = parser.parse(sourceCode)
360 if (!tree) {
361 return {}
362 }
363 try {
364 const captures = query.captures(tree.rootNode)
365 const result: { [key: string]: string[] } = {}
366
367 for (const capture of captures) {
368 const { name, node } = capture
369 if (!result[name]) {
370 result[name] = []
371 }
372 result[name].push(node.text)
373 }
374
375 return result
376 } finally {
377 ;(tree as { delete?: () => void }).delete?.()
378 }
379}

Callers 1

parseTokensWithLimitsFunction · 0.85

Calls 2

parseMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected