diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-03-12 13:06:43 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-04-02 16:14:58 +0200 |
| commit | 96404ee8443c7475b3b6a7b9beb142e7e9354673 (patch) | |
| tree | e58feead43d306e1230bd104a7ac9f517acf6a97 /src/libsyntax | |
| parent | f694222887cf31f51e68927716c25736e62f037f (diff) | |
| download | rust-96404ee8443c7475b3b6a7b9beb142e7e9354673.tar.gz rust-96404ee8443c7475b3b6a7b9beb142e7e9354673.zip | |
Emit ansi color codes in the `rendered` field of json diagnostics
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/json.rs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 9acd0d099a0..55005a821b2 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -30,37 +30,46 @@ pub struct JsonEmitter { sm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>, pretty: bool, ui_testing: bool, + colorful_rendered: bool, } impl JsonEmitter { - pub fn stderr(registry: Option<Registry>, - source_map: Lrc<SourceMap>, - pretty: bool) -> JsonEmitter { + pub fn stderr( + registry: Option<Registry>, + source_map: Lrc<SourceMap>, + pretty: bool, + colorful_rendered: bool, + ) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), registry, sm: source_map, pretty, ui_testing: false, + colorful_rendered, } } - pub fn basic(pretty: bool) -> JsonEmitter { + pub fn basic(pretty: bool, colorful_rendered: bool) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); JsonEmitter::stderr(None, Lrc::new(SourceMap::new(file_path_mapping)), - pretty) + pretty, colorful_rendered) } - pub fn new(dst: Box<dyn Write + Send>, - registry: Option<Registry>, - source_map: Lrc<SourceMap>, - pretty: bool) -> JsonEmitter { + pub fn new( + dst: Box<dyn Write + Send>, + registry: Option<Registry>, + source_map: Lrc<SourceMap>, + pretty: bool, + colorful_rendered: bool, + ) -> JsonEmitter { JsonEmitter { dst, registry, sm: source_map, pretty, ui_testing: false, + colorful_rendered, } } @@ -190,7 +199,7 @@ impl Diagnostic { } let buf = BufWriter::default(); let output = buf.clone(); - EmitterWriter::new(Box::new(buf), Some(je.sm.clone()), false, false) + EmitterWriter::new(Box::new(buf), Some(je.sm.clone()), false, false, je.colorful_rendered) .ui_testing(je.ui_testing).emit(db); let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); let output = String::from_utf8(output).unwrap(); |
