Skip to content

Adjust AST range for ERB if-else-end tags#45

Open
tk0miya wants to merge 1 commit into
mainfrom
claude/adjust-erb-ast-range-QHlBe
Open

Adjust AST range for ERB if-else-end tags#45
tk0miya wants to merge 1 commit into
mainfrom
claude/adjust-erb-ast-range-QHlBe

Conversation

@tk0miya

@tk0miya tk0miya commented Jan 19, 2026

Copy link
Copy Markdown
Owner
  • Rename HtmlTag to Tag and unify handling for HTML and ERB tags
  • Add restore_source flag to Tag (false for ERB, true for HTML)
  • Record ERB tag info (if/else/end) in RubyRenderer
  • Adjust expression and end ranges in RuboCopASTTransformer
  • Keep keyword and else ranges unchanged to preserve RuboCop cop compatibility

@tk0miya tk0miya force-pushed the claude/adjust-erb-ast-range-QHlBe branch 9 times, most recently from 5d22ec0 to bc271f7 Compare January 19, 2026 18:55
- Add patch/erb_ast.rb with monkey patches for IfNode#keyword and Range#is?
  to extract Ruby keyword from ERB-wrapped source (e.g., "<% if %>" -> "if")
- Add on_if handler in RuboCopASTTransformer to restore ERB tag locations
- Record ERB tags (if/elsif/else/end) in RubyRenderer for AST restoration
- Handle elsif nodes which have no loc.end (only outer if has it)
- Add tests for if-elsif-else-end and multi-level elsif range adjustment
@tk0miya tk0miya force-pushed the claude/adjust-erb-ast-range-QHlBe branch from bc271f7 to e985da3 Compare January 19, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants