Rework global statement extraction without DB scheme change

This commit is contained in:
Tamas Vajk
2021-02-12 12:37:15 +01:00
parent a14db7a04f
commit 4967664d09
8 changed files with 17 additions and 32 deletions

View File

@@ -51,11 +51,6 @@ namespace Semmle.Extraction.CSharp.Entities
Overrides(trapFile);
ExtractRefReturn(trapFile, symbol, this);
ExtractCompilerGenerated(trapFile);
if (SymbolEqualityComparer.Default.Equals(symbol, Context.Compilation.GetEntryPoint(System.Threading.CancellationToken.None)))
{
trapFile.entry_methods(this);
}
}
public static new OrdinaryMethod Create(Context cx, IMethodSymbol method) => OrdinaryMethodFactory.Instance.CreateEntityFromSymbol(cx, method);

View File

@@ -7,16 +7,19 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
{
internal class GlobalStatementsBlock : Statement
{
private readonly Method parent;
private GlobalStatementsBlock(Context cx, Method parent)
: base(cx, StmtKind.BLOCK, parent, 0) { }
: base(cx, StmtKind.BLOCK, parent, 0)
{
this.parent = parent;
}
public override Microsoft.CodeAnalysis.Location ReportingLocation
{
get
{
// We only create a `GlobalStatementsBlock` if there are global statements. This also means that the
// entry point is going to be the generated method around those global statements
return cx.Compilation.GetEntryPoint(System.Threading.CancellationToken.None)
return parent.symbol
?.DeclaringSyntaxReferences
.FirstOrDefault()
?.GetSyntax()
@@ -33,8 +36,6 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
protected override void PopulateStatement(TextWriter trapFile)
{
trapFile.global_stmt_block(this);
trapFile.stmt_location(this, cx.CreateLocation(ReportingLocation));
}
}