Module: Yoda::AST::Vnode::Positional

Included in:
Yoda::AST::Vnode
Defined in:
lib/yoda/ast/vnode.rb

Instance Method Summary collapse

Instance Method Details

#locationParsing::Location?

Returns:



109
110
111
# File 'lib/yoda/ast/vnode.rb', line 109

def location
  source_map && Parsing::Location.of_ast_location(source_map)
end

#positionally_include?(target) ⇒ boolean

Parameters:

Returns:

  • (boolean)


125
126
127
# File 'lib/yoda/ast/vnode.rb', line 125

def positionally_include?(target)
  range && range.include?(target)
end

#positionally_nearest_child(target) ⇒ Vnode

Parameters:

  • target (Location, Range, nil)

Returns:



131
132
133
134
135
136
137
# File 'lib/yoda/ast/vnode.rb', line 131

def positionally_nearest_child(target)
  if positionally_include?(target)
    children.find { |child| child.positionally_include?(target) }&.positionally_nearest_child(target) || self
  else
    nil
  end
end

#rangeRange?

Returns:

  • (Range, nil)


114
115
116
# File 'lib/yoda/ast/vnode.rb', line 114

def range
  source_map && Parsing::Range.of_ast_location(source_map)
end

#source_mapParser::Source::Map?

Returns:

  • (Parser::Source::Map, nil)


119
120
121
# File 'lib/yoda/ast/vnode.rb', line 119

def source_map
  nil
end