Struct syntex_syntax::codemap::CodeMap [] [src]

pub struct CodeMap {
    pub files: RefCell<Vec<Rc<FileMap>>>,
    // some fields omitted
}

Fields

files: RefCell<Vec<Rc<FileMap>>>

Methods

impl CodeMap
[src]

fn new() -> CodeMap

fn with_file_loader(file_loader: Box<FileLoader>) -> CodeMap

fn file_exists(&self, path: &Path) -> bool

fn load_file(&self, path: &Path) -> Result<Rc<FileMap>>

fn new_filemap(&self, filename: FileName, src: String) -> Rc<FileMap>

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, src: &str) -> Rc<FileMap>

Creates a new filemap and sets its line information.

fn new_imported_filemap(&self, filename: FileName, source_len: usize, file_local_lines: Vec<BytePos>, file_local_multibyte_chars: Vec<MultiByteChar>) -> Rc<FileMap>

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

fn lookup_char_pos(&self, pos: BytePos) -> Loc

Lookup source information about a BytePos

fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt

fn span_to_string(&self, sp: Span) -> String

fn span_to_expanded_string(&self, sp: Span) -> String

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

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>

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

fn span_to_lines(&self, sp: Span) -> FileLinesResult

fn span_to_snippet(&self, sp: Span) -> Result<StringSpanSnippetError>

fn custom_group_spans<F>(&self, spans: Vec<Span>, push: F) -> Vec<MultiSpan> where F: Fn(&mut MultiSpan, Span)

Groups and sorts spans by lines into MultiSpans, where push adds them to their group, specifying the unification behaviour for overlapping spans. Spans overflowing a line are put into their own one-element-group.

fn group_spans(&self, spans: Vec<Span>) -> Vec<MultiSpan>

Groups and sorts spans by lines into MultiSpans, merging overlapping spans. Spans overflowing a line are put into their own one-element-group.

fn end_group_spans(&self, spans: Vec<Span>) -> Vec<MultiSpan>

Like group_spans, but trims overlapping spans instead of merging them (for use with end_highlight_lines)

fn get_filemap(&self, filename: &str) -> Rc<FileMap>

fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos

For a global BytePos compute the local offset within the containing FileMap

fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos

Converts an absolute BytePos to a CharPos relative to the filemap.

fn record_expansion(&self, expn_info: ExpnInfo) -> ExpnId

fn with_expn_info<T, F>(&self, id: ExpnId, f: F) -> T where F: FnOnce(Option<&ExpnInfo>) -> T

fn span_allows_unstable(&self, span: Span) -> bool

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