span: SpanUtils<'l>,
fmt: FmtStrs<'l>,
- cur_scope: NodeId
+ cur_scope: NodeId,
}
impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
pub fn new(tcx: &'l ty::ctxt<'tcx>,
analysis: &'l ty::CrateAnalysis,
- output_file: Box<File>) -> DumpCsvVisitor<'l, 'tcx> {
+ output_file: Box<File>)
+ -> DumpCsvVisitor<'l, 'tcx> {
let span_utils = SpanUtils::new(&tcx.sess);
DumpCsvVisitor {
sess: &tcx.sess,
save_ctxt: SaveContext::from_span_utils(tcx, span_utils.clone()),
analysis: analysis,
span: span_utils.clone(),
- fmt: FmtStrs::new(box Recorder {
- out: output_file,
- dump_spans: false,
- }, span_utils),
- cur_scope: 0
+ fmt: FmtStrs::new(box Recorder { out: output_file, dump_spans: false },
+ span_utils),
+ cur_scope: 0,
}
}
- fn nest<F>(&mut self, scope_id: NodeId, f: F) where
- F: FnOnce(&mut DumpCsvVisitor<'l, 'tcx>),
+ fn nest<F>(&mut self, scope_id: NodeId, f: F)
+ where F: FnOnce(&mut DumpCsvVisitor<'l, 'tcx>)
{
let parent_scope = self.cur_scope;
self.cur_scope = scope_id;
let mut segs = vec!();
for (i, (seg, span)) in path.segments.iter().zip(&spans).enumerate() {
segs.push(seg.clone());
- let sub_path = ast::Path{span: *span, // span for the last segment
- global: path.global,
- segments: segs};
+ let sub_path = ast::Path {
+ span: *span, // span for the last segment
+ global: path.global,
+ segments: segs,
+ };
let qualname = if i == 0 && path.global {
format!("::{}", path_to_string(&sub_path))
} else {
def::DefPrimTy(_) => {
self.sess.span_bug(span, &format!("lookup_def_kind for unexpected item: {:?}",
def));
- },
+ }
}
}
}
}
- fn process_struct_field_def(&mut self,
- field: &ast::StructField,
- parent_id: NodeId) {
+ fn process_struct_field_def(&mut self, field: &ast::StructField, parent_id: NodeId) {
let field_data = self.save_ctxt.get_field_data(field, parent_id);
if let Some(field_data) = field_data {
self.fmt.field_str(field.span,
// Dump generic params bindings, then visit_generics
fn process_generic_params(&mut self,
- generics:&ast::Generics,
+ generics: &ast::Generics,
full_span: Span,
prefix: &str,
id: NodeId) {
self.nest(item.id, |v| v.visit_block(&body));
}
- fn process_static_or_const_item(&mut self,
- item: &ast::Item,
- typ: &ast::Ty,
- expr: &ast::Expr)
- {
+ fn process_static_or_const_item(&mut self, item: &ast::Item, typ: &ast::Ty, expr: &ast::Expr) {
let var_data = self.save_ctxt.get_item_data(item);
down_cast_data!(var_data, VariableData, self, item.span);
self.fmt.static_str(item.span,
ident: &ast::Ident,
span: Span,
typ: &ast::Ty,
- expr: &ast::Expr)
- {
+ expr: &ast::Expr) {
let qualname = format!("::{}", self.tcx.map.path_to_string(id));
let sub_span = self.span.sub_span_after_keyword(span,
sub_span,
id,
item.id);
- },
- None => ()
+ }
+ None => (),
}
}
}
}
- fn process_mod(&mut self,
- item: &ast::Item) { // The module in question, represented as an item.
+ fn process_mod(&mut self, item: &ast::Item) { // The module in question, represented as an item.
let mod_data = self.save_ctxt.get_item_data(item);
down_cast_data!(mod_data, ModData, self, item.span);
self.fmt.mod_str(item.span,
&mod_data.filename);
}
- fn process_path(&mut self,
- id: NodeId,
- path: &ast::Path,
- ref_kind: Option<recorder::Row>) {
+ fn process_path(&mut self, id: NodeId, path: &ast::Path, ref_kind: Option<recorder::Row>) {
if generated_code(path.span) {
return;
}
def::DefStruct(_) |
def::DefVariant(..) |
def::DefFn(..) => self.write_sub_paths_truncated(path, false),
- _ => {},
+ _ => {}
}
}
visit::walk_expr_opt(self, base)
}
- fn process_method_call(&mut self,
- ex: &ast::Expr,
- args: &Vec<P<ast::Expr>>) {
+ fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec<P<ast::Expr>>) {
if let Some(call_data) = self.save_ctxt.get_expr_data(ex) {
down_cast_data!(call_data, MethodCallData, self, ex.span);
self.fmt.meth_call_str(ex.span,
visit::walk_exprs(self, &args);
}
- fn process_pat(&mut self, p:&ast::Pat) {
+ fn process_pat(&mut self, p: &ast::Pat) {
if generated_code(p.span) {
return;
}
self.visit_pat(&field.pat);
}
}
- _ => visit::walk_pat(self, p)
+ _ => visit::walk_pat(self, p),
}
}
}
sub_span,
def_id,
self.cur_scope),
- None => {},
+ None => {}
}
Some(def_id)
- },
+ }
None => None,
};
match plid.node {
ast::PathListIdent { id, .. } => {
match self.lookup_type_ref(id) {
- Some(def_id) =>
- match self.lookup_def_kind(id, plid.span) {
- Some(kind) => {
- self.fmt.ref_str(
+ Some(def_id) => match self.lookup_def_kind(id, plid.span) {
+ Some(kind) => {
+ self.fmt.ref_str(
kind, plid.span,
Some(plid.span),
def_id, self.cur_scope);
- }
- None => ()
- },
- None => ()
+ }
+ None => (),
+ },
+ None => (),
}
- },
- ast::PathListMod { .. } => ()
+ }
+ ast::PathListMod { .. } => (),
}
}
self.visit_ty(&**ty);
self.process_generic_params(ty_params, item.span, &qualname, item.id);
- },
+ }
ast::ItemMac(_) => (),
_ => visit::walk_item(self, item),
}
sub_span,
id,
self.cur_scope);
- },
- None => ()
+ }
+ None => (),
}
self.write_sub_paths_truncated(path, false);
visit::walk_path(self, path);
- },
+ }
_ => visit::walk_ty(self, t),
}
}
field_data.ref_id,
field_data.scope);
}
- },
+ }
ast::ExprTupField(ref sub_ex, idx) => {
if generated_code(sub_ex.span) {
return
&format!("Expected struct or tuple \
type, found {:?}", ty)),
}
- },
+ }
ast::ExprClosure(_, ref decl, ref body) => {
if generated_code(body.span) {
return
// walk the body
self.nest(ex.id, |v| v.visit_block(&**body));
- },
+ }
_ => {
visit::walk_expr(self, ex)
}
}
let def = def_map.get(&id).unwrap().full_def();
match def {
- def::DefLocal(id) => {
+ def::DefLocal(id) => {
let value = if immut == ast::MutImmutable {
self.span.snippet(p.span).to_string()
} else {
def::DefConst(..) |
def::DefAssociatedConst(..) => {}
_ => error!("unexpected definition kind when processing collected paths: {:?}",
- def)
+ def),
}
}