pub struct AnalysisContext<'a> {
pub file_path: &'a Path,
pub source: &'a str,
pub ast: &'a File,
pub config: &'a Config,
/* private fields */
}Expand description
Context passed to rules during analysis.
Contains all information needed to analyze a single file.
Fields§
§file_path: &'a Path§source: &'a str§ast: &'a File§config: &'a ConfigImplementations§
Source§impl<'a> AnalysisContext<'a>
impl<'a> AnalysisContext<'a>
Sourcepub fn new(
file_path: &'a Path,
source: &'a str,
ast: &'a File,
config: &'a Config,
) -> Self
pub fn new( file_path: &'a Path, source: &'a str, ast: &'a File, config: &'a Config, ) -> Self
Create a new analysis context.
Sourcepub fn line_col(&self, offset: usize) -> (usize, usize)
pub fn line_col(&self, offset: usize) -> (usize, usize)
Get line and column from a byte offset (1-indexed).
This is O(log n) where n is the number of lines.
Sourcepub fn get_line(&self, line_num: usize) -> Option<&str>
pub fn get_line(&self, line_num: usize) -> Option<&str>
Get the source line at the given line number (1-indexed).
Sourcepub fn line_index(&self) -> &LineIndex
pub fn line_index(&self) -> &LineIndex
Get a reference to the line index for advanced lookups.
Auto Trait Implementations§
impl<'a> Freeze for AnalysisContext<'a>
impl<'a> RefUnwindSafe for AnalysisContext<'a>
impl<'a> !Send for AnalysisContext<'a>
impl<'a> !Sync for AnalysisContext<'a>
impl<'a> Unpin for AnalysisContext<'a>
impl<'a> UnwindSafe for AnalysisContext<'a>
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> 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