Skip to content

Conversation

@denbezrukov
Copy link
Contributor

Summary

We need to optimize the memory layout of the FormatElement enum to store the text size within the element; otherwise, it exceeds 24 bytes.
#7983

Test Plan

Green CI

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

🦋 Changeset detected

Latest commit: 83cb4cc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Project Area: project A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages L-CSS Language: CSS L-JSON Language: JSON and super languages L-HTML Language: HTML and super languages L-Grit Language: GritQL A-Type-Inference Area: type inference labels Nov 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 50977 50977 0
Passed 49765 49765 0
Failed 1170 1170 0
Panics 42 42 0
Coverage 97.62% 97.62% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6320 6320 0
Passed 2106 2106 0
Failed 4214 4214 0
Panics 0 0 0
Coverage 33.32% 33.32% 0.00%

ts/babel

Test result main count This PR count Difference
Total 835 835 0
Passed 742 742 0
Failed 93 93 0
Panics 0 0 0
Coverage 88.86% 88.86% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18813 18813 0
Passed 14065 14065 0
Failed 4747 4747 0
Panics 1 1 0
Coverage 74.76% 74.76% 0.00%

…source position from Text and LocatedTokenText variant
@denbezrukov denbezrukov force-pushed the dbezrukov/format-element-source branch from f21050d to b888584 Compare November 6, 2025 10:04
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 6, 2025

CodSpeed Performance Report

Merging #8012 will degrade performances by 7.99%

Comparing dbezrukov/format-element-source (83cb4cc) with main (5c55347)

Summary

❌ 8 regressions
✅ 45 untouched
⏩ 85 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
js_formatter[checker_6456328407951392140.ts] 909.4 ms 977.1 ms -6.93%
js_formatter[compiler_3469143416596620219.js] 531.9 ms 578.1 ms -7.99%
js_formatter[d3.min_16009850199655599998.js] 433.9 ms 468.9 ms -7.47%
js_formatter[ios.d_12216376241674358710.d.ts] 761.3 ms 811.2 ms -6.16%
js_formatter[math_5920422916221598348.js] 848.7 ms 906.7 ms -6.4%
js_formatter[pixi.min_8151088792683739606.js] 471.8 ms 512.4 ms -7.93%
js_formatter[typescript_5583633924076080079.js] 3.5 s 3.7 s -6.52%
js_formatter[vue.global.prod_4065256639735990520.js] 177 ms 188.4 ms -6.09%

Footnotes

  1. 85 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Walkthrough

This PR centralises source-position tracking in the formatter: it removes source_position fields from FormatElement::Text and FormatElement::LocatedTokenText, adds FormatElement::SourcePosition(TextSize), changes text() to accept Option<TextSize> (call sites updated to Some(...) or None), and updates the printer to defer and flush pending source positions when emitting text. Document rendering, debug and format implementations were adjusted to emit and handle the new SourcePosition element.

Possibly related PRs

Suggested labels

A-Core

Suggested reviewers

  • ematipico
  • siketyan

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.86% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main refactoring: introducing SourcePosition element and removing source_position from Text and LocatedTokenText variants.
Description check ✅ Passed The description relates to the changeset by explaining the memory optimisation motivation and references the associated PR, though it could be more detailed about the specific changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dbezrukov/format-element-source

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dddb70c and 83cb4cc.

📒 Files selected for processing (1)
  • crates/biome_formatter/src/macros.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_formatter/src/macros.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Parser conformance
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_formatter)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_formatter/src/builders.rs (1)

434-440: Consider using the helper for consistency.

Line 436 writes FormatElement::SourcePosition directly, bypassing the IR-level deduplication in the source_position() helper (lines 321–325). For consistency with Text::fmt (line 349) and SyntaxTokenCowSlice::fmt (line 384), consider:

-        f.write_element(FormatElement::SourcePosition(self.source_position))?;
+        source_position(self.source_position).fmt(f)?;

This avoids potential consecutive duplicate SourcePosition elements in the IR.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c55347 and f21050d.

📒 Files selected for processing (34)
  • .changeset/real-tires-move.md (1 hunks)
  • crates/biome_css_formatter/src/comments.rs (2 hunks)
  • crates/biome_css_formatter/src/css/value/url_value_raw.rs (1 hunks)
  • crates/biome_css_formatter/src/lib.rs (1 hunks)
  • crates/biome_css_formatter/src/utils/string_utils.rs (1 hunks)
  • crates/biome_css_formatter/src/verbatim.rs (1 hunks)
  • crates/biome_css_semantic/src/format_semantic_model.rs (5 hunks)
  • crates/biome_formatter/src/builders.rs (7 hunks)
  • crates/biome_formatter/src/format_element.rs (5 hunks)
  • crates/biome_formatter/src/format_element/document.rs (14 hunks)
  • crates/biome_formatter/src/format_extensions.rs (2 hunks)
  • crates/biome_formatter/src/lib.rs (1 hunks)
  • crates/biome_formatter/src/macros.rs (1 hunks)
  • crates/biome_formatter/src/printer/mod.rs (12 hunks)
  • crates/biome_graphql_formatter/src/comments.rs (2 hunks)
  • crates/biome_graphql_formatter/src/graphql/value/string_value.rs (1 hunks)
  • crates/biome_graphql_formatter/src/verbatim.rs (1 hunks)
  • crates/biome_grit_formatter/src/comments.rs (2 hunks)
  • crates/biome_grit_formatter/src/verbatim.rs (1 hunks)
  • crates/biome_html_formatter/src/utils/children.rs (1 hunks)
  • crates/biome_html_formatter/src/utils/formatters.rs (1 hunks)
  • crates/biome_html_formatter/src/verbatim.rs (1 hunks)
  • crates/biome_js_formatter/src/comments.rs (2 hunks)
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs (1 hunks)
  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs (1 hunks)
  • crates/biome_js_formatter/src/utils/jsx.rs (1 hunks)
  • crates/biome_js_formatter/src/utils/test_each_template.rs (1 hunks)
  • crates/biome_js_formatter/src/verbatim.rs (1 hunks)
  • crates/biome_js_semantic/src/format_semantic_model.rs (4 hunks)
  • crates/biome_js_type_info/src/format_type_info.rs (18 hunks)
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs (1 hunks)
  • crates/biome_json_formatter/src/comments.rs (2 hunks)
  • crates/biome_json_formatter/src/verbatim.rs (1 hunks)
  • crates/biome_module_graph/src/format_module_graph.rs (6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_js_formatter/**/*.rs

📄 CodeRabbit inference engine (crates/biome_js_formatter/CONTRIBUTING.md)

crates/biome_js_formatter/**/*.rs: Implement the Format trait for your node type and use JsFormatter with write!/format_args! to define formatting
Import and use the FormatNode trait for AST nodes
When a token is mandatory and present in the AST, use the AST-provided token (e.g., node.l_paren_token().format()) instead of emitting a static token
For non-mandatory tokens, use the provided helper constructors (e.g., token, space_token, dynamic_token)
Do not attempt to fix code; if a mandatory token/node is missing, return None instead
Use dbg_write! to debug and inspect the emitted IR during formatting

Files:

  • crates/biome_js_formatter/src/utils/test_each_template.rs
  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_js_formatter/src/verbatim.rs
crates/biome_formatter/src/**/*.rs

📄 CodeRabbit inference engine (crates/biome_formatter/CONTRIBUTING.md)

After generation, remove usages of format_verbatim_node and implement real formatting with biome_formatter utilities

Files:

  • crates/biome_formatter/src/macros.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_formatter/src/format_extensions.rs
crates/biome_formatter/src/lib.rs

📄 CodeRabbit inference engine (crates/biome_formatter/CONTRIBUTING.md)

crates/biome_formatter/src/lib.rs: Add the provided AsFormat, IntoFormat, and iterator plumbing code to lib.rs
Implement FormatLanguage for HtmlFormatLanguage with associated types: SyntaxLanguage=HtmlLanguage, Context=HtmlFormatContext, FormatRule=FormatHtmlSyntaxNode
Define the HtmlFormatter type alias: type HtmlFormatter<'buf> = Formatter<'buf, HtmlFormatContext>;
Expose a documented public function format_node(options: HtmlFormatOptions, root: &HtmlSyntaxNode) -> FormatResult<Formatted<HtmlFormatContext>> delegating to biome_formatter::format_node

Files:

  • crates/biome_formatter/src/lib.rs
🧠 Learnings (33)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/context.rs : Create HtmlFormatContext in context.rs with comments and source_map fields and implement FormatContext and CstFormatContext
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to fix code; if a mandatory token/node is missing, return `None` instead

Applied to files:

  • crates/biome_css_formatter/src/css/value/url_value_raw.rs
  • crates/biome_grit_formatter/src/verbatim.rs
  • crates/biome_js_formatter/src/utils/test_each_template.rs
  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs
  • crates/biome_css_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs
  • crates/biome_json_formatter/src/comments.rs
  • crates/biome_graphql_formatter/src/verbatim.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_graphql_formatter/src/graphql/value/string_value.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_grit_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_js_formatter/src/verbatim.rs
  • crates/biome_formatter/src/macros.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/**/*.rs : After generation, remove usages of `format_verbatim_node` and implement real formatting with biome_formatter utilities

Applied to files:

  • crates/biome_css_formatter/src/css/value/url_value_raw.rs
  • crates/biome_grit_formatter/src/verbatim.rs
  • crates/biome_js_formatter/src/utils/test_each_template.rs
  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs
  • crates/biome_css_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs
  • crates/biome_json_formatter/src/comments.rs
  • crates/biome_graphql_formatter/src/verbatim.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_graphql_formatter/src/graphql/value/string_value.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_grit_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_js_formatter/src/verbatim.rs
  • crates/biome_formatter/src/macros.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • .changeset/real-tires-move.md
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When a token is mandatory and present in the AST, use the AST-provided token (e.g., `node.l_paren_token().format()`) instead of emitting a static token

Applied to files:

  • crates/biome_js_formatter/src/utils/test_each_template.rs
  • crates/biome_css_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs
  • crates/biome_graphql_formatter/src/verbatim.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import and use the `FormatNode` trait for AST nodes

Applied to files:

  • crates/biome_js_formatter/src/utils/test_each_template.rs
  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs
  • crates/biome_css_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs
  • crates/biome_json_formatter/src/comments.rs
  • crates/biome_graphql_formatter/src/verbatim.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_graphql_formatter/src/graphql/value/string_value.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • .changeset/real-tires-move.md
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For non-mandatory tokens, use the provided helper constructors (e.g., `token`, `space_token`, `dynamic_token`)

Applied to files:

  • crates/biome_js_formatter/src/utils/test_each_template.rs
  • crates/biome_css_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_js_formatter/src/verbatim.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/type_info.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/{type_info,local_inference,resolver,flattening}.rs : Avoid recursive type structures and cross-module Arcs; represent links between types using TypeReference and TypeData::Reference.

Applied to files:

  • crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Expose a documented public function `format_node(options: HtmlFormatOptions, root: &HtmlSyntaxNode) -> FormatResult<Formatted<HtmlFormatContext>>` delegating to `biome_formatter::format_node`

Applied to files:

  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Implement FormatLanguage for HtmlFormatLanguage with associated types: SyntaxLanguage=HtmlLanguage, Context=HtmlFormatContext, FormatRule=FormatHtmlSyntaxNode

Applied to files:

  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/cst.rs : Create FormatHtmlSyntaxNode in cst.rs implementing FormatRule<HtmlSyntaxNode> and AsFormat/IntoFormat for HtmlSyntaxNode using the provided plumbing

Applied to files:

  • crates/biome_html_formatter/src/verbatim.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/context.rs : Create HtmlFormatContext in context.rs with comments and source_map fields and implement FormatContext and CstFormatContext

Applied to files:

  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_json_formatter/src/comments.rs
  • crates/biome_css_formatter/src/lib.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_grit_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Add the provided AsFormat, IntoFormat, and iterator plumbing code to lib.rs

Applied to files:

  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/builders.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/language.rs : Create tests/language.rs defining `HtmlTestFormatLanguage` and implement the TestFormatLanguage trait

Applied to files:

  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/macros.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Implement the `Format` trait for your node type and use `JsFormatter` with `write!`/`format_args!` to define formatting

Applied to files:

  • crates/biome_html_formatter/src/utils/formatters.rs
  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_json_formatter/src/verbatim.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_css_formatter/src/utils/string_utils.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/comments.rs : Define HtmlCommentStyle implementing CommentStyle in comments.rs

Applied to files:

  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_json_formatter/src/comments.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_grit_formatter/src/comments.rs
  • crates/biome_js_formatter/src/comments.rs
  • crates/biome_html_formatter/src/utils/children.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/comments.rs : Expose a public HtmlComments type alias: `pub type HtmlComments = Comments<HtmlLanguage>;`

Applied to files:

  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_json_formatter/src/comments.rs
  • crates/biome_css_formatter/src/comments.rs
  • crates/biome_js_formatter/src/comments.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use `dbg_write!` to debug and inspect the emitted IR during formatting

Applied to files:

  • crates/biome_graphql_formatter/src/comments.rs
  • crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs
  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_js_formatter/src/utils/jsx.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/builders.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/{type_info,local_inference}.rs : When inference is missing or cannot determine a type, use TypeData::Unknown; use TypeData::UnknownKeyword only when the user explicitly wrote unknown.

Applied to files:

  • crates/biome_js_type_info/src/format_type_info.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/collector.rs : Thin (module-level) inference should resolve local and global bindings to TypeReference::Resolved, mark imported bindings as TypeReference::Import, and fall back to TypeReference::Unknown if unresolved.

Applied to files:

  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_module_graph/src/format_module_graph.rs
📚 Learning: 2025-08-20T16:24:59.781Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.

Applied to files:

  • crates/biome_js_type_info/src/format_type_info.rs
📚 Learning: 2025-10-03T12:28:56.788Z
Learnt from: ematipico
Repo: biomejs/biome PR: 7670
File: crates/biome_service/src/file_handlers/html.rs:744-748
Timestamp: 2025-10-03T12:28:56.788Z
Learning: In Biome's codebase, when creating tokens with new text content, use the factory pattern with functions like `ident(text)` from the respective `*_factory` crates (e.g., `biome_html_factory::make::ident`). There is no `.with_text()` method on tokens. The `ident()` function creates a new detached token with the IDENT kind, which is the standard approach for token construction.

Applied to files:

  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_js_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/format_element.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Define the HtmlFormatter type alias: `type HtmlFormatter<'buf> = Formatter<'buf, HtmlFormatContext>;`

Applied to files:

  • crates/biome_js_type_info/src/format_type_info.rs
  • crates/biome_html_formatter/src/utils/children.rs
  • crates/biome_module_graph/src/format_module_graph.rs
  • crates/biome_formatter/src/format_element/document.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/spec_tests.rs : In tests/spec_tests.rs, generate tests with `tests_macros::gen_tests! {"tests/specs/html/**/*.html", crate::spec_test::run, ""}`

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/macros.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:25:05.698Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:25:05.698Z
Learning: Applies to crates/biome_service/../biome_lsp/src/server.tests.rs : Keep end-to-end LSP tests in ../biome_lsp/src/server.tests.rs

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/format_element.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: The formatter relies on two pillars: implementing `Format`/`FormatNode` for nodes and creating an intermediate IR via helpers

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/spec_test.rs : Implement a `run` function in tests/spec_test.rs that wires SpecSnapshot and includes!("language.rs") as shown

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/format_element/document.rs
  • crates/biome_formatter/src/format_element.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_formatter/src/format_extensions.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/** : Create a tests directory containing a specs subfolder and the files spec_test.rs, spec_tests.rs, and language.rs

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/format_element/document.rs
📚 Learning: 2025-10-15T09:25:05.698Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:25:05.698Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Place watcher tests related to workspace methods in src/workspace/watcher.tests.rs

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Lexer must implement the biome_parser::Lexer trait

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_formatter/src/format_element.rs
📚 Learning: 2025-09-13T16:16:06.459Z
Learnt from: ematipico
Repo: biomejs/biome PR: 7467
File: crates/biome_service/src/file_handlers/html.rs:456-466
Timestamp: 2025-09-13T16:16:06.459Z
Learning: In biome_formatter, the printer correctly handles consecutive LineMode::Hard elements without creating extra blank lines. Multiple consecutive FormatElement::Line(LineMode::Hard) elements in the formatting code do not result in duplicate blank lines in the output because the printer has logic to track line states and handle indentation properly.

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/**/*.rs : Do not copy or clone data between module graph entries (including behind Arc). Each module must avoid holding duplicated data from another module to enable simple invalidation.

Applied to files:

  • crates/biome_module_graph/src/format_module_graph.rs
📚 Learning: 2025-09-13T16:16:06.459Z
Learnt from: ematipico
Repo: biomejs/biome PR: 7467
File: crates/biome_service/src/file_handlers/html.rs:456-466
Timestamp: 2025-09-13T16:16:06.459Z
Learning: In biome_formatter, consecutive LineMode::Hard elements are automatically collapsed to a single newline by the printer. The printer has a test "it_prints_consecutive_hard_lines_as_one" that demonstrates this behavior - multiple consecutive hard line breaks result in only one newline in the output, not extra blank lines.

Applied to files:

  • crates/biome_formatter/src/format_element.rs
🔇 Additional comments (37)
crates/biome_jsdoc_comment/src/format_jsdoc_comment.rs (1)

17-17: LGTM! Clean adaptation to the new text() API.

The change from TextSize::default() to None is appropriate for JSDoc comment formatting where specific position tracking isn't required.

crates/biome_html_formatter/src/utils/children.rs (1)

66-70: LGTM! Core refactoring correctly implemented.

Source position is now emitted separately via source_position().fmt() before the token text, removing the need for the source_position field in LocatedTokenText. This aligns perfectly with the PR's architectural goal.

crates/biome_js_formatter/src/utils/test_each_template.rs (1)

321-321: LGTM! Position tracking preserved correctly.

The position argument is now wrapped in Some(...), maintaining the same position tracking whilst adapting to the new Optional API.

crates/biome_json_formatter/src/verbatim.rs (1)

119-119: LGTM! Verbatim formatting adapted correctly.

Position is now wrapped in Some(...), maintaining source mapping for verbatim nodes.

crates/biome_html_formatter/src/utils/formatters.rs (1)

30-30: LGTM! Token replacement position preserved.

The token's start position is correctly wrapped in Some(...) for the replacement text.

crates/biome_js_formatter/src/ts/types/bigint_literal_type.rs (1)

29-29: LGTM! BigInt literal formatting updated correctly.

Position tracking maintained when converting to lowercase.

crates/biome_grit_formatter/src/verbatim.rs (1)

120-120: LGTM! Grit verbatim formatting aligned with other formatters.

Consistent with the pattern used across all verbatim formatters.

crates/biome_js_formatter/src/comments.rs (2)

43-43: LGTM! Comment position tracking preserved.

Source offsets for alignable comments are now wrapped in Some(...), maintaining correct positioning for multiline comment alignment.


57-57: LGTM! Subsequent lines handled consistently.

Each line in the multiline comment maintains its position tracking through Some(source_offset).

crates/biome_graphql_formatter/src/verbatim.rs (1)

118-122: LGTM!

Position correctly wrapped with Some() to match the updated text() signature.

crates/biome_html_formatter/src/verbatim.rs (1)

142-146: LGTM!

Consistent with the refactoring—position wrapped with Some().

crates/biome_graphql_formatter/src/comments.rs (1)

24-58: LGTM!

Both text() calls correctly updated to pass Some(source_offset).

crates/biome_js_formatter/src/utils/jsx.rs (1)

421-428: LGTM!

Source position now emitted separately before LocatedTokenText—this properly decouples position tracking from the text element.

crates/biome_js_formatter/src/js/expressions/bigint_literal_expression.rs (1)

26-33: LGTM!

Position correctly wrapped with Some().

crates/biome_json_formatter/src/comments.rs (1)

26-59: LGTM!

Both text() calls correctly updated with Some(source_offset).

crates/biome_grit_formatter/src/comments.rs (1)

46-84: LGTM!

Both text() calls correctly updated with Some(source_offset).

crates/biome_module_graph/src/format_module_graph.rs (5)

67-94: LGTM!

Using None for synthetic formatting is correct, and the joiner.finish() call properly completes the formatting.


205-259: LGTM!

All text() calls correctly updated to use None for synthetic content.


291-314: LGTM!

Correct usage of None for synthetic text formatting.


317-348: LGTM!

Consistent use of None for synthetic text.


97-131: Verify the control flow change.

Line 129 now returns Ok(()) directly, whereas Exports::fmt calls joiner.finish(). Should this also call joiner.finish() for consistency?

crates/biome_js_type_info/src/format_type_info.rs (2)

5-11: LGTM! Import reorganisation aligns with new API.

The addition of explicit format_args and write imports supports the updated text() calls throughout the file.


98-1038: Consistent refactor to optional text positions.

All text() calls have been updated to use None for positions (replacing TextSize::default() or previously omitted positions). This mechanical change aligns perfectly with the PR's objective to separate source position tracking from text elements.

crates/biome_js_formatter/src/verbatim.rs (1)

118-121: Position wrapped correctly for verbatim formatting.

The concrete start position is now properly wrapped in Some(), maintaining source mapping for verbatim nodes whilst conforming to the new optional position API.

crates/biome_formatter/src/lib.rs (1)

1139-1163: Documentation updated to reflect new API.

The example now demonstrates the preferred pattern of using None for text positions, keeping the documentation current with the API changes.

crates/biome_js_semantic/src/format_semantic_model.rs (2)

2-2: Import additions support updated API usage.


108-182: Semantic model formatting updated consistently.

All text() calls now use None for positions, replacing the previous TextSize::default(). The semantic model display logic remains unchanged whilst adopting the new optional position API.

crates/biome_formatter/src/macros.rs (1)

387-403: Test updated to match new text position API.

The test now uses None instead of TextSize::default(), ensuring test compatibility with the refactored API whilst maintaining the same test behaviour.

crates/biome_css_formatter/src/css/value/url_value_raw.rs (1)

12-21: URL value position correctly wrapped.

The concrete start position is now wrapped in Some(), preserving source mapping for URL value tokens whilst conforming to the new optional position API.

crates/biome_css_formatter/src/comments.rs (1)

29-62: Doc comment formatting positions preserved.

Both text() calls now wrap source_offset with Some(), maintaining accurate source position tracking for doc comment lines whilst adopting the new optional position API.

crates/biome_css_formatter/src/verbatim.rs (1)

117-121: Verbatim node position wrapped correctly.

The concrete start position is now properly wrapped in Some(), maintaining source mapping for CSS verbatim nodes whilst conforming to the new optional position API.

crates/biome_formatter/src/printer/mod.rs (3)

142-148: LGTM – clean deferral mechanism.

The source position queuing avoids the indent-mapping issue mentioned in the comments. Well thought through.


319-397: Deferral logic correctly implemented.

The pending position is consumed at text emission time, source_position is advanced appropriately, and markers are emitted at the right boundaries. The refactoring achieves the stated goal of preventing enum bloat.


1160-1162: Correct to ignore SourcePosition during fits checking.

Source position tracking doesn't affect layout decisions. The explicit handling avoids unintended side effects.

crates/biome_formatter/src/builders.rs (3)

278-331: Well-designed source position helper.

The deduplication logic (lines 321–325) avoids redundant consecutive SourcePosition elements in the IR. Documentation is clear with good examples.


334-355: API change correctly implemented.

The Option<TextSize> parameter allows formatter-generated text (None) to be distinguished from source text (Some). The Format impl correctly uses the source_position() helper for deduplication.


382-404: Correct usage of the source_position helper.

Line 384 properly delegates to the helper, ensuring IR-level deduplication applies here as well.

}
}

if source_position.is_some() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it isn’t 100% correct to use text_len to calculate the source position of the second marker, because the text can be modified during formatting. However, if it doesn’t produce an error, I think it’s better to keep it as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really a user facing change, so this doesn't need a changeset.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could if we manage to increase the performance of the formatter

@ematipico
Copy link
Member

I don't know why, but the benchmarks are weird. If you open the dashboard, you'll see improvements up to 6% too.

@denbezrukov
Copy link
Contributor Author

I don't know why, but the benchmarks are weird. If you open the dashboard, you'll see improvements up to 6% too.

I guess the degradation makes sense, we now spend more time on allocation because we’re pushing extra elements. But I'm not sure about the improvement part, since we removed source_position to make room for text_width, yet the total layout size is still 24 because of padding, right?
I’m thinking about how we could implement caching or handle the source position other ways. Otherwise, I’m not sure if it really makes sense to merge this yet =(

@ematipico
Copy link
Member

ematipico commented Nov 9, 2025

I wonder if we can remove the Option and just use TextWidth, and conditionally check if the width is 0. This would allow us to remove the additional memory introduced by Option; however, I don't know if this has real impact on the memory layout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Project Area: project A-Type-Inference Area: type inference L-CSS Language: CSS L-Grit Language: GritQL L-HTML Language: HTML and super languages L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants