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

View File

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