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

Function extract

src/resolution/frameworks/react-native.ts:512–540  ·  view source on GitHub ↗

* Extract `RCT_EXPORT_METHOD` / `RCT_REMAP_METHOD` declarations as method * nodes. These macros parse as a macro-expression (an ERROR node), NOT a * `method_definition`, so the ObjC extractor never made a node for them — the * iOS half of a native module was invisible, so a JS call couldn't

(filePath, source)

Source from the content-addressed store, hash-verified

510 * `RCT_REMAP_METHOD` JS name) so it matches the Android `@ReactMethod` method.
511 */
512 extract(filePath, source) {
513 if (!filePath.endsWith('.m') && !filePath.endsWith('.mm')) return { nodes: [], references: [] };
514 if (!/RCT_EXPORT_MODULE\b/.test(source)) return { nodes: [], references: [] };
515 const exports = parseObjcRNExports(source, findObjcClassName(source));
516 const now = Date.now();
517 const nodes: Node[] = [];
518 const seen = new Set<string>();
519 for (const e of exports) {
520 if (seen.has(e.jsName)) continue;
521 seen.add(e.jsName);
522 nodes.push({
523 id: `rn-export:${filePath}:${e.moduleName}.${e.jsName}`,
524 kind: 'method',
525 name: e.jsName,
526 qualifiedName: `${filePath}::${e.moduleName}.${e.jsName}`,
527 filePath,
528 language: 'objc',
529 startLine: e.line,
530 endLine: e.line,
531 startColumn: 0,
532 endColumn: 0,
533 isExported: true,
534 docstring: `RCT_EXPORT_METHOD ${e.nativeSelectorFirstKw} (module ${e.moduleName})`,
535 signature: `RCT_EXPORT_METHOD(${e.nativeSelectorFirstKw}:…)`,
536 updatedAt: now,
537 });
538 }
539 return { nodes, references: [] };
540 },
541
542 /**
543 * Detect: package.json depends on `react-native`, OR any source file

Callers

nothing calls this directly

Calls 5

parseObjcRNExportsFunction · 0.85
findObjcClassNameFunction · 0.85
hasMethod · 0.80
pushMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected