Class YARD::Handlers::Processor
In: lib/yard/handlers/processor.rb
Parent: Object

Iterates over all statements in a file and delegates them to the {Handlers::Base} objects that are registered to handle the statement.

This class is passed to each handler and keeps overall processing state. For example, if the {visibility} is set in a handler, all following statements will have access to this state. This allows "public", "protected" and "private" statements to be handled in classes and modules. In addition, the {namespace} can be set during parsing to control where objects are being created from.

@see Handlers::Base

Methods

Attributes

file  [RW]  @return [String] the filename
load_order_errors  [RW]  @return [Boolean] whether or not {Parser::LoadOrderError} is raised
namespace  [RW]  @return [CodeObjects::NamespaceObject] the current namespace
namespace_for_handler  [R]  @return [Hash] a list of registered parser type extensions @private @since 0.6.0
owner  [RW]  @return [CodeObjects::Base, nil] unlike the namespace, the owner
  is a non-namespace object that should be stored between statements.
  For instance, when parsing a method body, the {CodeObjects::MethodObject}
  is set as the owner, in case any extra method information is processed.
parser_type  [RW]  @return [Symbol] the parser type (:ruby, :ruby18, :c)
scope  [RW]  @return [Symbol] the current scope (class, instance)
visibility  [RW]  @return [Symbol] the current visibility (public, private, protected)

Public Class methods

Creates a new Processor for a file.

@param [String] file the name of the file that is being processed.

  uses '(stdin)' if file is nil.

@param [Boolean] load_order_error whether or not to raise {Parser::LoadOrderError}

  when a file has unresolved references that need to be parsed first.
  If these errors are raised, the processor will attempt to load all
  other files before continuing to parse the file.

@param [Symbol] parser_type the parser type (:ruby, :ruby18, :c) from

  the parser. Used to select the handler (since handlers are specific
  to a parser type).

Registers a new namespace for handlers of the given type. @since 0.6.0

Public Instance methods

Searches for all handlers in {Base.subclasses} that match the statement

@param statement the statement object to match. @return [Array<Base>] a list of handlers to process the statement with.

Processes a list of statements by finding handlers to process each one.

@param [Array] statements a list of statements @return [void]

[Validate]