To me, there are currently three major categories of information not accessible by macros:
- Lexical context
- Type information about sub-expressions
- Reflection of arbitrary types
It looks like the proposed addition would be sufficient to solve the first case, at least for the macros I have experimented with. I don't have a preference as to whether this info made accessible as a function parentContext() or returned as a [Syntax] array, as suggested by @wes1.
Another point: I think it would be important for the Syntax instances to contain all attributes, inheritance clauses, etc. of the parent declarations, i.e.:
@MainActor class ViewModel<Content>: ObservableObject where Content: View { }
instead of just:
class ViewModel { }