pub struct StructuralLocator { /* private fields */ }Expand description
Structural code locator using tree-sitter queries.
Implementations§
Source§impl StructuralLocator
impl StructuralLocator
Sourcepub fn new() -> Result<Self, TreeSitterError>
pub fn new() -> Result<Self, TreeSitterError>
Create a new structural locator.
Sourcepub fn locate(
&mut self,
source: &str,
target: &StructuralTarget,
) -> Result<LocatorResult, TreeSitterError>
pub fn locate( &mut self, source: &str, target: &StructuralTarget, ) -> Result<LocatorResult, TreeSitterError>
Locate a structural target in source code, expecting exactly one match.
Sourcepub fn locate_all(
&mut self,
source: &str,
target: &StructuralTarget,
) -> Result<Vec<LocatorResult>, TreeSitterError>
pub fn locate_all( &mut self, source: &str, target: &StructuralTarget, ) -> Result<Vec<LocatorResult>, TreeSitterError>
Locate all matches for a structural target.
Sourcepub fn locate_in_file(
&mut self,
path: &Path,
target: &StructuralTarget,
) -> Result<LocatorResult, TreeSitterError>
pub fn locate_in_file( &mut self, path: &Path, target: &StructuralTarget, ) -> Result<LocatorResult, TreeSitterError>
Locate a target in a file.
Sourcepub fn has_errors(&mut self, source: &str) -> Result<bool, TreeSitterError>
pub fn has_errors(&mut self, source: &str) -> Result<bool, TreeSitterError>
Check if source has syntax errors.
Sourcepub fn parser_mut(&mut self) -> &mut RustParser
pub fn parser_mut(&mut self) -> &mut RustParser
Get the underlying parser for direct tree-sitter access.
Source§impl StructuralLocator
Convenience functions for common operations.
impl StructuralLocator
Convenience functions for common operations.
Sourcepub fn find_function(
&mut self,
source: &str,
name: &str,
) -> Result<LocatorResult, TreeSitterError>
pub fn find_function( &mut self, source: &str, name: &str, ) -> Result<LocatorResult, TreeSitterError>
Find a function by name.
Sourcepub fn find_struct(
&mut self,
source: &str,
name: &str,
) -> Result<LocatorResult, TreeSitterError>
pub fn find_struct( &mut self, source: &str, name: &str, ) -> Result<LocatorResult, TreeSitterError>
Find a struct by name.
Sourcepub fn find_const(
&mut self,
source: &str,
name: &str,
) -> Result<LocatorResult, TreeSitterError>
pub fn find_const( &mut self, source: &str, name: &str, ) -> Result<LocatorResult, TreeSitterError>
Find a const by name.
Sourcepub fn find_consts_matching(
&mut self,
source: &str,
pattern: &str,
) -> Result<Vec<LocatorResult>, TreeSitterError>
pub fn find_consts_matching( &mut self, source: &str, pattern: &str, ) -> Result<Vec<LocatorResult>, TreeSitterError>
Find all consts matching a pattern.
Sourcepub fn find_impl(
&mut self,
source: &str,
type_name: &str,
) -> Result<LocatorResult, TreeSitterError>
pub fn find_impl( &mut self, source: &str, type_name: &str, ) -> Result<LocatorResult, TreeSitterError>
Find an impl block for a type.
Sourcepub fn find_method(
&mut self,
source: &str,
type_name: &str,
method_name: &str,
) -> Result<LocatorResult, TreeSitterError>
pub fn find_method( &mut self, source: &str, type_name: &str, method_name: &str, ) -> Result<LocatorResult, TreeSitterError>
Find a method in an impl block.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StructuralLocator
impl RefUnwindSafe for StructuralLocator
impl Send for StructuralLocator
impl Sync for StructuralLocator
impl Unpin for StructuralLocator
impl UnsafeUnpin for StructuralLocator
impl UnwindSafe for StructuralLocator
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