Class: RSpec::Expectations::BlockSnippetExtractor::BlockLocator Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Struct
|
|
Instance Chain:
self,
Struct
|
|
Inherits: |
Struct
|
Defined in: | rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb |
Overview
Locates target block with node information (semantics), which tokens don’t have.
Instance Attribute Summary
-
#beginning_line_number
rw
private
Internal use only
Locates target block with node information (semantics), which tokens don’t have.
-
#method_name
rw
private
Internal use only
Locates target block with node information (semantics), which tokens don’t have.
-
#source
rw
private
Internal use only
Locates target block with node information (semantics), which tokens don’t have.
Instance Method Summary
- #body_content_locations Internal use only
- #method_call_location Internal use only
- #block_body_node private Internal use only
- #block_wrapper_node private Internal use only
- #candidate_block_wrapper_nodes private Internal use only
- #candidate_method_ident_nodes private Internal use only
- #method_ident_node private Internal use only
- #method_ident_node?(node) ⇒ Boolean private Internal use only
Instance Attribute Details
#beginning_line_number (rw, private)
Locates target block with node information (semantics), which tokens don’t have.
# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 200
BlockLocator = Struct.new(:method_name, :source, :beginning_line_number)
#method_name (rw, private)
Locates target block with node information (semantics), which tokens don’t have.
# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 200
BlockLocator = Struct.new(:method_name, :source, :beginning_line_number)
#source (rw, private)
Locates target block with node information (semantics), which tokens don’t have.
# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 200
BlockLocator = Struct.new(:method_name, :source, :beginning_line_number)
Instance Method Details
#block_body_node (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 218
def block_body_node block_node = block_wrapper_node.children[1] block_node.children.last end
#block_wrapper_node (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 223
def block_wrapper_node case candidate_block_wrapper_nodes.size when 1 candidate_block_wrapper_nodes.first when 0 raise TargetNotFoundError else raise AmbiguousTargetError end end
#body_content_locations
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 205
def body_content_locations @body_content_locations ||= block_body_node.map(&:location).compact end
#candidate_block_wrapper_nodes (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 234
def candidate_block_wrapper_nodes @candidate_block_wrapper_nodes ||= candidate_method_ident_nodes.map do |method_ident_node| block_wrapper_node = method_ident_node.each_ancestor.find { |node| node.type == :method_add_block } next nil unless block_wrapper_node method_call_node = block_wrapper_node.children.first method_call_node.include?(method_ident_node) ? block_wrapper_node : nil end.compact end
#candidate_method_ident_nodes (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 243
def candidate_method_ident_nodes source.nodes_by_line_number[beginning_line_number].select do |node| method_ident_node?(node) end end
#method_call_location
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 201
def method_call_location @method_call_location ||= method_ident_node.location end
#method_ident_node (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 211
def method_ident_node method_call_node = block_wrapper_node.children.first method_call_node.find do |node| method_ident_node?(node) end end
#method_ident_node?(node) ⇒ Boolean
(private)
# File 'rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb', line 249
def method_ident_node?(node) node.type == :@ident && node.args.first == method_name end