From 68c0ba284d3729a02392d7379673fb196c4a3711 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 25 Jul 2019 12:26:28 -0400 Subject: [PATCH] Rename JsonDumper to Dumper The Dumper no longer has anything to do specifically with JSON, it merely represents processing into an `Analysis` output. --- src/librustc_save_analysis/dump_visitor.rs | 8 ++++---- .../{json_dumper.rs => dumper.rs} | 10 +++++----- src/librustc_save_analysis/lib.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) rename src/librustc_save_analysis/{json_dumper.rs => dumper.rs} (95%) diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index fed0764ba9aff..2b349613dc54f 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -10,7 +10,7 @@ //! //! SpanUtils is used to manipulate spans. In particular, to extract sub-spans //! from spans (e.g., the span for `bar` from the above example path). -//! DumpVisitor walks the AST and processes it, and JsonDumper is used for +//! DumpVisitor walks the AST and processes it, and Dumper is used for //! recording the output. use rustc::hir::def::{Res, DefKind as HirDefKind}; @@ -38,7 +38,7 @@ use syntax_pos::*; use crate::{escape, generated_code, id_from_def_id, id_from_node_id, lower_attributes, PathCollector, SaveContext}; -use crate::json_dumper::{Access, JsonDumper}; +use crate::dumper::{Access, Dumper}; use crate::span_utils::SpanUtils; use crate::sig; @@ -78,7 +78,7 @@ macro_rules! access_from_vis { pub struct DumpVisitor<'l, 'tcx, 'll> { save_ctxt: SaveContext<'l, 'tcx>, tcx: TyCtxt<'tcx>, - dumper: &'ll mut JsonDumper, + dumper: &'ll mut Dumper, span: SpanUtils<'l>, @@ -95,7 +95,7 @@ pub struct DumpVisitor<'l, 'tcx, 'll> { impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> { pub fn new( save_ctxt: SaveContext<'l, 'tcx>, - dumper: &'ll mut JsonDumper, + dumper: &'ll mut Dumper, ) -> DumpVisitor<'l, 'tcx, 'll> { let span_utils = SpanUtils::new(&save_ctxt.tcx.sess); DumpVisitor { diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/dumper.rs similarity index 95% rename from src/librustc_save_analysis/json_dumper.rs rename to src/librustc_save_analysis/dumper.rs index c1437a27e5d22..6fb55e6c99055 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/dumper.rs @@ -9,14 +9,14 @@ pub struct Access { pub public: bool, } -pub struct JsonDumper { +pub struct Dumper { result: Analysis, config: Config, } -impl JsonDumper { - pub fn new(config: Config) -> JsonDumper { - JsonDumper { +impl Dumper { + pub fn new(config: Config) -> Dumper { + Dumper { config: config.clone(), result: Analysis::new(config), } @@ -27,7 +27,7 @@ impl JsonDumper { } } -impl JsonDumper { +impl Dumper { pub fn crate_prelude(&mut self, data: CratePreludeData) { self.result.prelude = Some(data) } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index edaf4c7df67b6..ade5e2eca60ba 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -7,7 +7,7 @@ #![recursion_limit="256"] -mod json_dumper; +mod dumper; mod dump_visitor; #[macro_use] mod span_utils; @@ -39,7 +39,7 @@ use syntax::visit::{self, Visitor}; use syntax::print::pprust::{arg_to_string, ty_to_string}; use syntax_pos::*; -use json_dumper::JsonDumper; +use dumper::Dumper; use dump_visitor::DumpVisitor; use span_utils::SpanUtils; @@ -1076,7 +1076,7 @@ impl<'a> SaveHandler for DumpHandler<'a> { ) { let sess = &save_ctxt.tcx.sess; let (output, file_name) = self.output_file(&save_ctxt); - let mut dumper = JsonDumper::new(save_ctxt.config.clone()); + let mut dumper = Dumper::new(save_ctxt.config.clone()); let mut visitor = DumpVisitor::new(save_ctxt, &mut dumper); visitor.dump_crate_info(cratename, krate); @@ -1109,12 +1109,12 @@ impl<'b> SaveHandler for CallbackHandler<'b> { cratename: &str, input: &'l Input, ) { - // We're using the JsonDumper here because it has the format of the + // We're using the Dumper here because it has the format of the // save-analysis results that we will pass to the callback. IOW, we are - // using the JsonDumper to collect the save-analysis results, but not + // using the Dumper to collect the save-analysis results, but not // actually to dump them to a file. This is all a bit convoluted and // there is certainly a simpler design here trying to get out (FIXME). - let mut dumper = JsonDumper::new(save_ctxt.config.clone()); + let mut dumper = Dumper::new(save_ctxt.config.clone()); let mut visitor = DumpVisitor::new(save_ctxt, &mut dumper); visitor.dump_crate_info(cratename, krate);