MCPcopy
hub / github.com/thesysdev/openui / pickEntryId

Function pickEntryId

packages/lang-core/src/parser/parser.ts:164–180  ·  view source on GitHub ↗
(
  stmtMap: Map<string, Statement>,
  typedStmts: Statement[],
  firstId: string,
  rootName?: string,
)

Source from the content-addressed store, hash-verified

162}
163
164function pickEntryId(
165 stmtMap: Map<string, Statement>,
166 typedStmts: Statement[],
167 firstId: string,
168 rootName?: string,
169): string {
170 if (stmtMap.has(DEFAULT_ROOT_STATEMENT_ID)) return DEFAULT_ROOT_STATEMENT_ID;
171 if (rootName && stmtMap.has(rootName)) return rootName;
172
173 const preferredComponent = rootName
174 ? typedStmts.find((stmt) => isComponentStatement(stmt) && stmt.expr.name === rootName)
175 : undefined;
176 if (preferredComponent) return preferredComponent.id;
177
178 const firstComponent = typedStmts.find(isComponentStatement);
179 return firstComponent?.id ?? firstId;
180}
181
182function buildResult(
183 stmtMap: Map<string, Statement>,

Callers 1

buildResultFunction · 0.85

Calls 2

isComponentStatementFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected