Skip to content

feat(angular): support @-blocks - #160

Open
Shinigami92 wants to merge 7 commits into
mainfrom
feat-support-angular-blocks
Open

feat(angular): support @-blocks#160
Shinigami92 wants to merge 7 commits into
mainfrom
feat-support-angular-blocks

Conversation

@Shinigami92

@Shinigami92 Shinigami92 commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added full Angular-style @‑block support across parsing, formatting, compilation, and validation: @let, @if/@else if/@else, @for/@empty, @switch/@case/@default, @defer (placeholder/loading/error + optional triggers), and @boundary/@catch.
  • Documentation
    • Updated README and added Angular HSML examples, including supported constructs and compiled output; marked Angular @‑block support complete.
  • Tests
    • Expanded formatter/parser/compiler/validator regression coverage and updated invalid-input strings in CLI/LSP/wasm tests.

@Shinigami92 Shinigami92 self-assigned this Jun 12, 2026
@Shinigami92 Shinigami92 added the c: feature Request for new feature label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Shinigami92, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cbb9c2fc-569f-4b43-9752-ee4ea412e837

📥 Commits

Reviewing files that changed from the base of the PR and between e0093aa and 80ad053.

⛔ Files ignored due to path filters (6)
  • tests/snapshots/compiler__it_should_pretty_print_boundary.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_pretty_print_defer.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_pretty_print_for_empty.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_pretty_print_if_else.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_pretty_print_switch.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_pretty_print_switch_with_default_never.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/validate/tests/validate.rs
  • tests/compiler.rs
📝 Walkthrough

Walkthrough

Adds Angular @-block parsing, AST, formatting, compilation, validation, docs, examples, and related test updates across HSML.

Changes

Angular @-block Support

Layer / File(s) Summary
Angular AST and core parser
src/parser/angular/mod.rs, src/parser/angular/node.rs, src/parser/angular/process.rs, src/parser/angular/tests/node.rs
Defines Angular AST node types, parsing helpers, and parsers for @let, @if, @for, @switch, @defer, and @boundary, with parser tests for success and error cases.
Parser integration and child parsing refactor
src/parser/children.rs, src/parser/mod.rs, src/parser/parse.rs, src/parser/tag/node.rs
Adds shared child parsing, exposes Angular parser modules, adds HsmlNode::Angular, dispatches @ input through angular_node, and refactors tag children to use the shared parser.
Angular node formatter
src/formatter/mod.rs, src/formatter/tests/format.rs
Formats Angular nodes and adds formatter tests for branching, loops, switches, defer blocks, boundary blocks, and blank-line preservation.
Angular node compiler
src/compiler/mod.rs, tests/compiler.rs
Compiles Angular AST nodes into Angular template syntax and adds compiler tests for generated and pretty-printed output.
Angular node validator
src/validate/mod.rs, src/validate/tests/validate.rs
Extends validation to recurse through Angular block bodies and adds tests for diagnostics inside Angular control structures.
Documentation and examples
README.md, examples/angular.hsml, examples/angular.html
Documents Angular @-block support and adds example HSML plus compiled Angular output.
Test infrastructure: invalid input markers
tests/cli.rs, tests/compiler.rs, tests/lsp.rs, tests/wasm.rs
Updates invalid fixture markers from @@@-based strings to %%%-based strings across multiple test suites.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • hsml-lab/hsml#16: Shared indentation-handling changes overlap with the new src/parser/children.rs parsing flow.
  • hsml-lab/hsml#39: Both PRs extend src/compiler/mod.rs dispatch for a new HsmlNode variant.
  • hsml-lab/hsml#41: The main parser loop changes overlap with parser-entry refactoring in src/parser/parse.rs.

Poem

A rabbit hopped through @-blocks tonight,
With @if, @for, and @switch in sight.
@defer dozed while @boundary stood near,
HSML sang Angular—hop, hop, cheer! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Angular @-block support.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-support-angular-blocks

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/compiler.rs (1)

21-146: ⚡ Quick win

Add at least one pretty-mode Angular compiler assertion.

compile_angular_node and compile_block_body now have separate pretty-print branches, but every new Angular compiler test here goes through compile_content_core, so only compact output is exercised. A small pretty-mode regression for something like @if plus @switch would protect the new indentation/newline path before merge.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/compiler.rs` around lines 21 - 146, Add a new test in the same
tests/compiler.rs that exercises the pretty-print branch for Angular output (so
the new pretty-mode code paths in compile_angular_node and compile_block_body
are covered) — create a small input containing an Angular combination such as an
`@if` followed by an `@switch`, call the pretty-mode compiler helper (invoke
whatever test helper triggers pretty printing — e.g., a compile_content_pretty
or compile_content_core with a pretty=true flag) and assert the expected
pretty-formatted HTML string; reference compile_angular_node and
compile_block_body as the targeted code paths and keep the test similar in style
to existing ones.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/compiler.rs`:
- Around line 21-146: Add a new test in the same tests/compiler.rs that
exercises the pretty-print branch for Angular output (so the new pretty-mode
code paths in compile_angular_node and compile_block_body are covered) — create
a small input containing an Angular combination such as an `@if` followed by an
`@switch`, call the pretty-mode compiler helper (invoke whatever test helper
triggers pretty printing — e.g., a compile_content_pretty or
compile_content_core with a pretty=true flag) and assert the expected
pretty-formatted HTML string; reference compile_angular_node and
compile_block_body as the targeted code paths and keep the test similar in style
to existing ones.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1588ec5d-c440-4670-aa98-e3db8ded7f26

