private StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node) { var exprNode = node.Accept(_nodesVisitor); var expression = exprNode as ExpressionSyntax; return(expression != null?WrapRootExpression(expression) : (StatementSyntax)exprNode); }
StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node) { var exprNode = node.Accept(_nodesVisitor); if (!(exprNode is StatementSyntax)) { exprNode = SyntaxFactory.ExpressionStatement((ExpressionSyntax)exprNode); } return((StatementSyntax)exprNode); }
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)))); }
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)); }
public VisualBasicSyntaxNode ConvertTopLevelExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax topLevelExpression) { return(topLevelExpression.Accept(_nodesVisitor)); }