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

Function extractObjcMethodName

src/extraction/languages/objc.ts:24–40  ·  view source on GitHub ↗

Build ObjC selector: `greet`, `doThing:`, or `doThing:with:`.

(node: SyntaxNode, source: string)

Source from the content-addressed store, hash-verified

22
23/** Build ObjC selector: `greet`, `doThing:`, or `doThing:with:`. */
24function extractObjcMethodName(node: SyntaxNode, source: string): string | undefined {
25 if (node.type !== 'method_definition' && node.type !== 'method_declaration') {
26 return undefined;
27 }
28
29 const identifiers = node.namedChildren.filter((c) => c.type === 'identifier');
30 if (identifiers.length === 0) return undefined;
31
32 const hasParameters = node.namedChildren.some((c) => c.type === 'method_parameter');
33 const firstIdentifier = identifiers[0];
34 if (!firstIdentifier) return undefined;
35 if (!hasParameters) {
36 return getNodeText(firstIdentifier, source);
37 }
38
39 return identifiers.map((id) => `${getNodeText(id, source)}:`).join('');
40}
41
42/** Nullability / ARC qualifiers that sit where a return type's first type
43 * identifier does (`(nonnull instancetype)`, `(nullable Bar *)`) — never the type. */

Callers 1

objc.tsFile · 0.85

Calls 3

getNodeTextFunction · 0.90
mapMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected