Optimizing transform_ast with TraceTree #10217
oovm
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
I find it very difficult to generate sourcemap now. I need to trace
dst_line
of each transform.It is difficult to know the final position after multiple complex transformations.
I think the current Span-based ParseTree is not suitable for ast transformation.
It needs to be changed to SourceNode-based TraceTree.
Design
Roughly the same as SourceNode high level api, but using strongly typed ast instead of string.
The core idea is to store the three core info
source_line + source_column + source_file_id
, orsource_start + source_end + source_file_id
.Then this node can be copied to any place and combined in any way.
The final generated ast can retain and read the original position information, and compare it with the position in the generated product to get the source map between the final state and the initial state.
Beta Was this translation helpful? Give feedback.
All reactions