Class: Evilution::Mutator::Operator::SuperclassRemoval
- Defined in:
- lib/evilution/mutator/operator/superclass_removal.rb
Defined Under Namespace
Classes: ClassFinder
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
clear_parse_cache!, #initialize, operator_name, parsed_tree_for
Constructor Details
This class inherits a constructor from Evilution::Mutator::Base
Instance Method Details
#call(subject, filter: nil) ⇒ Object
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 |
# File 'lib/evilution/mutator/operator/superclass_removal.rb', line 8 def call(subject, filter: nil) @subject = subject @file_source = File.read(subject.file_path) @mutations = [] @filter = filter tree = self.class.parsed_tree_for(subject.file_path, @file_source) enclosing = find_enclosing_class(tree, subject.line_number) return @mutations unless enclosing return @mutations unless enclosing.superclass first_method_line = find_first_method_line(enclosing) return @mutations unless first_method_line == subject.line_number name_end = enclosing.constant_path.location.start_offset + enclosing.constant_path.location.length superclass_end = enclosing.superclass.location.start_offset + enclosing.superclass.location.length add_mutation( offset: name_end, length: superclass_end - name_end, replacement: "", node: enclosing ) @mutations end |