Module rowan::cursor

source ·
Expand description

Implementation of the cursors – API for convenient access to syntax trees.

Functional programmers will recognize that this module implements a zipper for a purely functional (green) tree.

A cursor node (SyntaxNode) points to a GreenNode and a parent SyntaxNode. This allows cursor to provide iteration over both ancestors and descendants, as well as a cheep access to absolute offset of the node in file.

By default SyntaxNodes are immutable, but you can get a mutable copy of the tree by calling clone_for_update. Mutation is based on interior mutability and doesn’t need &mut. You can have two SyntaxNodes pointing at different parts of the same tree; mutations via the first node will be reflected in the other.

Structs§

Type Aliases§