MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / formatSymbol

Function formatSymbol

src/core/parser.ts:363–377  ·  view source on GitHub ↗
(sym: CodeSymbol, indent: number = 0)

Source from the content-addressed store, hash-verified

361}
362
363export function formatSymbol(sym: CodeSymbol, indent: number = 0): string {
364 const prefix = " ".repeat(indent);
365 const kindLabel = sym.kind === SymbolKind.Method ? "method" : sym.kind;
366 const lineLabel = sym.endLine > sym.line ? `L${sym.line}-L${sym.endLine}` : `L${sym.line}`;
367 let result = `${prefix}${kindLabel}: ${sym.name} (${lineLabel})`;
368
369 if (sym.kind === SymbolKind.Function || sym.kind === SymbolKind.Method) {
370 result = `${prefix}${kindLabel}: ${sym.signature} (${lineLabel})`;
371 }
372
373 for (const child of sym.children) {
374 result += "\n" + formatSymbol(child, indent + 1);
375 }
376 return result;
377}
378
379export function isSupportedFile(filePath: string): boolean {
380 const ext = extname(filePath).toLowerCase();

Callers 3

parser.test.mjsFile · 0.85
parser.demo.mjsFile · 0.85
buildTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected