pub struct ExpansionInfo<'db> {
pub(crate) expanded: InMacroFile<SyntaxNode>,
pub(crate) arg: InFile<Option<SyntaxNode>>,
pub(crate) exp_map: &'db ExpansionSpanMap,
pub(crate) arg_map: SpanMap<'db>,
pub(crate) loc: &'db MacroCallLoc,
}Expand description
ExpansionInfo mainly describes how to map text range between src and expanded macro
Fields§
§expanded: InMacroFile<SyntaxNode>§arg: InFile<Option<SyntaxNode>>The argument TokenTree or item for attributes
exp_map: &'db ExpansionSpanMap§arg_map: SpanMap<'db>§loc: &'db MacroCallLocImplementations§
Source§impl<'db> ExpansionInfo<'db>
impl<'db> ExpansionInfo<'db>
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, SyntaxContext)> + '_>>
pub fn map_range_down_exact( &self, span: Span, ) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContext)> + '_>>
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, SyntaxContext)> + '_>>
pub fn map_range_down( &self, span: Span, ) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContext)> + '_>>
Maps the passed in file range down into a macro expansion if it is the input to a macro call.
Unlike ExpansionInfo::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 SourceDatabase,
offset: TextSize,
) -> (FileRange, SyntaxContext)
pub fn span_for_offset( &self, db: &dyn SourceDatabase, offset: TextSize, ) -> (FileRange, SyntaxContext)
Looks up the span at the given offset.
Sourcepub fn map_node_range_up(
&self,
db: &dyn SourceDatabase,
range: TextRange,
) -> Option<(FileRange, SyntaxContext)>
pub fn map_node_range_up( &self, db: &dyn SourceDatabase, range: TextRange, ) -> Option<(FileRange, SyntaxContext)>
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 SourceDatabase,
token: TextRange,
) -> InFile<SmallVec<[TextRange; 1]>>
pub fn map_range_up_once( &self, db: &dyn SourceDatabase, token: TextRange, ) -> InFile<SmallVec<[TextRange; 1]>>
Maps up the text range out of the expansion into its macro call.
Note that this may return multiple ranges as we lose the precise association between input to output and as such we may consider inputs that are unrelated.
pub fn new( db: &'db dyn SourceDatabase, macro_file: MacroCallId, ) -> ExpansionInfo<'db>
Trait Implementations§
Source§impl<'db> Clone for ExpansionInfo<'db>
impl<'db> Clone for ExpansionInfo<'db>
Source§fn clone(&self) -> ExpansionInfo<'db>
fn clone(&self) -> ExpansionInfo<'db>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'db> Debug for ExpansionInfo<'db>
impl<'db> Debug for ExpansionInfo<'db>
Source§impl<'db> PartialEq for ExpansionInfo<'db>
impl<'db> PartialEq for ExpansionInfo<'db>
Source§fn eq(&self, other: &ExpansionInfo<'db>) -> bool
fn eq(&self, other: &ExpansionInfo<'db>) -> bool
self and other values to be equal, and is used by ==.impl<'db> Eq for ExpansionInfo<'db>
impl<'db> StructuralPartialEq for ExpansionInfo<'db>
Auto Trait Implementations§
impl<'db> Freeze for ExpansionInfo<'db>
impl<'db> !RefUnwindSafe for ExpansionInfo<'db>
impl<'db> !Send for ExpansionInfo<'db>
impl<'db> !Sync for ExpansionInfo<'db>
impl<'db> Unpin for ExpansionInfo<'db>
impl<'db> UnsafeUnpin for ExpansionInfo<'db>
impl<'db> !UnwindSafe for ExpansionInfo<'db>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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
§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
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>
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>
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