📥 Commits

Reviewing files that changed from the base of the PR and between cd96d81 and efd1995.

📒 Files selected for processing (21)
  • README.md
  • examples/angular.hsml
  • examples/angular.html
  • src/compiler/mod.rs
  • src/formatter/mod.rs
  • src/formatter/tests/format.rs
  • src/parser/angular/mod.rs
  • src/parser/angular/node.rs
  • src/parser/angular/process.rs
  • src/parser/angular/tests/mod.rs
  • src/parser/angular/tests/node.rs
  • src/parser/children.rs
  • src/parser/mod.rs
  • src/parser/parse.rs
  • src/parser/tag/node.rs
  • src/validate/mod.rs
  • src/validate/tests/validate.rs
  • tests/cli.rs
  • tests/compiler.rs
  • tests/lsp.rs
  • tests/wasm.rs

Comment thread src/formatter/mod.rs
@Shinigami92
Shinigami92 force-pushed the feat-support-angular-blocks branch from efd1995 to 8b387b4 Compare June 12, 2026 12:02
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

@Shinigami92
Shinigami92 force-pushed the feat-support-angular-blocks branch from 8c42c0e to e0093aa Compare June 29, 2026 17:23
@Shinigami92
Shinigami92 marked this pull request as draft June 29, 2026 17:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/validate/tests/validate.rs (1)

75-82: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use ErrorCode::DuplicateClass.code() instead of "W002".

Line 81 re-hardcodes the diagnostic contract that the rest of this file already references through ErrorCode. Reusing the enum keeps the helper from drifting if the code changes later.

Suggested change
 fn dup_class_count(source: &str) -> usize {
     let (_, ast) = parse(Span::new(source)).unwrap();
     validate(&ast, source)
         .iter()
-        .filter(|d| d.code.as_deref() == Some("W002"))
+        .filter(|d| d.code.as_deref() == Some(ErrorCode::DuplicateClass.code()))
         .count()
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/validate/tests/validate.rs` around lines 75 - 82, The dup_class_count
helper is hardcoding the duplicate-class diagnostic string instead of using the
shared ErrorCode contract. Update the filter in dup_class_count to compare
against ErrorCode::DuplicateClass.code() so the test stays aligned with the
validator’s diagnostic symbol and does not drift if the code changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/validate/tests/validate.rs`:
- Around line 75-82: The dup_class_count helper is hardcoding the
duplicate-class diagnostic string instead of using the shared ErrorCode
contract. Update the filter in dup_class_count to compare against
ErrorCode::DuplicateClass.code() so the test stays aligned with the validator’s
diagnostic symbol and does not drift if the code changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a10b46ef-15fa-4d5c-be2e-9f1d3d664bbd

📥 Commits

Reviewing files that changed from the base of the PR and between 8b387b4 and e0093aa.

📒 Files selected for processing (21)
  • README.md
  • examples/angular.hsml
  • examples/angular.html
  • src/compiler/mod.rs
  • src/formatter/mod.rs
  • src/formatter/tests/format.rs
  • src/parser/angular/mod.rs
  • src/parser/angular/node.rs
  • src/parser/angular/process.rs
  • src/parser/angular/tests/mod.rs
  • src/parser/angular/tests/node.rs
  • src/parser/children.rs
  • src/parser/mod.rs
  • src/parser/parse.rs
  • src/parser/tag/node.rs
  • src/validate/mod.rs
  • src/validate/tests/validate.rs
  • tests/cli.rs
  • tests/compiler.rs
  • tests/lsp.rs
  • tests/wasm.rs
✅ Files skipped from review due to trivial changes (4)
  • src/parser/angular/tests/mod.rs
  • tests/wasm.rs
  • tests/lsp.rs
  • README.md
🚧 Files skipped from review as they are similar to previous changes (14)
  • src/parser/angular/mod.rs
  • src/formatter/tests/format.rs
  • src/parser/parse.rs
  • examples/angular.hsml
  • src/validate/mod.rs
  • src/parser/angular/process.rs
  • src/parser/mod.rs
  • src/parser/children.rs
  • src/formatter/mod.rs
  • src/parser/tag/node.rs
  • tests/compiler.rs
  • src/compiler/mod.rs
  • tests/cli.rs
  • src/parser/angular/node.rs

@Shinigami92
Shinigami92 marked this pull request as ready for review June 29, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant