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

Function extractPropNames

src/resolution/frameworks/fabric.ts:118–136  ·  view source on GitHub ↗

* Parse the NativeProps interface body and return prop names. * Each prop is `name?: Type;` or `name: Type;` on its own line. * We don't care about types — just the JS-visible name.

(body: string)

Source from the content-addressed store, hash-verified

116 * We don't care about types — just the JS-visible name.
117 */
118function extractPropNames(body: string): string[] {
119 const props: string[] = [];
120 // Anchor to start-of-line (after optional whitespace), then capture an
121 // identifier, then optional `?`, then `:`. Skip lines that look like
122 // method declarations (`name(`) — those are TurboModule spec methods,
123 // not view props.
124 const regex = /^\s*([A-Za-z_][A-Za-z0-9_]*)\??\s*:/gm;
125 let m: RegExpExecArray | null;
126 while ((m = regex.exec(body)) !== null) {
127 const name = m[1]!;
128 // Exclude any line that immediately turns into a function-shape (e.g.
129 // `onTap?: () => void` is fine — it's a prop, not a method body —
130 // but a literal `name(arg: T): R` is a method declaration).
131 const after = body.slice(m.index + m[0].length, m.index + m[0].length + 80);
132 if (/^\s*\(/.test(after)) continue; // method-shape, skip
133 props.push(name);
134 }
135 return props;
136}
137
138/**
139 * Extract legacy Paper view-manager declarations from a .m/.mm file.

Callers 1

extractFabricNodesFunction · 0.85

Calls 2

pushMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected