+
Skip to content

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Oct 3, 2025

Summary

Renames EmbeddedSnippets to AnyEmbeddedSnippet and EmbeddedLanguageContent to EmbeddedSnippet.

Also applied my own suggestion to return references from the as_*_embedded_snippet() methods, since I touched those methods anyway, so this shouldn't cause additional merge conflicts.

Test Plan

Greenness.

Docs

N/A

Copy link

changeset-bot bot commented Oct 3, 2025

⚠️ No Changeset found

Latest commit: 5d47e57

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions bot added the A-Project Area: project label Oct 3, 2025
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

The PR renames and consolidates embedded-content types across the service: EmbeddedLanguageContent and EmbeddedSnippets are replaced by EmbeddedSnippet and AnyEmbeddedSnippet. HTML file handlers now return EmbeddedSnippet for script/style/JSON parsing. Workspace document structures and accessors are updated to store and expose AnyEmbeddedSnippet and EmbeddedSnippet, with expanded fields (element/content ranges, offset, file_source_index). Re-exports in workspace and mod are adjusted, and server paths now produce/consume AnyEmbeddedSnippet. ParseEmbedResult.nodes switches to Vec<(AnyEmbeddedSnippet, DocumentFileSource)>. No behavioural changes are introduced beyond type and field propagation.

Possibly related PRs

Suggested labels

A-Project, A-Core, L-HTML, L-JavaScript, L-CSS, L-JSON

Suggested reviewers

  • ematipico

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% 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 accurately references one of the key renames in the changeset and clearly indicates a terminology update, though it omits the corresponding EmbeddedLanguageContent to EmbeddedSnippet change.
Description Check ✅ Passed The description clearly summarises the renaming of EmbeddedSnippets to AnyEmbeddedSnippet, EmbeddedLanguageContent to EmbeddedSnippet, and notes the reference changes to the as_*_embedded_snippet() methods, matching the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 (3)
crates/biome_service/src/workspace/server.rs (1)

500-506: Return type update looks good; drop an unnecessary clone in lint path

  • get_language_snippets now returns Vec — good.
  • In pull_diagnostics, parse() already returns an owned AnyParse; the trailing .clone() is redundant.

Apply:

-                    parse: embedded_node.parse().clone(),
+                    parse: embedded_node.parse(),

Also applies to: 1416-1421

crates/biome_service/src/file_handlers/html.rs (1)

469-502: Optional: factor shared snippet-building logic

The three parse_embedded_* functions share identical child extraction and EmbeddedSnippet::new patterns. Consider a small helper to reduce duplication and keep future fixes in one place.

Also applies to: 508-534

crates/biome_service/src/workspace/document.rs (1)

215-216: Remove redundant clone when preparing format nodes

parse() already returns an owned AnyParse (cloned from the snippet). No need to clone again.

-            .map(|node| FormatEmbedNode {
-                range: node.content_range(),
-                source: get_file_source(node.file_source_index()),
-                node: node.parse().clone(),
-            })
+            .map(|node| FormatEmbedNode {
+                range: node.content_range(),
+                source: get_file_source(node.file_source_index()),
+                node: node.parse(),
+            })

Also applies to: 223-231

📜 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 357b8f7 and 5d47e57.

📒 Files selected for processing (5)
  • crates/biome_service/src/file_handlers/html.rs (7 hunks)
  • crates/biome_service/src/file_handlers/mod.rs (2 hunks)
  • crates/biome_service/src/workspace.rs (1 hunks)
  • crates/biome_service/src/workspace/document.rs (5 hunks)
  • crates/biome_service/src/workspace/server.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/workspace.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/workspace.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/workspace.rs
crates/biome_service/src/workspace.rs

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

Workspace trait implementation entry point is located at src/workspace.rs

Files:

  • crates/biome_service/src/workspace.rs
🧠 Learnings (1)
📚 Learning: 2025-10-02T13:00:18.232Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T13:00:18.232Z
Learning: Applies to crates/biome_service/src/workspace.rs : `Workspace` trait implementation entry point is located at src/workspace.rs

Applied to files:

  • crates/biome_service/src/workspace.rs
🧬 Code graph analysis (2)
crates/biome_service/src/file_handlers/html.rs (2)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • DocumentFileSource (9365-9373)
crates/biome_service/src/workspace/document.rs (1)
  • new (150-164)
crates/biome_service/src/file_handlers/mod.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • DocumentFileSource (9365-9373)
⏰ 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). (7)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: autofix
🔇 Additional comments (11)
crates/biome_service/src/workspace/server.rs (2)

18-18: Type rename wired in

Importing AnyEmbeddedSnippet from document is correct and aligns with the new API.


516-536: parse_embedded_language_snippets now returns AnyEmbeddedSnippet

Signature and body match the new ParseEmbedResult element type. Setting file_source_index before pushing is spot‑on.

crates/biome_service/src/workspace.rs (1)

58-58: Public re‑exports updated correctly

AnyEmbeddedSnippet and EmbeddedSnippet are the right surface types now.

crates/biome_service/src/file_handlers/mod.rs (2)

14-16: API import aligns with workspace changes

Bringing AnyEmbeddedSnippet into scope is correct.


465-466: ParseEmbedResult uses AnyEmbeddedSnippet

Type switch is consistent with producers and consumers.

crates/biome_service/src/file_handlers/html.rs (3)

7-7: Switch to EmbeddedSnippet import

Matches the new embedded content type. All good.


422-463: parse_embedded_script: type and construction look right

  • Return type updated to EmbeddedSnippet.
  • element/content ranges and offset are correctly passed to EmbeddedSnippet::new.

491-496: Consistent snippet construction for CSS/JSON

Constructor usage mirrors the JS path with correct ranges and offsets.

Also applies to: 526-531

crates/biome_service/src/workspace/document.rs (3)

15-19: Enum and conversions updated cleanly

AnyEmbeddedSnippet variants and From<EmbeddedSnippet<...>> impls are tidy and match usage across the crate.

Also applies to: 21-37


39-119: as_ methods now return references*

Good change: avoids needless cloning of embedded snippets. The remaining accessors (parse, ranges, offsets, file_source_index) are consistent.


126-146: EmbeddedSnippet structure and ctor are sound

Fields and constructor parameters fit the embedded use‑case (element/content ranges + offset). node() and into_serde_diagnostics() correctly apply the content offset.

Also applies to: 148-186

@ematipico
Copy link
Member

ematipico commented Oct 3, 2025

Also applied my own suggestion to return references from the as_*_embedded_snippet()

D'oh! I already did that in my other PR 😅

@arendjr arendjr merged commit a1d4b6b into biomejs:next Oct 3, 2025
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载