| 2899 | // memoized. Reads the class body for the mixin; only consulted for actual dispatch receivers. |
| 2900 | const performCache = new Map<string, Node | null>(); |
| 2901 | const performOf = (cls: Node): Node | null => { |
| 2902 | let v = performCache.get(cls.id); |
| 2903 | if (v !== undefined) return v; |
| 2904 | v = null; |
| 2905 | const content = ctx.readFile(cls.filePath); |
| 2906 | if (content) { |
| 2907 | const end = cls.endLine ?? cls.startLine; |
| 2908 | const body = content.split('\n').slice(cls.startLine - 1, end).join('\n'); |
| 2909 | if (SIDEKIQ_WORKER_RE.test(body)) { |
| 2910 | v = ctx.getNodesInFile(cls.filePath).find( |
| 2911 | (n) => n.kind === 'method' && n.name === 'perform' && n.startLine >= cls.startLine && n.startLine <= end |
| 2912 | ) ?? null; |
| 2913 | } |
| 2914 | } |
| 2915 | performCache.set(cls.id, v); |
| 2916 | return v; |
| 2917 | }; |
| 2918 | |
| 2919 | // Resolve a (possibly namespaced) worker reference to its `perform`. A namespaced ref is |
| 2920 | // matched by EXACT qualified name first, so same-named workers in different namespaces |