Beispiel #1
0
        private bool TryConvertRaiseEvent(CSS.StatementSyntax resultStatement,
                                          CSS.BinaryExpressionSyntax be, ref StatementSyntax raiseEventStatement)
        {
            CSS.ExpressionStatementSyntax singleStatement;
            if (resultStatement is CSS.BlockSyntax block)
            {
                if (block.Statements.Count != 1)
                {
                    return(false);
                }
                singleStatement = block.Statements[0] as CSS.ExpressionStatementSyntax;
            }
            else
            {
                singleStatement = resultStatement as CSS.ExpressionStatementSyntax;
            }

            if (!(singleStatement?.Expression is CSS.InvocationExpressionSyntax singleInvocationExpression))
            {
                return(false);
            }

            raiseEventStatement = singleInvocationExpression.Accept(_nodesVisitor) as RaiseEventStatementSyntax;
            return(raiseEventStatement != null);
        }
Beispiel #2
0
        private SyntaxList <StatementSyntax> ConvertStatement(Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement, CSharpSyntaxVisitor <SyntaxList <StatementSyntax> > methodBodyVisitor)
        {
            var convertedStatements = statement.Accept(methodBodyVisitor);

            convertedStatements = InsertRequiredDeclarations(convertedStatements, statement);

            return(convertedStatements);
        }
Beispiel #3
0
 bool IsSimpleStatement(CSS.StatementSyntax statement)
 {
     return(statement is CSS.ExpressionStatementSyntax ||
            statement is CSS.BreakStatementSyntax ||
            statement is CSS.ContinueStatementSyntax ||
            statement is CSS.ReturnStatementSyntax ||
            statement is CSS.YieldStatementSyntax ||
            statement is CSS.ThrowStatementSyntax);
 }
Beispiel #4
0
 SyntaxList <StatementSyntax> ConvertBlock(CSS.StatementSyntax node, params StatementSyntax[] prefixExtraVbStatements)
 {
     if (node is CSS.BlockSyntax b)
     {
         return(SyntaxFactory.List(prefixExtraVbStatements.Concat(b.Statements.Where(s => !(s is CSS.EmptyStatementSyntax))
                                                                  .SelectMany(s => s.Accept(CommentConvertingVisitor)))));
     }
     if (node is CSS.EmptyStatementSyntax)
     {
         return(SyntaxFactory.List(prefixExtraVbStatements));
     }
     return(node.Accept(CommentConvertingVisitor));
 }
Beispiel #5
0
 SyntaxList <StatementSyntax> ConvertBlock(CSS.StatementSyntax node)
 {
     if (node is CSS.BlockSyntax)
     {
         var b = (CSS.BlockSyntax)node;
         return(SyntaxFactory.List(b.Statements.Where(s => !(s is CSS.EmptyStatementSyntax)).SelectMany(s => s.Accept(CommentConvertingVisitor))));
     }
     if (node is CSS.EmptyStatementSyntax)
     {
         return(SyntaxFactory.List <StatementSyntax>());
     }
     return(node.Accept(CommentConvertingVisitor));
 }
Beispiel #6
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));
        }