pub struct File {
pub source: String,
pub name: String,
pub path: Option<PathBuf>,
pub id: usize,
pub kind: FileKind,
pub line_starts: Vec<usize>,
}
Expand description
A structure representing either a concrete (in-disk) or virtual (temporary/non-disk) js, ts, or mjs file.
Fields§
§source: String
§name: String
The name of the file.
path: Option<PathBuf>
The path in disk if this is a concrete file.
id: usize
The rslint_errors id assigned to this file used to refer back to it.
kind: FileKind
The kind of file this is.
line_starts: Vec<usize>
The cached line start locations in this file.
Implementations§
Source§impl File
impl File
pub fn new_concrete(source: String, path: PathBuf) -> Self
pub fn from_string( source: impl ToString, kind: FileKind, name: impl ToString, ) -> Self
pub fn update_src(&mut self, new: String)
pub fn line_starts(source: &str) -> impl Iterator<Item = usize> + '_
pub fn line_start(&self, line_index: usize) -> Option<usize>
pub fn line_index(&self, byte_index: usize) -> usize
pub fn line_col_to_index(&self, line: usize, column: usize) -> Option<usize>
pub fn line_range(&self, line_index: usize) -> Option<Range<usize>>
Sourcepub fn parse(&self) -> SyntaxNode
pub fn parse(&self) -> SyntaxNode
Parse this file into a syntax node, ignoring any errors produced. This
pub fn parse_with_errors(&self) -> (Vec<ParserError>, SyntaxNode)
Trait Implementations§
impl Eq for File
impl StructuralPartialEq for File
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
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