Struct tree_sitter_graph::ast::File

source ·
pub struct File {
    pub language: Language,
    pub globals: Vec<Global>,
    pub inherited_variables: HashSet<Identifier>,
    pub query: Option<Query>,
    pub stanzas: Vec<Stanza>,
    pub shorthands: AttributeShorthands,
}
Expand description

A graph DSL file

Fields§

§language: Language§globals: Vec<Global>

The expected global variables used in this file

§inherited_variables: HashSet<Identifier>

The scoped variables that are inherited by child nodes

§query: Option<Query>

The combined query of all stanzas in the file

§stanzas: Vec<Stanza>

The list of stanzas in the file

§shorthands: AttributeShorthands

Attribute shorthands defined in the file

Implementations§

source§

impl File

source

pub fn new(language: Language) -> File

source§

impl File

source

pub fn check(&mut self) -> Result<(), CheckError>

source§

impl File

source

pub fn execute<'a, 'tree>( &self, tree: &'tree Tree, source: &'tree str, config: &ExecutionConfig<'_, '_>, cancellation_flag: &dyn CancellationFlag ) -> Result<Graph<'tree>, ExecutionError>

Executes this graph DSL file against a source file. You must provide the parsed syntax tree (tree) as well as the source text that it was parsed from (source). You also provide the set of functions and global variables that are available during execution.

source

pub fn execute_into<'a, 'tree>( &self, graph: &mut Graph<'tree>, tree: &'tree Tree, source: &'tree str, config: &ExecutionConfig<'_, '_>, cancellation_flag: &dyn CancellationFlag ) -> Result<(), ExecutionError>

Executes this graph DSL file against a source file, saving the results into an existing Graph instance. You must provide the parsed syntax tree (tree) as well as the source text that it was parsed from (source). You also provide the set of functions and global variables that are available during execution. This variant is useful when you need to “pre-seed” the graph with some predefined nodes and/or edges before executing the DSL file.

source

pub fn try_visit_matches<'tree, E, F>( &self, tree: &'tree Tree, source: &'tree str, lazy: bool, visit: F ) -> Result<(), E>
where F: FnMut(Match<'_, 'tree>) -> Result<(), E>,

source§

impl File

source

pub fn from_str(language: Language, source: &str) -> Result<Self, ParseError>

Parses a graph DSL file, returning a new File instance.

source

pub fn parse(&mut self, content: &str) -> Result<(), ParseError>

👎Deprecated: Parsing multiple times into the same File instance is unsound. Use File::from_str instead.

Parses a graph DSL file, adding its content to an existing File instance.

Trait Implementations§

source§

impl Debug for File

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

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.