refactor: migrate my-blocks converter to register pattern with dynamic call handler #398
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
Successfully implemented a hybrid approach for my-blocks.js that maintains special language construct handlers while adopting the register pattern for procedure calls. This innovative solution addresses the unique two-phase architecture of custom block handling.
Implementation Details
Infrastructure Changes (index.js)
registerDynamicCallMethod()- Runtime procedure call registration systemcallMethod()prioritization - Dynamic handlers checked before static lookupMy-blocks Converter Changes (my-blocks.js)
register()function - Uses dynamic call handler for procedure callsonVarandonDefs- Special language construct handlers remain unchangedTechnical Innovation
This is the first converter to implement:
onDefsbuilds procedure registry, dynamic handler uses it for callsKey Benefits
Files Modified
src/lib/ruby-to-blocks-converter/index.js- Added dynamic call handler infrastructuresrc/lib/ruby-to-blocks-converter/my-blocks.js- Migrated to hybrid register patternTest Coverage
Test Plan
def self.made_block(arg1, arg2) ... endcreates proper blocksmade_block(12, true)resolves to correct procedure_call blocksThis completes the my-blocks.js refactoring as part of GitHub Issue #394, using an innovative hybrid approach that respects the unique architecture requirements of custom block handling while maintaining consistency with the register pattern used by other converters.
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]