Class: Spoom::Deadcode::Remover
- Inherits:
-
Object
- Object
- Spoom::Deadcode::Remover
- Defined in:
- lib/spoom/deadcode/remover.rb
Defined Under Namespace
Classes: Error, NodeContext, NodeFinder, NodeRemover
Instance Method Summary collapse
-
#initialize(context) ⇒ Remover
constructor
: (Context context) -> void.
-
#remove_location(kind, location) ⇒ Object
: (Definition::Kind? kind, Location location) -> String.
Constructor Details
#initialize(context) ⇒ Remover
: (Context context) -> void
10 11 12 |
# File 'lib/spoom/deadcode/remover.rb', line 10 def initialize(context) @context = context end |
Instance Method Details
#remove_location(kind, location) ⇒ Object
: (Definition::Kind? kind, Location location) -> String
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/spoom/deadcode/remover.rb', line 15 def remove_location(kind, location) file = location.file unless @context.file?(file) raise Error, "Can't find file at #{file}" end node_remover = NodeRemover.new(@context.read(file), kind, location) node_remover.apply_edit node_remover.new_source end |