Macros: Add a way to obtain the StackTrace responsible for generating a code. #56916
Labels
area-pkg
Used for miscellaneous pkg/ packages not associated with specific area- teams.
feature-macros
Implementation of the macros feature
P2
A bug or feature request we're likely to work on
pkg-macros
The experimental package:_macros library
type-enhancement
A request for a change that isn't a bug
Hello!
Problem
When using code-generators, one challenge is: It's difficult to know what line was responsible for the generation of a piece of code.
Code-generators can become quite complex. It can take a lot of time to find exactly which line was responsible for generating a specific code.
Proposal
It would be interesting to have a "jump to the macro code that generated this line".
Since macros don't actually write to the file system but rather use some virtual file ; we could use this as an opportunity to store extra metadata.
Specifically, we could associate any piece of generated code with a
Stacktrace
that points to the exact line responsible for this generation.The IDE could then use this StackTrace to jump to the macro code ; how could display the whole stacktrace to help debugging.
Of course, accessing the StackTrace can be slow.
For the sake of efficiency, I see two possible solutions:
analysis_options.yaml
config or something elseConsidering a macro should have a deterministic output, this shouldn't cause the IDE to jump to the wrong file/line.
The text was updated successfully, but these errors were encountered: