class SyntaxTree::Statements
def attach_comments(parser, start_char, end_char)
Experimental RBS support (using type sampling data from the type_fusion
project).
def attach_comments: (SyntaxTree::Parser parser, Integer start_char, Integer end_char) -> untyped
This signature was generated using 12 samples from 1 application.
found while this statements list was being parsed and add them into the
As efficiently as possible, gather up all of the comments that have been
def attach_comments(parser, start_char, end_char) parser_comments = parser.comments comment_index = 0 body_index = 0 while comment_index < parser_comments.size comment = parser_comments[comment_index] location = comment.location if !comment.inline? && (start_char <= location.start_char) && (end_char >= location.end_char) && !comment.ignore? while (node = body[body_index]) && ( node.is_a?(VoidStmt) || node.location.start_char < location.start_char ) body_index += 1 end if body_index != 0 && body[body_index - 1].location.start_char < location.start_char && body[body_index - 1].location.end_char > location.start_char # The previous node entirely encapsules the comment, so we don't # want to attach it here since it will get attached normally. This # is mostly in the case of hash and array literals. comment_index += 1 else parser_comments.delete_at(comment_index) body.insert(body_index, comment) end else comment_index += 1 end end end