class SyntaxTree::Index::EntryComments
This class handles parsing comments from Ruby source code in the case that we use the instruction sequence backend. Because the instruction sequence backend doesn’t provide comments (since they are dropped) we provide this interface to lazily parse them out.
Attributes
Public Class Methods
Source
# File lib/syntax_tree/index.rb, line 156 def initialize(file_comments, location) @file_comments = file_comments @location = location end
Public Instance Methods
Source
# File lib/syntax_tree/index.rb, line 161 def each(&block) line = location.line - 1 result = [] while line >= 0 && (comment = file_comments.comments[line]) result.unshift(comment) line -= 1 end result.each(&block) end