Struct hir_expand::ExpansionInfo
source · pub struct ExpansionInfo { /* private fields */ }
Expand description
ExpansionInfo mainly describes how to map text range between src and expanded macro
Implementations§
source§impl ExpansionInfo
impl ExpansionInfo
pub fn expanded(&self) -> InMacroFile<SyntaxNode>
pub fn arg(&self) -> InFile<Option<&SyntaxNode>>
pub fn call_file(&self) -> HirFileId
pub fn is_attr(&self) -> bool
sourcepub fn map_range_down_exact(
&self,
span: Span,
) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContextId)> + '_>>
pub fn map_range_down_exact( &self, span: Span, ) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContextId)> + '_>>
Maps the passed in file range down into a macro expansion if it is the input to a macro call.
Note this does a linear search through the entire backing vector of the spanmap.
sourcepub fn map_range_down(
&self,
span: Span,
) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContextId)> + '_>>
pub fn map_range_down( &self, span: Span, ) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContextId)> + '_>>
Maps the passed in file range down into a macro expansion if it is the input to a macro call.
Unlike [map_range_down_exact
], this will consider spans that contain the given span.
Note this does a linear search through the entire backing vector of the spanmap.
sourcepub fn span_for_offset(
&self,
db: &dyn ExpandDatabase,
offset: TextSize,
) -> (FileRange, SyntaxContextId)
pub fn span_for_offset( &self, db: &dyn ExpandDatabase, offset: TextSize, ) -> (FileRange, SyntaxContextId)
Looks up the span at the given offset.
sourcepub fn map_node_range_up(
&self,
db: &dyn ExpandDatabase,
range: TextRange,
) -> Option<(FileRange, SyntaxContextId)>
pub fn map_node_range_up( &self, db: &dyn ExpandDatabase, range: TextRange, ) -> Option<(FileRange, SyntaxContextId)>
Maps up the text range out of the expansion hierarchy back into the original file its from.
sourcepub fn map_range_up_once(
&self,
db: &dyn ExpandDatabase,
token: TextRange,
) -> InFile<SmallVec<[TextRange; 1]>>
pub fn map_range_up_once( &self, db: &dyn ExpandDatabase, token: TextRange, ) -> InFile<SmallVec<[TextRange; 1]>>
Maps up the text range out of the expansion into is macro call.
pub fn new(db: &dyn ExpandDatabase, macro_file: MacroFileId) -> ExpansionInfo
Trait Implementations§
source§impl Clone for ExpansionInfo
impl Clone for ExpansionInfo
source§fn clone(&self) -> ExpansionInfo
fn clone(&self) -> ExpansionInfo
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ExpansionInfo
impl Debug for ExpansionInfo
source§impl PartialEq for ExpansionInfo
impl PartialEq for ExpansionInfo
impl Eq for ExpansionInfo
impl StructuralPartialEq for ExpansionInfo
Auto Trait Implementations§
impl Freeze for ExpansionInfo
impl !RefUnwindSafe for ExpansionInfo
impl !Send for ExpansionInfo
impl !Sync for ExpansionInfo
impl Unpin for ExpansionInfo
impl !UnwindSafe for ExpansionInfo
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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