Module: RuboCop::Cop::RSpec::CommentsHelp
- Includes:
- FinalEndLocation
- Included in:
- RSpec::Corrector::MoveNode
- Defined in:
- lib/rubocop/cop/rspec/mixin/comments_help.rb
Overview
Help methods for working with nodes containing comments.
Instance Method Summary collapse
- #begin_pos_with_comment(node) ⇒ Object
- #buffer ⇒ Object
- #end_line_position(node) ⇒ Object
- #source_range_with_comment(node) ⇒ Object
- #start_line_position(node) ⇒ Object
Methods included from FinalEndLocation
Instance Method Details
#begin_pos_with_comment(node) ⇒ Object
17 18 19 20 21 |
# File 'lib/rubocop/cop/rspec/mixin/comments_help.rb', line 17 def begin_pos_with_comment(node) first_comment = processed_source.ast_with_comments[node].first start_line_position(first_comment || node) end |
#buffer ⇒ Object
32 33 34 |
# File 'lib/rubocop/cop/rspec/mixin/comments_help.rb', line 32 def buffer processed_source.buffer end |
#end_line_position(node) ⇒ Object
27 28 29 30 |
# File 'lib/rubocop/cop/rspec/mixin/comments_help.rb', line 27 def end_line_position(node) end_line = buffer.line_for_position(final_end_location(node).end_pos) buffer.line_range(end_line) end |
#source_range_with_comment(node) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rubocop/cop/rspec/mixin/comments_help.rb', line 10 def source_range_with_comment(node) begin_pos = begin_pos_with_comment(node).begin_pos end_pos = end_line_position(node).end_pos Parser::Source::Range.new(buffer, begin_pos, end_pos) end |
#start_line_position(node) ⇒ Object
23 24 25 |
# File 'lib/rubocop/cop/rspec/mixin/comments_help.rb', line 23 def start_line_position(node) buffer.line_range(node.loc.line) end |