@@ -215,7 +215,7 @@ public void PopulateAll()
215215 }
216216 catch ( Exception ex ) // lgtm[cs/catch-of-all-exceptions]
217217 {
218- ExtractionError ( "Uncaught exception" , ex . Message , GeneratedLocation . Create ( this ) , ex . StackTrace ) ;
218+ ExtractionError ( "Uncaught exception" , ex . Message , Entities . Location . Create ( this ) , ex . StackTrace ) ;
219219 }
220220 }
221221 }
@@ -250,6 +250,8 @@ public Context(IExtractor e, Compilation c, TrapWriter trapWriter, IExtractionSc
250250
251251 private IExtractionScope scope { get ; }
252252
253+ public SyntaxTree ? SourceTree => scope is SourceScope sc ? sc . SourceTree : null ;
254+
253255 /// <summary>
254256 /// Whether the given symbol needs to be defined in this context.
255257 /// This is the case if the symbol is contained in the source/assembly, or
@@ -451,7 +453,7 @@ public void ExtractionError(string message, ISymbol? optionalSymbol, IEntity opt
451453 }
452454 else
453455 {
454- ExtractionError ( message , "" , GeneratedLocation . Create ( this ) ) ;
456+ ExtractionError ( message , "" , Entities . Location . Create ( this ) ) ;
455457 }
456458 }
457459
@@ -522,13 +524,21 @@ public static void Try(this Context context, SyntaxNode? node, ISymbol? symbol,
522524 Message message ;
523525
524526 if ( node != null )
527+ {
525528 message = Message . Create ( context , ex . Message , node , ex . StackTrace ) ;
529+ }
526530 else if ( symbol != null )
531+ {
527532 message = Message . Create ( context , ex . Message , symbol , ex . StackTrace ) ;
533+ }
528534 else if ( ex is InternalError ie )
535+ {
529536 message = new Message ( ie . Text , ie . EntityText , Entities . Location . Create ( context , ie . Location ) , ex . StackTrace ) ;
537+ }
530538 else
531- message = new Message ( "Uncaught exception" , ex . Message , GeneratedLocation . Create ( context ) , ex . StackTrace ) ;
539+ {
540+ message = new Message ( "Uncaught exception" , ex . Message , Entities . Location . Create ( context ) , ex . StackTrace ) ;
541+ }
532542
533543 context . ExtractionError ( message ) ;
534544 }
0 commit comments