@@ -48,12 +48,13 @@ use syntax::ptr::P;
4848use syntax:: codemap:: Spanned ;
4949use syntax_pos:: * ;
5050
51- use super :: { escape, generated_code, SaveContext , PathCollector , docs_for_attrs} ;
52- use super :: data:: * ;
53- use super :: dump:: Dump ;
54- use super :: external_data:: { Lower , make_def_id} ;
55- use super :: span_utils:: SpanUtils ;
56- use super :: recorder;
51+ use { escape, generated_code, SaveContext , PathCollector , docs_for_attrs} ;
52+ use data:: * ;
53+ use dump:: Dump ;
54+ use external_data:: { Lower , make_def_id} ;
55+ use recorder;
56+ use span_utils:: SpanUtils ;
57+ use sig;
5758
5859use rls_data:: ExternalCrateData ;
5960
@@ -391,13 +392,13 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
391392 sig : & ' l ast:: MethodSig ,
392393 body : Option < & ' l ast:: Block > ,
393394 id : ast:: NodeId ,
394- name : ast:: Name ,
395+ name : ast:: Ident ,
395396 vis : Visibility ,
396397 attrs : & ' l [ Attribute ] ,
397398 span : Span ) {
398399 debug ! ( "process_method: {}:{}" , id, name) ;
399400
400- if let Some ( method_data) = self . save_ctxt . get_method_data ( id, name, span) {
401+ if let Some ( method_data) = self . save_ctxt . get_method_data ( id, name. name , span) {
401402
402403 let sig_str = :: make_signature ( & sig. decl , & sig. generics ) ;
403404 if body. is_some ( ) {
@@ -423,7 +424,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
423424 Some ( id) => {
424425 for item in self . tcx . associated_items ( id) {
425426 if item. kind == ty:: AssociatedKind :: Method {
426- if item. name == name {
427+ if item. name == name. name {
427428 decl_id = Some ( item. def_id ) ;
428429 break ;
429430 }
@@ -455,7 +456,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
455456 parent : trait_id,
456457 visibility : vis,
457458 docs : docs_for_attrs ( attrs) ,
458- sig : method_data . sig ,
459+ sig : sig:: method_signature ( id , name , sig , & self . save_ctxt ) ,
459460 attributes : attrs. to_vec ( ) ,
460461 } . lower ( self . tcx ) ) ;
461462 }
@@ -580,13 +581,14 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
580581 name : ast:: Name ,
581582 span : Span ,
582583 typ : & ' l ast:: Ty ,
583- expr : & ' l ast:: Expr ,
584+ expr : Option < & ' l ast:: Expr > ,
584585 parent_id : DefId ,
585586 vis : Visibility ,
586587 attrs : & ' l [ Attribute ] ) {
587588 let qualname = format ! ( "::{}" , self . tcx. node_path_str( id) ) ;
588589
589590 let sub_span = self . span . sub_span_after_keyword ( span, keywords:: Const ) ;
591+ let value = expr. map ( |e| self . span . snippet ( e. span ) ) . unwrap_or ( String :: new ( ) ) ;
590592
591593 if !self . span . filter_generated ( sub_span, span) {
592594 self . dumper . variable ( VariableData {
@@ -595,20 +597,22 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
595597 id : id,
596598 name : name. to_string ( ) ,
597599 qualname : qualname,
598- value : self . span . snippet ( expr . span ) ,
600+ value : value ,
599601 type_value : ty_to_string ( & typ) ,
600602 scope : self . cur_scope ,
601603 parent : Some ( parent_id) ,
602604 visibility : vis,
603605 docs : docs_for_attrs ( attrs) ,
604- sig : None ,
606+ sig : sig :: assoc_const_signature ( id , name , typ , expr , & self . save_ctxt ) ,
605607 attributes : attrs. to_vec ( ) ,
606608 } . lower ( self . tcx ) ) ;
607609 }
608610
609611 // walk type and init value
610612 self . visit_ty ( typ) ;
611- self . visit_expr ( expr) ;
613+ if let Some ( expr) = expr {
614+ self . visit_expr ( expr) ;
615+ }
612616 }
613617
614618 // FIXME tuple structs should generate tuple-specific data.
@@ -646,7 +650,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
646650 fields : fields,
647651 visibility : From :: from ( & item. vis ) ,
648652 docs : docs_for_attrs ( & item. attrs ) ,
649- sig : self . save_ctxt . sig_base ( item ) ,
653+ sig : sig :: item_signature ( item , & self . save_ctxt ) ,
650654 attributes : item. attrs . clone ( ) ,
651655 } . lower ( self . tcx ) ) ;
652656 }
@@ -679,18 +683,6 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
679683 qualname. push_str ( "::" ) ;
680684 qualname. push_str ( & name) ;
681685
682- let text = self . span . signature_string_for_span ( variant. span ) ;
683- let ident_start = text. find ( & name) . unwrap ( ) ;
684- let ident_end = ident_start + name. len ( ) ;
685- let sig = Signature {
686- span : variant. span ,
687- text : text,
688- ident_start : ident_start,
689- ident_end : ident_end,
690- defs : vec ! [ ] ,
691- refs : vec ! [ ] ,
692- } ;
693-
694686 match variant. node . data {
695687 ast:: VariantData :: Struct ( ref fields, _) => {
696688 let sub_span = self . span . span_for_first_ident ( variant. span ) ;
@@ -712,7 +704,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
712704 scope : enum_data. scope ,
713705 parent : Some ( make_def_id ( item. id , & self . tcx . hir ) ) ,
714706 docs : docs_for_attrs ( & variant. node . attrs ) ,
715- sig : sig,
707+ sig : sig:: variant_signature ( variant , & self . save_ctxt ) ,
716708 attributes : variant. node . attrs . clone ( ) ,
717709 } . lower ( self . tcx ) ) ;
718710 }
@@ -739,7 +731,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
739731 scope : enum_data. scope ,
740732 parent : Some ( make_def_id ( item. id , & self . tcx . hir ) ) ,
741733 docs : docs_for_attrs ( & variant. node . attrs ) ,
742- sig : sig,
734+ sig : sig:: variant_signature ( variant , & self . save_ctxt ) ,
743735 attributes : variant. node . attrs . clone ( ) ,
744736 } . lower ( self . tcx ) ) ;
745737 }
@@ -811,7 +803,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
811803 items : methods. iter ( ) . map ( |i| i. id ) . collect ( ) ,
812804 visibility : From :: from ( & item. vis ) ,
813805 docs : docs_for_attrs ( & item. attrs ) ,
814- sig : self . save_ctxt . sig_base ( item ) ,
806+ sig : sig :: item_signature ( item , & self . save_ctxt ) ,
815807 attributes : item. attrs . clone ( ) ,
816808 } . lower ( self . tcx ) ) ;
817809 }
@@ -1133,12 +1125,12 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11331125 fn process_trait_item ( & mut self , trait_item : & ' l ast:: TraitItem , trait_id : DefId ) {
11341126 self . process_macro_use ( trait_item. span , trait_item. id ) ;
11351127 match trait_item. node {
1136- ast:: TraitItemKind :: Const ( ref ty, Some ( ref expr) ) => {
1128+ ast:: TraitItemKind :: Const ( ref ty, ref expr) => {
11371129 self . process_assoc_const ( trait_item. id ,
11381130 trait_item. ident . name ,
11391131 trait_item. span ,
11401132 & ty,
1141- & expr,
1133+ expr. as_ref ( ) . map ( |e| & * * e ) ,
11421134 trait_id,
11431135 Visibility :: Public ,
11441136 & trait_item. attrs ) ;
@@ -1147,12 +1139,12 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11471139 self . process_method ( sig,
11481140 body. as_ref ( ) . map ( |x| & * * x) ,
11491141 trait_item. id ,
1150- trait_item. ident . name ,
1142+ trait_item. ident ,
11511143 Visibility :: Public ,
11521144 & trait_item. attrs ,
11531145 trait_item. span ) ;
11541146 }
1155- ast:: TraitItemKind :: Type ( ref _bounds , ref default_ty) => {
1147+ ast:: TraitItemKind :: Type ( ref bounds , ref default_ty) => {
11561148 // FIXME do something with _bounds (for type refs)
11571149 let name = trait_item. ident . name . to_string ( ) ;
11581150 let qualname = format ! ( "::{}" , self . tcx. node_path_str( trait_item. id) ) ;
@@ -1168,7 +1160,11 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11681160 visibility : Visibility :: Public ,
11691161 parent : Some ( trait_id) ,
11701162 docs : docs_for_attrs ( & trait_item. attrs ) ,
1171- sig : None ,
1163+ sig : sig:: assoc_type_signature ( trait_item. id ,
1164+ trait_item. ident ,
1165+ Some ( bounds) ,
1166+ default_ty. as_ref ( ) . map ( |ty| & * * ty) ,
1167+ & self . save_ctxt ) ,
11721168 attributes : trait_item. attrs . clone ( ) ,
11731169 } . lower ( self . tcx ) ) ;
11741170 }
@@ -1177,7 +1173,6 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11771173 self . visit_ty ( default_ty)
11781174 }
11791175 }
1180- ast:: TraitItemKind :: Const ( ref ty, None ) => self . visit_ty ( ty) ,
11811176 ast:: TraitItemKind :: Macro ( _) => { }
11821177 }
11831178 }
@@ -1190,7 +1185,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11901185 impl_item. ident . name ,
11911186 impl_item. span ,
11921187 & ty,
1193- & expr,
1188+ Some ( expr) ,
11941189 impl_id,
11951190 From :: from ( & impl_item. vis ) ,
11961191 & impl_item. attrs ) ;
@@ -1199,12 +1194,17 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11991194 self . process_method ( sig,
12001195 Some ( body) ,
12011196 impl_item. id ,
1202- impl_item. ident . name ,
1197+ impl_item. ident ,
12031198 From :: from ( & impl_item. vis ) ,
12041199 & impl_item. attrs ,
12051200 impl_item. span ) ;
12061201 }
1207- ast:: ImplItemKind :: Type ( ref ty) => self . visit_ty ( ty) ,
1202+ ast:: ImplItemKind :: Type ( ref ty) => {
1203+ // FIXME uses of the assoc type should ideally point to this
1204+ // 'def' and the name here should be a ref to the def in the
1205+ // trait.
1206+ self . visit_ty ( ty)
1207+ }
12081208 ast:: ImplItemKind :: Macro ( _) => { }
12091209 }
12101210 }
@@ -1369,7 +1369,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
13691369 visibility : From :: from ( & item. vis ) ,
13701370 parent : None ,
13711371 docs : docs_for_attrs ( & item. attrs ) ,
1372- sig : Some ( self . save_ctxt . sig_base ( item ) ) ,
1372+ sig : sig :: item_signature ( item , & self . save_ctxt ) ,
13731373 attributes : item. attrs . clone ( ) ,
13741374 } . lower ( self . tcx ) ) ;
13751375 }
0 commit comments