/// <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); } } }
/// <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); }
/// <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); }
/// <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); }
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); } } }