MCPcopy Create free account
hub / github.com/backnotprop/plannotator / classifyMatch

Function classifyMatch

packages/shared/code-nav.ts:248–273  ·  view source on GitHub ↗
(
  snippet: string,
  symbol: string,
  language?: string,
)

Source from the content-addressed store, hash-verified

246// ---------------------------------------------------------------------------
247
248export function classifyMatch(
249 snippet: string,
250 symbol: string,
251 language?: string,
252): "definition" | "reference" {
253 const escaped = escapeRegex(symbol);
254
255 if (language) {
256 const langPatterns = DEFINITION_PATTERNS.find((p) =>
257 p.languages.includes(language),
258 );
259 if (langPatterns) {
260 for (const pattern of langPatterns.patterns) {
261 const re = new RegExp(pattern.replace("SYMBOL", escaped));
262 if (re.test(snippet)) return "definition";
263 }
264 }
265 }
266
267 for (const pattern of GENERIC_DEFINITION_PATTERNS) {
268 const re = new RegExp(pattern.replace("SYMBOL", escaped));
269 if (re.test(snippet)) return "definition";
270 }
271
272 return "reference";
273}
274
275// ---------------------------------------------------------------------------
276// Ranking

Callers 2

code-nav.test.tsFile · 0.90
parseRgJsonOutputFunction · 0.85

Calls 2

replaceMethod · 0.80
escapeRegexFunction · 0.70

Tested by

no test coverage detected