Module: RuboCop::Cop::CommentsHelp

Overview

Help methods for working with nodes containing comments.

Instance Method Summary collapse

Instance Method Details

#contains_comments?(node) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
# File 'lib/rubocop/cop/mixin/comments_help.rb', line 14

def contains_comments?(node)
  start_line = node.source_range.line
  end_line = find_end_line(node)

  processed_source.each_comment_in_lines(start_line...end_line).any?
end

#source_range_with_comment(node) ⇒ Object



7
8
9
10
11
12
# File 'lib/rubocop/cop/mixin/comments_help.rb', line 7

def source_range_with_comment(node)
  begin_pos = begin_pos_with_comment(node)
  end_pos = end_position_for(node)

  Parser::Source::Range.new(buffer, begin_pos, end_pos)
end