private StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node)
        {
            var exprNode   = node.Accept(_nodesVisitor);
            var expression = exprNode as ExpressionSyntax;

            return(expression != null?WrapRootExpression(expression) : (StatementSyntax)exprNode);
        }
Example #2
0
        StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node)
        {
            var exprNode = node.Accept(_nodesVisitor);

            if (!(exprNode is StatementSyntax))
            {
                exprNode = SyntaxFactory.ExpressionStatement((ExpressionSyntax)exprNode);
            }

            return((StatementSyntax)exprNode);
        }
Example #3
0
        public ExpressionSyntax ReduceArrayUpperBoundExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expr)
        {
            var constant = _semanticModel.GetConstantValue(expr);

            if (constant.HasValue && constant.Value is int)
            {
                return(SyntaxFactory.NumericLiteralExpression(SyntaxFactory.Literal((int)constant.Value - 1)));
            }

            return(SyntaxFactory.BinaryExpression(
                       SyntaxKind.SubtractExpression,
                       (ExpressionSyntax)expr.Accept(_nodesVisitor), SyntaxFactory.Token(SyntaxKind.MinusToken), SyntaxFactory.NumericLiteralExpression(SyntaxFactory.Literal(1))));
        }
Example #4
0
        private SyntaxList <StatementSyntax> CreateForEachStatement(VisualBasicSyntaxNode vbVariable,
                                                                    CSS.ExpressionSyntax csExpression, CSS.StatementSyntax csStatement, params StatementSyntax[] prefixExtraVbStatements)
        {
            var expression = (ExpressionSyntax)csExpression.Accept(_nodesVisitor);
            var stmt       = ConvertBlock(csStatement, prefixExtraVbStatements);
            var block      = SyntaxFactory.ForEachBlock(
                SyntaxFactory.ForEachStatement(vbVariable, expression),
                stmt,
                SyntaxFactory.NextStatement()
                );

            return(SyntaxFactory.SingletonList <StatementSyntax>(block));
        }
Example #5
0
 public VisualBasicSyntaxNode ConvertTopLevelExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax topLevelExpression)
 {
     return(topLevelExpression.Accept(_nodesVisitor));
 }