Class: Yoda::Parsing::SourceAnalyzer
Deprecated
- Inherits:
-
Object
- Object
- Yoda::Parsing::SourceAnalyzer
show all
- Includes:
- AstTraversable
- Defined in:
- lib/yoda/parsing/source_analyzer.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#calc_nodes_to_current_location
Constructor Details
#initialize(ast, location) ⇒ SourceAnalyzer
Returns a new instance of SourceAnalyzer.
18
19
20
21
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 18
def initialize(ast, location)
@ast = ast
@location = location
end
|
Instance Attribute Details
#ast ⇒ Object
Returns the value of attribute ast.
14
15
16
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 14
def ast
@ast
end
|
#location ⇒ Object
Returns the value of attribute location.
14
15
16
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 14
def location
@location
end
|
Class Method Details
.from_source(source, location) ⇒ SourceAnalyzer
10
11
12
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 10
def self.from_source(source, location)
new(Parser.new.parse(source), location)
end
|
Instance Method Details
#current_method ⇒ NodeObjects::MethodDefition?
54
55
56
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 54
def current_method
@current_method ||= namespace.calc_current_location_method(location)
end
|
#current_method_node ⇒ ::Parser::AST::Node
34
35
36
|
# 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
|
49
50
51
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 49
def current_namespace
@current_namespace ||= namespace.calc_current_location_namespace(location)
end
|
#current_namespace_nodes ⇒ Array<::Parser::AST::Node>
39
40
41
|
# 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 ⇒ Namespace
44
45
46
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 44
def namespace
@namespace ||= NodeObjects::Namespace.new(self.ast)
end
|
#nodes_to_current_location_from_root ⇒ Array<::Parser::AST::Node>
24
25
26
|
# 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? ⇒ true, false
29
30
31
|
# File 'lib/yoda/parsing/source_analyzer.rb', line 29
def on_method?
!!current_method_node
end
|