@@ -136,15 +136,31 @@ impl StackGraph {
136136 Node :: JumpToScope { .. } | Node :: Root { .. } => None ,
137137 } ;
138138
139- if let ( Some ( handle) , Some ( source_info) ) = ( handle, n. source_info ( ) ) {
140- * graph. source_info_mut ( handle) = crate :: graph:: SourceInfo {
141- span : source_info. span . clone ( ) ,
142- syntax_type : source_info
143- . syntax_type
144- . as_ref ( )
145- . map ( |st| graph. add_string ( st. as_str ( ) ) ) ,
146- ..Default :: default ( )
147- } ;
139+ if let Some ( handle) = handle {
140+ // load source-info of each node
141+ if let Some ( source_info) = n. source_info ( ) {
142+ * graph. source_info_mut ( handle) = crate :: graph:: SourceInfo {
143+ span : source_info. span . clone ( ) ,
144+ syntax_type : source_info
145+ . syntax_type
146+ . as_ref ( )
147+ . map ( |st| graph. add_string ( st. as_str ( ) ) ) ,
148+ ..Default :: default ( )
149+ } ;
150+ }
151+
152+ // load debug-info of each node
153+ if let Some ( debug_info) = n. debug_info ( ) {
154+ * graph. debug_info_mut ( handle) = debug_info. data . iter ( ) . fold (
155+ crate :: graph:: DebugInfo :: default ( ) ,
156+ |mut info, entry| {
157+ let key = graph. add_string ( entry. key . as_str ( ) ) ;
158+ let value = graph. add_string ( entry. value . as_str ( ) ) ;
159+ info. add ( key, value) ;
160+ info
161+ } ,
162+ ) ;
163+ }
148164 }
149165 }
150166 Ok ( ( ) )
@@ -262,6 +278,20 @@ impl Node {
262278 }
263279 . as_ref ( )
264280 }
281+
282+ fn debug_info ( & self ) -> Option < & DebugInfo > {
283+ match self {
284+ Self :: DropScopes { debug_info, .. } => debug_info,
285+ Self :: JumpToScope { debug_info, .. } => debug_info,
286+ Self :: PopScopedSymbol { debug_info, .. } => debug_info,
287+ Self :: PopSymbol { debug_info, .. } => debug_info,
288+ Self :: PushScopedSymbol { debug_info, .. } => debug_info,
289+ Self :: PushSymbol { debug_info, .. } => debug_info,
290+ Self :: Root { debug_info, .. } => debug_info,
291+ Self :: Scope { debug_info, .. } => debug_info,
292+ }
293+ . as_ref ( )
294+ }
265295}
266296
267297#[ derive( Serialize , Deserialize , PartialEq , Eq , Debug , Clone ) ]
0 commit comments