Spicy
Public Types | Public Member Functions | Public Attributes | List of all members
hilti::visitor::Position< E > Struct Template Reference

#include <visitor-types.h>

Public Types

using Erased = typename std::decay< E >::type
 

Public Member Functions

auto pathLength () const
 
parent (unsigned int parent_nr=1) const
 
template<typename T >
std::optional< std::reference_wrapper< const T > > findParent () const
 
template<typename T >
NodeRef findParentRef () const
 

Public Attributes

node
 
const std::vector< Location< E > > & path
 

Detailed Description

template<typename E>
struct hilti::visitor::Position< E >

Represents the path to a node inside an AST during iteration.

Member Function Documentation

◆ findParent()

template<typename E >
template<typename T >
std::optional<std::reference_wrapper<const T> > hilti::visitor::Position< E >::findParent ( ) const
inline

Returns the first parent that has a given type.

◆ findParentRef()

template<typename E >
template<typename T >
NodeRef hilti::visitor::Position< E >::findParentRef ( ) const
inline

Returns a reference to the first parent that has a given type.

◆ parent()

template<typename E >
E hilti::visitor::Position< E >::parent ( unsigned int  parent_nr = 1) const
inline

Returns a parent.

Parameters
parent_nrnumber of the parent to return; 1 returns immediate parent, 2 the 2nd, etc.
Exceptions
<tt>std::out_of_range</tt>if the requested parent does not exist

◆ pathLength()

template<typename E >
auto hilti::visitor::Position< E >::pathLength ( ) const
inline

Returns the length of the AST path to the current node if we're indeed traversing an AST. If we're just dispatching a single node, this will return zero.

Member Data Documentation

◆ node

template<typename E >
E hilti::visitor::Position< E >::node

Node the position refers to.

◆ path

template<typename E >
const std::vector<Location<E> >& hilti::visitor::Position< E >::path

Path to reach the node. The node itself is the last element inside the path.


The documentation for this struct was generated from the following file: