Class: Evilution::Mutator::Operator::StringLiteral
- Defined in:
- lib/evilution/mutator/operator/string_literal.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(skip_heredoc_literals: false, **rest) ⇒ StringLiteral
constructor
A new instance of StringLiteral.
- #visit_interpolated_string_node(node) ⇒ Object
- #visit_string_node(node) ⇒ Object
Methods inherited from Base
#call, clear_parse_cache!, operator_name, parsed_tree_for
Constructor Details
#initialize(skip_heredoc_literals: false, **rest) ⇒ StringLiteral
Returns a new instance of StringLiteral.
6 7 8 9 |
# File 'lib/evilution/mutator/operator/string_literal.rb', line 6 def initialize(skip_heredoc_literals: false, **rest) super(**rest) @skip_heredoc_literals = skip_heredoc_literals end |
Instance Method Details
#visit_interpolated_string_node(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/evilution/mutator/operator/string_literal.rb', line 11 def visit_interpolated_string_node(node) return super unless node.heredoc? return if @skip_heredoc_literals node.parts.each do |part| next if part.is_a?(Prism::StringNode) visit(part) end end |
#visit_string_node(node) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/evilution/mutator/operator/string_literal.rb', line 22 def visit_string_node(node) return super if node.heredoc? replacement = node.content.empty? ? '"mutation"' : '""' add_mutation( offset: node.location.start_offset, length: node.location.length, replacement: replacement, node: node ) add_mutation( offset: node.location.start_offset, length: node.location.length, replacement: "nil", node: node ) super end |