1
Fork 0

save-analysis: add values for types

This commit is contained in:
Nick Cameron 2014-11-23 14:57:26 +13:00
parent e83785c51f
commit 34c76646b5
2 changed files with 22 additions and 13 deletions

View file

@ -568,13 +568,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() {
@ -590,12 +592,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
enum_definition: &ast::EnumDef,
ty_params: &ast::Generics) {
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,
enum_name.as_slice(),
self.cur_scope),
self.cur_scope,
val.as_slice()),
None => self.sess.span_bug(item.span,
format!("Could not find subspan for enum {}",
enum_name).as_slice()),
@ -700,13 +704,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,7 +106,7 @@ impl<'a> FmtStrs<'a> {
Variable => ("variable",
vec!("id","name","qualname","value","type","scopeid"),
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","type","value","scopeid"),
true, true),
@ -117,8 +117,8 @@ impl<'a> FmtStrs<'a> {
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",
@ -161,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 {
@ -327,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,
@ -411,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,
@ -423,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,