MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / definitionLine

Function definitionLine

graph-ui/src/browser-ai/code-facts.ts:120–125  ·  view source on GitHub ↗

The line that declares `name`, or the first line of code; without its opening brace.

(lines: readonly string[], name: string | undefined, fence: string)

Source from the content-addressed store, hash-verified

118
119/** The line that declares `name`, or the first line of code; without its opening brace. */
120function definitionLine(lines: readonly string[], name: string | undefined, fence: string): CodeFacts | undefined {
121 const code = lines.filter(line => line.trim() && !/^\s*(?:\/\/|\/\*|\*|#|--|<!--)/.test(line));
122 const named = name ? code.find(line => new RegExp(`(?:^|[^\\w$])${escape(name)}(?:[^\\w$]|$)`).test(line)) : undefined;
123 const line = (named ?? code[0])?.trim().replace(/\s*\{\s*$/, '');
124 return line ? { lines: [bounded(line)], more: 0, unit: 'lines', fence } : undefined;
125}
126
127/** The facts of the code a selection stands for, or undefined without code. */
128export function codeFacts(source: { text: string; path: string }, subject?: { name: string; kind?: string }): CodeFacts | undefined {

Callers 1

codeFactsFunction · 0.85

Calls 2

escapeFunction · 0.70
boundedFunction · 0.70

Tested by

no test coverage detected