Struct hir_expand::files::InFileWrapper
source · 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§
source§impl<N: AstIdNode> InFileWrapper<HirFileId, FileAstId<N>>
impl<N: AstIdNode> InFileWrapper<HirFileId, FileAstId<N>>
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) -> InFile<N>
pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> AstPtr<N>
source§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
source§impl<FileKind, T> InFileWrapper<FileKind, T>
impl<FileKind, T> InFileWrapper<FileKind, T>
source§impl<FileKind: Copy, T> InFileWrapper<FileKind, T>
impl<FileKind: Copy, T> InFileWrapper<FileKind, T>
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>,
source§impl<FileKind: Copy, T: Clone> InFileWrapper<FileKind, &T>
impl<FileKind: Copy, T: Clone> InFileWrapper<FileKind, &T>
pub fn cloned(&self) -> InFileWrapper<FileKind, T>
source§impl<FileKind, T> InFileWrapper<FileKind, Option<T>>
impl<FileKind, T> InFileWrapper<FileKind, Option<T>>
pub fn transpose(self) -> Option<InFileWrapper<FileKind, T>>
source§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>>
source§impl<FileId: FileIdToSyntax, T> InFileWrapper<FileId, T>
impl<FileId: FileIdToSyntax, T> InFileWrapper<FileId, T>
pub fn file_syntax(&self, db: &dyn ExpandDatabase) -> SyntaxNode
source§impl<FileId: Copy, N: AstNode> InFileWrapper<FileId, N>
impl<FileId: Copy, N: AstNode> InFileWrapper<FileId, N>
pub fn syntax(&self) -> InFileWrapper<FileId, &SyntaxNode>
source§impl<FileId: Copy, N: AstNode> InFileWrapper<FileId, &N>
impl<FileId: Copy, N: AstNode> InFileWrapper<FileId, &N>
pub fn syntax_ref(&self) -> InFileWrapper<FileId, &SyntaxNode>
source§impl<SN: Borrow<SyntaxNode>> InFileWrapper<EditionedFileId, SN>
impl<SN: Borrow<SyntaxNode>> InFileWrapper<EditionedFileId, SN>
pub fn file_range(&self) -> FileRange
source§impl<SN: Borrow<SyntaxNode>> InFileWrapper<HirFileId, SN>
impl<SN: Borrow<SyntaxNode>> InFileWrapper<HirFileId, SN>
pub fn parent_ancestors_with_macros( self, db: &dyn ExpandDatabase, ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_
pub fn ancestors_with_macros( self, db: &dyn ExpandDatabase, ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_
pub fn kind(&self) -> SyntaxKind
pub fn text_range(&self) -> TextRange
sourcepub fn original_file_range_rooted(self, db: &dyn ExpandDatabase) -> FileRange
pub fn original_file_range_rooted(self, db: &dyn ExpandDatabase) -> FileRange
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
].
sourcepub fn original_file_range_with_macro_call_body(
self,
db: &dyn ExpandDatabase,
) -> FileRange
pub fn original_file_range_with_macro_call_body( self, db: &dyn ExpandDatabase, ) -> FileRange
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<InRealFile<SyntaxNode>>
source§impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>
impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>
sourcepub fn original_file_range_opt(
self,
db: &dyn ExpandDatabase,
) -> Option<(FileRange, SyntaxContextId)>
pub fn original_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<(FileRange, SyntaxContextId)>
Attempts to map the syntax node back up its macro calls.
source§impl InFileWrapper<MacroFileId, SyntaxToken<RustLanguage>>
impl InFileWrapper<MacroFileId, SyntaxToken<RustLanguage>>
pub fn upmap_once( self, db: &dyn ExpandDatabase, ) -> InFile<SmallVec<[TextRange; 1]>>
source§impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>
impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>
sourcepub fn original_file_range(self, db: &dyn ExpandDatabase) -> FileRange
pub fn original_file_range(self, db: &dyn ExpandDatabase) -> FileRange
Falls back to the macro call range if the node cannot be mapped up fully.
sourcepub fn original_file_range_opt(
self,
db: &dyn ExpandDatabase,
) -> Option<FileRange>
pub fn original_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<FileRange>
Attempts to map the syntax node back up its macro calls.
source§impl InFileWrapper<MacroFileId, TextSize>
impl InFileWrapper<MacroFileId, TextSize>
pub fn original_file_range( self, db: &dyn ExpandDatabase, ) -> (FileRange, SyntaxContextId)
source§impl InFileWrapper<HirFileId, TextRange>
impl InFileWrapper<HirFileId, TextRange>
pub fn original_node_file_range( self, db: &dyn ExpandDatabase, ) -> (FileRange, SyntaxContextId)
pub fn original_node_file_range_rooted( self, db: &dyn ExpandDatabase, ) -> FileRange
pub fn original_node_file_range_with_macro_call_body( self, db: &dyn ExpandDatabase, ) -> FileRange
pub fn original_node_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<(FileRange, SyntaxContextId)>
source§impl<N: AstNode> InFileWrapper<HirFileId, N>
impl<N: AstNode> InFileWrapper<HirFileId, N>
pub fn original_ast_node_rooted( self, db: &dyn ExpandDatabase, ) -> Option<InRealFile<N>>
source§impl<T> InFileWrapper<HirFileId, T>
impl<T> InFileWrapper<HirFileId, T>
pub fn into_real_file(self) -> Result<InRealFile<T>, InFile<T>>
Trait Implementations§
source§impl<FileKind: Clone, T: Clone> Clone for InFileWrapper<FileKind, T>
impl<FileKind: Clone, T: Clone> Clone for InFileWrapper<FileKind, T>
source§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 moresource§impl<T> From<InFileWrapper<EditionedFileId, T>> for InFile<T>
impl<T> From<InFileWrapper<EditionedFileId, T>> for InFile<T>
source§fn from(_: InRealFile<T>) -> Self
fn from(_: InRealFile<T>) -> Self
Converts to this type from the input type.
source§impl<T> From<InFileWrapper<MacroFileId, T>> for InFile<T>
impl<T> From<InFileWrapper<MacroFileId, T>> for InFile<T>
source§fn from(_: InMacroFile<T>) -> Self
fn from(_: InMacroFile<T>) -> Self
Converts to this type from the input type.
impl<FileKind: Copy, T: Copy> Copy for InFileWrapper<FileKind, T>
impl<FileKind: Eq, T: Eq> 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
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