mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Move location-like entities to the Semmle.Extraction.CSharp namespace
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Semmle.Extraction.CSharp.Comments
|
||||
|
||||
public IEnumerable<CommentLine> CommentLines => lines;
|
||||
|
||||
public Location Location { get; private set; }
|
||||
public Microsoft.CodeAnalysis.Location Location { get; private set; }
|
||||
|
||||
public CommentBlock(CommentLine firstLine)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace Semmle.Extraction.CSharp.Comments
|
||||
{
|
||||
Location = !lines.Any()
|
||||
? line.Location
|
||||
: Location.Create(
|
||||
: Microsoft.CodeAnalysis.Location.Create(
|
||||
line.Location.SourceTree!,
|
||||
new TextSpan(Location.SourceSpan.Start, line.Location.SourceSpan.End - Location.SourceSpan.Start));
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
|
||||
// Comments sorted by location.
|
||||
private readonly SortedDictionary<Location, CommentLine> comments = new SortedDictionary<Location, CommentLine>(new LocationComparer());
|
||||
private readonly SortedDictionary<Microsoft.CodeAnalysis.Location, CommentLine> comments = new SortedDictionary<Microsoft.CodeAnalysis.Location, CommentLine>(new LocationComparer());
|
||||
|
||||
// Program elements sorted by location.
|
||||
private readonly SortedDictionary<Location, Label> elements = new SortedDictionary<Location, Label>(new LocationComparer());
|
||||
private readonly SortedDictionary<Microsoft.CodeAnalysis.Location, Label> elements = new SortedDictionary<Microsoft.CodeAnalysis.Location, Label>(new LocationComparer());
|
||||
|
||||
private readonly Dictionary<Label, Key> duplicationGuardKeys = new Dictionary<Label, Key>();
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Semmle.Extraction.CSharp
|
||||
return null;
|
||||
}
|
||||
|
||||
private class LocationComparer : IComparer<Location>
|
||||
private class LocationComparer : IComparer<Microsoft.CodeAnalysis.Location>
|
||||
{
|
||||
public int Compare(Location? l1, Location? l2) => CommentProcessor.Compare(l1, l2);
|
||||
public int Compare(Microsoft.CodeAnalysis.Location? l1, Microsoft.CodeAnalysis.Location? l2) => CommentProcessor.Compare(l1, l2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +44,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="l1">First location</param>
|
||||
/// <param name="l2">Second location</param>
|
||||
/// <returns><0 if l1 before l2, >0 if l1 after l2, else 0.</returns>
|
||||
private static int Compare(Location? l1, Location? l2)
|
||||
private static int Compare(Microsoft.CodeAnalysis.Location? l1, Microsoft.CodeAnalysis.Location? l2)
|
||||
{
|
||||
if (object.ReferenceEquals(l1, l2))
|
||||
return 0;
|
||||
@@ -68,7 +68,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="elementLabel">The label of the element in the trap file.</param>
|
||||
/// <param name="duplicationGuardKey">The duplication guard key of the element, if any.</param>
|
||||
/// <param name="loc">The location of the element.</param>
|
||||
public void AddElement(Label elementLabel, Key? duplicationGuardKey, Location? loc)
|
||||
public void AddElement(Label elementLabel, Key? duplicationGuardKey, Microsoft.CodeAnalysis.Location? loc)
|
||||
{
|
||||
if (loc is not null && loc.IsInSource)
|
||||
elements[loc] = elementLabel;
|
||||
@@ -78,7 +78,7 @@ namespace Semmle.Extraction.CSharp
|
||||
|
||||
// Ensure that commentBlock and element refer to the same file
|
||||
// which can happen when processing multiple files.
|
||||
private static void EnsureSameFile(Comments.CommentBlock commentBlock, ref KeyValuePair<Location, Label>? element)
|
||||
private static void EnsureSameFile(Comments.CommentBlock commentBlock, ref KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? element)
|
||||
{
|
||||
if (element is not null && element.Value.Key.SourceTree != commentBlock.Location.SourceTree)
|
||||
element = null;
|
||||
@@ -96,9 +96,9 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="callback">Output binding information.</param>
|
||||
private void GenerateBindings(
|
||||
Comments.CommentBlock commentBlock,
|
||||
KeyValuePair<Location, Label>? previousElement,
|
||||
KeyValuePair<Location, Label>? nextElement,
|
||||
KeyValuePair<Location, Label>? parentElement,
|
||||
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? previousElement,
|
||||
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? nextElement,
|
||||
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? parentElement,
|
||||
CommentBindingCallback callback
|
||||
)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
|
||||
// Heuristic to decide which is the "best" element associated with the comment.
|
||||
KeyValuePair<Location, Label>? bestElement;
|
||||
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? bestElement;
|
||||
|
||||
if (previousElement is not null && previousElement.Value.Key.EndLine() == commentBlock.Location.StartLine())
|
||||
{
|
||||
@@ -180,14 +180,14 @@ namespace Semmle.Extraction.CSharp
|
||||
private class ElementStack
|
||||
{
|
||||
// Invariant: the top of the stack must be contained by items below it.
|
||||
private readonly Stack<KeyValuePair<Location, Label>> elementStack = new Stack<KeyValuePair<Location, Label>>();
|
||||
private readonly Stack<KeyValuePair<Microsoft.CodeAnalysis.Location, Label>> elementStack = new();
|
||||
|
||||
/// <summary>
|
||||
/// Add a new element to the stack.
|
||||
/// </summary>
|
||||
/// The stack is maintained.
|
||||
/// <param name="value">The new element to push.</param>
|
||||
public void Push(KeyValuePair<Location, Label> value)
|
||||
public void Push(KeyValuePair<Microsoft.CodeAnalysis.Location, Label> value)
|
||||
{
|
||||
// Maintain the invariant by popping existing elements
|
||||
while (elementStack.Count > 0 && !elementStack.Peek().Key.Contains(value.Key))
|
||||
@@ -201,7 +201,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </summary>
|
||||
/// <param name="l">The location of the comment.</param>
|
||||
/// <returns>An element completely containing l, or null if none found.</returns>
|
||||
public KeyValuePair<Location, Label>? FindParent(Location l) =>
|
||||
public KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? FindParent(Microsoft.CodeAnalysis.Location l) =>
|
||||
elementStack.Where(v => v.Key.Contains(l)).FirstOrNull();
|
||||
|
||||
/// <summary>
|
||||
@@ -209,7 +209,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </summary>
|
||||
/// <param name="l">The location of the comment.</param>
|
||||
/// <returns>The element before l, or null.</returns>
|
||||
public KeyValuePair<Location, Label>? FindBefore(Location l)
|
||||
public KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? FindBefore(Microsoft.CodeAnalysis.Location l)
|
||||
{
|
||||
return elementStack
|
||||
.Where(v => v.Key.SourceSpan.End < l.SourceSpan.Start)
|
||||
@@ -222,7 +222,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="comment">The location of the comment.</param>
|
||||
/// <param name="next">The next element.</param>
|
||||
/// <returns>The next element.</returns>
|
||||
public KeyValuePair<Location, Label>? FindAfter(Location comment, KeyValuePair<Location, Label>? next)
|
||||
public KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? FindAfter(Microsoft.CodeAnalysis.Location comment, KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? next)
|
||||
{
|
||||
var p = FindParent(comment);
|
||||
return next.HasValue && p.HasValue && p.Value.Key.Before(next.Value.Key) ? null : next;
|
||||
@@ -233,7 +233,7 @@ namespace Semmle.Extraction.CSharp
|
||||
private void GenerateBindings(
|
||||
Comments.CommentBlock block,
|
||||
ElementStack elementStack,
|
||||
KeyValuePair<Location, Label>? nextElement,
|
||||
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? nextElement,
|
||||
CommentBindingCallback cb
|
||||
)
|
||||
{
|
||||
@@ -259,8 +259,8 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="cb">Where to send the results.</param>
|
||||
/// <returns>true if there are more comments to process, false otherwise.</returns>
|
||||
private bool GenerateBindings(
|
||||
IEnumerator<KeyValuePair<Location, CommentLine>> commentEnumerator,
|
||||
KeyValuePair<Location, Label>? nextElement,
|
||||
IEnumerator<KeyValuePair<Microsoft.CodeAnalysis.Location, CommentLine>> commentEnumerator,
|
||||
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? nextElement,
|
||||
ElementStack elementStack,
|
||||
CommentBindingCallback cb
|
||||
)
|
||||
@@ -319,8 +319,8 @@ namespace Semmle.Extraction.CSharp
|
||||
|
||||
var elementStack = new ElementStack();
|
||||
|
||||
using IEnumerator<KeyValuePair<Location, Label>> elementEnumerator = elements.GetEnumerator();
|
||||
using IEnumerator<KeyValuePair<Location, CommentLine>> commentEnumerator = comments.GetEnumerator();
|
||||
using IEnumerator<KeyValuePair<Microsoft.CodeAnalysis.Location, Label>> elementEnumerator = elements.GetEnumerator();
|
||||
using IEnumerator<KeyValuePair<Microsoft.CodeAnalysis.Location, CommentLine>> commentEnumerator = comments.GetEnumerator();
|
||||
if (!commentEnumerator.MoveNext())
|
||||
{
|
||||
// There are no comments to process.
|
||||
|
||||
@@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class Assembly : Extraction.Entities.Location
|
||||
internal class Assembly : Location
|
||||
{
|
||||
public override Context Context => (Context)base.Context;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Extraction.Entities.Location Create(Context cx, Microsoft.CodeAnalysis.Location loc) => AssemblyConstructorFactory.Instance.CreateEntity(cx, loc, loc);
|
||||
public static Location Create(Context cx, Microsoft.CodeAnalysis.Location loc) => AssemblyConstructorFactory.Instance.CreateEntity(cx, loc, loc);
|
||||
|
||||
private class AssemblyConstructorFactory : CachedEntityFactory<Microsoft.CodeAnalysis.Location?, Assembly>
|
||||
{
|
||||
|
||||
@@ -151,9 +151,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => attributeSyntax?.Name.GetLocation();
|
||||
|
||||
private Semmle.Extraction.Entities.Location? location;
|
||||
private Location? location;
|
||||
|
||||
private Semmle.Extraction.Entities.Location Location =>
|
||||
private Location Location =>
|
||||
location ??= Context.CreateLocation(attributeSyntax is null
|
||||
? entity.ReportingLocation
|
||||
: attributeSyntax.Name.GetLocation());
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// </summary>
|
||||
public virtual Microsoft.CodeAnalysis.Location? FullLocation => Symbol.Locations.BestOrDefault();
|
||||
|
||||
public virtual IEnumerable<Extraction.Entities.Location> Locations
|
||||
public virtual IEnumerable<Location> Locations
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -143,6 +143,6 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override bool NeedsPopulation => Context.Defines(Symbol);
|
||||
|
||||
public Extraction.Entities.Location Location => Context.CreateLocation(ReportingLocation);
|
||||
public Location Location => Context.CreateLocation(ReportingLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtractSourceInitializer(TextWriter trapFile, ITypeSymbol? type, IMethodSymbol? symbol, ArgumentListSyntax arguments, Location location)
|
||||
private void ExtractSourceInitializer(TextWriter trapFile, ITypeSymbol? type, IMethodSymbol? symbol, ArgumentListSyntax arguments, Microsoft.CodeAnalysis.Location location)
|
||||
{
|
||||
var initInfo = new ExpressionInfo(Context,
|
||||
AnnotatedTypeSymbol.CreateNotAnnotated(type),
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
private readonly IExpressionInfo info;
|
||||
public AnnotatedTypeSymbol? Type { get; private set; }
|
||||
public Extraction.Entities.Location Location { get; }
|
||||
public Location Location { get; }
|
||||
public ExprKind Kind { get; }
|
||||
|
||||
internal Expression(IExpressionInfo info, bool shouldPopulate = true)
|
||||
@@ -62,7 +62,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
type.PopulateGenerics();
|
||||
}
|
||||
|
||||
public override Location? ReportingLocation => Location.Symbol;
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => Location.Symbol;
|
||||
|
||||
internal void SetType(ITypeSymbol? type)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// Creates a generated expression from a typed constant.
|
||||
/// </summary>
|
||||
public static Expression? CreateGenerated(Context cx, TypedConstant constant, IExpressionParentEntity parent,
|
||||
int childIndex, Extraction.Entities.Location location)
|
||||
int childIndex, Location location)
|
||||
{
|
||||
if (constant.IsNull ||
|
||||
constant.Type is null)
|
||||
@@ -176,7 +176,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// Creates a generated expression for a default argument value.
|
||||
/// </summary>
|
||||
public static Expression? CreateGenerated(Context cx, IParameterSymbol parameter, IExpressionParentEntity parent,
|
||||
int childIndex, Extraction.Entities.Location location)
|
||||
int childIndex, Location location)
|
||||
{
|
||||
if (!parameter.HasExplicitDefaultValue ||
|
||||
parameter.Type is IErrorTypeSymbol)
|
||||
@@ -315,7 +315,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
/// <summary>
|
||||
/// Given `b` in `a?.b.c`, return `(a?.b, a?.b)`.
|
||||
///
|
||||
///
|
||||
/// Given `c` in `a?.b?.c.d`, return `(b?.c, a?.b?.c)`.
|
||||
/// </summary>
|
||||
/// <param name="node">A MemberBindingExpression.</param>
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public Context Context { get; }
|
||||
public AnnotatedTypeSymbol? Type { get; }
|
||||
public Extraction.Entities.Location Location { get; }
|
||||
public Location Location { get; }
|
||||
public ExprKind Kind { get; }
|
||||
public IExpressionParentEntity Parent { get; }
|
||||
public int Child { get; }
|
||||
public bool IsCompilerGenerated { get; }
|
||||
public string? ExprValue { get; }
|
||||
|
||||
public ExpressionInfo(Context cx, AnnotatedTypeSymbol? type, Extraction.Entities.Location location, ExprKind kind,
|
||||
public ExpressionInfo(Context cx, AnnotatedTypeSymbol? type, Location location, ExprKind kind,
|
||||
IExpressionParentEntity parent, int child, bool isCompilerGenerated, string? value)
|
||||
{
|
||||
Context = cx;
|
||||
|
||||
@@ -115,9 +115,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
private Extraction.Entities.Location? cachedLocation;
|
||||
private Location? cachedLocation;
|
||||
|
||||
public Extraction.Entities.Location Location
|
||||
public Location Location
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new NormalArrayCreation(info).TryPopulate();
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, IEnumerable<TypedConstant> items, Semmle.Extraction.Entities.Location location)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, IEnumerable<TypedConstant> items, Location location)
|
||||
{
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location ReportingLocation => Syntax.GetLocation();
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Microsoft.CodeAnalysis.ITypeSymbol type, object? value, Action<Expression, int> createChild, Extraction.Entities.Location location)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Microsoft.CodeAnalysis.ITypeSymbol type, object? value, Action<Expression, int> createChild, Location location)
|
||||
{
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
TypeAccess.Create(Context, Syntax.Type, this, 0);
|
||||
}
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Extraction.Entities.Location location, string? value)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Location location, string? value)
|
||||
{
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
/// Creates a new generated expression with an implicit conversion added.
|
||||
/// </summary>
|
||||
public static Expression CreateGeneratedConversion(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, object value,
|
||||
Extraction.Entities.Location location)
|
||||
Location location)
|
||||
{
|
||||
ExpressionInfo create(ExprKind kind, string? v) =>
|
||||
new ExpressionInfo(
|
||||
@@ -85,7 +85,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
/// Creates a new generated cast expression.
|
||||
/// </summary>
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, object value,
|
||||
Extraction.Entities.Location location)
|
||||
Location location)
|
||||
{
|
||||
var info = new ExpressionInfo(cx,
|
||||
AnnotatedTypeSymbol.CreateNotAnnotated(type),
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int index, Extraction.Entities.Location location)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int index, Location location)
|
||||
{
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
return GetExprKind(type, info.Node, info.Location, info.Context);
|
||||
}
|
||||
|
||||
private static ExprKind GetExprKind(ITypeSymbol? type, ExpressionSyntax? expr, Extraction.Entities.Location loc, Context context)
|
||||
private static ExprKind GetExprKind(ITypeSymbol? type, ExpressionSyntax? expr, Location loc, Context context)
|
||||
{
|
||||
switch (type?.SpecialType)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, object? value,
|
||||
Extraction.Entities.Location location)
|
||||
Location location)
|
||||
{
|
||||
var kind = value is null ? ExprKind.NULL_LITERAL : GetExprKind(type, null, location, cx);
|
||||
var info = new ExpressionInfo(
|
||||
@@ -103,7 +103,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
return new Expression(info);
|
||||
}
|
||||
|
||||
public static Expression CreateGeneratedNullLiteral(Context cx, IExpressionParentEntity parent, int childIndex, Extraction.Entities.Location location)
|
||||
public static Expression CreateGeneratedNullLiteral(Context cx, IExpressionParentEntity parent, int childIndex, Location location)
|
||||
{
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
// The `type` symbol must be a System.DateTime type and the value must be a System.DateTime object.
|
||||
// The expression that is being created is a call to the System.DateTime(long) constructor, where
|
||||
// the number of ticks from the `value` object is used as the argument to the constructor call.
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, object? value, Extraction.Entities.Location location)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, ITypeSymbol type, object? value, Location location)
|
||||
{
|
||||
var constructorSymbol = GetDateTimeConstructor(type) ?? throw new InternalError("Could not find symbol for System.DateTime(long)");
|
||||
var expr = new DateTimeObjectCreation(constructorSymbol, new ExpressionInfo(
|
||||
@@ -68,4 +68,4 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
return expr.TryPopulate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
private This(IExpressionInfo info) : base(info) { }
|
||||
|
||||
public static This CreateImplicit(Context cx, ITypeSymbol @class, Extraction.Entities.Location loc, IExpressionParentEntity parent, int child) =>
|
||||
public static This CreateImplicit(Context cx, ITypeSymbol @class, Location loc, IExpressionParentEntity parent, int child) =>
|
||||
new This(new ExpressionInfo(cx, AnnotatedTypeSymbol.CreateNotAnnotated(@class), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, isCompilerGenerated: true, null));
|
||||
|
||||
public static This CreateExplicit(ExpressionNodeInfo info) => new This(info.SetKind(ExprKind.THIS_ACCESS));
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new TypeAccess(info).TryPopulate();
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Microsoft.CodeAnalysis.ITypeSymbol type, Extraction.Entities.Location location)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Microsoft.CodeAnalysis.ITypeSymbol type, Location location)
|
||||
{
|
||||
var typeAccessInfo = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
TypeAccess.Create(Context, Syntax.Type, this, TypeAccessIndex);
|
||||
}
|
||||
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Microsoft.CodeAnalysis.ITypeSymbol type, Extraction.Entities.Location location)
|
||||
public static Expression CreateGenerated(Context cx, IExpressionParentEntity parent, int childIndex, Microsoft.CodeAnalysis.ITypeSymbol type, Location location)
|
||||
{
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
private VariableDeclaration(IExpressionInfo info) : base(info) { }
|
||||
|
||||
public static VariableDeclaration Create(Context cx, ISymbol symbol, AnnotatedTypeSymbol? type, TypeSyntax? optionalSyntax, Extraction.Entities.Location exprLocation, bool isVar, IExpressionParentEntity parent, int child)
|
||||
public static VariableDeclaration Create(Context cx, ISymbol symbol, AnnotatedTypeSymbol? type, TypeSyntax? optionalSyntax, Location exprLocation, bool isVar, IExpressionParentEntity parent, int child)
|
||||
{
|
||||
var ret = new VariableDeclaration(new ExpressionInfo(cx, type, exprLocation, ExprKind.LOCAL_VAR_DECL, parent, child, isCompilerGenerated: false, null));
|
||||
cx.Try(null, null, () =>
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
private Expression AddInitializerAssignment(TextWriter trapFile, ExpressionSyntax initializer, Extraction.Entities.Location loc,
|
||||
private Expression AddInitializerAssignment(TextWriter trapFile, ExpressionSyntax initializer, Location loc,
|
||||
string? constValue, ref int child)
|
||||
{
|
||||
var type = Symbol.GetAnnotatedType();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// <summary>
|
||||
/// The location of the expression.
|
||||
/// </summary>
|
||||
Extraction.Entities.Location Location { get; }
|
||||
Location Location { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The kind of the expression.
|
||||
|
||||
@@ -6,21 +6,37 @@ using Semmle.Util;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class File : Extraction.Entities.File
|
||||
public class File : Extraction.CachedEntity<string>
|
||||
{
|
||||
protected readonly string originalPath;
|
||||
private readonly Lazy<PathTransformer.ITransformedPath> transformedPathLazy;
|
||||
protected PathTransformer.ITransformedPath TransformedPath => transformedPathLazy.Value;
|
||||
public override Context Context => (Context)base.Context;
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
|
||||
|
||||
public override bool NeedsPopulation => true;
|
||||
|
||||
protected File(Context cx, string path)
|
||||
: base(cx, path)
|
||||
{
|
||||
originalPath = path;
|
||||
var adjustedPath = BinaryLogExtractionContext.GetAdjustedPath(Context.ExtractionContext, originalPath) ?? path;
|
||||
transformedPathLazy = new Lazy<PathTransformer.ITransformedPath>(() => Context.ExtractionContext.PathTransformer.Transform(adjustedPath));
|
||||
}
|
||||
|
||||
public override void WriteId(EscapingTextWriter trapFile)
|
||||
{
|
||||
trapFile.Write(TransformedPath.DatabaseId);
|
||||
trapFile.Write(";sourcefile");
|
||||
}
|
||||
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.files(this, TransformedPath.Value);
|
||||
|
||||
if (TransformedPath.ParentDirectory is PathTransformer.ITransformedPath dir)
|
||||
trapFile.containerparent(Extraction.Entities.Folder.Create(Context, dir), this);
|
||||
trapFile.containerparent(Folder.Create(Context, dir), this);
|
||||
|
||||
var trees = Context.Compilation.SyntaxTrees.Where(t => t.FilePath == originalPath);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.Entities
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public sealed class Folder : CachedEntity<PathTransformer.ITransformedPath>
|
||||
public sealed class Folder : Extraction.CachedEntity<PathTransformer.ITransformedPath>
|
||||
{
|
||||
private Folder(Context cx, PathTransformer.ITransformedPath init) : base(cx, init) { }
|
||||
private Folder(Extraction.Context cx, PathTransformer.ITransformedPath init) : base(cx, init) { }
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
@@ -21,16 +21,16 @@ namespace Semmle.Extraction.Entities
|
||||
trapFile.Write(";folder");
|
||||
}
|
||||
|
||||
public static Folder Create(Context cx, PathTransformer.ITransformedPath folder) =>
|
||||
public static Folder Create(Extraction.Context cx, PathTransformer.ITransformedPath folder) =>
|
||||
FolderFactory.Instance.CreateEntity(cx, folder, folder);
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
|
||||
|
||||
private class FolderFactory : CachedEntityFactory<PathTransformer.ITransformedPath, Folder>
|
||||
private class FolderFactory : Extraction.CachedEntityFactory<PathTransformer.ITransformedPath, Folder>
|
||||
{
|
||||
public static FolderFactory Instance { get; } = new FolderFactory();
|
||||
|
||||
public override Folder Create(Context cx, PathTransformer.ITransformedPath init) => new Folder(cx, init);
|
||||
public override Folder Create(Extraction.Context cx, PathTransformer.ITransformedPath init) => new Folder(cx, init);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Symbol.GetHashCode();
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.Entities
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class GeneratedFile : File
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.Entities
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public class GeneratedLocation : SourceLocation
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
public override bool Equals(object? obj) => obj is not null && obj.GetType() == typeof(GeneratedLocation);
|
||||
|
||||
public static GeneratedLocation Create(Context cx) => GeneratedLocationFactory.Instance.CreateEntity(cx, typeof(GeneratedLocation), null);
|
||||
public static GeneratedLocation Create(Extraction.Context cx) => GeneratedLocationFactory.Instance.CreateEntity(cx, typeof(GeneratedLocation), null);
|
||||
|
||||
private class GeneratedLocationFactory : CachedEntityFactory<string?, GeneratedLocation>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Semmle.Extraction.Entities
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
#nullable disable warnings
|
||||
public abstract class Location : CachedEntity<Microsoft.CodeAnalysis.Location?>
|
||||
public abstract class Location : Extraction.CachedEntity<Microsoft.CodeAnalysis.Location?>
|
||||
{
|
||||
#nullable restore warnings
|
||||
protected Location(Context cx, Microsoft.CodeAnalysis.Location? init)
|
||||
@@ -1,22 +1,20 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Semmle.Util.Logging;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class NonGeneratedSourceLocation : Extraction.Entities.SourceLocation
|
||||
internal class NonGeneratedSourceLocation : SourceLocation
|
||||
{
|
||||
public override Context Context => (Context)base.Context;
|
||||
|
||||
protected NonGeneratedSourceLocation(Context cx, Location init)
|
||||
protected NonGeneratedSourceLocation(Context cx, Microsoft.CodeAnalysis.Location init)
|
||||
: base(cx, init)
|
||||
{
|
||||
Position = init.GetLineSpan();
|
||||
FileEntity = File.Create(Context, Position.Path);
|
||||
}
|
||||
|
||||
public static NonGeneratedSourceLocation Create(Context cx, Location loc) => SourceLocationFactory.Instance.CreateEntity(cx, loc, loc);
|
||||
public static NonGeneratedSourceLocation Create(Context cx, Microsoft.CodeAnalysis.Location loc) => SourceLocationFactory.Instance.CreateEntity(cx, loc, loc);
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
@@ -28,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (mapped.HasMappedPath && mapped.IsValid)
|
||||
{
|
||||
var path = Context.TryAdjustRelativeMappedFilePath(mapped.Path, Position.Path);
|
||||
var mappedLoc = Create(Context, Location.Create(path, default, mapped.Span));
|
||||
var mappedLoc = Create(Context, Microsoft.CodeAnalysis.Location.Create(path, default, mapped.Span));
|
||||
|
||||
trapFile.locations_mapped(this, mappedLoc);
|
||||
}
|
||||
@@ -58,11 +56,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.Write(Position.Span.End.Character);
|
||||
}
|
||||
|
||||
private class SourceLocationFactory : CachedEntityFactory<Location, NonGeneratedSourceLocation>
|
||||
private class SourceLocationFactory : CachedEntityFactory<Microsoft.CodeAnalysis.Location, NonGeneratedSourceLocation>
|
||||
{
|
||||
public static SourceLocationFactory Instance { get; } = new SourceLocationFactory();
|
||||
|
||||
public override NonGeneratedSourceLocation Create(Context cx, Location init) => new NonGeneratedSourceLocation(cx, init);
|
||||
public override NonGeneratedSourceLocation Create(Context cx, Microsoft.CodeAnalysis.Location init) => new NonGeneratedSourceLocation(cx, init);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Semmle.Extraction.Entities
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public abstract class SourceLocation : Location
|
||||
{
|
||||
@@ -290,7 +290,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public Method OriginalDefinition => Create(Context, Symbol.OriginalDefinition);
|
||||
|
||||
public override Location? FullLocation => ReportingLocation;
|
||||
public override Microsoft.CodeAnalysis.Location? FullLocation => ReportingLocation;
|
||||
|
||||
public override bool IsSourceDeclaration => Symbol.IsSourceDeclaration();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
private Modifier(Context cx, string init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public override Location? ReportingLocation => null;
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
|
||||
|
||||
public override void WriteId(EscapingTextWriter trapFile)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
private Namespace(Context cx, INamespaceSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public override Location? ReportingLocation => null;
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override IEnumerable<Type> TypeMentions => TypeArguments;
|
||||
|
||||
public override IEnumerable<Extraction.Entities.Location> Locations
|
||||
public override IEnumerable<Location> Locations
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
}
|
||||
|
||||
public override Location ReportingLocation => throw new System.NotImplementedException();
|
||||
public override Microsoft.CodeAnalysis.Location ReportingLocation => throw new System.NotImplementedException();
|
||||
|
||||
public override bool NeedsPopulation => true;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public override Location? ReportingLocation => null;
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
|
||||
|
||||
public static TypeParameterConstraints Create(Context cx, TypeParameter p) =>
|
||||
TypeParameterConstraintsFactory.Instance.CreateEntity(cx, (typeof(TypeParameterConstraints), p), p);
|
||||
@@ -62,4 +62,3 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// State that needs to be available throughout the extraction process.
|
||||
/// There is one Context object per trap output file.
|
||||
/// </summary>
|
||||
internal class Context : Extraction.Context
|
||||
public class Context : Extraction.Context
|
||||
{
|
||||
/// <summary>
|
||||
/// The program database provided by Roslyn.
|
||||
@@ -117,17 +117,17 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public override Extraction.Entities.Location CreateLocation()
|
||||
public override Entities.Location CreateLocation()
|
||||
{
|
||||
return SourceTree is null
|
||||
? GeneratedLocation.Create(this)
|
||||
? Entities.GeneratedLocation.Create(this)
|
||||
: CreateLocation(Microsoft.CodeAnalysis.Location.Create(SourceTree, Microsoft.CodeAnalysis.Text.TextSpan.FromBounds(0, 0)));
|
||||
}
|
||||
|
||||
public override Extraction.Entities.Location CreateLocation(Microsoft.CodeAnalysis.Location? location)
|
||||
public override Entities.Location CreateLocation(Microsoft.CodeAnalysis.Location? location)
|
||||
{
|
||||
return (location is null || location.Kind == LocationKind.None)
|
||||
? GeneratedLocation.Create(this)
|
||||
? Entities.GeneratedLocation.Create(this)
|
||||
: location.IsInSource
|
||||
? Entities.NonGeneratedSourceLocation.Create(this, location)
|
||||
: Entities.Assembly.Create(this, location);
|
||||
@@ -145,7 +145,7 @@ namespace Semmle.Extraction.CSharp
|
||||
CommentGenerator.AddElement(entity.Label, duplicationGuardKey, l);
|
||||
}
|
||||
|
||||
protected override bool IsEntityDuplicationGuarded(IEntity entity, [NotNullWhen(true)] out Extraction.Entities.Location? loc)
|
||||
protected override bool IsEntityDuplicationGuarded(IEntity entity, [NotNullWhen(true)] out Entities.Location? loc)
|
||||
{
|
||||
if (CreateLocation(entity.ReportingLocation) is Entities.NonGeneratedSourceLocation l)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </remarks>
|
||||
internal static class Tuples
|
||||
{
|
||||
internal static void assemblies(this System.IO.TextWriter trapFile, Assembly assembly, Extraction.Entities.File file, string identifier, string name, string version) =>
|
||||
internal static void assemblies(this System.IO.TextWriter trapFile, Assembly assembly, Entities.File file, string identifier, string name, string version) =>
|
||||
trapFile.WriteTuple("assemblies", assembly, file, identifier, name, version);
|
||||
|
||||
internal static void accessor_location(this TextWriter trapFile, Accessor accessorKey, Location location) =>
|
||||
@@ -74,10 +74,10 @@ namespace Semmle.Extraction.CSharp
|
||||
internal static void compilation_info(this TextWriter trapFile, Compilation compilation, string infoKey, string infoValue) =>
|
||||
trapFile.WriteTuple("compilation_info", compilation, infoKey, infoValue);
|
||||
|
||||
internal static void compilation_compiling_files(this TextWriter trapFile, Compilation compilation, int index, Extraction.Entities.File file) =>
|
||||
internal static void compilation_compiling_files(this TextWriter trapFile, Compilation compilation, int index, Entities.File file) =>
|
||||
trapFile.WriteTuple("compilation_compiling_files", compilation, index, file);
|
||||
|
||||
internal static void compilation_referencing_files(this TextWriter trapFile, Compilation compilation, int index, Extraction.Entities.File file) =>
|
||||
internal static void compilation_referencing_files(this TextWriter trapFile, Compilation compilation, int index, Entities.File file) =>
|
||||
trapFile.WriteTuple("compilation_referencing_files", compilation, index, file);
|
||||
|
||||
internal static void compilation_finished(this TextWriter trapFile, Compilation compilation, float cpuSeconds, float elapsedSeconds) =>
|
||||
@@ -398,7 +398,7 @@ namespace Semmle.Extraction.CSharp
|
||||
internal static void pragma_warning_error_codes(this TextWriter trapFile, PragmaWarningDirective pragma, string errorCode, int child) =>
|
||||
trapFile.WriteTuple("pragma_warning_error_codes", pragma, errorCode, child);
|
||||
|
||||
internal static void pragma_checksums(this TextWriter trapFile, PragmaChecksumDirective pragma, Extraction.Entities.File file, string guid, string bytes) =>
|
||||
internal static void pragma_checksums(this TextWriter trapFile, PragmaChecksumDirective pragma, Entities.File file, string guid, string bytes) =>
|
||||
trapFile.WriteTuple("pragma_checksums", pragma, file, guid, bytes);
|
||||
|
||||
internal static void directive_defines(this TextWriter trapFile, DefineDirective directive, string name) =>
|
||||
@@ -422,7 +422,7 @@ namespace Semmle.Extraction.CSharp
|
||||
internal static void directive_line_value(this TextWriter trapFile, LineDirective directive, int line) =>
|
||||
trapFile.WriteTuple("directive_line_value", directive, line);
|
||||
|
||||
internal static void directive_line_file<T>(this TextWriter trapFile, LineOrSpanDirective<T> directive, Extraction.Entities.File file) where T : LineOrSpanDirectiveTriviaSyntax =>
|
||||
internal static void directive_line_file<T>(this TextWriter trapFile, LineOrSpanDirective<T> directive, Entities.File file) where T : LineOrSpanDirectiveTriviaSyntax =>
|
||||
trapFile.WriteTuple("directive_line_file", directive, file);
|
||||
|
||||
internal static void directive_line_offset(this TextWriter trapFile, LineSpanDirective directive, int offset) =>
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Semmle.Extraction
|
||||
a();
|
||||
}
|
||||
|
||||
protected virtual bool IsEntityDuplicationGuarded(IEntity entity, [NotNullWhen(returnValue: true)] out Entities.Location? loc)
|
||||
protected virtual bool IsEntityDuplicationGuarded(IEntity entity, [NotNullWhen(returnValue: true)] out CSharp.Entities.Location? loc)
|
||||
{
|
||||
loc = null;
|
||||
return false;
|
||||
@@ -363,7 +363,7 @@ namespace Semmle.Extraction
|
||||
/// <param name="location">The location of the error.</param>
|
||||
/// <param name="stackTrace">An optional stack trace of the error, or null.</param>
|
||||
/// <param name="severity">The severity of the error.</param>
|
||||
public void ExtractionError(string message, string? entityText, Entities.Location? location, string? stackTrace = null, Severity severity = Severity.Error)
|
||||
public void ExtractionError(string message, string? entityText, CSharp.Entities.Location? location, string? stackTrace = null, Severity severity = Severity.Error)
|
||||
{
|
||||
var msg = new Message(message, entityText, location, stackTrace, severity);
|
||||
ExtractionError(msg);
|
||||
@@ -439,7 +439,7 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
/// <param name="loc">The location of the error.</param>
|
||||
/// <param name="msg">The error message.</param>
|
||||
public void ModelError(Entities.Location loc, string msg)
|
||||
public void ModelError(CSharp.Entities.Location loc, string msg)
|
||||
{
|
||||
ReportError(new InternalError(loc.ReportingLocation, msg));
|
||||
}
|
||||
@@ -491,10 +491,10 @@ namespace Semmle.Extraction
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Entities.Location CreateLocation() =>
|
||||
GeneratedLocation.Create(this);
|
||||
public virtual CSharp.Entities.Location CreateLocation() =>
|
||||
CSharp.Entities.GeneratedLocation.Create(this);
|
||||
|
||||
public virtual Entities.Location CreateLocation(Microsoft.CodeAnalysis.Location? location) =>
|
||||
public virtual CSharp.Entities.Location CreateLocation(Microsoft.CodeAnalysis.Location? location) =>
|
||||
CreateLocation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Semmle.Extraction.Entities
|
||||
{
|
||||
public abstract class File : CachedEntity<string>
|
||||
{
|
||||
protected File(Context cx, string path)
|
||||
: base(cx, path)
|
||||
{
|
||||
originalPath = path;
|
||||
var adjustedPath = BinaryLogExtractionContext.GetAdjustedPath(Context.ExtractionContext, originalPath) ?? path;
|
||||
transformedPathLazy = new Lazy<PathTransformer.ITransformedPath>(() => Context.ExtractionContext.PathTransformer.Transform(adjustedPath));
|
||||
}
|
||||
|
||||
protected readonly string originalPath;
|
||||
private readonly Lazy<PathTransformer.ITransformedPath> transformedPathLazy;
|
||||
protected PathTransformer.ITransformedPath TransformedPath => transformedPathLazy.Value;
|
||||
|
||||
public override bool NeedsPopulation => true;
|
||||
|
||||
public override void WriteId(EscapingTextWriter trapFile)
|
||||
{
|
||||
trapFile.Write(TransformedPath.DatabaseId);
|
||||
trapFile.Write(";sourcefile");
|
||||
}
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,9 @@ namespace Semmle.Extraction
|
||||
public string Text { get; }
|
||||
public string? StackTrace { get; }
|
||||
public string? EntityText { get; }
|
||||
public Entities.Location? Location { get; }
|
||||
public CSharp.Entities.Location? Location { get; }
|
||||
|
||||
public Message(string text, string? entityText, Entities.Location? location, string? stackTrace = null, Severity severity = Severity.Error)
|
||||
public Message(string text, string? entityText, CSharp.Entities.Location? location, string? stackTrace = null, Severity severity = Severity.Error)
|
||||
{
|
||||
Severity = severity;
|
||||
Text = text;
|
||||
|
||||
@@ -7,27 +7,27 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public static class Tuples
|
||||
{
|
||||
public static void containerparent(this System.IO.TextWriter trapFile, Folder parent, IEntity child)
|
||||
public static void containerparent(this System.IO.TextWriter trapFile, CSharp.Entities.Folder parent, IEntity child)
|
||||
{
|
||||
trapFile.WriteTuple("containerparent", parent, child);
|
||||
}
|
||||
|
||||
internal static void extractor_messages(this System.IO.TextWriter trapFile, ExtractionMessage error, Semmle.Util.Logging.Severity severity, string errorMessage, string entityText, Location location, string stackTrace)
|
||||
internal static void extractor_messages(this System.IO.TextWriter trapFile, ExtractionMessage error, Semmle.Util.Logging.Severity severity, string errorMessage, string entityText, CSharp.Entities.Location location, string stackTrace)
|
||||
{
|
||||
trapFile.WriteTuple("extractor_messages", error, (int)severity, "C# extractor", errorMessage, entityText, location, stackTrace);
|
||||
}
|
||||
|
||||
public static void files(this System.IO.TextWriter trapFile, File file, string fullName)
|
||||
public static void files(this System.IO.TextWriter trapFile, CSharp.Entities.File file, string fullName)
|
||||
{
|
||||
trapFile.WriteTuple("files", file, fullName);
|
||||
}
|
||||
|
||||
internal static void folders(this System.IO.TextWriter trapFile, Folder folder, string path)
|
||||
internal static void folders(this System.IO.TextWriter trapFile, CSharp.Entities.Folder folder, string path)
|
||||
{
|
||||
trapFile.WriteTuple("folders", folder, path);
|
||||
}
|
||||
|
||||
public static void locations_default(this System.IO.TextWriter trapFile, SourceLocation label, Entities.File file, int startLine, int startCol, int endLine, int endCol)
|
||||
public static void locations_default(this System.IO.TextWriter trapFile, CSharp.Entities.SourceLocation label, CSharp.Entities.File file, int startLine, int startCol, int endLine, int endCol)
|
||||
{
|
||||
trapFile.WriteTuple("locations_default", label, file, startLine, startCol, endLine, endCol);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user