(content: string)
| 94 | * m.top.observeFieldScoped("fieldName", "handlerName") |
| 95 | */ |
| 96 | export function extractBrightScriptObservers(content: string): BrightScriptObserver[] { |
| 97 | const out: BrightScriptObserver[] = []; |
| 98 | const lines = content.split("\n"); |
| 99 | const pattern = /(\bm\.top|\bm\.global|\b[\w.]+?)\.observeField(?:Scoped)?\s*\(\s*["']([^"']+)["']\s*,\s*["']([^"']+)["']/gi; |
| 100 | |
| 101 | for (let i = 0; i < lines.length; i++) { |
| 102 | let match: RegExpExecArray | null; |
| 103 | pattern.lastIndex = 0; |
| 104 | while ((match = pattern.exec(lines[i])) !== null) { |
| 105 | const receiver = match[1]; |
| 106 | let scope: BrightScriptObserver["scope"] = "other"; |
| 107 | if (/^m\.top$/i.test(receiver)) scope = "top"; |
| 108 | else if (/^m\.global$/i.test(receiver)) scope = "global"; |
| 109 | out.push({ field: match[2], handler: match[3], scope, line: i + 1 }); |
| 110 | } |
| 111 | } |
| 112 | return out; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Extract screen-open call-sites for a configurable set of helper names. |
no outgoing calls
no test coverage detected