MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / componentClassesIn

Function componentClassesIn

src/resolution/frameworks/angular-router.ts:371–385  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

369
370/** The `@Component` classes a file declares, in order, with whether each is the default export. */
371export function componentClassesIn(content: string): Array<{ name: string; isDefault: boolean; decoratorAt: number }> {
372 const out: Array<{ name: string; isDefault: boolean; decoratorAt: number }> = [];
373 const safe = stripCommentsForRegex(content, 'typescript');
374 COMPONENT_CLASS.lastIndex = 0;
375 let m: RegExpExecArray | null;
376 while ((m = COMPONENT_CLASS.exec(safe)) !== null) {
377 const open = m.index + m[0].length - 1;
378 const close = matchBracket(safe, open);
379 if (close < 0) continue;
380 const after = /^\s*(export\s+)?(default\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/.exec(safe.slice(close + 1, close + 400));
381 if (after) out.push({ name: after[3]!, isDefault: !!after[2], decoratorAt: m.index });
382 COMPONENT_CLASS.lastIndex = close;
383 }
384 return out;
385}
386
387/** The component class a lazily loaded file provides: the member named, else its default export, else its only component. */
388function lazyComponent(spec: string, member: string | null, fromFile: string, context: ResolutionContext): Node | null {

Callers 1

lazyComponentFunction · 0.85

Calls 4

stripCommentsForRegexFunction · 0.90
matchBracketFunction · 0.90
pushMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected