I'd be interested in seeing more information provided in the MacroExpansionContext
. When implementing a delegate method, I frequently find myself doing this:
func delegator(_ delegator: Delegator, willBegin operation: SomeOperation) {
print(#function, delegator, operation)
}
func delegator(_ delegator: Delegator, didFinish operation: SomeOperation) {
print(#function, delegator, operation)
}
This is a quick way for me to try out a new piece of code and quickly get a sense of the control flow between the delegator and the delegate. I was thinking that this would potentially be a nice macro:
func delegator(_ delegator: Delegator, willBegin operation: SomeOperation) {
#printArguments
}
However, when I looked at the MacroExpansionContext
, I didn't see a way I could implement this. Is there a way to get the containing scope and, if it's an argument-taking thing, get the list of arguments so I can splat out a print(...)
call?