module Noir::ObjcCalleeExtractor

Overview

Best-effort 1-hop callee extraction for Objective-C method bodies. Mirrors SwiftCalleeExtractor but understands the message-send syntax ([receiver selector:arg]) that dominates Objective-C — the selector is the callee. C-style function calls (CGRectMake(...)) are picked up too.

Comment / string stripping is shared with the Swift extractor (Objective-C uses the same //, /* */, and "..." lexical forms).

Extended Modules

Defined in:

miniparsers/objc_callee_extractor.cr

Constant Summary

C_CALL_RE = /(?<![.\w\]])([A-Za-z_]\w*)\s*\(/

A C-style function call (CGRectMake(...)), not a .method(/]( form.

MEMORY_SELECTORS = Set {"alloc", "init", "new", "retain", "release", "autorelease", "dealloc", "copy", "mutableCopy"}

Pure memory-management selectors — real calls, but noise as callees.

MSG_BRACKET_RECEIVER_RE = /\]\s+([A-Za-z_]\w*)\s*[:\]]/

The selector of an outer message whose receiver is itself a bracketed subexpression: [[Foo bar] selector:...] -> the ] selector boundary.

MSG_IDENT_RECEIVER_RE = /\[\s*(?:[A-Za-z_]\w*)(?:\s*\.\s*[A-Za-z_]\w*)*\s+([A-Za-z_]\w*)\s*[:\]]/

[receiver selector...] where the receiver is an identifier / dotted property chain / self — captures the first selector keyword.

RESERVED = Set {"if", "else", "for", "while", "do", "switch", "case", "default", "return", "break", "continue", "goto", "sizeof", "self", "super", "nil", "Nil", "NULL", "YES", "NO", "id", "void", "BOOL", "in", "typeof", "__typeof", "__bridge", "__weak", "__strong", "instancetype", "const", "static", "extern", "inline", "_cmd", "block", "weakSelf"}

Keywords and primitive type names that can sit where a selector / call name would, but are never a 1-hop callee.

Instance Method Summary

Instance Method Detail

def callees_for_body(body : String, file_path : String, start_line : Int32) : Array(Entry) #

[View source]