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

Function buildObjcMap

src/resolution/frameworks/swift-objc.ts:116–142  ·  view source on GitHub ↗
(context: ResolutionContext)

Source from the content-addressed store, hash-verified

114]);
115
116function buildObjcMap(context: ResolutionContext): Map<string, Node[]> {
117 const cached = objcByCandidateSwiftBase.get(context);
118 if (cached) return cached;
119
120 const map = new Map<string, Node[]>();
121 const objcMethods = context
122 .getNodesByKind('method')
123 .filter((n) => n.language === 'objc');
124 for (const node of objcMethods) {
125 const candidates = swiftBaseNamesForObjcSelector(node.name);
126 for (const c of candidates) {
127 // Skip the trivial case where the Swift base name equals the ObjC
128 // method name verbatim (no colons) — the regular name-matcher
129 // already handles that and our map would just duplicate the work.
130 if (c === node.name && !node.name.includes(':')) continue;
131 // Skip generic Cocoa names (init, description, etc.) — they would
132 // false-positive against any project-local ObjC method of the same
133 // name. The regular name-matcher handles them.
134 if (GENERIC_NAMES.has(c)) continue;
135 const arr = map.get(c);
136 if (arr) arr.push(node);
137 else map.set(c, [node]);
138 }
139 }
140 objcByCandidateSwiftBase.set(context, map);
141 return map;
142}
143
144/**
145 * Window of source text around a Swift declaration used by `isObjcExposed`

Callers 1

resolveSwiftCallToObjcFunction · 0.85

Calls 5

hasMethod · 0.80
getMethod · 0.65
getNodesByKindMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected