-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathLocalFunction.cs
More file actions
45 lines (40 loc) · 1.6 KB
/
Copy pathLocalFunction.cs
File metadata and controls
45 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Semmle.Extraction.Kinds;
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.CreateLocation(node.GetLocation())) { }
public static LocalFunction Create(Context cx, LocalFunctionStatementSyntax node, IStatementParentEntity parent, int child)
{
var ret = new LocalFunction(cx, node, parent, child);
ret.TryPopulate();
return ret;
}
/// <summary>
/// Gets the IMethodSymbol for this local function statement.
/// </summary>
private IMethodSymbol? Symbol
{
get
{
var m = Context.GetModel(Stmt);
return m.GetDeclaredSymbol(Stmt) as IMethodSymbol;
}
}
protected override void PopulateStatement(TextWriter trapFile)
{
if (Symbol is null)
{
Context.ExtractionError("Could not get local function symbol", null, Context.CreateLocation(this.ReportingLocation), severity: Semmle.Util.Logging.Severity.Warning);
return;
}
var function = Entities.LocalFunction.Create(Context, Symbol);
trapFile.local_function_stmts(this, function);
}
}
}