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