Struct ra_ap_hir_expand::HirFileId
source · pub struct HirFileId(/* private fields */);Expand description
Input to the analyzer is a set of files, where each file is identified by
FileId and contains source code. However, another source of source code in
Rust are macros: each macro can be thought of as producing a “temporary
file”. To assign an id to such a file, we use the id of the macro call that
produced the file. So, a HirFileId is either a FileId (source code
written by user), or a MacroCallId (source code produced by macro).
What is a MacroCallId? Simplifying, it’s a HirFileId of a file
containing the call plus the offset of the macro call in the file. Note that
this is a recursive definition! However, the size_of of HirFileId is
finite (because everything bottoms out at the real FileId) and small
(MacroCallId uses the location interning. You can check details here:
https://en.wikipedia.org/wiki/String_interning).
The two variants are encoded in a single u32 which are differentiated by the MSB.
If the MSB is 0, the value represents a FileId, otherwise the remaining 31 bits represent a
MacroCallId.
Implementations§
source§impl HirFileId
impl HirFileId
sourcepub fn original_file(self, db: &dyn ExpandDatabase) -> FileId
pub fn original_file(self, db: &dyn ExpandDatabase) -> FileId
For macro-expansion files, returns the file original source file the expansion originated from.
pub fn expansion_level(self, db: &dyn ExpandDatabase) -> u32
sourcepub fn call_node(self, db: &dyn ExpandDatabase) -> Option<InFile<SyntaxNode>>
pub fn call_node(self, db: &dyn ExpandDatabase) -> Option<InFile<SyntaxNode>>
If this is a macro call, returns the syntax node of the call.
sourcepub fn original_call_node(
self,
db: &dyn ExpandDatabase
) -> Option<(FileId, SyntaxNode)>
pub fn original_call_node( self, db: &dyn ExpandDatabase ) -> Option<(FileId, SyntaxNode)>
If this is a macro call, returns the syntax node of the very first macro call this file resides in.
sourcepub fn expansion_info(self, db: &dyn ExpandDatabase) -> Option<ExpansionInfo>
pub fn expansion_info(self, db: &dyn ExpandDatabase) -> Option<ExpansionInfo>
Return expansion information if it is a macro-expansion file
pub fn as_builtin_derive_attr_node( &self, db: &dyn ExpandDatabase ) -> Option<InFile<Attr>>
pub fn is_custom_derive(&self, db: &dyn ExpandDatabase) -> bool
pub fn is_builtin_derive(&self, db: &dyn ExpandDatabase) -> bool
sourcepub fn is_include_macro(&self, db: &dyn ExpandDatabase) -> bool
pub fn is_include_macro(&self, db: &dyn ExpandDatabase) -> bool
Return whether this file is an include macro
pub fn is_eager(&self, db: &dyn ExpandDatabase) -> bool
sourcepub fn is_attr_macro(&self, db: &dyn ExpandDatabase) -> bool
pub fn is_attr_macro(&self, db: &dyn ExpandDatabase) -> bool
Return whether this file is an attr macro
sourcepub fn is_derive_attr_pseudo_expansion(&self, db: &dyn ExpandDatabase) -> bool
pub fn is_derive_attr_pseudo_expansion(&self, db: &dyn ExpandDatabase) -> bool
Return whether this file is the pseudo expansion of the derive attribute.
See [crate::builtin_attr_macro::derive_attr_expand].
pub fn is_macro(self) -> bool
pub fn macro_file(self) -> Option<MacroFile>
pub fn file_id(self) -> Option<FileId>
Trait Implementations§
source§impl PartialEq for HirFileId
impl PartialEq for HirFileId
impl Copy for HirFileId
impl Eq for HirFileId
impl StructuralEq for HirFileId
impl StructuralPartialEq for HirFileId
Auto Trait Implementations§
impl RefUnwindSafe for HirFileId
impl Send for HirFileId
impl Sync for HirFileId
impl Unpin for HirFileId
impl UnwindSafe for HirFileId
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
§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
key and return true if they are equal.