save-analysis: api-ify method calls
This commit is contained in:
parent
9f26f14dc9
commit
8ac0bce64e
@ -886,18 +886,14 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||
fn process_method_call(&mut self,
|
||||
ex: &ast::Expr,
|
||||
args: &Vec<P<ast::Expr>>) {
|
||||
let method_call = ty::MethodCall::expr(ex.id);
|
||||
let method_id = self.tcx.tables.borrow().method_map[&method_call].def_id;
|
||||
let (def_id, decl_id) = match self.tcx.impl_or_trait_item(method_id).container() {
|
||||
ty::ImplContainer(_) => (Some(method_id), None),
|
||||
ty::TraitContainer(_) => (None, Some(method_id))
|
||||
};
|
||||
let sub_span = self.span.sub_span_for_meth_name(ex.span);
|
||||
self.fmt.meth_call_str(ex.span,
|
||||
sub_span,
|
||||
def_id,
|
||||
decl_id,
|
||||
self.cur_scope);
|
||||
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,
|
||||
Some(call_data.span),
|
||||
call_data.ref_id,
|
||||
call_data.decl_id,
|
||||
call_data.scope);
|
||||
}
|
||||
|
||||
// walk receiver and args
|
||||
visit::walk_exprs(self, &args);
|
||||
|
@ -61,6 +61,8 @@ pub enum Data {
|
||||
VariableRefData(VariableRefData),
|
||||
/// Data for a reference to a type or trait.
|
||||
TypeRefData(TypeRefData),
|
||||
/// Data about a method call.
|
||||
MethodCallData(MethodCallData),
|
||||
}
|
||||
|
||||
/// Data for all kinds of functions and methods.
|
||||
@ -137,6 +139,16 @@ pub struct TypeRefData {
|
||||
pub ref_id: DefId,
|
||||
}
|
||||
|
||||
/// Data about a method call.
|
||||
#[derive(Debug)]
|
||||
pub struct MethodCallData {
|
||||
pub span: Span,
|
||||
pub scope: NodeId,
|
||||
pub ref_id: Option<DefId>,
|
||||
pub decl_id: Option<DefId>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
pub fn new(tcx: &'l ty::ctxt<'tcx>,
|
||||
@ -372,6 +384,21 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
ast::ExprMethodCall(..) => {
|
||||
let method_call = ty::MethodCall::expr(expr.id);
|
||||
let method_id = self.tcx.tables.borrow().method_map[&method_call].def_id;
|
||||
let (def_id, decl_id) = match self.tcx.impl_or_trait_item(method_id).container() {
|
||||
ty::ImplContainer(_) => (Some(method_id), None),
|
||||
ty::TraitContainer(_) => (None, Some(method_id))
|
||||
};
|
||||
let sub_span = self.span_utils.sub_span_for_meth_name(expr.span);
|
||||
Some(Data::MethodCallData(MethodCallData {
|
||||
span: sub_span.unwrap(),
|
||||
scope: self.tcx.map.get_enclosing_scope(expr.id).unwrap_or(0),
|
||||
ref_id: def_id,
|
||||
decl_id: decl_id,
|
||||
}))
|
||||
}
|
||||
_ => {
|
||||
// FIXME
|
||||
unimplemented!();
|
||||
|
Loading…
x
Reference in New Issue
Block a user