Skip to content

Conversation

@yhk1038
Copy link
Contributor

@yhk1038 yhk1038 commented Dec 26, 2025

Summary

Parser improvements and legacy code removal based on Reddit feedback

Issues Fixed

RBS Generation Improvements

  • Visibility modifiers now reflected in RBS output (private defprivate def in RBS)
  • RBS does not support protected, so it is treated as public (Protected methods ruby/rbs#579)

Legacy Code Removal

  • Removed TRuby::RBSGenerator (using IR::RBSGenerator)
  • Removed LegacyCompiler, LegacyParser classes
  • Removed use_ir, use_combinator parameters (always use IR)
  • Net 350 lines of code reduced

Test plan

  • Unit tests: visibility parsing (parser_spec.rb)
  • Unit tests: heredoc/block comment detection (heredoc_detector_spec.rb)
  • Unit tests: default value preservation (type_erasure_spec.rb)
  • E2E tests: RBS visibility generation (class_rbs_generation_spec.rb)
  • All tests passing (957 examples, 0 failures)

Closes #17, Closes #18, Closes #21

Add visibility modifier support for method definitions:
- Parse `private def`, `protected def`, `public def` syntax
- Extract visibility info and include in parse result
- Preserve visibility keywords during type erasure
- Add VISIBILITY_PATTERN constant for reuse

Fixes #17
Add HeredocDetector to identify heredoc regions and skip them during
parsing. This prevents def patterns inside heredoc from being
incorrectly recognized as method definitions.

- Add HeredocDetector class with detect() and inside_heredoc?() methods
- Support <<DELIM, <<-DELIM, <<~DELIM, <<'DELIM', <<"DELIM" syntax
- Integrate heredoc detection in Parser.parse()
- Add comprehensive tests for HeredocDetector

Fixes #18
Add private/protected visibility prefix to generated RBS method
signatures. Both TRuby::RBSGenerator and TRuby::IR::RBSGenerator
now output correct RBS format like 'private def method: () -> Type'.

Related to #17
- Pass visibility from parser to IR MethodDef nodes
- Add private prefix to RBS output (RBS doesn't support protected)
- Add E2E tests for visibility in RBS and compiled Ruby
- Update unit tests for RBS generator visibility handling

RBS only supports private, not protected (ruby/rbs#579)

Related to #17
Extend HeredocDetector to also detect Ruby block comments.
Parser now correctly ignores def patterns inside =begin/=end blocks.

Related to #18
Remove legacy components that are no longer needed:
- Remove TRuby::RBSGenerator (use IR::RBSGenerator)
- Remove LegacyCompiler class
- Remove LegacyParser class
- Remove use_ir parameter from Compiler (always use IR)
- Remove use_combinator parameter from Parser (always enabled)

This simplifies the codebase by eliminating dual-path maintenance.
@yhk1038 yhk1038 merged commit 24d9870 into main Dec 26, 2025
9 checks passed
@yhk1038 yhk1038 deleted the fix/parser-improvements branch December 26, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants