Struct ra_ap_hir_expand::InFile
source · pub struct InFile<T> {
pub file_id: HirFileId,
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: HirFileId
§value: T
Implementations§
source§impl<N: AstIdNode> InFile<FileAstId<N>>
impl<N: AstIdNode> InFile<FileAstId<N>>
pub fn to_node(&self, db: &dyn ExpandDatabase) -> N
pub fn to_in_file_node(&self, db: &dyn ExpandDatabase) -> InFile<N>
pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> AstPtr<N>
source§impl InFile<Idx<SyntaxNodePtr<RustLanguage>>>
impl InFile<Idx<SyntaxNodePtr<RustLanguage>>>
pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> SyntaxNodePtr
source§impl<T> InFile<T>
impl<T> InFile<T>
pub fn new(file_id: HirFileId, value: T) -> InFile<T>
pub fn with_value<U>(&self, value: U) -> InFile<U>
pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> InFile<U>
pub fn as_ref(&self) -> InFile<&T>
pub fn file_syntax(&self, db: &dyn ExpandDatabase) -> SyntaxNode
source§impl InFile<&SyntaxNode>
impl InFile<&SyntaxNode>
pub fn ancestors_with_macros( self, db: &dyn ExpandDatabase ) -> impl Iterator<Item = InFile<SyntaxNode>> + Clone + '_
sourcepub fn ancestors_with_macros_skip_attr_item(
self,
db: &dyn ExpandDatabase
) -> impl Iterator<Item = InFile<SyntaxNode>> + '_
pub fn ancestors_with_macros_skip_attr_item( self, db: &dyn ExpandDatabase ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_
Skips the attributed item that caused the macro invocation we are climbing up
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.
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_full(self, db: &dyn ExpandDatabase) -> FileRange
pub fn original_file_range_full(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.
pub fn original_syntax_node( self, db: &dyn ExpandDatabase ) -> Option<InFile<SyntaxNode>>
source§impl InFile<SyntaxToken>
impl InFile<SyntaxToken>
pub fn upmap(self, db: &dyn ExpandDatabase) -> Option<InFile<SyntaxToken>>
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<N: AstNode> InFile<N>
impl<N: AstNode> InFile<N>
pub fn descendants<T: AstNode>(self) -> impl Iterator<Item = InFile<T>>
pub fn original_ast_node(self, db: &dyn ExpandDatabase) -> Option<InFile<N>>
pub fn syntax(&self) -> InFile<&SyntaxNode>
Trait Implementations§
source§impl<T> From<InMacroFile<T>> for InFile<T>
impl<T> From<InMacroFile<T>> for InFile<T>
source§fn from(macro_file: InMacroFile<T>) -> Self
fn from(macro_file: InMacroFile<T>) -> Self
Converts to this type from the input type.
source§impl<T: PartialEq> PartialEq<InFile<T>> for InFile<T>
impl<T: PartialEq> PartialEq<InFile<T>> for InFile<T>
impl<T: Copy> Copy for InFile<T>
impl<T: Eq> Eq for InFile<T>
impl<T> StructuralEq for InFile<T>
impl<T> StructuralPartialEq for InFile<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for InFile<T>where T: RefUnwindSafe,
impl<T> Send for InFile<T>where T: Send,
impl<T> Sync for InFile<T>where T: Sync,
impl<T> Unpin for InFile<T>where T: Unpin,
impl<T> UnwindSafe for InFile<T>where 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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.