class Parser::Source::Comment::Associator

A processor which associates AST nodes with comments based on their location in source code. It may be used, for example, to implement rdoc-style processing.

@example

require 'parser/current'

ast, comments = Parser::CurrentRuby.parse_with_comments(<<-CODE)
# Class stuff
class Foo
  # Attr stuff
  # @see bar
  attr_accessor :foo
end
CODE

p Parser::Source::Comment.associate(ast, comments)
# => {
#   (class (const nil :Foo) ...) =>
#     [#<Parser::Source::Comment (string):1:1 "# Class stuff">],
#   (send nil :attr_accessor (sym :foo)) =>
#     [#<Parser::Source::Comment (string):3:3 "# Attr stuff">,
#      #<Parser::Source::Comment (string):4:3 "# @see bar">]
# }

@see {associate}

@!attribute skip_directives

Skip file processing directives disguised as comments.
Namely:

  * Shebang line,
  * Magic encoding comment.

@return [Boolean]

@api public