File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed
Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ public override void Populate(TextWriter trapFile)
5454 // Note: symbol.Locations seems to be very inconsistent
5555 // about what locations are available for a tuple type.
5656 // Sometimes it's the source code, and sometimes it's empty.
57- foreach ( var l in Symbol . Locations )
58- WriteLocationToTrap ( trapFile . type_location , this , Context . CreateLocation ( l ) ) ;
57+ var locations = Context . GetLocations ( Symbol ) ;
58+ WriteLocationsToTrap ( trapFile . type_location , this , locations ) ;
5959 }
6060
6161 private readonly Lazy < Field ? [ ] > tupleElementsLazy ;
Original file line number Diff line number Diff line change @@ -28,10 +28,8 @@ public override void Populate(TextWriter trapFile)
2828
2929 if ( Context . ExtractLocation ( Symbol ) )
3030 {
31- foreach ( var l in Symbol . Locations )
32- {
33- WriteLocationToTrap ( trapFile . type_location , this , Context . CreateLocation ( l ) ) ;
34- }
31+ var locations = Context . GetLocations ( Symbol ) ;
32+ WriteLocationsToTrap ( trapFile . type_location , this , locations ) ;
3533 }
3634
3735 if ( IsSourceDeclaration )
Original file line number Diff line number Diff line change @@ -554,6 +554,18 @@ public bool ExtractLocation(ISymbol symbol) =>
554554 SymbolEqualityComparer . Default . Equals ( symbol , symbol . OriginalDefinition ) &&
555555 scope . InScope ( symbol ) ;
556556
557+ /// <summary>
558+ /// Gets the locations of the symbol that are either
559+ /// (1) In assemblies.
560+ /// (2) In the current context.
561+ /// </summary>
562+ /// <param name="symbol">The symbol</param>
563+ /// <returns>List of locations</returns>
564+ public IEnumerable < Entities . Location > GetLocations ( ISymbol symbol ) =>
565+ symbol . Locations
566+ . Where ( l => ! l . IsInSource || IsLocationInContext ( l ) )
567+ . Select ( CreateLocation ) ;
568+
557569 public bool IsLocationInContext ( Location location ) =>
558570 location . SourceTree == SourceTree ;
559571
You can’t perform that action at this time.
0 commit comments