Class: Literally::Processor
- Inherits:
-
BaseProcessor
- Object
- Prism::Visitor
- BaseProcessor
- Literally::Processor
- Defined in:
- lib/literally/processor.rb
Constant Summary
Constants inherited from BaseProcessor
Instance Attribute Summary
Attributes inherited from BaseProcessor
Instance Method Summary collapse
-
#visit_def_node(node) ⇒ Object
: (Prism::DefNode) -> void.
Methods inherited from BaseProcessor
Constructor Details
This class inherits a constructor from Literally::BaseProcessor
Instance Method Details
#visit_def_node(node) ⇒ Object
: (Prism::DefNode) -> void
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/literally/processor.rb', line 5 def visit_def_node(node) return super unless node.equal_loc return super unless node in { body: { body: [ Prism::CallNode[ block: Prism::BlockNode[ body: Prism::StatementsNode ] => block ] => call ] } } if (keywords = node.parameters&.keywords) foo = keywords.map do |keyword| loc = keyword.value.location @annotations << [loc.start_offset, loc.end_offset - loc.start_offset, "nil"] "#{keyword.name}: #{keyword.value.slice}" end.join(", ") end @annotations << [ start = node.rparen_loc.start_offset + 1, block.opening_loc.end_offset - start, ";binding.assert(#{foo});__literally_returns__ = (;" ] @annotations << [ block.closing_loc.start_offset, 0, ";);binding.assert(__literally_returns__: #{call.name});__literally_returns__;" ] end |