Module annotation

Module annotation 

Source
Expand description

A utility for pretty-printing source code annotations, warnings and errors.

display_annotations returns an object that implements Display, that will pretty-print some source code based on a list of Annotations.

§Example

use sqparse::annotation::{Annotation, display_annotations, Mode};

yansi::Paint::disable();

let source = "highlight me!";
let annotations = [
    Annotation {
        mode: Mode::Info,
        text: "this is me!".to_string(),
        note: "".to_string(),
        highlight: 10..12,
        visible: 10..12,
    }
];
let annotations = format!("{}", display_annotations(Some("file.txt"), source, &annotations));
assert_eq!(annotations, " --> file.txt:1:11
  |
1 | highlight me!
  |           -- this is me!");

Structs§

Annotation
A source code annotation.

Enums§

Mode
Controls the theme/styling of an Annotation.

Functions§

display_annotations
Displays a list of annotations from a source string.