@@ -62,7 +62,6 @@ impl<'b, W: Write + 'b> Dump for JsonDumper<'b, W> {
62
62
impl_fn ! ( function, FunctionData , defs) ;
63
63
impl_fn ! ( method, MethodData , defs) ;
64
64
impl_fn ! ( macro_data, MacroData , defs) ;
65
- impl_fn ! ( mod_data, ModData , defs) ;
66
65
impl_fn ! ( typedef, TypeDefData , defs) ;
67
66
impl_fn ! ( variable, VariableData , defs) ;
68
67
@@ -75,6 +74,43 @@ impl<'b, W: Write + 'b> Dump for JsonDumper<'b, W> {
75
74
76
75
impl_fn ! ( macro_use, MacroUseData , macro_refs) ;
77
76
77
+ fn mod_data ( & mut self , data : ModData ) {
78
+ let id: Id = From :: from ( data. id ) ;
79
+ let mut def = Def {
80
+ kind : DefKind :: Mod ,
81
+ id : id,
82
+ span : data. span ,
83
+ name : data. name ,
84
+ qualname : data. qualname ,
85
+ value : data. filename ,
86
+ children : data. items . into_iter ( ) . map ( |id| From :: from ( id) ) . collect ( ) ,
87
+ decl_id : None ,
88
+ docs : data. docs ,
89
+ } ;
90
+ if def. span . file_name != def. value {
91
+ // If the module is an out-of-line defintion, then we'll make the
92
+ // defintion the first character in the module's file and turn the
93
+ // the declaration into a reference to it.
94
+ let rf = Ref {
95
+ kind : RefKind :: Mod ,
96
+ span : def. span ,
97
+ ref_id : id,
98
+ } ;
99
+ self . result . refs . push ( rf) ;
100
+ def. span = SpanData {
101
+ file_name : def. value . clone ( ) ,
102
+ byte_start : 0 ,
103
+ byte_end : 0 ,
104
+ line_start : 1 ,
105
+ line_end : 1 ,
106
+ column_start : 1 ,
107
+ column_end : 1 ,
108
+ }
109
+ }
110
+
111
+ self . result . defs . push ( def) ;
112
+ }
113
+
78
114
// FIXME store this instead of throwing it away.
79
115
fn impl_data ( & mut self , _data : ImplData ) { }
80
116
fn inheritance ( & mut self , _data : InheritanceData ) { }
@@ -111,7 +147,7 @@ impl Analysis {
111
147
112
148
// DefId::index is a newtype and so the JSON serialisation is ugly. Therefore
113
149
// we use our own Id which is the same, but without the newtype.
114
- #[ derive( Debug , RustcEncodable ) ]
150
+ #[ derive( Clone , Copy , Debug , RustcEncodable ) ]
115
151
struct Id {
116
152
krate : u32 ,
117
153
index : u32 ,
@@ -337,21 +373,7 @@ impl From<MacroData> for Def {
337
373
}
338
374
}
339
375
}
340
- impl From < ModData > for Def {
341
- fn from ( data : ModData ) -> Def {
342
- Def {
343
- kind : DefKind :: Mod ,
344
- id : From :: from ( data. id ) ,
345
- span : data. span ,
346
- name : data. name ,
347
- qualname : data. qualname ,
348
- value : data. filename ,
349
- children : data. items . into_iter ( ) . map ( |id| From :: from ( id) ) . collect ( ) ,
350
- decl_id : None ,
351
- docs : data. docs ,
352
- }
353
- }
354
- }
376
+
355
377
impl From < TypeDefData > for Def {
356
378
fn from ( data : TypeDefData ) -> Def {
357
379
Def {
0 commit comments