1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Code for annotating snippets.
13 use syntax_pos::{Span, FileMap};
19 pub struct SnippetData {
20 codemap: Rc<CodeMapper>,
28 /// The "primary file", if any, gets a `-->` marker instead of
29 /// `>>>`, and has a line-number/column printed and not just a
30 /// filename. It appears first in the listing. It is known to
31 /// contain at least one primary span, though primary spans (which
32 /// are designated with `^^^`) may also occur in other files.
33 primary_span: Option<Span>,
38 #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
40 pub line_index: usize,
41 pub annotations: Vec<Annotation>,
44 #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
45 pub struct Annotation {
46 /// Start column, 0-based indexing -- counting *characters*, not
47 /// utf-8 bytes. Note that it is important that this field goes
48 /// first, so that when we sort, we sort orderings by start
52 /// End column within the line (exclusive)
55 /// Is this annotation derived from primary span
58 /// Is this a large span minimized down to a smaller span
59 pub is_minimized: bool,
61 /// Optional label to display adjacent to the annotation.
62 pub label: Option<String>,
66 pub struct StyledString {
71 #[derive(Copy, Clone, Debug, PartialEq)]