Skip to content

refactor(codegen): extract consume_pending_indent_space helper#22211

Merged
graphite-app[bot] merged 1 commit into
mainfrom
refactor/codegen-extract-pending-indent-space-helpers
May 7, 2026
Merged

refactor(codegen): extract consume_pending_indent_space helper#22211
graphite-app[bot] merged 1 commit into
mainfrom
refactor/codegen-extract-pending-indent-space-helpers

Conversation

@Dunqing

@Dunqing Dunqing commented May 7, 2026

Copy link
Copy Markdown
Member

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

  • 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 fix(codegen): swap mapping/indent order for top-level decls #22206 already covers the Directive indent path)
  • cargo test -p oxc_isolated_declarations passes (the namespace / declare module snapshot fixtures that already exercise indented import/export decls)
  • No snapshot updates needed

@github-actions github-actions Bot added the A-codegen Area - Code Generation label May 7, 2026

Dunqing commented May 7, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@Dunqing Dunqing force-pushed the refactor/codegen-extract-pending-indent-space-helpers branch from b7949e1 to 17664a3 Compare May 7, 2026 06:44
@codspeed-hq

codspeed-hq Bot commented May 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing refactor/codegen-extract-pending-indent-space-helpers (f14f340) with fix/codegen-indent-before-mapping-for-decls (a623ceb)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Dunqing Dunqing changed the title refactor(codegen): extract pending-indent-space helpers, switch top-level decls refactor(codegen): extract consume_pending_indent_space helper May 7, 2026
@Dunqing Dunqing force-pushed the refactor/codegen-extract-pending-indent-space-helpers branch from 17664a3 to f14f340 Compare May 7, 2026 06:48
@Dunqing Dunqing marked this pull request as ready for review May 7, 2026 08:41
@Dunqing Dunqing requested a review from Boshen May 7, 2026 08:41
@Dunqing

Dunqing commented May 7, 2026

Copy link
Copy Markdown
Member Author

Pure refactor

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label May 7, 2026

Dunqing commented May 7, 2026

Copy link
Copy Markdown
Member Author

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
@graphite-app graphite-app Bot force-pushed the fix/codegen-indent-before-mapping-for-decls branch from a623ceb to 29a3cd7 Compare May 7, 2026 14:11
@graphite-app graphite-app Bot force-pushed the refactor/codegen-extract-pending-indent-space-helpers branch from f14f340 to 5bdf497 Compare May 7, 2026 14:12
Base automatically changed from fix/codegen-indent-before-mapping-for-decls to main May 7, 2026 14:16
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 7, 2026
@graphite-app graphite-app Bot merged commit 5bdf497 into main May 7, 2026
30 checks passed
@graphite-app graphite-app Bot deleted the refactor/codegen-extract-pending-indent-space-helpers branch May 7, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant