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

Function hasSynthesisPattern

src/resolution/callback-synthesizer.ts:5310–5344  ·  view source on GitHub ↗
(filePath: string, content: string)

Source from the content-addressed store, hash-verified

5308
5309/** Conservative input gates for SYNTH_PASSES; keep these in sync when adding a pass. */
5310export function hasSynthesisPattern(filePath: string, content: string): boolean {
5311 // These passes consume declarations/layouts as well as dispatch sites. A
5312 // header or markup edit can change a channel whose endpoints live elsewhere.
5313 if (/\.(?:vue|svelte|dfm|fmx|nix|xml)$/.test(filePath)) return true;
5314 // A Next proxy and the routes its matcher covers are joined by path and config, not by any line of code.
5315 if (NEXT_PROXY_FILE.test(filePath) || nextRouteForFile(filePath) !== null) return true;
5316 if (/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx|cppm|ipp|inl|tcc|def|inc|tbl)$/i.test(filePath) &&
5317 /\b(?:struct|union|typedef|virtual|override)\b|#\s*(?:include|define|if)|=|->|\[|</.test(content)) return true;
5318 if (/\b(?:class|interface|protocol|trait|impl|extends|implements|expect|actual)\b/.test(content)) return true;
5319 // Every Go file: besides the declarations the interface passes read, a call
5320 // through a func field, or a function put in one, can sit in any of them.
5321 if (/\.go$/.test(filePath)) return true;
5322 if (hasCrossTierPattern(content) || hasTestRequestPattern(filePath, content) || hasTauriPattern(filePath, content)) return true;
5323 if (/\b(?:render|build|setState|defineStore|createStore|createApi|Store|href|sendEvent|sendEventWithName)\b|<\/|\/>/.test(content)) return true;
5324 // A wrapper renders the component it wraps (jsxEdges), in a file with no markup of its own too.
5325 if (WRAPPER_CALL_RE.test(content)) return true;
5326 if (hasConstAliasShape(filePath, content)) return true;
5327 if (/\.(?:forEach|append|add|push|insert|fire|dispatchEvent|addListener|Use|GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|Any|Handle)\s*\(/.test(content)) return true;
5328 if (/[\w$]\s*\[\s*[A-Za-z_$]/.test(content) || /\b(?:dispatch|commit)\s*\(/.test(content)) return true;
5329 const patterns = [THUNK_DECL_RE, CELERY_TASK_DECORATOR_RE, CELERY_DISPATCH_RE,
5330 SPRING_LISTENER_ANNO_RE, SPRING_APP_LISTENER_RE, SPRING_PUBLISH_RE,
5331 MEDIATR_HANDLER_BASE_RE, MEDIATR_DISPATCH_RE, SIDEKIQ_WORKER_RE, SIDEKIQ_DISPATCH_RE,
5332 ERLANG_CALLBACK_DECL_RE, ERLANG_DISPATCH_RE, LARAVEL_DISPATCH_RE, ARKUI_EMITTER_CALL_RE,
5333 ARKUI_ROUTER_RE];
5334 for (const re of patterns) {
5335 re.lastIndex = 0;
5336 const matches = re.test(content);
5337 re.lastIndex = 0;
5338 if (matches) return true;
5339 }
5340 // Field-backed observers use method-name gates rather than fixed call names.
5341 return (content.match(/[A-Za-z_$][\w$]*/g) ?? []).some(
5342 (name) => REGISTRAR_NAME.test(name) || DISPATCHER_NAME.test(name)
5343 );
5344}
5345
5346/**
5347 * The independent passes, in MERGE ORDER — the first-seen dedup in

Callers 4

tauri-ipc.test.tsFile · 0.90
syncMethod · 0.85
collectInputsFunction · 0.85

Calls 5

nextRouteForFileFunction · 0.90
hasCrossTierPatternFunction · 0.90
hasTestRequestPatternFunction · 0.90
hasTauriPatternFunction · 0.90
hasConstAliasShapeFunction · 0.90

Tested by

no test coverage detected