refactor: replace send/respond_to? and improve remark roundtrip#306
Merged
Conversation
Replace all private send calls with public_send across remark_attacher, model_visitor, and search_engine. Replace respond_to? with explicit type checks (is_a?) for better type safety and encapsulation. Files changed: - remark_attacher: send -> public_send, respond_to? -> node_has_remarks? - model_visitor: send -> public_send for attribute iteration - search_engine: send -> public_send for collection access - expression_builder: respond_to?(:empty?) -> is_a?(Array)
Add format_end_scope_remark to Function, Procedure, Rule, SubtypeConstraint, and Entity (unconditional) formatters. Previously only Type emitted these remarks, losing section marker comments attached to the last child of each declaration group. Remove dead format_scope_remarks method (60 lines of unused code). Update formatted fixture files to reflect improved remark output.
Add regression specs for: CASE statements, formal parameters with multiple IDs, SELECT types, interval in WHERE, nested functions, WhereRule remark attachment, and shorthand variable declarations. Verify that tail remarks correctly attach to WhereRule nodes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Code quality and remark formatting improvements:
Code quality
sendcalls withpublic_send(respects encapsulation) acrossremark_attacher,model_visitor,search_enginerespond_to?with explicitis_a?type checks for better type safetynode_has_remarks?helper checkingIdentifier,RemarkItem, andInterfacedItemRemark formatting
format_end_scope_remarkto all declaration types (Function, Procedure, Rule, SubtypeConstraint, Entity)format_scope_remarksmethod (60 lines of unused recursive code)Specs
Test plan
bundle exec rspec spec/expressir/— 1363 examples, 0 failuresbundle exec rubocop— no offenses