refactor(codegen): extract consume_pending_indent_space helper#22211
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
b7949e1 to
17664a3
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
consume_pending_indent_space helper
17664a3 to
f14f340
Compare
|
Pure refactor |
Merge activity
|
) Stacked on #22206. Pure refactor — no behavior change. The `print_next_indent_as_space` flag was being read inline at **five** sites in `gen.rs` via copy-pasted `if flag { print_hard_space(); flag = false }` blocks. Two named private helpers replace those: - `consume_pending_indent_space() -> bool` — emit space + clear flag, returns whether anything was emitted - `clear_pending_indent_space()` — drop the flag without emitting `print_indent` continues to call `consume_pending_indent_space` internally, preserving the flag-as-space contract at every existing `print_indent` site. ## Test plan - [x] `cargo test -p oxc_codegen` passes (100 integration tests, no new tests added since the existing `top_level_decl_mappings_start_after_generated_indent` from #22206 already covers the `Directive` indent path) - [x] `cargo test -p oxc_isolated_declarations` passes (the namespace / `declare module` snapshot fixtures that already exercise indented import/export decls) - [x] No snapshot updates needed
a623ceb to
29a3cd7
Compare
f14f340 to
5bdf497
Compare

Stacked on #22206. Pure refactor — no behavior change.
The
print_next_indent_as_spaceflag was being read inline at five sites ingen.rsvia copy-pastedif flag { print_hard_space(); flag = false }blocks. Two named private helpers replace those:consume_pending_indent_space() -> bool— emit space + clear flag, returns whether anything was emittedclear_pending_indent_space()— drop the flag without emittingprint_indentcontinues to callconsume_pending_indent_spaceinternally, preserving the flag-as-space contract at every existingprint_indentsite.Test plan
cargo test -p oxc_codegenpasses (100 integration tests, no new tests added since the existingtop_level_decl_mappings_start_after_generated_indentfrom fix(codegen): swap mapping/indent order for top-level decls #22206 already covers theDirectiveindent path)cargo test -p oxc_isolated_declarationspasses (the namespace /declare modulesnapshot fixtures that already exercise indented import/export decls)