Class: YARD::Handlers::Ruby::Base Abstract
- Inherits:
-
Base
- Object
- Base
- YARD::Handlers::Ruby::Base
- Extended by:
- Parser::Ruby
- Includes:
- Parser::Ruby
- Defined in:
- lib/yard/handlers/ruby/base.rb
Overview
See Base for subclassing information.
This is the base handler class for the new-style (1.9) Ruby parser. All handlers that subclass this base class will be used when the new-style parser is used. For implementing legacy handlers, see Legacy::Base.
Direct Known Subclasses
AliasHandler, AttributeHandler, ClassConditionHandler, ClassHandler, ClassVariableHandler, CommentHandler, ConstantHandler, DSLHandler, ExceptionHandler, MethodConditionHandler, MethodHandler, MixinHandler, ModuleFunctionHandler, ModuleHandler, PrivateConstantHandler, VisibilityHandler, YieldHandler
Constant Summary
Constant Summary
Constants included from CodeObjects
CodeObjects::BUILTIN_ALL, CodeObjects::BUILTIN_CLASSES, CodeObjects::BUILTIN_EXCEPTIONS, CodeObjects::BUILTIN_EXCEPTIONS_HASH, CodeObjects::BUILTIN_MODULES, CodeObjects::CONSTANTMATCH, CodeObjects::CSEP, CodeObjects::CSEPQ, CodeObjects::ISEP, CodeObjects::ISEPQ, CodeObjects::METHODMATCH, CodeObjects::METHODNAMEMATCH, CodeObjects::NAMESPACEMATCH, CodeObjects::NSEP, CodeObjects::NSEPQ
Instance Attribute Summary (collapse)
-
- (Object) extra_state
inherited
from Base
readonly
Returns the value of attribute extra_state.
-
- (Object) globals
inherited
from Base
readonly
Returns the value of attribute globals.
-
- (Object) namespace
inherited
from Base
Returns the value of attribute namespace.
-
- (Object) owner
inherited
from Base
Returns the value of attribute owner.
-
- (Processor) parser
inherited
from Base
readonly
The processor object that manages all global state during handling.
-
- (Object) scope
inherited
from Base
Returns the value of attribute scope.
-
- (Object) statement
inherited
from Base
readonly
The statement object currently being processed.
-
- (Object) visibility
inherited
from Base
Returns the value of attribute visibility.
Statement Matcher Extensions (collapse)
-
+ (void) meta_type(type)
Matcher for handling a node with a specific meta-type.
-
+ (void) method_call(name = nil)
Matcher for handling any type of method call.
Testing for a Handler (collapse)
-
+ (Boolean) handles?(node)
Whether or not an Parser::Ruby::AstNode object should be handled by this handler.
Parsing an Inner Block (collapse)
Macro Handling (collapse)
Methods included from Parser::Ruby
Constructor Details
This class inherits a constructor from YARD::Handlers::Base
Instance Attribute Details
- (Object) extra_state (readonly) Originally defined in class Base
Returns the value of attribute extra_state
- (Object) globals (readonly) Originally defined in class Base
Returns the value of attribute globals
- (Object) namespace Originally defined in class Base
Returns the value of attribute namespace
- (Object) owner Originally defined in class Base
Returns the value of attribute owner
- (Processor) parser (readonly) Originally defined in class Base
Returns the processor object that manages all global state during handling.
- (Object) scope Originally defined in class Base
Returns the value of attribute scope
- (Object) statement (readonly) Originally defined in class Base
Returns the statement object currently being processed. Usually refers to one semantic language statement, though the strict definition depends on the parser used.
- (Object) visibility Originally defined in class Base
Returns the value of attribute visibility
Class Method Details
+ (Boolean) handles?(node)
Returns whether or not an Parser::Ruby::AstNode object should be handled by this handler
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/yard/handlers/ruby/base.rb', line 110 def handles?(node) handlers.any? do |a_handler| case a_handler when Symbol a_handler == node.type when String node.source == a_handler when Regexp node.source =~ a_handler when Parser::Ruby::AstNode a_handler == node when HandlesExtension a_handler.matches?(node) end end end |
+ (void) meta_type(type)
This method returns an undefined value.
Matcher for handling a node with a specific meta-type. An Parser::Ruby::AstNode has a Parser::Ruby::AstNode#type to define its type but can also be associated with a set of types. For instance, :if and :unless are both of the meta-type :condition.
A meta-type is any method on the Parser::Ruby::AstNode class ending in "?", though you should not include the "?" suffix in your declaration. Some examples are: "condition", "call", "literal", "kw", "token", "ref".
102 103 104 |
# File 'lib/yard/handlers/ruby/base.rb', line 102 def (type) TestNodeWrapper.new(type.to_s + "?") end |
+ (void) method_call(name = nil)
This method returns an undefined value.
Matcher for handling any type of method call. Method calls can be expressed by many Parser::Ruby::AstNode types depending on the syntax with which it is called, so YARD allows you to use this matcher to simplify matching a method call.
83 84 85 |
# File 'lib/yard/handlers/ruby/base.rb', line 83 def method_call(name = nil) MethodCallWrapper.new(name ? name.to_s : nil) end |
Instance Method Details
- (Object) call_params
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/yard/handlers/ruby/base.rb', line 141 def call_params return [] unless statement.respond_to?(:parameters) statement.parameters(false).compact.map do |param| if param.type == :list param.map {|n| n.jump(:ident, :kw, :tstring_content).source } else param.jump(:ident, :kw, :tstring_content).source end end.flatten end |
- (Object) caller_method
152 153 154 155 156 157 158 159 160 |
# File 'lib/yard/handlers/ruby/base.rb', line 152 def caller_method if statement.call? || statement.def? statement.method_name(true).to_s elsif statement.type == :var_ref || statement.type == :vcall statement[0].jump(:ident, :kw).source else nil end end |
- (Object) parse_block(inner_node, opts = {})
132 133 134 135 136 137 |
# File 'lib/yard/handlers/ruby/base.rb', line 132 def parse_block(inner_node, opts = {}) push_state(opts) do nodes = inner_node.type == :list ? inner_node.children : [inner_node] parser.process(nodes) end end |