rollup merge of #19230: nick29581/dxr-values

r?
This commit is contained in:
Jakub Bukaj 2014-11-23 14:11:59 -05:00
commit 34ab1544e2
2 changed files with 43 additions and 26 deletions

View File

@ -560,13 +560,15 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
Some(node_id) => node_id,
None => -1,
};
let val = self.span.snippet(item.span);
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
self.fmt.struct_str(item.span,
sub_span,
item.id,
ctor_id,
qualname.as_slice(),
self.cur_scope);
self.cur_scope,
val.as_slice());
// fields
for field in def.fields.iter() {
@ -581,21 +583,23 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
item: &ast::Item,
enum_definition: &ast::EnumDef,
ty_params: &ast::Generics) {
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
let enum_name = self.analysis.ty_cx.map.path_to_string(item.id);
let val = self.span.snippet(item.span);
match self.span.sub_span_after_keyword(item.span, keywords::Enum) {
Some(sub_span) => self.fmt.enum_str(item.span,
Some(sub_span),
item.id,
qualname.as_slice(),
self.cur_scope),
enum_name.as_slice(),
self.cur_scope,
val.as_slice()),
None => self.sess.span_bug(item.span,
format!("Could not find subspan for enum {}",
qualname).as_slice()),
enum_name).as_slice()),
}
for variant in enum_definition.variants.iter() {
let name = get_ident(variant.node.name);
let name = name.get();
let mut qualname = qualname.clone();
let mut qualname = enum_name.clone();
qualname.push_str("::");
qualname.push_str(name);
let val = self.span.snippet(variant.span);
@ -607,6 +611,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
variant.node.id,
name,
qualname.as_slice(),
enum_name.as_slice(),
val.as_slice(),
item.id);
for arg in args.iter() {
@ -624,18 +629,19 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
variant.node.id,
ctor_id,
qualname.as_slice(),
enum_name.as_slice(),
val.as_slice(),
item.id);
for field in struct_def.fields.iter() {
self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
self.process_struct_field_def(field, enum_name.as_slice(), variant.node.id);
self.visit_ty(&*field.node.ty);
}
}
}
}
self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
self.process_generic_params(ty_params, item.span, enum_name.as_slice(), item.id);
}
fn process_impl(&mut self,
@ -690,13 +696,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
trait_refs: &OwnedSlice<ast::TyParamBound>,
methods: &Vec<ast::TraitItem>) {
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
let val = self.span.snippet(item.span);
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait);
self.fmt.trait_str(item.span,
sub_span,
item.id,
qualname.as_slice(),
self.cur_scope);
self.cur_scope,
val.as_slice());
// super-traits
for super_bound in trait_refs.iter() {

View File

@ -106,15 +106,19 @@ impl<'a> FmtStrs<'a> {
Variable => ("variable",
vec!("id","name","qualname","value","type","scopeid"),
true, true),
Enum => ("enum", vec!("id","qualname","scopeid"), true, true),
Variant => ("variant", vec!("id","name","qualname","value","scopeid"), true, true),
Enum => ("enum", vec!("id","qualname","scopeid","value"), true, true),
Variant => ("variant",
vec!("id","name","qualname","type","value","scopeid"),
true, true),
VariantStruct => ("variant_struct",
vec!("id","ctor_id","qualname","value","scopeid"), true, true),
Function => ("function", vec!("id","qualname","declid","declidcrate","scopeid"),
vec!("id","ctor_id","qualname","type","value","scopeid"),
true, true),
Function => ("function",
vec!("id","qualname","declid","declidcrate","scopeid"),
true, true),
MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid"), true, true),
Trait => ("trait", vec!("id","qualname","scopeid"), true, true),
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid","value"), true, true),
Trait => ("trait", vec!("id","qualname","scopeid","value"), true, true),
Impl => ("impl", vec!("id","refid","refidcrate","scopeid"), true, true),
Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
UseAlias => ("use_alias",
@ -128,7 +132,7 @@ impl<'a> FmtStrs<'a> {
true, false),
MethodCall => ("method_call",
vec!("refid","refidcrate","declid","declidcrate","scopeid"),
true, true),
true, true),
Typedef => ("typedef", vec!("id","qualname","value"), true, true),
ExternalCrate => ("external_crate", vec!("name","crate","file_name"), false, false),
Crate => ("crate", vec!("name"), true, false),
@ -140,7 +144,7 @@ impl<'a> FmtStrs<'a> {
true, true),
StructRef => ("struct_ref",
vec!("refid","refidcrate","qualname","scopeid"),
true, true),
true, true),
FnRef => ("fn_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true)
}
}
@ -157,6 +161,7 @@ impl<'a> FmtStrs<'a> {
}
let values = values.iter().map(|s| {
// Never take more than 1020 chars
if s.len() > 1020 {
s.as_slice().slice_to(1020)
} else {
@ -323,11 +328,12 @@ impl<'a> FmtStrs<'a> {
sub_span: Option<Span>,
id: NodeId,
name: &str,
scope_id: NodeId) {
scope_id: NodeId,
value: &str) {
self.check_and_record(Enum,
span,
sub_span,
svec!(id, name, scope_id));
svec!(id, name, scope_id, value));
}
pub fn tuple_variant_str(&mut self,
@ -336,12 +342,13 @@ impl<'a> FmtStrs<'a> {
id: NodeId,
name: &str,
qualname: &str,
typ: &str,
val: &str,
scope_id: NodeId) {
self.check_and_record(Variant,
span,
sub_span,
svec!(id, name, qualname, val, scope_id));
svec!(id, name, qualname, typ, val, scope_id));
}
pub fn struct_variant_str(&mut self,
@ -350,12 +357,13 @@ impl<'a> FmtStrs<'a> {
id: NodeId,
ctor_id: NodeId,
name: &str,
typ: &str,
val: &str,
scope_id: NodeId) {
self.check_and_record(VariantStruct,
span,
sub_span,
svec!(id, ctor_id, name, val, scope_id));
svec!(id, ctor_id, name, typ, val, scope_id));
}
pub fn fn_str(&mut self,
@ -405,11 +413,12 @@ impl<'a> FmtStrs<'a> {
id: NodeId,
ctor_id: NodeId,
name: &str,
scope_id: NodeId) {
scope_id: NodeId,
value: &str) {
self.check_and_record(Struct,
span,
sub_span,
svec!(id, ctor_id, name, scope_id));
svec!(id, ctor_id, name, scope_id, value));
}
pub fn trait_str(&mut self,
@ -417,11 +426,12 @@ impl<'a> FmtStrs<'a> {
sub_span: Option<Span>,
id: NodeId,
name: &str,
scope_id: NodeId) {
scope_id: NodeId,
value: &str) {
self.check_and_record(Trait,
span,
sub_span,
svec!(id, name, scope_id));
svec!(id, name, scope_id, value));
}
pub fn impl_str(&mut self,