Struct syntax::codemap::CodeMap
[−]
[src]
pub struct CodeMap { pub files: RefCell<Vec<Rc<FileMap>>>, // some fields omitted }
rustc_private
)Fields
files: RefCell<Vec<Rc<FileMap>>>
rustc_private
)Methods
impl CodeMap
[src]
fn new() -> CodeMap
rustc_private
)fn with_file_loader(file_loader: Box<FileLoader>) -> CodeMap
rustc_private
)fn file_exists(&self, path: &Path) -> bool
rustc_private
)fn load_file(&self, path: &Path) -> Result<Rc<FileMap>>
rustc_private
)fn new_filemap(&self,
filename: FileName,
abs_path: Option<FileName>,
src: String)
-> Rc<FileMap>
filename: FileName,
abs_path: Option<FileName>,
src: String)
-> Rc<FileMap>
rustc_private
)Creates a new filemap without setting its line information. If you don't intend to set the line information yourself, you should use new_filemap_and_lines.
fn new_filemap_and_lines(&self,
filename: &str,
abs_path: Option<&str>,
src: &str)
-> Rc<FileMap>
filename: &str,
abs_path: Option<&str>,
src: &str)
-> Rc<FileMap>
rustc_private
)Creates a new filemap and sets its line information.
fn new_imported_filemap(&self,
filename: FileName,
abs_path: Option<FileName>,
source_len: usize,
file_local_lines: Vec<BytePos>,
file_local_multibyte_chars: Vec<MultiByteChar>)
-> Rc<FileMap>
filename: FileName,
abs_path: Option<FileName>,
source_len: usize,
file_local_lines: Vec<BytePos>,
file_local_multibyte_chars: Vec<MultiByteChar>)
-> Rc<FileMap>
rustc_private
)Allocates a new FileMap representing a source file from an external crate. The source code of such an "imported filemap" is not available, but we still know enough to generate accurate debuginfo location information for things inlined from other crates.
fn mk_substr_filename(&self, sp: Span) -> String
rustc_private
)fn lookup_char_pos(&self, pos: BytePos) -> Loc
rustc_private
)Lookup source information about a BytePos
fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt
rustc_private
)fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>
rustc_private
)Returns Some(span)
, a union of the lhs and rhs span. The lhs must precede the rhs. If
there are gaps between lhs and rhs, the resulting union will cross these gaps.
For this to work, the spans have to be:
* the expn_id of both spans much match
* the lhs span needs to end on the same line the rhs span begins
* the lhs span must start at or before the rhs span
fn span_to_string(&self, sp: Span) -> String
rustc_private
)fn span_to_expanded_string(&self, sp: Span) -> String
rustc_private
)Returns a formatted string showing the expansion chain of a span
Spans are printed in the following format:
filename:start_line:col: end_line:col snippet Callee: Callee span Callsite: Callsite span
Callees and callsites are printed recursively (if available, otherwise header and span is omitted), expanding into their own callee/callsite spans. Each layer of recursion has an increased indent, and snippets are truncated to at most 50 characters. Finally, recursive calls to the same macro are squashed, with '...' used to represent any number of recursive calls.
fn source_callsite(&self, sp: Span) -> Span
rustc_private
)Return the source span - this is either the supplied span, or the span for the macro callsite that expanded to it.
fn source_callee(&self, sp: Span) -> Option<NameAndSpan>
rustc_private
)Return the source callee.
Returns None if the supplied span has no expansion trace, else returns the NameAndSpan for the macro definition corresponding to the source callsite.
fn span_to_filename(&self, sp: Span) -> FileName
rustc_private
)fn span_to_lines(&self, sp: Span) -> FileLinesResult
rustc_private
)fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError>
rustc_private
)fn get_filemap(&self, filename: &str) -> Option<Rc<FileMap>>
rustc_private
)fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos
rustc_private
)For a global BytePos compute the local offset within the containing FileMap
fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos
rustc_private
)Converts an absolute BytePos to a CharPos relative to the filemap.
fn lookup_filemap_idx(&self, pos: BytePos) -> usize
rustc_private
)fn record_expansion(&self, expn_info: ExpnInfo) -> ExpnId
rustc_private
)fn with_expn_info<T, F>(&self, id: ExpnId, f: F) -> T where F: FnOnce(Option<&ExpnInfo>) -> T
rustc_private
)fn span_allows_unstable(&self, span: Span) -> bool
rustc_private
)Check if a span is "internal" to a macro in which #[unstable]
items can be used (that is, a macro marked with
#[allow_internal_unstable]
).
fn count_lines(&self) -> usize
rustc_private
)fn macro_backtrace(&self, span: Span) -> Vec<MacroBacktrace>
rustc_private
)Trait Implementations
impl CodeMapper for CodeMap
[src]
fn lookup_char_pos(&self, pos: BytePos) -> Loc
rustc_private
)fn span_to_lines(&self, sp: Span) -> FileLinesResult
rustc_private
)fn span_to_string(&self, sp: Span) -> String
rustc_private
)fn span_to_filename(&self, sp: Span) -> FileName
rustc_private
)fn macro_backtrace(&self, span: Span) -> Vec<MacroBacktrace>
rustc_private
)fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>
rustc_private
)