I think I found a solution-
- Get the definition of the cursor (in the above case it was
CXCursor_ParmDecl
but it could be anything, likeCXCursor_VarDecl
, etc. - Get the first child of this cursor
Here is my updated code- it's hacky and needs some cleanup/clarification, but posting here for posterity.
- (void)processMethodDeclaration:(const CXIdxDeclInfo *)declaration {
clang_visitChildrenWithBlock(declaration->cursor, ^enum CXChildVisitResult(CXCursor cursor, CXCursor parent) {
if (cursor.kind == CXCursor_ObjCMessageExpr) {
__block NSString* memberName = nil;
__block NSString* referencedObjectName = nil;
clang_visitChildrenWithBlock(cursor, ^enum CXChildVisitResult(CXCursor cursor, CXCursor parent) {
if (cursor.kind == CXCursor_MemberRefExpr) {
memberName = [NSString stringWithUTF8String:clang_getCString(clang_getCursorDisplayName(cursor))];
referencedObjectName = [NSString stringWithUTF8String:clang_getCString(clang_getCursorDisplayName(clang_getCursorSemanticParent(clang_getCursorReferenced(cursor))))];
} else {
if (memberName) {
__block NSString* passedClassName = nil;
clang_visitChildrenWithBlock(cursor, ^enum CXChildVisitResult(CXCursor cursor, CXCursor parent) {
if (cursor.kind == CXCursor_DeclRefExpr) {
CXCursor def = clang_getCursorDefinition(cursor);
clang_visitChildrenWithBlock(def, ^enum CXChildVisitResult(CXCursor cursor, CXCursor parent) {
passedClassName = [NSString stringWithUTF8String:clang_getCString(clang_getCursorDisplayName(cursor))];
return CXChildVisit_Break;
});
}
return CXChildVisit_Recurse;
});
return CXChildVisit_Break;
}
}
return CXChildVisit_Continue;
});
}
return CXChildVisit_Recurse;
});
}