class Yoda::Parsing::SourceAnalyzer
@deprecated
Attributes
ast[R]
location[R]
Public Class Methods
from_source(source, location)
click to toggle source
@param source [String] @param location [Location] @return [SourceAnalyzer]
# File lib/yoda/parsing/source_analyzer.rb, line 10 def self.from_source(source, location) new(Parser.new.parse(source), location) end
new(ast, location)
click to toggle source
@param ast [::Parser::AST::Node] @param location [Location]
# File lib/yoda/parsing/source_analyzer.rb, line 18 def initialize(ast, location) @ast = ast @location = location end
Public Instance Methods
current_method()
click to toggle source
@return [NodeObjects::MethodDefition, nil]
# File lib/yoda/parsing/source_analyzer.rb, line 54 def current_method @current_method ||= namespace.calc_current_location_method(location) end
current_method_node()
click to toggle source
@return [::Parser::AST::Node]
# File lib/yoda/parsing/source_analyzer.rb, line 34 def current_method_node nodes_to_current_location_from_root.reverse.find { |node| [:def, :defs].include?(node.type) } end
current_namespace()
click to toggle source
@return [NodeObjects::Namespace, nil]
# File lib/yoda/parsing/source_analyzer.rb, line 49 def current_namespace @current_namespace ||= namespace.calc_current_location_namespace(location) end
current_namespace_nodes()
click to toggle source
@return [Array<::Parser::AST::Node>]
# File lib/yoda/parsing/source_analyzer.rb, line 39 def current_namespace_nodes nodes_to_current_location_from_root.find_all { |node| [:class, :module, :sclass].include?(node.type) } end
namespace()
click to toggle source
@return [Namespace]
# File lib/yoda/parsing/source_analyzer.rb, line 44 def namespace @namespace ||= NodeObjects::Namespace.new(self.ast) end
nodes_to_current_location_from_root()
click to toggle source
@return [Array<::Parser::AST::Node>]
# File lib/yoda/parsing/source_analyzer.rb, line 24 def nodes_to_current_location_from_root @nodes_to_current_location ||= calc_nodes_to_current_location(ast, location) end
on_method?()
click to toggle source
@return [true, false]
# File lib/yoda/parsing/source_analyzer.rb, line 29 def on_method? !!current_method_node end