MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / classifyTree

Function classifyTree

src/extraction/syntax-tokens.ts:246–263  ·  view source on GitHub ↗
(
  root: SyntaxNode,
  source: string,
  language: Language,
  offset = 0
)

Source from the content-addressed store, hash-verified

244 * entry point is {@link tokenizeSource}, which parses first.
245 */
246export function classifyTree(
247 root: SyntaxNode,
248 source: string,
249 language: Language,
250 offset = 0
251): SyntaxSpan[] {
252 const extractor = EXTRACTORS[language];
253 const ctx: WalkContext = {
254 source,
255 out: [],
256 defTypes: extractor ? definitionTypesFor(extractor) : new Set<string>(),
257 nameField: extractor?.nameField ?? 'name',
258 defStarts: new Set<number>(),
259 offset,
260 };
261 visit(root, ctx, false);
262 return ctx.out;
263}
264
265function visit(node: SyntaxNode, ctx: WalkContext, inString: boolean): void {
266 const type = node.type;

Callers 2

tokenizeRegionFunction · 0.85

Calls 2

definitionTypesForFunction · 0.85
visitFunction · 0.70

Tested by

no test coverage detected