@@ -179,6 +179,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
179
179
type_value : ty_to_string ( & typ) ,
180
180
visibility : From :: from ( & item. vis ) ,
181
181
docs : docs_for_attrs ( & item. attrs ) ,
182
+ sig : None ,
182
183
} ) )
183
184
}
184
185
ast:: ItemKind :: Const ( ref typ, ref expr) => {
@@ -197,6 +198,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
197
198
type_value : ty_to_string ( & typ) ,
198
199
visibility : From :: from ( & item. vis ) ,
199
200
docs : docs_for_attrs ( & item. attrs ) ,
201
+ sig : None ,
200
202
} ) )
201
203
}
202
204
ast:: ItemKind :: Mod ( ref m) => {
@@ -287,18 +289,39 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
287
289
}
288
290
}
289
291
290
- pub fn get_field_data ( & self , field : & ast:: StructField ,
291
- scope : NodeId ) -> Option < VariableData > {
292
+ pub fn get_field_data ( & self ,
293
+ field : & ast:: StructField ,
294
+ scope : NodeId )
295
+ -> Option < VariableData > {
292
296
if let Some ( ident) = field. ident {
297
+ let name = ident. to_string ( ) ;
293
298
let qualname = format ! ( "::{}::{}" , self . tcx. node_path_str( scope) , ident) ;
294
- let def_id = self . tcx . map . local_def_id ( field. id ) ;
295
- let typ = self . tcx . item_type ( def_id) . to_string ( ) ;
296
299
let sub_span = self . span_utils . sub_span_before_token ( field. span , token:: Colon ) ;
297
300
filter ! ( self . span_utils, sub_span, field. span, None ) ;
301
+ let def_id = self . tcx . map . local_def_id ( field. id ) ;
302
+ let typ = self . tcx . item_type ( def_id) . to_string ( ) ;
303
+
304
+ let span = field. span ;
305
+ let text = self . span_utils . snippet ( field. span ) ;
306
+ let ident_start = text. find ( & name) . unwrap ( ) ;
307
+ let ident_end = ident_start + name. len ( ) ;
308
+ // TODO refs
309
+ let sig = Signature {
310
+ span : span,
311
+ text : text,
312
+ ident_start : ident_start,
313
+ ident_end : ident_end,
314
+ defs : vec ! [ SigElement {
315
+ id: def_id,
316
+ start: ident_start,
317
+ end: ident_end,
318
+ } ] ,
319
+ refs : vec ! [ ] ,
320
+ } ;
298
321
Some ( VariableData {
299
322
id : field. id ,
300
323
kind : VariableKind :: Field ,
301
- name : ident . to_string ( ) ,
324
+ name : name ,
302
325
qualname : qualname,
303
326
span : sub_span. unwrap ( ) ,
304
327
scope : scope,
@@ -307,6 +330,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
307
330
type_value : typ,
308
331
visibility : From :: from ( & field. vis ) ,
309
332
docs : docs_for_attrs ( & field. attrs ) ,
333
+ sig : Some ( sig) ,
310
334
} )
311
335
} else {
312
336
None
0 commit comments