C#: Synthesize an empty body for primary constructors.

This commit is contained in:
Michael Nebel
2024-02-16 15:30:38 +01:00
parent dcde6597bc
commit 28d5c11b6f
3 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
using System.IO;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Semmle.Extraction.Entities;
using Semmle.Extraction.Kinds;
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) { }
public static SyntheticEmptyBlock Create(Context cx, IStatementParentEntity parent, int child, Location location)
{
var block = SyntaxFactory.Block();
var ret = new SyntheticEmptyBlock(cx, block, parent, child, location);
ret.TryPopulate();
return ret;
}
protected override void PopulateStatement(TextWriter trapFile) { }
}
}