feat(css): add support for SCSS binary expressions in lexer and parser#9343
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdds SCSS-specific re-lexing and parser changes to treat leading Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
Merging this PR will degrade performance by 7.56%
Performance Changes
Comparing Footnotes
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_css_parser/src/syntax/scss/expression/mod.rs (1)
271-281: Consider adding a brief doc comment.The function works correctly, but a short rustdoc comment would clarify its purpose and side-effect nature for future maintainers.
📝 Suggested doc comment
+/// Re-lexes signed numeric tokens (e.g., `+5`, `-10px`) as separate operator +/// and value tokens when in a binary expression context. #[inline] fn re_lex_signed_numeric_as_scss_operator(p: &mut CssParser) {Based on learnings: "Use inline rustdoc documentation for rules, assists, and their options".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_css_parser/src/syntax/scss/expression/mod.rs` around lines 271 - 281, Add a short rustdoc comment above the function re_lex_signed_numeric_as_scss_operator explaining that it checks the current token for a numeric literal or dimension that begins with '+' or '-' and, if so, calls p.re_lex with CssReLexContext::ScssExpression to treat the sign as a SCSS operator (note the side effect of mutating the parser state via CssParser::re_lex). Keep it concise (one or two sentences), mention the conditions checked (CSS_NUMBER_LITERAL or is_at_any_dimension) and the mutation side effect.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_css_parser/src/syntax/scss/expression/mod.rs`:
- Around line 271-281: Add a short rustdoc comment above the function
re_lex_signed_numeric_as_scss_operator explaining that it checks the current
token for a numeric literal or dimension that begins with '+' or '-' and, if so,
calls p.re_lex with CssReLexContext::ScssExpression to treat the sign as a SCSS
operator (note the side effect of mutating the parser state via
CssParser::re_lex). Keep it concise (one or two sentences), mention the
conditions checked (CSS_NUMBER_LITERAL or is_at_any_dimension) and the mutation
side effect.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3052522f-8377-4656-a0e4-507a0c26b4f1
📒 Files selected for processing (1)
crates/biome_css_parser/src/syntax/scss/expression/mod.rs
#9343) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary
SCSS expressions with tight signed numeric tokens were parsed inconsistently in binary contexts
(for example 1+2, 10+10px, 10+10%).
This PR updates SCSS expression parsing so signed numeric-like tokens are handled as binary
operators where appropriate, and adds targeted parser/formatter coverage for these cases,
including unary/binary combinations like 1 - -2, 1 + -3, and 1 + +5.
Test Plan
Ran and passed: