I’m not sure if this is the right term, but a few issues have come up that require alignment specific to what I’m calling scope context, i.e. only align declarations in an enum, function parameters, or shortened case labels (#52983, #51202, #42113). My thought is that all of these, and potentially other, cases could be addressed with the addition of scope context awareness in AlignTokenSequence
.
As of right now, that function uses a small vector to keep track of current scope depth using the indices of the first token on each scope. This is sufficient for handling nesting/scope transitions but doesn’t help us if we need to know (simply, at least) if we’re in a struct or enum or conditional, etc.
I’m posting here to get input/ideas, but the first thing that comes to mind is another small vector like ScopeStack
that keeps track of scope context, maybe with pre-defined integer constants corresponding to block types.
Please share your thoughts if you have them.