Expand description
File and span related types.
Structs§
- AstId
Map - Maps items’
SyntaxNode
s toErasedFileAstId
s and back. - Editioned
File Id - A
FileId
andEdition
bundled up together. The MSB is reserved forHirFileId
encoding, more upper bits are used to then encode the edition. - Erased
File AstId - See crates\hir-expand\src\ast_id_map.rs This is a type erased FileAstId.
- File
AstId AstId
points to an AST node in a specific file.- FileId
- Handle to a file in
Vfs
- HirFile
Id - 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, aHirFileId
is either aFileId
(source code written by user), or aMacroCallId
(source code produced by macro). - Macro
Call Id MacroCallId
identifies a particular macro invocation, likeprintln!("Hello, {}", world)
.- Macro
File Id - Real
Span Map - Span
Anchor - Span
Data - Spans represent a region of code, used by the IDE to be able link macro inputs and outputs
together. Positions in spans are relative to some
SpanAnchor
to make them more incremental friendly. - SpanMap
- Maps absolute text ranges for the corresponding file to the relevant span data.
- Syntax
Context - A syntax context describes a hierarchy tracking order of macro definitions.
- Text
Range - A range in text, represented as a pair of
TextSize
. - Text
Size - A measure of text length. Also, equivalently, an index into text.
- TokenId
- Legacy span type, only defined here as it is still used by the proc-macro server. While rust-analyzer doesn’t use this anymore at all, RustRover relies on the legacy type for proc-macro expansion.
Enums§
- Edition
- HirFile
IdRepr - Transparency
- A property of a macro expansion that determines how identifiers produced by that expansion are resolved.
Constants§
- FIXUP_
ERASED_ FILE_ AST_ ID_ MARKER - FileId used as the span for syntax node fixups. Any Span containing this file id is to be considered fake.
- ROOT_
ERASED_ FILE_ AST_ ID - The root ast id always points to the encompassing file, using this in spans is discouraged as any range relative to it will be effectively absolute, ruining the entire point of anchored relative text ranges.