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

Function resolve

src/resolution/frameworks/react-native.ts:445–480  ·  view source on GitHub ↗
(ref, context)

Source from the content-addressed store, hash-verified

443 },
444
445 resolve(ref, context) {
446 // We only redirect JS callers — native callers don't need this resolver.
447 if (
448 ref.language !== 'javascript' &&
449 ref.language !== 'typescript' &&
450 ref.language !== 'tsx' &&
451 ref.language !== 'jsx'
452 ) {
453 return null;
454 }
455
456 // JS callsites of `obj.method()` reach the resolver as either
457 // `obj.method` (qualified) or `method` (bare). Strip a single dot
458 // prefix to get the JS-visible method name.
459 const name = ref.referenceName.includes('.')
460 ? ref.referenceName.slice(ref.referenceName.lastIndexOf('.') + 1)
461 : ref.referenceName;
462
463 const maps = buildRNMaps(context);
464 const entries = maps.byJsName.get(name);
465 if (!entries || entries.length === 0) return null;
466
467 // Prefer the iOS (ObjC) target over Android when both exist — iOS is
468 // the conventional first-class platform for RN library docs and most
469 // graph queries. We still record only one edge; a JVM-only resolution
470 // is fine when no ObjC target exists.
471 const objc = entries.find((e) => e.node.language === 'objc');
472 const target = objc ?? entries[0];
473 if (!target) return null;
474 return {
475 original: ref,
476 targetNodeId: target.node.id,
477 confidence: 0.6,
478 resolvedBy: 'framework',
479 };
480 },
481};

Callers

nothing calls this directly

Calls 2

buildRNMapsFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected