Struct ParsedFile

Source
pub struct ParsedFile<'a> { /* private fields */ }
Expand description

The result of finding function with a given name. Use Self::search_file or Self::search_file_with_name to do the searching.

Implementations§

Source§

impl<'a> ParsedFile<'a>

Source

pub fn new( file: &'a str, function_name: &'a str, language_type: &'a str, tree: Tree, results: Box<[Range]>, ) -> Self

Source

pub fn filter(&self, f: fn(&Node<'_>) -> bool) -> Result<Self, Error>

Filters out commits not matching the filter [f]. Returns new version of the current ParsedFile with only the results that match the filter.

§Errors

If the filter [f] filters out all the results of this file

Source

pub const fn language(&self) -> &str

Get the name of the language used to parse this file

Source

pub const fn search_name(&self) -> &str

Get the name of the function that was searched for to make this ParsedFile

Source

pub fn search_file( name: &'a str, code: &'a str, language: &'a dyn SupportedLanguage, ) -> Result<Self, Error>

Search for all function with the name [name], in string [code] with the specified language [language].

Note: to obtain the the language you may use get_file_type_from_file or get_file_type_from_file_ext. Alternativly use Self::search_file_with_name to let us find the correct language for you.

§Errors

If something with tree sitter goes wrong. If the code cannot be parsed properly. If no results are found for this function name.

Source

pub fn search_file_with_name( name: &'a str, code: &'a str, file_name: &'a str, langs: &'a [&'a dyn SupportedLanguage], ) -> Result<Self, Error>

Search for all function with the name [name], in string [code] with a language found from the file name [file_name] and the languages [langs].

§Errors

If there is no language found for the given file name. If something with tree sitter goes wrong. If the code cannot be parsed properly, If no results are found for this function name.

Source

pub const fn file_name(&self) -> Option<&str>

Get the file name of this file.

Source

pub fn results(&self) -> &[Range]

Get the Range of each found function.

Trait Implementations§

Source§

impl<'a> Clone for ParsedFile<'a>

Source§

fn clone(&self) -> ParsedFile<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ParsedFile<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for ParsedFile<'_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl IntoIterator for ParsedFile<'_>

Source§

type Item = (Range, String)

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = <ParsedFile<'_> as IntoIterator>::Item>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ParsedFile<'a>

§

impl<'a> RefUnwindSafe for ParsedFile<'a>

§

impl<'a> Send for ParsedFile<'a>

§

impl<'a> Sync for ParsedFile<'a>

§

impl<'a> Unpin for ParsedFile<'a>

§

impl<'a> UnwindSafe for ParsedFile<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.