minilua::SourceChangeTree class

Wrapper for the source change tree.

Walk the tree with SourceChangeTree::visit, SourceChangeTree::visit_first_alternative, SourceChangeTree::visit_all.

To simply get the first complete source change use SourceChangeTree::collect_first_alternative.

Supports equality operators.

Constructors, destructors, conversion operators

SourceChangeTree(SourceChange)
Constructor taking a single SourceChange.
SourceChangeTree(SourceChangeCombination)
Constructor taking a SourceChangeCombination.
SourceChangeTree(SourceChangeAlternative)
Constructor taking a SourceChangeAlternative.
SourceChangeTree(Type)
Constructor taking the internal std::variant.

Public functions

auto origin() const -> const std::string & -> auto
The origin of the root source change.
auto origin() -> std::string & -> auto
The origin of the root source change.
auto hint() const -> const std::string & -> auto
The hint of the root source change.
auto hint() -> std::string & -> auto
The hint of the root source change.
void remove_filename()
template<typename Visitor>
auto visit(Visitor visitor) -> auto
Visit the root node of the tree of source changes.
template<typename Visitor>
auto visit(Visitor visitor) -> auto
Visit the root node of the tree of source changes.
template<typename Visitor>
void visit_first_alternative(Visitor visitor)
Visits only the first child (left) of an SourceChangeAlternative node.
template<typename Visitor>
void visit_first_alternative(Visitor visitor) const
Visits only the first child (left) of an SourceChangeAlternative node.
template<typename Visitor>
void visit_all(Visitor visitor)
Visit all leaf SourceChange nodes.
template<typename Visitor>
void visit_all(Visitor visitor) const
Visit all leaf SourceChange nodes.
auto collect_first_alternative() const -> std::vector< SourceChange > -> auto
Collect only the left side of SourceChangeAlternative branches.
auto simplify() const -> std::optional< SourceChangeTree > -> auto
auto operator*() -> Type & -> auto
Derefernce to the underlying variant type.
auto operator*() const -> const Type & -> auto
Derefernce to the underlying variant type.
auto operator->() -> Type * -> auto
Derefernce to the underlying variant type.

Function documentation

void minilua::SourceChangeTree::remove_filename()

Removes the filename from the ranges in the tree.

template<typename Visitor>
auto minilua::SourceChangeTree::visit(Visitor visitor)

Visit the root node of the tree of source changes.

Visitor has to be callable with SourceChange&, SourceChangeCombination& and SourceChangeAlternative&.

For possible implementations see SourceChangeTree::visit_first_alternative.

template<typename Visitor>
auto minilua::SourceChangeTree::visit(Visitor visitor)

Visit the root node of the tree of source changes.

Visitor has to be callable with const SourceChange&, const SourceChangeCombination& and const SourceChangeAlternative&.

For possible usage see implementation of SourceChangeTree::visit_first_alternative.

template<typename Visitor>
void minilua::SourceChangeTree::visit_first_alternative(Visitor visitor)

Visits only the first child (left) of an SourceChangeAlternative node.

SourceChangeCombination nodes are completely visited.

template<typename Visitor>
void minilua::SourceChangeTree::visit_first_alternative(Visitor visitor) const

Visits only the first child (left) of an SourceChangeAlternative node.

SourceChangeCombination nodes are completely visited.

auto minilua::SourceChangeTree::simplify() const -> std::optional< SourceChangeTree >

Simplify the source change tree removing all redundant nodes.

This is recursive.

Empty alternatives and combinations will be converted to nullopts.

auto minilua::SourceChangeTree::operator*() -> Type &

Derefernce to the underlying variant type.

Returns a reference to the variant type.

auto minilua::SourceChangeTree::operator*() const -> const Type &

Derefernce to the underlying variant type.

Returns a reference to the variant type.

auto minilua::SourceChangeTree::operator->() -> Type *

Derefernce to the underlying variant type.

Returns a pointer to the variant type.