[go: up one dir, main page]

Struct FileMap

Source
pub struct FileMap {
    pub name: FileName,
    pub name_was_remapped: bool,
    pub crate_of_origin: u32,
    pub src: Option<Rc<String>>,
    pub start_pos: BytePos,
    pub end_pos: BytePos,
    pub lines: RefCell<Vec<BytePos>>,
    pub multibyte_chars: RefCell<Vec<MultiByteChar>>,
}
Expand description

A single source in the CodeMap.

Fields§

§name: FileName

The name of the file that the source came from, source that doesn’t originate from files has names between angle brackets by convention, e.g. <anon>

§name_was_remapped: bool

True if the name field above has been modified by -Zremap-path-prefix

§crate_of_origin: u32

Indicates which crate this FileMap was imported from.

§src: Option<Rc<String>>

The complete source code

§start_pos: BytePos

The start position of this source in the CodeMap

§end_pos: BytePos

The end position of this source in the CodeMap

§lines: RefCell<Vec<BytePos>>

Locations of lines beginnings in the source code

§multibyte_chars: RefCell<Vec<MultiByteChar>>

Locations of multi-byte characters in the source code

Implementations§

Source§

impl FileMap

Source

pub fn next_line(&self, pos: BytePos)

EFFECT: register a start-of-line offset in the table of line-beginnings. UNCHECKED INVARIANT: these offsets must be added in the right order and must be in the right places; there is shared knowledge about what ends a line between this file and parse.rs WARNING: pos param here is the offset relative to start of CodeMap, and CodeMap will append a newline when adding a filemap without a newline at the end, so the safe way to call this is with value calculated as filemap.start_pos + newline_offset_relative_to_the_start_of_filemap.

Source

pub fn get_line(&self, line_number: usize) -> Option<&str>

get a line from the list of pre-computed line-beginnings. line-number here is 0-based.

Source

pub fn record_multibyte_char(&self, pos: BytePos, bytes: usize)

Source

pub fn is_real_file(&self) -> bool

Source

pub fn is_imported(&self) -> bool

Source

pub fn byte_length(&self) -> u32

Source

pub fn count_lines(&self) -> usize

Source

pub fn lookup_line(&self, pos: BytePos) -> Option<usize>

Find the line containing the given position. The return value is the index into the lines array of this FileMap, not the 1-based line number. If the filemap is empty or the position is located before the first line, None is returned.

Source

pub fn line_bounds(&self, line_index: usize) -> (BytePos, BytePos)

Trait Implementations§

Source§

impl Clone for FileMap

Source§

fn clone(&self) -> FileMap

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileMap

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FileMap

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FileMap

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl !Freeze for FileMap

§

impl !RefUnwindSafe for FileMap

§

impl !Send for FileMap

§

impl !Sync for FileMap

§

impl Unpin for FileMap

§

impl UnwindSafe for FileMap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,