in src/Core/Compiling/Policy/WaitCompiler.cs [23:67]
public void Handle(ICompilationContext context, InvocationExpressionSyntax node)
{
if (node.ArgumentList.Arguments.Count is > 2 or < 1)
{
context.Report(Diagnostic.Create(
CompilationErrors.ArgumentCountMissMatchForPolicy,
node.ArgumentList.GetLocation(),
"wait"));
return;
}
ExpressionSyntax childPoliciesLambdaExpression = node.ArgumentList.Arguments[0].Expression;
if (childPoliciesLambdaExpression is not LambdaExpressionSyntax lambda)
{
context.Report(Diagnostic.Create(
CompilationErrors.ValueShouldBe,
childPoliciesLambdaExpression.GetLocation(),
"wait",
nameof(LambdaExpressionSyntax)));
return;
}
if (lambda.Block is null)
{
context.Report(Diagnostic.Create(
CompilationErrors.NotSupportedStatement,
lambda.GetLocation(),
childPoliciesLambdaExpression.GetType().FullName
));
return;
}
XElement element = new("wait");
if (node.ArgumentList.Arguments.Count == 2)
{
string value = node.ArgumentList.Arguments[1].Expression.ProcessParameter(context);
element.Add(new XAttribute("for", value));
}
SubCompilationContext subContext = new(context, element);
_blockCompiler.Value.Compile(subContext, lambda.Block);
context.AddPolicy(element);
}