-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a simplified pretty printer for tree transformations #6987
Conversation
Paging for review: @mhegazy, @ahejlsberg, @yuit, @DanielRosenwasser, @RyanCavanaugh, @vladima |
You can get around this by using Reviewable. |
Review status: 0 of 8 files reviewed at latest revision, 5 unresolved discussions. src/compiler/comments.ts, line 143 [r1] (raw file): Put some sort of quote demarcation around the emit. src/compiler/comments.ts, line 148 [r1] (raw file): src/compiler/comments.ts, line 185 [r1] (raw file): src/compiler/utilities.ts, line 115 [r1] (raw file): src/compiler/factory.ts, line 148 [r1] (raw file): Comments from the review on Reviewable.io |
Review status: 0 of 7 files reviewed at latest revision, 5 unresolved discussions. src/compiler/comments.ts, line 143 [r1] (raw file): src/compiler/comments.ts, line 148 [r1] (raw file): src/compiler/comments.ts, line 185 [r1] (raw file): src/compiler/utilities.ts, line 115 [r1] (raw file): Comments from the review on Reviewable.io |
Review status: 0 of 7 files reviewed at latest revision, 13 unresolved discussions. src/compiler/printer.ts, line 184 [r1] (raw file): src/compiler/printer.ts, line 742 [r1] (raw file): src/compiler/printer.ts, line 995 [r1] (raw file): src/compiler/printer.ts, line 1106 [r1] (raw file): emitExpressionWithPrefix(node.asteriskToken ? "yield* " : "yield ", node.expression);· src/compiler/printer.ts, line 1788 [r1] (raw file): src/compiler/printer.ts, line 1798 [r1] (raw file): src/compiler/printer.ts, line 1870 [r1] (raw file): src/compiler/printer.ts, line 1984 [r1] (raw file): What about default initializers and optional parameters? Do we have tests for these cases? Comments from the review on Reviewable.io |
Review status: 0 of 12 files reviewed at latest revision, 13 unresolved discussions. src/compiler/printer.ts, line 742 [r1] (raw file): src/compiler/printer.ts, line 995 [r1] (raw file): src/compiler/printer.ts, line 1106 [r1] (raw file): src/compiler/printer.ts, line 1788 [r1] (raw file): src/compiler/printer.ts, line 1798 [r1] (raw file): src/compiler/printer.ts, line 1870 [r1] (raw file): src/compiler/printer.ts, line 1984 [r1] (raw file): Comments from the review on Reviewable.io |
Adds the Module transformers
Adds the ES6 transformer
Adds the ES7 transformer
Adds the JSX transformer
Adds the TypeScript transformer
Adds a simplified pretty printer for tree transformations
Unfortunately, we cannot easily leverage our existing emitter to emit transformed nodes. The current emitter often assumes nodes are original source tree nodes, rather than synthesized nodes created during a transformation phase. Transformers are not required to set parent pointers on nodes, as they will often reuse existing source tree nodes and should not change the parent pointers on these nodes.
Instead we will add a new, simpler node printer whose responsibility is to emit the exact node tree provided.
The
printFiles
function will eventually supplant the existingemitFiles
function. When called, this function will get a list ofTransformer
callbacks based on the provided compiler options, adding the node printer as the last transformer in the list. This gives the node printer access to theTransformationContext
, allowing it to process substitutions and track any hoisted declarations added during just-in-time substitution.The node printer in
printFiles
is designed for performance, and minimizes the number of conditional branches within the emit for any node. The expectation is that all transformers have finished every non-substitution transformation before the printer is called, and therefore the node printer will print nodes verbatim.In addition, similarly to how source maps were extracted from
emitter.ts
and into aSourceMapWriter
to support the node printer, comment emit is now also extracted into aCommentWriter
.Related Pull Requests: