MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / extractBrightScriptObservers

Function extractBrightScriptObservers

src/ast/extract-brightscript.ts:96–113  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

94 * m.top.observeFieldScoped("fieldName", "handlerName")
95 */
96export 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.

Callers 2

detectEventsFunction · 0.85
detectMiddlewareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected