refactor: labeled expressions implementation#244
Draft
timofei-iatsenko wants to merge 6 commits into
Draft
Conversation
# Conflicts: # crates/lingui_macro/src/builder.rs # crates/lingui_macro/tests/jsx.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #244 +/- ##
==========================================
- Coverage 95.06% 94.81% -0.26%
==========================================
Files 9 9
Lines 2251 2334 +83
==========================================
+ Hits 2140 2213 +73
- Misses 111 121 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is my attempt on fixing #241 and #239
This is more systematic refactoring rather then ad-hoc fix. The refactoring make closer SWC implementation to a babel's one, so they not diverge.
Previously indexes for expression were allocated during processing a Message Phase in a message builder, in babel version those indexes where assigned during AST scanning phase, so it produced a diffrent result described in #241
Additionally
phmacro was not processed uniformly. It was processed in some places but were skipped in other, for example:With this refactoring, ph support is added everywhere and processed uniformly.
Other changes:
TransformCtx(formerlyMacroCtx) — global per-file context holding macro imports, options, directives, and runtime identifiers.MacroCtx<'a>— short-lived, created fresh for each macro invocation. Borrows&'a mut TransformCtxand owns its own expression index counter starting at 0.tokenize_tpl,tokenize_expr_to_arg,try_tokenize_call_expr_as_choice_cmp,try_tokenize_expr, andget_choice_cases_from_objare now free functions taking&mut MacroCtxexplicitly, making the data flow clear.