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>
impl<'a> ParsedFile<'a>
pub fn new( file: &'a str, function_name: &'a str, language_type: &'a str, tree: Tree, results: Box<[Range]>, ) -> Self
Sourcepub fn filter(&self, f: fn(&Node<'_>) -> bool) -> Result<Self, Error>
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
Sourcepub const fn search_name(&self) -> &str
pub const fn search_name(&self) -> &str
Get the name of the function that was searched for to make this ParsedFile
Sourcepub fn search_file(
name: &'a str,
code: &'a str,
language: &'a dyn SupportedLanguage,
) -> Result<Self, Error>
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.
Sourcepub fn search_file_with_name(
name: &'a str,
code: &'a str,
file_name: &'a str,
langs: &'a [&'a dyn SupportedLanguage],
) -> Result<Self, Error>
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.
Trait Implementations§
Source§impl<'a> Clone for ParsedFile<'a>
impl<'a> Clone for ParsedFile<'a>
Source§fn clone(&self) -> ParsedFile<'a>
fn clone(&self) -> ParsedFile<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more