pub struct Graph<'tree> { /* private fields */ }
Expand description

A graph produced by executing a graph DSL file. Graphs include a lifetime parameter to ensure that they don’t outlive the tree-sitter syntax tree that they are generated from.

Implementations§

source§

impl<'tree> Graph<'tree>

source

pub fn new() -> Graph<'tree>

Creates a new, empty graph.

source

pub fn add_syntax_node(&mut self, node: Node<'tree>) -> SyntaxNodeRef

Adds a syntax node to the graph, returning a graph DSL reference to it.

The graph won’t contain every syntax node in the parsed syntax tree; it will only contain those nodes that are referenced at some point during the execution of the graph DSL file.

source

pub fn add_graph_node(&mut self) -> GraphNodeRef

Adds a new graph node to the graph, returning a graph DSL reference to it.

source

pub fn pretty_print<'a>(&'a self) -> impl Display + 'a

Pretty-prints the contents of this graph.

source

pub fn display_json(&self, path: Option<&Path>) -> Result<()>

source

pub fn iter_nodes(&self) -> impl Iterator<Item = GraphNodeRef>

source

pub fn node_count(&self) -> usize

Trait Implementations§

source§

impl<'tree> Default for Graph<'tree>

source§

fn default() -> Graph<'tree>

Returns the “default value” for a type. Read more
source§

impl Index<GraphNodeRef> for Graph<'_>

§

type Output = GraphNode

The returned type after indexing.
source§

fn index(&self, index: GraphNodeRef) -> &GraphNode

Performs the indexing (container[index]) operation. Read more
source§

impl<'tree> Index<SyntaxNodeRef> for Graph<'tree>

§

type Output = Node<'tree>

The returned type after indexing.
source§

fn index(&self, node_ref: SyntaxNodeRef) -> &Node<'tree>

Performs the indexing (container[index]) operation. Read more
source§

impl<'tree> IndexMut<GraphNodeRef> for Graph<'_>

source§

fn index_mut(&mut self, index: GraphNodeRef) -> &mut GraphNode

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'tree> Serialize for Graph<'tree>

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'tree> RefUnwindSafe for Graph<'tree>

§

impl<'tree> !Send for Graph<'tree>

§

impl<'tree> !Sync for Graph<'tree>

§

impl<'tree> Unpin for Graph<'tree>

§

impl<'tree> UnwindSafe for Graph<'tree>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.