diff --git a/lib/rfactor/line_finder.rb b/lib/rfactor/line_finder.rb index 14f69e7..dccf0c3 100644 --- a/lib/rfactor/line_finder.rb +++ b/lib/rfactor/line_finder.rb @@ -1,7 +1,5 @@ module Rfactor - class LineFinder - def initialize(ast) @ast = ast end @@ -33,7 +31,15 @@ module Rfactor @last_method_line = exp.endline end exp - end + end + + def process_defs(exp) + current = exp.line + if current > @method_line && current < @line + @method_line = current + @last_method_line = exp.last.line + end + exp + end end - end diff --git a/spec/line_finder_spec.rb b/spec/line_finder_spec.rb index 262fd42..a8cb12c 100644 --- a/spec/line_finder_spec.rb +++ b/spec/line_finder_spec.rb @@ -33,6 +33,10 @@ describe Rfactor::LineFinder do @finder.method_lines(3).last.should == 6 end + it "it should find method end line even if the method is the last" do + @finder.method_lines(13).last.should == 14 + end + it "should find a class method start line" do @finder.method_lines(9).first.should == 8 end @@ -40,9 +44,4 @@ describe Rfactor::LineFinder do it "should find a class method end line" do @finder.method_lines(9).last.should == 10 end - - it "it should find method end line even if the method is the last" do - @finder.method_lines(13).last.should == 14 - end - end \ No newline at end of file