Walks a block AST node. TODO: Attention, MethodASTWalker has great part of the logic is in common.
Inheritance: ASTWalker, IASTWalker
        /// <summary>
        /// In charge of executing a fixed visit of this node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="index"></param>
        private void VisitNode(IfStatementSyntax node, int index)
        {
            // Handling conditional expression
            this.Statement.SetTestExpression(
                new ExpressionTranslationUnitBuilder(node.Condition, this.semanticModel).Build(),
                index);

            // Handling body
            IASTWalker walker = (node.Statement as BlockSyntax != null) ?
                                BlockASTWalker.Create(node.Statement) :
                                new StatementASTWalkerBuilder(node.Statement).Build();
            ITranslationUnit translationUnit = walker.Walk();

            this.Statement.SetStatementInConditionalBlock(translationUnit, index);

            // TODO: Remember to call the event for node traversal

            if (node.Else != null && node.Else.Statement != null)
            {
                if (node.Else.Statement as IfStatementSyntax != null)
                {
                    // To the next node
                    this.VisitNode(node.Else.Statement as IfStatementSyntax, ++index);
                }
                else
                {
                    walker = (node.Else.Statement as BlockSyntax != null) ?
                             BlockASTWalker.Create(node.Else.Statement) :
                             new StatementASTWalkerBuilder(node.Else.Statement).Build();
                    translationUnit = walker.Walk();
                    this.Statement.SetStatementInElseBlock(translationUnit);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// In charge of executing a fixed visit of this node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="index"></param>
        private void VisitNode(TryStatementSyntax node, int index)
        {
            // Handling body
            IASTWalker walker = (node.Block as BlockSyntax != null) ?
                                BlockASTWalker.Create(node.Block) :
                                new StatementASTWalkerBuilder(node.Block).Build();
            ITranslationUnit translationUnit = walker.Walk();

            this.Statement.SetBlockExpression(translationUnit);
        }
Exemplo n.º 3
0
        /// <summary>
        /// In charge of executing a fixed visit of this node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="index"></param>
        private void VisitNode(ForStatementSyntax node, int index)
        {
            //for condition
            this.Statement.SetForExpression(
                new ExpressionTranslationUnitBuilder(node.Condition, this.semanticModel).Build());


            // Handling body
            IASTWalker walker = (node.Statement as BlockSyntax != null) ?
                                BlockASTWalker.Create(node.Statement) :
                                new StatementASTWalkerBuilder(node.Statement).Build();
            ITranslationUnit translationUnit = walker.Walk();

            this.Statement.SetStatementInConditionalBlock(translationUnit);
        }
Exemplo n.º 4
0
        /// <summary>
        /// In charge of executing a fixed visit of this node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="index"></param>
        private void VisitNode(ForEachStatementSyntax node, int index)
        {
            //Passing through strings makes it a little easier to initialize the lambda 'foreach' statement.
            string[] forEachExpression = new string[3] {
                node.Type.ToString(), node.Identifier.ValueText, node.Expression.ToString()
            };
            this.Statement.SetForEachExpression(forEachExpression);

            // Handling body
            IASTWalker walker = (node.Statement as BlockSyntax != null) ?
                                BlockASTWalker.Create(node.Statement) :
                                new StatementASTWalkerBuilder(node.Statement).Build();
            ITranslationUnit translationUnit = walker.Walk();

            this.Statement.SetStatementInConditionalBlock(translationUnit);
        }
Exemplo n.º 5
0
        private void VisitNode(PropertyDeclarationSyntax node)
        {
            foreach (var accessor in node.AccessorList.Accessors)
            {
                IASTWalker       walker          = BlockASTWalker.Create(accessor.Body, null, this.semanticModel);
                ITranslationUnit translationUnit = walker.Walk();

                // TODO: call events
                if (accessor.Kind() == SyntaxKind.GetAccessorDeclaration)
                {
                    this.propertyDeclaration.SetGetAccessor(translationUnit);
                }
                else if (accessor.Kind() == SyntaxKind.SetAccessorDeclaration)
                {
                    this.propertyDeclaration.SetSetAccessor(translationUnit);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Copy initializes a new instance of the <see cref="BlockASTWalker"/> class.
 /// </summary>
 /// <param name="other"></param>
 public BlockASTWalker(BlockASTWalker other)
     : base(other)
 {
     this.statementsGroup = other.statementsGroup;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Copy initializes a new instance of the <see cref="BlockASTWalker"/> class.
 /// </summary>
 /// <param name="other"></param>
 public BlockASTWalker(BlockASTWalker other)
     : base(other)
 {
     this.statementsGroup = other.statementsGroup;
 }