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

Function extractBrightScriptNavigationCalls

src/ast/extract-brightscript.ts:126–156  ·  view source on GitHub ↗
(
  content: string,
  helperNames: string[]
)

Source from the content-addressed store, hash-verified

124 * argument is the literal `true` (Roku BrightScript has no named args).
125 */
126export function extractBrightScriptNavigationCalls(
127 content: string,
128 helperNames: string[]
129): ShowScreenCall[] {
130 const out: ShowScreenCall[] = [];
131 if (helperNames.length === 0) return out;
132 const lines = content.split("\n");
133 const alternation = helperNames.map((h) => h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
134 const pattern = new RegExp(
135 `\\b(?:${alternation})\\s*\\(\\s*([^),]+?)\\s*(?:,\\s*(true|false|\\w+))?\\s*\\)`,
136 "gi"
137 );
138 for (let i = 0; i < lines.length; i++) {
139 const line = lines[i];
140 pattern.lastIndex = 0;
141 let m: RegExpExecArray | null;
142 while ((m = pattern.exec(line)) !== null) {
143 const target = m[1].trim();
144 // Skip obvious non-targets (empty string literal, string literal, number)
145 if (!target || /^["']/.test(target) || /^\d/.test(target)) continue;
146 const second = (m[2] ?? "").trim().toLowerCase();
147 out.push({
148 target,
149 modal: second === "true",
150 helper: "show",
151 line: i + 1,
152 });
153 }
154 }
155 return out;
156}
157
158/**
159 * Extract screen-stack navigation call-sites.

Callers 1

detectRokuScreensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected