C#: Respect the context when extracting locations for type parameters and tuple typles.

This commit is contained in:
Michael Nebel
2025-10-07 15:15:34 +02:00
parent ea4d4751f3
commit f0842e430d
3 changed files with 16 additions and 6 deletions

View File

@@ -554,6 +554,18 @@ namespace Semmle.Extraction.CSharp
SymbolEqualityComparer.Default.Equals(symbol, symbol.OriginalDefinition) &&
scope.InScope(symbol);
/// <summary>
/// Gets the locations of the symbol that are either
/// (1) In assemblies.
/// (2) In the current context.
/// </summary>
/// <param name="symbol">The symbol</param>
/// <returns>List of locations</returns>
public IEnumerable<Entities.Location> GetLocations(ISymbol symbol) =>
symbol.Locations
.Where(l => !l.IsInSource || IsLocationInContext(l))
.Select(CreateLocation);
public bool IsLocationInContext(Location location) =>
location.SourceTree == SourceTree;