Skip to content

Commit 4e8d2a9

Browse files
author
Kapil Borle
committed
Add wrapper extension methods
1 parent 8a5ce80 commit 4e8d2a9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Engine/Extensions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ public static Range ToRange(this IScriptExtent extent)
3030
extent.EndColumnNumber);
3131
}
3232

33+
/// <summary>
34+
/// Get the parameter Asts from a function definition Ast.
35+
///
36+
/// If not parameters are found, return null.
37+
/// </summary>
38+
public static IEnumerable<ParameterAst> GetParameterAsts(
39+
this FunctionDefinitionAst functionDefinitionAst)
40+
{
41+
ParamBlockAst paramBlockAst;
42+
return functionDefinitionAst.GetParameterAsts(out paramBlockAst);
43+
}
44+
3345
/// <summary>
3446
/// Get the parameter Asts from a function definition Ast.
3547
///
@@ -41,6 +53,8 @@ public static IEnumerable<ParameterAst> GetParameterAsts(
4153
this FunctionDefinitionAst functionDefinitionAst,
4254
out ParamBlockAst paramBlockAst)
4355
{
56+
// todo instead of returning null return an empty enumerator if no parameter is found
57+
// this removes the burden from the user for null checking.
4458
paramBlockAst = null;
4559
if (functionDefinitionAst.Parameters != null)
4660
{
@@ -114,6 +128,16 @@ public static NamedAttributeArgumentAst GetSupportsShouldProcessAst(this Attribu
114128
return null;
115129
}
116130

131+
132+
/// <summary>
133+
/// Return the boolean value of a named attribute argument.
134+
/// </summary>
135+
public static bool GetValue(this NamedAttributeArgumentAst attrAst)
136+
{
137+
ExpressionAst argumentAst;
138+
return attrAst.GetValue(out argumentAst);
139+
}
140+
117141
/// <summary>
118142
/// Return the boolean value of a named attribute argument.
119143
/// </summary>

0 commit comments

Comments
 (0)