C#: Do not bind comments to compiler generated statements.

This commit is contained in:
Michael Nebel
2024-02-22 13:14:48 +01:00
parent cf9c3d5dd1
commit d19c83228e
2 changed files with 6 additions and 3 deletions

View File

@@ -10,12 +10,15 @@ namespace Semmle.Extraction.CSharp.Entities
protected readonly TSyntax Stmt;
private readonly Location location;
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child, Location location)
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child, Location location, bool isCompilerGenerated = false)
: base(cx, kind, parent, child)
{
Stmt = stmt;
this.location = location;
cx.BindComments(this, location.Symbol);
if (!isCompilerGenerated)
{
cx.BindComments(this, location.Symbol);
}
}
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child)

View File

@@ -9,7 +9,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
internal class SyntheticEmptyBlock : Statement<BlockSyntax>
{
private SyntheticEmptyBlock(Context cx, BlockSyntax block, IStatementParentEntity parent, int child, Location location)
: base(cx, block, StmtKind.BLOCK, parent, child, location) { }
: base(cx, block, StmtKind.BLOCK, parent, child, location, isCompilerGenerated: true) { }
public static SyntheticEmptyBlock Create(Context cx, IStatementParentEntity parent, int child, Location location)
{