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: TImplementations§
Source§impl InFileWrapper<HirFileId, FileAstId<Macro>>
impl InFileWrapper<HirFileId, FileAstId<Macro>>
Sourcepub fn decl_macro_expander<'db>(
self: AstId<Macro>,
db: &'db dyn SourceDatabase,
def_crate: Crate,
) -> &'db DeclarativeMacroExpander
pub fn decl_macro_expander<'db>( self: AstId<Macro>, db: &'db dyn SourceDatabase, def_crate: Crate, ) -> &'db DeclarativeMacroExpander
Fetches (and compiles) the expander of this decl macro.
Source§impl<N: AstNode> InFileWrapper<HirFileId, FileAstId<N>>
impl<N: AstNode> InFileWrapper<HirFileId, FileAstId<N>>
pub fn to_node(&self, db: &dyn SourceDatabase) -> N
pub fn to_range(&self, db: &dyn SourceDatabase) -> TextRange
pub fn to_in_file_node(&self, db: &dyn SourceDatabase) -> InFile<N>
pub fn to_ptr(&self, db: &dyn SourceDatabase) -> AstPtr<N>
pub fn erase(&self) -> ErasedAstId
pub fn upcast<M: AstIdNode>(self) -> AstId<M>where
N: Into<M>,
Source§impl InFileWrapper<HirFileId, ErasedFileAstId>
impl InFileWrapper<HirFileId, ErasedFileAstId>
Source§impl<FileKind, N: AstNode> InFileWrapper<FileKind, AstPtr<N>>
impl<FileKind, N: AstNode> InFileWrapper<FileKind, AstPtr<N>>
pub fn upcast<M: AstNode>(self) -> InFileWrapper<FileKind, AstPtr<M>>where
N: Into<M>,
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 SourceDatabase) -> SyntaxNode
Source§impl<FileId: FileIdToSyntax, N: AstNode> InFileWrapper<FileId, AstPtr<N>>
impl<FileId: FileIdToSyntax, N: AstNode> InFileWrapper<FileId, AstPtr<N>>
Source§impl<FileId: Copy, N: AstNode> InFileWrapper<FileId, N>
impl<FileId: Copy, N: AstNode> InFileWrapper<FileId, N>
pub fn syntax(&self) -> InFileWrapper<FileId, &SyntaxNode>
pub fn node_file_range(&self) -> FileRangeWrapper<FileId>
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<FileId: Copy, SN: Borrow<SyntaxNode>> InFileWrapper<FileId, SN>
impl<FileId: Copy, SN: Borrow<SyntaxNode>> InFileWrapper<FileId, SN>
pub fn file_range(&self) -> FileRangeWrapper<FileId>
Source§impl<SN: Borrow<SyntaxNode>> InFileWrapper<HirFileId, SN>
impl<SN: Borrow<SyntaxNode>> InFileWrapper<HirFileId, SN>
pub fn parent_ancestors_with_macros( self, db: &dyn SourceDatabase, ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_
pub fn ancestors_with_macros( self, db: &dyn SourceDatabase, ) -> 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 SourceDatabase) -> FileRange
pub fn original_file_range_rooted(self, db: &dyn SourceDatabase) -> 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_input(
self,
db: &dyn SourceDatabase,
) -> FileRange
pub fn original_file_range_with_macro_call_input( self, db: &dyn SourceDatabase, ) -> 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 SourceDatabase, ) -> Option<InRealFile<SyntaxNode>>
Source§impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>
impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>
Sourcepub fn original_file_range_opt(
self,
db: &dyn SourceDatabase,
) -> Option<(FileRange, SyntaxContext)>
pub fn original_file_range_opt( self, db: &dyn SourceDatabase, ) -> Option<(FileRange, SyntaxContext)>
Attempts to map the syntax node back up its macro calls.
Source§impl InFileWrapper<MacroCallId, SyntaxToken<RustLanguage>>
impl InFileWrapper<MacroCallId, SyntaxToken<RustLanguage>>
pub fn upmap_once( self, db: &dyn SourceDatabase, ) -> InFile<SmallVec<[TextRange; 1]>>
Source§impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>
impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>
Sourcepub fn original_file_range(self, db: &dyn SourceDatabase) -> FileRange
pub fn original_file_range(self, db: &dyn SourceDatabase) -> 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 SourceDatabase,
) -> Option<FileRange>
pub fn original_file_range_opt( self, db: &dyn SourceDatabase, ) -> Option<FileRange>
Attempts to map the syntax node back up its macro calls.
Source§impl InFileWrapper<MacroCallId, TextSize>
impl InFileWrapper<MacroCallId, TextSize>
pub fn original_file_range( self, db: &dyn SourceDatabase, ) -> (FileRange, SyntaxContext)
Source§impl InFileWrapper<HirFileId, TextRange>
impl InFileWrapper<HirFileId, TextRange>
pub fn original_node_file_range( self, db: &dyn SourceDatabase, ) -> (FileRange, SyntaxContext)
pub fn original_node_file_range_rooted( self, db: &dyn SourceDatabase, ) -> FileRange
pub fn original_node_file_range_with_macro_call_input( self, db: &dyn SourceDatabase, ) -> FileRange
pub fn original_node_file_range_opt( self, db: &dyn SourceDatabase, ) -> Option<(FileRange, SyntaxContext)>
pub fn original_node_file_range_rooted_opt( self, db: &dyn SourceDatabase, ) -> Option<FileRange>
Source§impl<N: AstNode> InFileWrapper<HirFileId, N>
impl<N: AstNode> InFileWrapper<HirFileId, N>
pub fn original_ast_node_rooted( self, db: &dyn SourceDatabase, ) -> 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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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<MacroCallId, T>> for InFile<T>
impl<T> From<InFileWrapper<MacroCallId, T>> for InFile<T>
Source§fn from(_: InMacroFile<T>) -> Self
fn from(_: InMacroFile<T>) -> Self
Converts to this type from the input type.
Source§impl<FileKind: PartialEq, T: PartialEq> PartialEq for InFileWrapper<FileKind, T>
impl<FileKind: PartialEq, T: PartialEq> PartialEq for InFileWrapper<FileKind, T>
Source§fn eq(&self, other: &InFileWrapper<FileKind, T>) -> bool
fn eq(&self, other: &InFileWrapper<FileKind, T>) -> bool
Tests for
self and other values to be equal, and is used by ==.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> UnsafeUnpin for InFileWrapper<FileKind, T>where
FileKind: UnsafeUnpin,
T: UnsafeUnpin,
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,
§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> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
§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