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

Function extract

src/resolution/frameworks/react-native.ts:377–405  ·  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

375 * `RCT_REMAP_METHOD` JS name) so it matches the Android `@ReactMethod` method.
376 */
377 extract(filePath, source) {
378 if (!filePath.endsWith('.m') && !filePath.endsWith('.mm')) return { nodes: [], references: [] };
379 if (!/RCT_EXPORT_MODULE\b/.test(source)) return { nodes: [], references: [] };
380 const exports = parseObjcRNExports(source, findObjcClassName(source));
381 const now = Date.now();
382 const nodes: Node[] = [];
383 const seen = new Set<string>();
384 for (const e of exports) {
385 if (seen.has(e.jsName)) continue;
386 seen.add(e.jsName);
387 nodes.push({
388 id: `rn-export:${filePath}:${e.moduleName}.${e.jsName}`,
389 kind: 'method',
390 name: e.jsName,
391 qualifiedName: `${filePath}::${e.moduleName}.${e.jsName}`,
392 filePath,
393 language: 'objc',
394 startLine: e.line,
395 endLine: e.line,
396 startColumn: 0,
397 endColumn: 0,
398 isExported: true,
399 docstring: `RCT_EXPORT_METHOD ${e.nativeSelectorFirstKw} (module ${e.moduleName})`,
400 signature: `RCT_EXPORT_METHOD(${e.nativeSelectorFirstKw}:…)`,
401 updatedAt: now,
402 });
403 }
404 return { nodes, references: [] };
405 },
406
407 /**
408 * Detect: package.json depends on `react-native`, OR any source file

Callers

nothing calls this directly

Calls 3

parseObjcRNExportsFunction · 0.85
findObjcClassNameFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected