public void ExpressionInCode(string expression, bool isImplicit) { ExpressionBlock expressionBlock; if (isImplicit) { expressionBlock = new ExpressionBlock( Factory.CodeTransition(), Factory.Code(expression) .AsImplicitExpression(VBCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharacters.NonWhiteSpace)); } else { expressionBlock = new ExpressionBlock( Factory.CodeTransition(), Factory.MetaCode("(").Accepts(AcceptedCharacters.None), Factory.Code(expression).AsExpression(), Factory.MetaCode(")").Accepts(AcceptedCharacters.None)); } string code; if (isImplicit) { code = @"If foo IsNot Nothing Then @" + expression + @" End If"; } else { code = @"If foo IsNot Nothing Then @(" + expression + @") End If"; } ParseBlockTest(code, new StatementBlock( Factory.Code("If foo IsNot Nothing Then\r\n ") .AsStatement(), expressionBlock, Factory.Code("\r\nEnd If") .AsStatement() .Accepts(AcceptedCharacters.None))); }
private void RunInCodeExpressionTest(string expression, ExpressionBlock expressionBlock) { ParseBlockTest(@"If foo IsNot Nothing Then @" + expression + @" End If", new StatementBlock( new CodeSpan(@"If foo IsNot Nothing Then "), expressionBlock, new CodeSpan(@" End If", hidden: false, acceptedCharacters: AcceptedCharacters.None))); }