Class: ActiveMutator::Operators::StatementDeletion
- Defined in:
- lib/active_mutator/operators/statement_deletion.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#edits(node) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/active_mutator/operators/statement_deletion.rb', line 4 def edits(node) return [] unless node.is_a?(Prism::StatementsNode) return [] if node.body.size < 2 # A heredoc's body lives on the lines after the statement, outside the # node's byte range, so deleting the range leaves the body behind as # unparseable text. Skip those statements. node.body.reject { |stmt| contains_heredoc?(stmt) }.map do |stmt| edit(loc_range(stmt.location), "", "delete `#{stmt.slice.lines.first.strip}`") end end |