Struct hir::InFileWrapper
pub struct InFileWrapper<FileKind, T> {
pub file_id: FileKind,
pub value: T,
}
Expand description
InFile<T>
stores a value of T
inside a particular file/syntax tree.
Typical usages are:
InFile<SyntaxNode>
– syntax node in a fileInFile<ast::FnDef>
– ast node in a fileInFile<TextSize>
– offset in a file
Fields§
§file_id: FileKind
§value: T
Implementations§
§impl<N> InFileWrapper<HirFileId, FileAstId<N>>where
N: AstIdNode,
impl<N> InFileWrapper<HirFileId, FileAstId<N>>where
N: AstIdNode,
pub fn to_node(&self, db: &dyn ExpandDatabase) -> N
pub fn to_range(&self, db: &dyn ExpandDatabase) -> TextRange
pub fn to_in_file_node( &self, db: &dyn ExpandDatabase, ) -> InFileWrapper<HirFileId, N>
pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> AstPtr<N>
§impl InFileWrapper<HirFileId, ErasedFileAstId>
impl InFileWrapper<HirFileId, ErasedFileAstId>
pub fn to_range(&self, db: &dyn ExpandDatabase) -> TextRange
pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> SyntaxNodePtr<RustLanguage>
§impl<FileKind, T> InFileWrapper<FileKind, T>
impl<FileKind, T> InFileWrapper<FileKind, T>
pub fn new(file_id: FileKind, value: T) -> InFileWrapper<FileKind, T>
pub fn map<F, U>(self, f: F) -> InFileWrapper<FileKind, U>where
F: FnOnce(T) -> U,
§impl<FileKind, T> InFileWrapper<FileKind, T>where
FileKind: Copy,
impl<FileKind, T> InFileWrapper<FileKind, T>where
FileKind: Copy,
pub fn with_value<U>(&self, value: U) -> InFileWrapper<FileKind, U>
pub fn as_ref(&self) -> InFileWrapper<FileKind, &T>
pub fn borrow<U>(&self) -> InFileWrapper<FileKind, &U>where
T: Borrow<U>,
§impl<FileKind, T> InFileWrapper<FileKind, &T>
impl<FileKind, T> InFileWrapper<FileKind, &T>
pub fn cloned(&self) -> InFileWrapper<FileKind, T>
§impl<FileKind, T> InFileWrapper<FileKind, Option<T>>
impl<FileKind, T> InFileWrapper<FileKind, Option<T>>
pub fn transpose(self) -> Option<InFileWrapper<FileKind, T>>
§impl<FileKind, L, R> InFileWrapper<FileKind, Either<L, R>>
impl<FileKind, L, R> InFileWrapper<FileKind, Either<L, R>>
pub fn transpose( self, ) -> Either<InFileWrapper<FileKind, L>, InFileWrapper<FileKind, R>>
§impl<FileId, T> InFileWrapper<FileId, T>where
FileId: FileIdToSyntax,
impl<FileId, T> InFileWrapper<FileId, T>where
FileId: FileIdToSyntax,
pub fn file_syntax(&self, db: &dyn ExpandDatabase) -> SyntaxNode<RustLanguage>
§impl<FileId, N> InFileWrapper<FileId, N>where
FileId: Copy,
N: AstNode,
impl<FileId, N> InFileWrapper<FileId, N>where
FileId: Copy,
N: AstNode,
pub fn syntax(&self) -> InFileWrapper<FileId, &SyntaxNode<RustLanguage>>
§impl<FileId, N> InFileWrapper<FileId, &N>where
FileId: Copy,
N: AstNode,
impl<FileId, N> InFileWrapper<FileId, &N>where
FileId: Copy,
N: AstNode,
pub fn syntax_ref(&self) -> InFileWrapper<FileId, &SyntaxNode<RustLanguage>>
§impl<SN> InFileWrapper<EditionedFileId, SN>where
SN: Borrow<SyntaxNode<RustLanguage>>,
impl<SN> InFileWrapper<EditionedFileId, SN>where
SN: Borrow<SyntaxNode<RustLanguage>>,
pub fn file_range(&self) -> FileRangeWrapper<EditionedFileId>
§impl<SN> InFileWrapper<HirFileId, SN>where
SN: Borrow<SyntaxNode<RustLanguage>>,
impl<SN> InFileWrapper<HirFileId, SN>where
SN: Borrow<SyntaxNode<RustLanguage>>,
pub fn parent_ancestors_with_macros( self, db: &dyn ExpandDatabase, ) -> impl Iterator<Item = InFileWrapper<HirFileId, SyntaxNode<RustLanguage>>>
pub fn ancestors_with_macros( self, db: &dyn ExpandDatabase, ) -> impl Iterator<Item = InFileWrapper<HirFileId, SyntaxNode<RustLanguage>>>
pub fn kind(&self) -> SyntaxKind
pub fn text_range(&self) -> TextRange
pub fn original_file_range_rooted(
self,
db: &dyn ExpandDatabase,
) -> FileRangeWrapper<EditionedFileId>
pub fn original_file_range_rooted( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>
Falls back to the macro call range if the node cannot be mapped up fully.
For attributes and derives, this will point back to the attribute only.
For the entire item use [InFile::original_file_range_full
].
pub fn original_file_range_with_macro_call_body(
self,
db: &dyn ExpandDatabase,
) -> FileRangeWrapper<EditionedFileId>
pub fn original_file_range_with_macro_call_body( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>
Falls back to the macro call range if the node cannot be mapped up fully.
pub fn original_syntax_node_rooted( self, db: &dyn ExpandDatabase, ) -> Option<InFileWrapper<EditionedFileId, SyntaxNode<RustLanguage>>>
§impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>
impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>
pub fn original_file_range_opt(
self,
db: &dyn ExpandDatabase,
) -> Option<(FileRangeWrapper<EditionedFileId>, SyntaxContextId)>
pub fn original_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<(FileRangeWrapper<EditionedFileId>, SyntaxContextId)>
Attempts to map the syntax node back up its macro calls.
§impl InFileWrapper<MacroFileId, SyntaxToken<RustLanguage>>
impl InFileWrapper<MacroFileId, SyntaxToken<RustLanguage>>
pub fn upmap_once( self, db: &dyn ExpandDatabase, ) -> InFileWrapper<HirFileId, SmallVec<[TextRange; 1]>>
§impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>
impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>
pub fn original_file_range(
self,
db: &dyn ExpandDatabase,
) -> FileRangeWrapper<EditionedFileId>
pub fn original_file_range( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>
Falls back to the macro call range if the node cannot be mapped up fully.
pub fn original_file_range_opt(
self,
db: &dyn ExpandDatabase,
) -> Option<FileRangeWrapper<EditionedFileId>>
pub fn original_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<FileRangeWrapper<EditionedFileId>>
Attempts to map the syntax node back up its macro calls.
§impl InFileWrapper<MacroFileId, TextSize>
impl InFileWrapper<MacroFileId, TextSize>
pub fn original_file_range( self, db: &dyn ExpandDatabase, ) -> (FileRangeWrapper<EditionedFileId>, SyntaxContextId)
§impl InFileWrapper<HirFileId, TextRange>
impl InFileWrapper<HirFileId, TextRange>
pub fn original_node_file_range( self, db: &dyn ExpandDatabase, ) -> (FileRangeWrapper<EditionedFileId>, SyntaxContextId)
pub fn original_node_file_range_rooted( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>
pub fn original_node_file_range_with_macro_call_body( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>
pub fn original_node_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<(FileRangeWrapper<EditionedFileId>, SyntaxContextId)>
§impl<N> InFileWrapper<HirFileId, N>where
N: AstNode,
impl<N> InFileWrapper<HirFileId, N>where
N: AstNode,
pub fn original_ast_node_rooted( self, db: &dyn ExpandDatabase, ) -> Option<InFileWrapper<EditionedFileId, N>>
§impl<T> InFileWrapper<HirFileId, T>
impl<T> InFileWrapper<HirFileId, T>
pub fn into_real_file( self, ) -> Result<InFileWrapper<EditionedFileId, T>, InFileWrapper<HirFileId, T>>
Trait Implementations§
§impl AsMacroCall for InFileWrapper<HirFileId, &MacroCall>
impl AsMacroCall for InFileWrapper<HirFileId, &MacroCall>
fn as_call_id_with_errors( &self, db: &dyn ExpandDatabase, krate: Idx<CrateData>, resolver: impl Fn(&ModPath) -> Option<MacroDefId> + Copy, ) -> Result<ValueResult<Option<MacroCallId>, ExpandError>, UnresolvedMacro>
fn as_call_id( &self, db: &dyn ExpandDatabase, krate: Idx<CrateData>, resolver: impl Fn(&ModPath) -> Option<MacroDefId> + Copy, ) -> Option<MacroCallId>
§impl<FileKind, T> Clone for InFileWrapper<FileKind, T>
impl<FileKind, T> Clone for InFileWrapper<FileKind, T>
§fn clone(&self) -> InFileWrapper<FileKind, T>
fn clone(&self) -> InFileWrapper<FileKind, T>
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 more§impl<FileKind, T> Debug for InFileWrapper<FileKind, T>
impl<FileKind, T> Debug for InFileWrapper<FileKind, T>
§impl<T> From<InFileWrapper<EditionedFileId, T>> for InFileWrapper<HirFileId, T>
impl<T> From<InFileWrapper<EditionedFileId, T>> for InFileWrapper<HirFileId, T>
§fn from(_: InFileWrapper<EditionedFileId, T>) -> InFileWrapper<HirFileId, T>
fn from(_: InFileWrapper<EditionedFileId, T>) -> InFileWrapper<HirFileId, T>
Converts to this type from the input type.
§impl<T> From<InFileWrapper<MacroFileId, T>> for InFileWrapper<HirFileId, T>
impl<T> From<InFileWrapper<MacroFileId, T>> for InFileWrapper<HirFileId, T>
§fn from(_: InFileWrapper<MacroFileId, T>) -> InFileWrapper<HirFileId, T>
fn from(_: InFileWrapper<MacroFileId, T>) -> InFileWrapper<HirFileId, T>
Converts to this type from the input type.
§impl<FileKind, T> Hash for InFileWrapper<FileKind, T>
impl<FileKind, T> Hash for InFileWrapper<FileKind, T>
§impl<FileKind, T> PartialEq for InFileWrapper<FileKind, T>
impl<FileKind, T> PartialEq for InFileWrapper<FileKind, T>
impl<FileKind, T> Copy for InFileWrapper<FileKind, T>
impl<FileKind, T> Eq for InFileWrapper<FileKind, T>
impl<FileKind, T> StructuralPartialEq for InFileWrapper<FileKind, T>
Auto Trait Implementations§
impl<FileKind, T> Freeze for InFileWrapper<FileKind, T>
impl<FileKind, T> RefUnwindSafe for InFileWrapper<FileKind, T>where
FileKind: RefUnwindSafe,
T: RefUnwindSafe,
impl<FileKind, T> Send for InFileWrapper<FileKind, T>
impl<FileKind, T> Sync for InFileWrapper<FileKind, T>
impl<FileKind, T> Unpin for InFileWrapper<FileKind, T>
impl<FileKind, T> UnwindSafe for InFileWrapper<FileKind, T>where
FileKind: UnwindSafe,
T: UnwindSafe,
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
§impl<T> Cast for T
impl<T> Cast for T
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