public MethodBodyVisitor(SemanticModel semanticModel,
                          CS.CSharpSyntaxVisitor <VisualBasicSyntaxNode> nodesVisitor, TriviaConverter triviaConverter)
 {
     this.semanticModel       = semanticModel;
     this.nodesVisitor        = nodesVisitor;
     CommentConvertingVisitor = new CommentConvertingMethodBodyVisitor(this, triviaConverter);
 }
Ejemplo n.º 2
0
 public MethodBodyExecutableStatementVisitor(SemanticModel semanticModel,
                                             CSharpSyntaxVisitor <VisualBasicSyntaxNode> nodesVisitor, TriviaConverter triviaConverter,
                                             CommonConversions commonConversions)
 {
     this._semanticModel      = semanticModel;
     this._nodesVisitor       = nodesVisitor;
     _commonConversions       = commonConversions;
     CommentConvertingVisitor = new CommentConvertingMethodBodyVisitor(this, triviaConverter);
 }
Ejemplo n.º 3
0
        private SyntaxList <StatementSyntax> ConvertStatement(Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement, CS.CSharpSyntaxVisitor <SyntaxList <StatementSyntax> > methodBodyVisitor)
        {
            var convertedStatements = statement.Accept(methodBodyVisitor);

            convertedStatements = InsertRequiredDeclarations(convertedStatements, statement);

            return(convertedStatements);
        }
Ejemplo n.º 4
0
        static SeparatedSyntaxList <VariableDeclaratorSyntax> RemodelVariableDeclaration(CSS.VariableDeclarationSyntax declaration, CS.CSharpSyntaxVisitor <VisualBasicSyntaxNode> nodesVisitor)
        {
            var type = (TypeSyntax)declaration.Type.Accept(nodesVisitor);
            var declaratorsWithoutInitializers = new List <CSS.VariableDeclaratorSyntax>();
            var declarators = new List <VariableDeclaratorSyntax>();

            foreach (var v in declaration.Variables)
            {
                if (v.Initializer == null)
                {
                    declaratorsWithoutInitializers.Add(v);
                    continue;
                }
                else
                {
                    declarators.Add(
                        SyntaxFactory.VariableDeclarator(
                            SyntaxFactory.SingletonSeparatedList(ExtractIdentifier(v)),
                            declaration.Type.IsVar ? null : SyntaxFactory.SimpleAsClause(type),
                            SyntaxFactory.EqualsValue((ExpressionSyntax)v.Initializer.Value.Accept(nodesVisitor))
                            )
                        );
                }
            }

            if (declaratorsWithoutInitializers.Count > 0)
            {
                declarators.Insert(0, SyntaxFactory.VariableDeclarator(SyntaxFactory.SeparatedList(declaratorsWithoutInitializers.Select(ExtractIdentifier)), SyntaxFactory.SimpleAsClause(type), null));
            }

            return(SyntaxFactory.SeparatedList(declarators));
        }