Add stack trace comment support to code writer #1198
Merged
+189
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's sometimes useful to know where in a code generator a line of code generated text came from. Enabling stack trace comments will output the last relevant stack trace information caused text to appear in the code writer's output.
Outputs:
The public API of this feature is just this method:
This tells the writer to turn on emitting stack trace comments. By default, the writer will emit C/Java-style block comments inline before calls to
write
,writeInline
,writeWithNoFormatting
, andwriteInlineWithNoFormatting
.But not every language supports inline comments or C/Java-style block comments. So for example, in Python, you could do:
The class will, by default, filter out any methods of
AbstractCodeWriter
and of the class that's extending it. Most implementations will not need to modify how frames are filtered, but this method is protected if you do: