Files
codeql/csharp/extractor/Semmle.Extraction/SourceScope.cs
2021-02-15 10:17:07 +01:00

24 lines
557 B
C#

using Microsoft.CodeAnalysis;
using System.Linq;
namespace Semmle.Extraction
{
/// <summary>
/// The scope of symbols in a source file.
/// </summary>
public class SourceScope : IExtractionScope
{
public SyntaxTree SourceTree { get; }
public SourceScope(SyntaxTree tree)
{
SourceTree = tree;
}
public bool InFileScope(string path) => path == SourceTree.FilePath;
public bool InScope(ISymbol symbol) => symbol.Locations.Any(loc => loc.SourceTree == SourceTree);
}
}