pub struct CodeParser { /* private fields */ }Expand description
A tree-sitter based code parser with query support.
Implementations§
Source§impl CodeParser
impl CodeParser
Sourcepub fn new(language: SupportedLanguage) -> Result<Self, ParserError>
pub fn new(language: SupportedLanguage) -> Result<Self, ParserError>
Create a new parser for the specified language.
Sourcepub fn for_path(path: &Path) -> Result<Self, ParserError>
pub fn for_path(path: &Path) -> Result<Self, ParserError>
Create a parser for the given file path.
Detects language from file extension.
Sourcepub fn language(&self) -> SupportedLanguage
pub fn language(&self) -> SupportedLanguage
Get the language this parser is configured for.
Sourcepub fn parse(&mut self, source: &str) -> Result<Tree, ParserError>
pub fn parse(&mut self, source: &str) -> Result<Tree, ParserError>
Parse source code into a syntax tree.
Sourcepub fn parse_with_old_tree(
&mut self,
source: &str,
old_tree: Option<&Tree>,
) -> Result<Tree, ParserError>
pub fn parse_with_old_tree( &mut self, source: &str, old_tree: Option<&Tree>, ) -> Result<Tree, ParserError>
Parse source code with an existing tree for incremental parsing.
Auto Trait Implementations§
impl Freeze for CodeParser
impl RefUnwindSafe for CodeParser
impl Send for CodeParser
impl Sync for CodeParser
impl Unpin for CodeParser
impl UnwindSafe for CodeParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more