提交 34c76646 编写于 作者: N Nick Cameron

save-analysis: add values for types

上级 e83785c5
......@@ -568,13 +568,15 @@ fn process_struct(&mut self,
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 @@ fn process_enum(&mut self,
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 @@ fn process_trait(&mut self,
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() {
......
......@@ -106,7 +106,7 @@ fn lookup_row(r: Row) -> (&'static str, Vec<&'static str>, bool, bool) {
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 @@ fn lookup_row(r: Row) -> (&'static str, Vec<&'static str>, bool, bool) {
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 @@ pub fn make_values_str(&self,
}
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 @@ pub fn enum_str(&mut self,
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 @@ pub fn struct_str(&mut self,
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 @@ pub fn trait_str(&mut self,
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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册