mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
Move location creation to instance method on context
This commit is contained in:
@@ -118,7 +118,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private Semmle.Extraction.Entities.Location location;
|
||||
private Semmle.Extraction.Entities.Location Location =>
|
||||
location ?? (location = Semmle.Extraction.Entities.Location.Create(Context, attributeSyntax is null ? entity.ReportingLocation : attributeSyntax.Name.GetLocation()));
|
||||
location ?? (location = Context.CreateLocation(attributeSyntax is null ? entity.ReportingLocation : attributeSyntax.Name.GetLocation()));
|
||||
|
||||
public override bool NeedsPopulation => true;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
trapFile.commentblock(this);
|
||||
var child = 0;
|
||||
trapFile.commentblock_location(this, Context.Create(symbol.Location));
|
||||
trapFile.commentblock_location(this, Context.CreateLocation(symbol.Location));
|
||||
foreach (var l in symbol.CommentLines)
|
||||
{
|
||||
trapFile.commentblock_child(this, (CommentLine)l, child++);
|
||||
@@ -24,7 +24,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
{
|
||||
trapFile.WriteSubId(Context.Create(symbol.Location));
|
||||
trapFile.WriteSubId(Context.CreateLocation(symbol.Location));
|
||||
trapFile.Write(";commentblock");
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
location = Context.Create(Location);
|
||||
location = Context.CreateLocation(Location);
|
||||
trapFile.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText);
|
||||
trapFile.commentline_location(this, location);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
{
|
||||
trapFile.WriteSubId(Context.Create(Location));
|
||||
trapFile.WriteSubId(Context.CreateLocation(Location));
|
||||
trapFile.Write(";commentline");
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.diagnostics(this, (int)diagnostic.Severity, diagnostic.Id, diagnostic.Descriptor.Title.ToString(),
|
||||
diagnostic.GetMessage(), Extraction.Entities.Location.Create(cx, diagnostic.Location));
|
||||
diagnostic.GetMessage(), cx.CreateLocation(diagnostic.Location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
var initInfo = new ExpressionInfo(Context,
|
||||
AnnotatedTypeSymbol.CreateNotAnnotated(initializerType),
|
||||
Context.Create(initializer.ThisOrBaseKeyword.GetLocation()),
|
||||
Context.CreateLocation(initializer.ThisOrBaseKeyword.GetLocation()),
|
||||
Kinds.ExprKind.CONSTRUCTOR_INIT,
|
||||
this,
|
||||
-1,
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
get
|
||||
{
|
||||
if (cachedLocation == null)
|
||||
cachedLocation = Context.Create(CodeAnalysisLocation);
|
||||
cachedLocation = Context.CreateLocation(CodeAnalysisLocation);
|
||||
return cachedLocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
|
||||
private Discard(Context cx, CSharpSyntaxNode syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, cx.GetType(syntax), cx.Create(syntax.GetLocation()), ExprKind.DISCARD, parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, cx.GetType(syntax), cx.CreateLocation(syntax.GetLocation()), ExprKind.DISCARD, parent, child, false, null))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
var addMethod = Method.Create(cx, collectionInfo.Symbol as IMethodSymbol);
|
||||
var voidType = AnnotatedTypeSymbol.CreateNotAnnotated(cx.Compilation.GetSpecialType(SpecialType.System_Void));
|
||||
|
||||
var invocation = new Expression(new ExpressionInfo(cx, voidType, cx.Create(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
|
||||
var invocation = new Expression(new ExpressionInfo(cx, voidType, cx.CreateLocation(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
|
||||
|
||||
if (addMethod != null)
|
||||
trapFile.expr_call(invocation, addMethod);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
case SyntaxKind.InterpolatedStringText:
|
||||
// Create a string literal
|
||||
var interpolatedText = (InterpolatedStringTextSyntax)c;
|
||||
new Expression(new ExpressionInfo(cx, Type, cx.Create(c.GetLocation()), ExprKind.STRING_LITERAL, this, child++, false, interpolatedText.TextToken.Text));
|
||||
new Expression(new ExpressionInfo(cx, Type, cx.CreateLocation(c.GetLocation()), ExprKind.STRING_LITERAL, this, child++, false, interpolatedText.TextToken.Text));
|
||||
break;
|
||||
default:
|
||||
throw new InternalError(c, $"Unhandled interpolation kind {c.Kind()}");
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
var property = cx.GetModel(init).GetDeclaredSymbol(init);
|
||||
var propEntity = Property.Create(cx, property);
|
||||
var type = property.GetAnnotatedType();
|
||||
var loc = cx.Create(init.GetLocation());
|
||||
var loc = cx.CreateLocation(init.GetLocation());
|
||||
|
||||
var assignment = new Expression(new ExpressionInfo(cx, type, loc, ExprKind.SIMPLE_ASSIGN, objectInitializer, child++, false, null));
|
||||
Create(cx, init.Expression, assignment, 0);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
internal class BinaryPattern : Expression
|
||||
{
|
||||
public BinaryPattern(Context cx, BinaryPatternSyntax syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.Create(syntax.GetLocation()), GetKind(syntax.OperatorToken, syntax), parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), GetKind(syntax.OperatorToken, syntax), parent, child, false, null))
|
||||
{
|
||||
Pattern.Create(cx, syntax.Left, this, 0);
|
||||
Pattern.Create(cx, syntax.Right, this, 1);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
if (cx.GetModel(syntax).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
|
||||
{
|
||||
var type = symbol.GetAnnotatedType();
|
||||
return VariableDeclaration.Create(cx, symbol, type, declPattern.Type, cx.Create(syntax.GetLocation()), false, parent, child);
|
||||
return VariableDeclaration.Create(cx, symbol, type, declPattern.Type, cx.CreateLocation(syntax.GetLocation()), false, parent, child);
|
||||
}
|
||||
if (designation is DiscardDesignationSyntax)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
var type = symbol.GetAnnotatedType();
|
||||
|
||||
return VariableDeclaration.Create(cx, symbol, type, null, cx.Create(syntax.GetLocation()), true, parent, child);
|
||||
return VariableDeclaration.Create(cx, symbol, type, null, cx.CreateLocation(syntax.GetLocation()), true, parent, child);
|
||||
}
|
||||
|
||||
throw new InternalError(varPattern, "Unable to get the declared symbol of the var pattern designation.");
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
internal class PositionalPattern : Expression
|
||||
{
|
||||
internal PositionalPattern(Context cx, PositionalPatternClauseSyntax posPc, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.Create(posPc.GetLocation()), ExprKind.POSITIONAL_PATTERN, parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(posPc.GetLocation()), ExprKind.POSITIONAL_PATTERN, parent, child, false, null))
|
||||
{
|
||||
child = 0;
|
||||
foreach (var sub in posPc.Subpatterns)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
internal class PropertyPattern : Expression
|
||||
{
|
||||
internal PropertyPattern(Context cx, PropertyPatternClauseSyntax pp, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.Create(pp.GetLocation()), ExprKind.PROPERTY_PATTERN, parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(pp.GetLocation()), ExprKind.PROPERTY_PATTERN, parent, child, false, null))
|
||||
{
|
||||
child = 0;
|
||||
var trapFile = cx.TrapWriter.Writer;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
/// <param name="parent">The parent pattern/expression.</param>
|
||||
/// <param name="child">The child index of this pattern.</param>
|
||||
public RecursivePattern(Context cx, RecursivePatternSyntax syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.Create(syntax.GetLocation()), ExprKind.RECURSIVE_PATTERN, parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.RECURSIVE_PATTERN, parent, child, false, null))
|
||||
{
|
||||
// Extract the type access
|
||||
if (syntax.Type is TypeSyntax t)
|
||||
@@ -27,7 +27,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
var type = symbol.GetAnnotatedType();
|
||||
|
||||
VariableDeclaration.Create(cx, symbol, type, null, cx.Create(syntax.GetLocation()), false, this, 0);
|
||||
VariableDeclaration.Create(cx, symbol, type, null, cx.CreateLocation(syntax.GetLocation()), false, this, 0);
|
||||
}
|
||||
|
||||
if (syntax.PositionalPatternClause is PositionalPatternClauseSyntax posPc)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
internal class RelationalPattern : Expression
|
||||
{
|
||||
public RelationalPattern(Context cx, RelationalPatternSyntax syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.Create(syntax.GetLocation()), GetKind(syntax.OperatorToken), parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), GetKind(syntax.OperatorToken), parent, child, false, null))
|
||||
{
|
||||
Expression.Create(cx, syntax.Expression, this, 0);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
internal class UnaryPattern : Expression
|
||||
{
|
||||
public UnaryPattern(Context cx, UnaryPatternSyntax syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.Create(syntax.GetLocation()), ExprKind.NOT_PATTERN, parent, child, false, null))
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.NOT_PATTERN, parent, child, false, null))
|
||||
{
|
||||
Pattern.Create(cx, syntax.Pattern, this, 0);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
public QueryCall(Context cx, IMethodSymbol method, SyntaxNode clause, IExpressionParentEntity parent, int child)
|
||||
: base(new ExpressionInfo(cx, method?.GetAnnotatedReturnType(),
|
||||
cx.Create(clause.GetLocation()),
|
||||
cx.CreateLocation(clause.GetLocation()),
|
||||
ExprKind.METHOD_INVOCATION, parent, child, false, null))
|
||||
{
|
||||
if (method != null)
|
||||
@@ -89,7 +89,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
variableSymbol,
|
||||
declType,
|
||||
declTypeSyntax,
|
||||
cx.Create(node.GetLocation()),
|
||||
cx.CreateLocation(node.GetLocation()),
|
||||
true,
|
||||
parent,
|
||||
child
|
||||
@@ -97,7 +97,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
Expression.Create(cx, Expr, decl, 0);
|
||||
|
||||
var nameLoc = cx.Create(name.GetLocation());
|
||||
var nameLoc = cx.CreateLocation(name.GetLocation());
|
||||
var access = new Expression(new ExpressionInfo(cx, type, nameLoc, ExprKind.LOCAL_VARIABLE_ACCESS, decl, 1, false, null));
|
||||
cx.TrapWriter.Writer.expr_access(access, LocalVariable.Create(cx, variableSymbol));
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
internal SwitchCase(Context cx, SwitchExpressionArmSyntax arm, Switch parent, int child) :
|
||||
base(new ExpressionInfo(
|
||||
cx, cx.GetType(arm.Expression), cx.Create(arm.GetLocation()),
|
||||
cx, cx.GetType(arm.Expression), cx.CreateLocation(arm.GetLocation()),
|
||||
ExprKind.SWITCH_CASE, parent, child, false, null))
|
||||
{
|
||||
Expressions.Pattern.Create(cx, arm.Pattern, this, 0);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public static Expression CreateParenthesized(Context cx, DeclarationExpressionSyntax node, ParenthesizedVariableDesignationSyntax designation, IExpressionParentEntity parent, int child)
|
||||
{
|
||||
AnnotatedTypeSymbol? type = null; // Should ideally be a corresponding tuple type
|
||||
var tuple = new Expression(new ExpressionInfo(cx, type, cx.Create(node.GetLocation()), ExprKind.TUPLE, parent, child, false, null));
|
||||
var tuple = new Expression(new ExpressionInfo(cx, type, cx.CreateLocation(node.GetLocation()), ExprKind.TUPLE, parent, child, false, null));
|
||||
|
||||
cx.Try(null, null, () =>
|
||||
{
|
||||
@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public static Expression CreateParenthesized(Context cx, VarPatternSyntax varPattern, ParenthesizedVariableDesignationSyntax designation, IExpressionParentEntity parent, int child)
|
||||
{
|
||||
AnnotatedTypeSymbol? type = null; // Should ideally be a corresponding tuple type
|
||||
var tuple = new Expression(new ExpressionInfo(cx, type, cx.Create(varPattern.GetLocation()), ExprKind.TUPLE, parent, child, false, null));
|
||||
var tuple = new Expression(new ExpressionInfo(cx, type, cx.CreateLocation(varPattern.GetLocation()), ExprKind.TUPLE, parent, child, false, null));
|
||||
|
||||
cx.Try(null, null, () =>
|
||||
{
|
||||
@@ -123,7 +123,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
Create(cx, node, node.Designation, parent, child);
|
||||
|
||||
public static VariableDeclaration Create(Context cx, CSharpSyntaxNode c, AnnotatedTypeSymbol? type, IExpressionParentEntity parent, int child) =>
|
||||
new VariableDeclaration(new ExpressionInfo(cx, type, cx.Create(c.FixedLocation()), ExprKind.LOCAL_VAR_DECL, parent, child, false, null));
|
||||
new VariableDeclaration(new ExpressionInfo(cx, type, cx.CreateLocation(c.FixedLocation()), ExprKind.LOCAL_VAR_DECL, parent, child, false, null));
|
||||
|
||||
public static VariableDeclaration Create(Context cx, CatchDeclarationSyntax d, bool isVar, IExpressionParentEntity parent, int child)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
Context.PopulateLater(() =>
|
||||
{
|
||||
var loc = Context.Create(initializer.GetLocation());
|
||||
var loc = Context.CreateLocation(initializer.GetLocation());
|
||||
|
||||
var fieldAccess = AddInitializerAssignment(trapFile, initializer.Initializer.Value, loc, null, ref child);
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
? Expression.ValueAsString(symbol.ConstantValue)
|
||||
: null;
|
||||
|
||||
var loc = Context.Create(initializer.GetLocation());
|
||||
var loc = Context.CreateLocation(initializer.GetLocation());
|
||||
|
||||
AddInitializerAssignment(trapFile, initializer.EqualsValue.Value, loc, constValue, ref child);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
{
|
||||
trapFile.WriteSubId(Context.Create(ReportingLocation));
|
||||
trapFile.WriteSubId(Context.CreateLocation(ReportingLocation));
|
||||
trapFile.Write(";namespacedeclaration");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
var @namespace = (INamespaceSymbol)Context.GetModel(node).GetSymbolInfo(node.Name).Symbol;
|
||||
var ns = Namespace.Create(Context, @namespace);
|
||||
trapFile.namespace_declarations(this, ns);
|
||||
trapFile.namespace_declaration_location(this, Context.Create(node.Name.GetLocation()));
|
||||
trapFile.namespace_declaration_location(this, Context.CreateLocation(node.Name.GetLocation()));
|
||||
|
||||
var visitor = new Populators.TypeOrNamespaceVisitor(Context, trapFile, this);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.@params(this, Name, type.TypeRef, Ordinal, ParamKind, Parent, Original);
|
||||
|
||||
foreach (var l in symbol.Locations)
|
||||
trapFile.param_location(this, Context.Create(l));
|
||||
trapFile.param_location(this, Context.CreateLocation(l));
|
||||
|
||||
if (!IsSourceDeclaration || !symbol.FromSource())
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
PopulatePreprocessor(trapFile);
|
||||
|
||||
trapFile.preprocessor_directive_active(this, trivia.IsActive);
|
||||
trapFile.preprocessor_directive_location(this, cx.Create(ReportingLocation));
|
||||
trapFile.preprocessor_directive_location(this, cx.CreateLocation(ReportingLocation));
|
||||
|
||||
if (!cx.Extractor.Standalone)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
Context.PopulateLater(() =>
|
||||
{
|
||||
var loc = Context.Create(initializer.GetLocation());
|
||||
var loc = Context.CreateLocation(initializer.GetLocation());
|
||||
var annotatedType = AnnotatedTypeSymbol.CreateNotAnnotated(symbol.Type);
|
||||
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, annotatedType, loc, ExprKind.SIMPLE_ASSIGN, this, child++, false, null));
|
||||
Expression.CreateFromNode(new ExpressionNodeInfo(Context, initializer.Value, simpleAssignExpr, 0));
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected abstract void PopulateStatement(TextWriter trapFile);
|
||||
|
||||
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child)
|
||||
: this(cx, stmt, kind, parent, child, cx.Create(stmt.FixedLocation())) { }
|
||||
: this(cx, stmt, kind, parent, child, cx.CreateLocation(stmt.FixedLocation())) { }
|
||||
|
||||
public override string ToString() => Label.ToString();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
internal abstract class Case<TSyntax> : Statement<TSyntax> where TSyntax : SwitchLabelSyntax
|
||||
{
|
||||
protected Case(Context cx, TSyntax node, Switch parent, int child)
|
||||
: base(cx, node, StmtKind.CASE, parent, child, cx.Create(node.GetLocation())) { }
|
||||
: base(cx, node, StmtKind.CASE, parent, child, cx.CreateLocation(node.GetLocation())) { }
|
||||
|
||||
public static Statement Create(Context cx, SwitchLabelSyntax node, Switch parent, int child)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
private static readonly string systemExceptionName = typeof(System.Exception).ToString();
|
||||
|
||||
private Catch(Context cx, CatchClauseSyntax node, Try parent, int child)
|
||||
: base(cx, node, StmtKind.CATCH, parent, child, cx.Create(node.GetLocation())) { }
|
||||
: base(cx, node, StmtKind.CATCH, parent, child, cx.CreateLocation(node.GetLocation())) { }
|
||||
|
||||
protected override void PopulateStatement(TextWriter trapFile)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
internal class Do : Statement<DoStatementSyntax>
|
||||
{
|
||||
private Do(Context cx, DoStatementSyntax node, IStatementParentEntity parent, int child)
|
||||
: base(cx, node, StmtKind.DO, parent, child, cx.Create(node.GetLocation())) { }
|
||||
: base(cx, node, StmtKind.DO, parent, child, cx.CreateLocation(node.GetLocation())) { }
|
||||
|
||||
public static Do Create(Context cx, DoStatementSyntax node, IStatementParentEntity parent, int child)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
var typeSymbol = semanticModel.GetDeclaredSymbol(Stmt);
|
||||
var type = typeSymbol.GetAnnotatedType();
|
||||
|
||||
var location = cx.Create(Stmt.Identifier.GetLocation());
|
||||
var location = cx.CreateLocation(Stmt.Identifier.GetLocation());
|
||||
|
||||
Expressions.VariableDeclaration.Create(cx, typeSymbol, type, Stmt.Type, location, Stmt.Type.IsVar, this, 0);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
internal class LocalFunction : Statement<LocalFunctionStatementSyntax>
|
||||
{
|
||||
private LocalFunction(Context cx, LocalFunctionStatementSyntax node, IStatementParentEntity parent, int child)
|
||||
: base(cx, node, StmtKind.LOCAL_FUNCTION, parent, child, cx.Create(node.GetLocation())) { }
|
||||
: base(cx, node, StmtKind.LOCAL_FUNCTION, parent, child, cx.CreateLocation(node.GetLocation())) { }
|
||||
|
||||
public static LocalFunction Create(Context cx, LocalFunctionStatementSyntax node, IStatementParentEntity parent, int child)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (loc != null)
|
||||
{
|
||||
// Some built in operators lack locations, so loc is null.
|
||||
yield return Context.Create(ReportingLocation);
|
||||
yield return Context.CreateLocation(ReportingLocation);
|
||||
if (Context.Extractor.OutputPath != null && loc.Kind == LocationKind.SourceFile)
|
||||
yield return Assembly.CreateOutputAssembly(Context);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override bool NeedsPopulation => Context.Defines(symbol);
|
||||
|
||||
public Extraction.Entities.Location Location => Context.Create(ReportingLocation);
|
||||
public Extraction.Entities.Location Location => Context.CreateLocation(ReportingLocation);
|
||||
|
||||
protected void PopulateMetadataHandle(TextWriter trapFile)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
private void Emit(TextWriter trapFile, Microsoft.CodeAnalysis.Location loc, IEntity parent, Type type)
|
||||
{
|
||||
trapFile.type_mention(this, type.TypeRef, parent);
|
||||
trapFile.type_mention_location(this, cx.Create(loc));
|
||||
trapFile.type_mention_location(this, cx.CreateLocation(loc));
|
||||
}
|
||||
|
||||
public static TypeMention Create(Context cx, TypeSyntax syntax, IEntity parent, Type type, Microsoft.CodeAnalysis.Location loc = null)
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
get
|
||||
{
|
||||
foreach (var l in GetLocations(symbol))
|
||||
yield return Context.Create(l);
|
||||
yield return Context.CreateLocation(l);
|
||||
|
||||
if (Context.Extractor.OutputPath != null && symbol.DeclaringSyntaxReferences.Any())
|
||||
yield return Assembly.CreateOutputAssembly(Context);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
// about what locations are available for a tuple type.
|
||||
// Sometimes it's the source code, and sometimes it's empty.
|
||||
foreach (var l in symbol.Locations)
|
||||
trapFile.type_location(this, Context.Create(l));
|
||||
trapFile.type_location(this, Context.CreateLocation(l));
|
||||
}
|
||||
|
||||
private readonly Lazy<Field[]> tupleElementsLazy;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
foreach (var l in symbol.Locations)
|
||||
{
|
||||
trapFile.type_location(this, Context.Create(l));
|
||||
trapFile.type_location(this, Context.CreateLocation(l));
|
||||
}
|
||||
|
||||
if (IsSourceDeclaration)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
var ns = Namespace.Create(cx, namespaceSymbol);
|
||||
trapFile.using_namespace_directives(this, ns);
|
||||
trapFile.using_directive_location(this, cx.Create(ReportingLocation));
|
||||
trapFile.using_directive_location(this, cx.CreateLocation(ReportingLocation));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
// A "using static"
|
||||
var m = Type.Create(cx, (ITypeSymbol)info.Symbol);
|
||||
trapFile.using_static_directives(this, m.TypeRef);
|
||||
trapFile.using_directive_location(this, cx.Create(ReportingLocation));
|
||||
trapFile.using_directive_location(this, cx.CreateLocation(ReportingLocation));
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
public override void VisitExternAliasDirective(ExternAliasDirectiveSyntax node)
|
||||
{
|
||||
// This information is not yet extracted.
|
||||
cx.ExtractionError("Not implemented extern alias directive", node.ToFullString(), Extraction.Entities.Location.Create(cx, node.GetLocation()), "", Severity.Info);
|
||||
cx.ExtractionError("Not implemented extern alias directive", node.ToFullString(), cx.CreateLocation(node.GetLocation()), "", Severity.Info);
|
||||
}
|
||||
|
||||
public override void VisitCompilationUnit(CompilationUnitSyntax compilationUnit)
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
if (regionStarts.Count == 0)
|
||||
{
|
||||
cx.ExtractionError("Couldn't find start region", null,
|
||||
Extraction.Entities.Location.Create(cx, node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
cx.CreateLocation(node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
if (ifStarts.Count == 0)
|
||||
{
|
||||
cx.ExtractionError("Couldn't find start if", null,
|
||||
Extraction.Entities.Location.Create(cx, node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
cx.CreateLocation(node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
if (ifStarts.Count == 0)
|
||||
{
|
||||
cx.ExtractionError("Couldn't find start if", null,
|
||||
Extraction.Entities.Location.Create(cx, node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
cx.CreateLocation(node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
if (ifStarts.Count == 0)
|
||||
{
|
||||
cx.ExtractionError("Couldn't find start if", null,
|
||||
Extraction.Entities.Location.Create(cx, node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
cx.CreateLocation(node.GetLocation()), null, Util.Logging.Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user