Пример #1
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            var token = CreateBlock($"while ({node.Condition})", SDNodeRole.DoWhileLoop);
            _tokenList.Add(token);

            VisitChildren(token.Statements, node.Statement);
        }
Пример #2
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            node.Condition?.Accept(this);
            node.Statement?.Accept(this);

            base.VisitDoStatement(node);
        }
Пример #3
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            DoStatementSyntax doStatement = root
                                            .FindNode(context.Span, getInnermostNodeForTie: true)?
                                            .FirstAncestorOrSelf <DoStatementSyntax>();

            if (doStatement == null)
            {
                return;
            }

            TextSpan span = TextSpan.FromBounds(
                doStatement.Statement.Span.End,
                doStatement.Span.End);

            if (root
                .DescendantTrivia(span)
                .All(f => f.IsWhitespaceOrEndOfLine()))
            {
                CodeAction codeAction = CodeAction.Create(
                    "Use while statement to create an infinite loop",
                    cancellationToken =>
                {
                    return(DoStatementRefactoring.ConvertToWhileStatementAsync(
                               context.Document,
                               doStatement,
                               cancellationToken));
                },
                    DiagnosticIdentifiers.AvoidUsageOfDoStatementToCreateInfiniteLoop + EquivalenceKeySuffix);

                context.RegisterCodeFix(codeAction, context.Diagnostics);
            }
        }
Пример #4
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            var topOfLoop           = GetNextState();
            var afterWhileStatement = GetNextState();
            var bodyState           = GetNextState();

            // The first thing that needs to happen is that the body should execute once,
            // regardless of the condition.  After that, we can just use a while loop,
            // since from that point on it's equivalent.
            GotoState(bodyState);

            CurrentState = bodyState;
            AcceptStatement(node.Statement, afterWhileStatement, topOfLoop);
            GotoState(topOfLoop);

            CurrentState = topOfLoop;
            var newWhileStatement = Js.While(
                (JsExpression)node.Condition.Accept(Transformer),
                GotoStateBlock(bodyState));

            CurrentState.Add(newWhileStatement);
            GotoState(afterWhileStatement);

            CurrentState = afterWhileStatement;
        }
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            base.VisitDoStatement(node);
            CyclomaticComplexityAnalyzer cyclomaticComplexityAnalyzer = this;

            cyclomaticComplexityAnalyzer.counter = checked (cyclomaticComplexityAnalyzer.counter + 1);
        }
Пример #6
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            if (!YieldChecker.HasSpecialStatement(node))
            {
                currentState.Add(StateMachineThisFixer.Fix(node));
            }
            else
            {
                MaybeCreateNewState();

                var nextState = GetNextState(node);

                var conditionState = new State(this)
                {
                    BreakState = nextState
                };

                var iterationState = currentState;

                conditionState.Add(Cs.If(StateMachineThisFixer.Fix(node.Condition), ChangeState(iterationState), ChangeState(nextState)));
                conditionState.Add(GotoTop());
                SetClosed(conditionState);
                iterationState.NextState = conditionState;

                node.Statement.Accept(this);
                if (currentState != nextState)
                {
                    Close(currentState);
                }

                currentState = nextState;
            }
        }
Пример #7
0
        public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            node = (DoStatementSyntax)base.VisitDoStatement(node);

            if (transformKind == TransformKind.DoToWhile)
            {
                // Get the different syntax nodes components of the Do Statement
                var doKeyword    = node.DoKeyword;
                var doStatement  = node.Statement;
                var whileKeyword = node.WhileKeyword;
                var condition    = node.Condition;
                var openParen    = node.OpenParenToken;
                var closeParen   = node.CloseParenToken;
                var semicolon    = node.SemicolonToken;

                // Preserve some level of trivia that was in the original Do keyword node.
                var newWhileKeyword = SyntaxFactory.Token(doKeyword.LeadingTrivia, SyntaxKind.WhileKeyword, whileKeyword.TrailingTrivia);

                // Preserve some level of trivia that was in the original Do keyword node and the original CloseParen token.
                var newCloseParenTrivias = closeParen.TrailingTrivia.ToList();
                newCloseParenTrivias.AddRange(doKeyword.TrailingTrivia.ToList());
                var newCloseParenTriviaList = SyntaxFactory.TriviaList(newCloseParenTrivias);
                var newCloseParen           = SyntaxFactory.Token(closeParen.LeadingTrivia, SyntaxKind.CloseParenToken, newCloseParenTriviaList);

                var newTrailingTrivias = doStatement.GetTrailingTrivia().ToList();
                newTrailingTrivias.AddRange(semicolon.TrailingTrivia.ToList());
                var newWhileStatement = doStatement.WithTrailingTrivia(newTrailingTrivias);

                return(SyntaxFactory.WhileStatement(newWhileKeyword, openParen, condition, newCloseParen, newWhileStatement));
            }

            return(node);
        }
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            DoStatementSyntax doStatement = root
                                            .FindNode(context.Span, getInnermostNodeForTie: true)?
                                            .FirstAncestorOrSelf <DoStatementSyntax>();

            if (doStatement == null)
            {
                return;
            }

            CodeAction codeAction = CodeAction.Create(
                "Use while to create an infinite loop",
                cancellationToken =>
            {
                return(ReplaceDoStatementWithWhileStatementRefactoring.RefactorAsync(
                           context.Document,
                           doStatement,
                           cancellationToken));
            },
                DiagnosticIdentifiers.AvoidUsageOfDoStatementToCreateInfiniteLoop + EquivalenceKeySuffix);

            context.RegisterCodeFix(codeAction, context.Diagnostics);
        }
        public static async Task <Document> RefactorAsync(
            Document document,
            DoStatementSyntax doStatement,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            SyntaxTriviaList trailingTrivia = doStatement.Statement
                                              .GetTrailingTrivia()
                                              .AddRange(doStatement.CloseParenToken.TrailingTrivia)
                                              .AddRange(doStatement.SemicolonToken.LeadingTrivia)
                                              .AddRange(doStatement.SemicolonToken.TrailingTrivia);

            WhileStatementSyntax newNode = WhileStatement(
                doStatement.WhileKeyword.WithLeadingTrivia(doStatement.DoKeyword.LeadingTrivia),
                doStatement.OpenParenToken,
                doStatement.Condition,
                doStatement.CloseParenToken.WithTrailingTrivia(doStatement.DoKeyword.TrailingTrivia),
                doStatement.Statement.WithTrailingTrivia(trailingTrivia));

            newNode = newNode.WithFormatterAnnotation();

            SyntaxNode newRoot = oldRoot.ReplaceNode(doStatement, newNode);

            return(document.WithSyntaxRoot(newRoot));
        }
Пример #10
0
            public override int VisitDoStatement(DoStatementSyntax node, BinderContext enclosing)
            {
                var context = new WhileBinderContext(this.method, enclosing, node);

                this.map = this.map.Add(node, context);
                return(base.VisitDoStatement(node, context));
            }
Пример #11
0
        public static async Task <Document> RefactorAsync(
            Document document,
            WhileStatementSyntax whileStatement,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            DoStatementSyntax doStatement = DoStatement(
                Token(
                    whileStatement.WhileKeyword.LeadingTrivia,
                    SyntaxKind.DoKeyword,
                    whileStatement.CloseParenToken.TrailingTrivia),
                whileStatement.Statement.WithoutTrailingTrivia(),
                Token(SyntaxKind.WhileKeyword),
                whileStatement.OpenParenToken,
                whileStatement.Condition,
                whileStatement.CloseParenToken.WithoutTrailingTrivia(),
                SemicolonToken());

            doStatement = doStatement
                          .WithTriviaFrom(whileStatement)
                          .WithFormatterAnnotation();

            SyntaxNode newRoot = oldRoot.ReplaceNode(whileStatement, doStatement);

            return(document.WithSyntaxRoot(newRoot));
        }
        public static async Task <Document> ConvertToWhileStatementAsync(
            Document document,
            DoStatementSyntax doStatement,
            CancellationToken cancellationToken)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (doStatement == null)
            {
                throw new ArgumentNullException(nameof(doStatement));
            }

            SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken);

            WhileStatementSyntax newNode = WhileStatement(
                Token(SyntaxKind.WhileKeyword),
                Token(SyntaxKind.OpenParenToken),
                LiteralExpression(SyntaxKind.TrueLiteralExpression),
                Token(
                    default(SyntaxTriviaList),
                    SyntaxKind.CloseParenToken,
                    doStatement.DoKeyword.TrailingTrivia),
                doStatement.Statement);

            newNode = newNode
                      .WithTriviaFrom(doStatement)
                      .WithAdditionalAnnotations(Formatter.Annotation);

            SyntaxNode newRoot = oldRoot.ReplaceNode(doStatement, newNode);

            return(document.WithSyntaxRoot(newRoot));
        }
Пример #13
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            base.VisitDoStatement(node);
            StatementsAnalyzer statementsAnalyzer = this;

            statementsAnalyzer.counter = checked (statementsAnalyzer.counter + 1);
        }
Пример #14
0
        /// <summary>
        /// Handles the given do statement.
        /// </summary>
        /// <param name="stmt">Statement</param>
        /// <param name="successor">Successor</param>
        private void HandleDoStatement(DoStatementSyntax stmt, ControlFlowGraphNode successor)
        {
            this.SyntaxNodes.Add(stmt.Condition);
            this.IsLoopHeadNode = true;

            if (successor != null)
            {
                this.ISuccessors.Add(successor);
                successor.IPredecessors.Add(this);
                this.LoopExitNode = successor;
            }

            var doNode = new ControlFlowGraphNode(this.Summary);

            this.ISuccessors.Add(doNode);
            doNode.IPredecessors.Add(this);

            if (stmt.Statement is BlockSyntax)
            {
                doNode.Construct((stmt.Statement as BlockSyntax).Statements, 0, false, this);
            }
            else
            {
                doNode.Construct(new SyntaxList <StatementSyntax> {
                    stmt.Statement
                }, 0, false, this);
            }
        }
Пример #15
0
        public override Evaluation VisitDoStatement(DoStatementSyntax node)
        {
            node.Condition?.Accept <Evaluation>(this);
            node.Statement?.Accept <Evaluation>(this);

            return(base.VisitDoStatement(node));
        }
Пример #16
0
            public override void VisitDoStatement(DoStatementSyntax node)
            {
                // <data> do { <bodyStart> embeddedStmt; <bodyEnd>} <condition> while(cond); <end>
                ControlFlowNode end           = builder.CreateEndNode(node, addToNodeList: false);
                ControlFlowNode conditionNode = builder.CreateSpecialNode(node, ControlFlowNodeType.LoopCondition, addToNodeList: false);

                breakTargets.Push(end);
                continueTargets.Push(conditionNode);

                ControlFlowNode bodyStart = builder.CreateStartNode(node.Statement);

                Connect(curNode, bodyStart);
                Visit(node.Statement);
                Connect(curNode, conditionNode);

                bool?cond = builder.EvaluateCondition(node.Condition);

                if (cond != false)
                {
                    Connect(conditionNode, bodyStart, ControlFlowEdgeType.ConditionTrue);
                }
                if (cond != true)
                {
                    Connect(conditionNode, end, ControlFlowEdgeType.ConditionFalse);
                }

                breakTargets.Pop();
                continueTargets.Pop();
                builder.nodes.Add(conditionNode);
                builder.nodes.Add(end);
                curNode = end;
            }
Пример #17
0
        private BoundStatement BindDoStatement(DoStatementSyntax syntax, Symbol parent)
        {
            BindAttributes(syntax.Attributes);

            return(new BoundDoStatement(
                       Bind(syntax.Condition, BindExpression),
                       Bind(syntax.Statement, x => BindStatement(x, parent))));
        }
Пример #18
0
        public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            var statement = (BlockSyntax)node.Statement;
            var line      = GetLineNumber(statement);
            var updated   = Block(new[] { ThrowIfCancelled.WithTrailingTrivia(GetLineDirective(line)) }.Concat(statement.Statements));

            return(base.VisitDoStatement(node.ReplaceNode(statement, updated)));
        }
Пример #19
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            base.VisitDoStatement(node);
            Count++;
            var conditionComplexity = GetConditionComplexity(node.Condition);

            Count += conditionComplexity;
        }
Пример #20
0
        private BoundStatement BindDoStatement(DoStatementSyntax syntax, Symbol parent)
        {
            BindAttributes(syntax.Attributes);

            return new BoundDoStatement(
                Bind(syntax.Condition, BindExpression),
                Bind(syntax.Statement, x => BindStatement(x, parent)));
        }
Пример #21
0
        public static DoStatementSyntax AddBraces(DoStatementSyntax doStatement)
        {
            Debug.Assert(doStatement != null && NeedsBraces(doStatement));

            return doStatement
                .WithStatement(SyntaxFactory.Block(doStatement.Statement))
                .WithAdditionalAnnotations(Formatter.Annotation);
        }
Пример #22
0
 private void DoStatement(DoStatementSyntax statement)
 {
     writer.WriteLinePrefix("do");
     WriteStatement(statement.Statement);
     writer.WritePrefix("while (");
     WriteExpression(statement.Condition);
     writer.WriteLine(");");
 }
Пример #23
0
 public override void VisitDoStatement(DoStatementSyntax node)
 {
     if (currentMethod != null)
     {
         currentMethod.cyclomaticComplexity++;
     }
     base.VisitDoStatement(node);
 }
 public override IStmt VisitDoStatement(DoStatementSyntax node)
 {
     return(new DoWhileStmt
     {
         Condition = Visit(node.Condition),
         Body = WrapToBlock(Visit(node.Statement))
     });
 }
Пример #25
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            var whileBinder = new WhileBinder(this.method, enclosing, node);

            AddToMap(node, whileBinder);

            VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
        }
Пример #26
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            var token = CreateBlock($"while ({node.Condition})", SDNodeRole.DoWhileLoop);

            _tokenList.Add(token);

            VisitChildren(token.Statements, node.Statement);
        }
Пример #27
0
        public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            var blockResumeLocation = GetBlockResumeLocation(node.Statement);

            node = (DoStatementSyntax)base.VisitDoStatement(node);

            node = node.WithStatement(InjectedBlock(node.Statement, blockResumeLocation));
            return(node);
        }
Пример #28
0
 public BoundDoStatement BindDo(DoStatementSyntax node)
 {
     var condition = BindBooleanExpression(node.Condition);
     var loopContext = this.containingMethod.BlockMap.GetValueOrDefault(node);
     Debug.Assert(loopContext != null);
     var analyzer = new SemanticAnalyzer(this.containingMethod, loopContext, this.diagnostics);
     var body = analyzer.BindStatement(node.Statement);
     return new BoundDoStatement(node, condition, body, loopContext.GetBreakLabel(), loopContext.GetContinueLabel());
 }
Пример #29
0
            public override void VisitDoStatement(DoStatementSyntax node)
            {
                if (RootStmtOpt != node)
                {
                    return;
                }

                Visit(node.Condition);
            }
        public static bool CanConvertToWhileStatement(DoStatementSyntax doStatement)
        {
            if (doStatement == null)
            {
                throw new ArgumentNullException(nameof(doStatement));
            }

            return(doStatement.Condition?.IsKind(SyntaxKind.TrueLiteralExpression) == true);
        }
        public static bool ContainsEmbeddedStatement(DoStatementSyntax doStatement)
        {
            if (doStatement == null)
            {
                throw new ArgumentNullException(nameof(doStatement));
            }

            return(doStatement.Statement?.IsKind(SyntaxKind.Block) == false);
        }
Пример #32
0
 public override void VisitDoStatement(DoStatementSyntax node)
 {
     if (entryPoint.IsMethodLevel() && node.IsParent <AnonymousFunctionExpressionSyntax>())
     {
         return;
     }
     noscounter++;
     base.VisitDoStatement(node);
 }
Пример #33
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            Debug.Assert((object)_method == _enclosing.ContainingMemberOrLambda);
            var whileBinder = new WhileBinder(_enclosing, node);

            AddToMap(node, whileBinder);

            VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
        }
            protected internal override object VisitDoStatement(DoStatementSyntax node, Binder enclosing)
            {
                var whileBinder = new WhileBinder(this.method, enclosing, node);

                this.map = this.map.Add(node, whileBinder);

                Visit(node.Statement, whileBinder);
                return(null);
            }
Пример #35
0
        protected override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            if (!node.DescendentNodes().OfType<BlockSyntax>().Any())
            {
                node = node.Update (node.DoKeyword, Syntax.Block (statements: node.Statement), node.WhileKeyword,
                                    node.OpenParenToken, node.Condition, node.CloseParenToken, node.SemicolonToken);
            }

            return base.VisitDoStatement (node);
        }
            public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
            {
                node = (DoStatementSyntax)base.VisitDoStatement(node);

                if (!node.Statement.IsKind(SyntaxKind.Block))
                {
                    this.addedAnnotations = true;
                    node = node.WithStatement(SyntaxFactory.Block(node.Statement));
                }

                return node;
            }
Пример #37
0
        public static void Go(OutputWriter writer, DoStatementSyntax statement)
        {
            var info = new LoopInfo(statement);

            writer.WriteLine("do");
            writer.OpenBrace();
            Core.WriteStatementAsBlock(writer, statement.Statement, false);
            writer.CloseBrace();

            writer.WriteIndent();
            writer.Write("while (");
            Core.Write(writer, statement.Condition);
            writer.Write(");\r\n");
        }
Пример #38
0
        public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            node = (DoStatementSyntax)base.VisitDoStatement(node);

            if (!node.CloseParenToken.IsMissing && node.Statement.Kind != SyntaxKind.Block)
            {
                return CodeAnnotations.Formatting.AddAnnotationTo(
                    Syntax.DoStatement(
                        node.DoKeyword,
                        WrapStatementWithBlock(node.Statement),
                        node.WhileKeyword,
                        node.OpenParenToken,
                        node.Condition,
                        node.CloseParenToken,
                        node.SemicolonToken));
            }
            else
            {
                return node;
            }
        }
Пример #39
0
			public override void VisitDoStatement(DoStatementSyntax node)
			{
				base.VisitDoStatement(node);
				_counter++;
			}
Пример #40
0
 public BoundDoStatement BindDo(DoStatementSyntax node, DiagnosticBag diagnostics)
 {
     var condition = BindBooleanExpression(node.Condition, diagnostics);
     var loopBinder = this.GetBinder(node);
     Debug.Assert(loopBinder != null);
     var body = loopBinder.BindPossibleEmbeddedStatement(node.Statement, diagnostics);
     return new BoundDoStatement(node, condition, body, loopBinder.BreakLabel, loopBinder.ContinueLabel);
 }
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            if (!YieldChecker.HasSpecialStatement(node))
            {
                currentState.Add(StateMachineThisFixer.Fix(node));
            }
            else
            {
                MaybeCreateNewState();

                var nextState = GetNextState(node);

                var conditionState = new State(this) { BreakState = nextState };

                var iterationState = currentState;

                conditionState.Add(Cs.If(StateMachineThisFixer.Fix(node.Condition), ChangeState(iterationState), ChangeState(nextState)));
                conditionState.Add(GotoTop());
                SetClosed(conditionState);
                iterationState.NextState = conditionState;

                node.Statement.Accept(this);
                if (currentState != nextState)
                {
                    Close(currentState);
                }

                currentState = nextState;
            }
        }
            private IEnumerable<ITypeSymbol> InferTypeInDoStatement(DoStatementSyntax doStatement, SyntaxToken? previousToken = null)
            {
                // If we have a position, we need to be after "do { } while("
                if (previousToken.HasValue && previousToken.Value != doStatement.OpenParenToken)
                {
                    return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
                }

                return SpecializedCollections.SingletonEnumerable(this.Compilation.GetSpecialType(SpecialType.System_Boolean));
            }
Пример #43
0
        public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            _output.WriteLine(node.DoKeyword, "do {");

            _output.IncreaseIndent();
            Visit(node.Statement);
            this.AppendCompensateSemicolon(node.Statement);
            _output.DecreaseIndent();

            _output.Write(node.WhileKeyword, "} while (");
            VisitExpression(node.Condition);
            _output.TrivialWrite(')');
            return node;
        }
            public override void VisitDoStatement(DoStatementSyntax node)
            {
                var saveCurrentScope = currentScope;
                currentScope = new DeclarationScope(currentScope);

                Visit(node.Condition);
                VisitPossibleEmbeddedStatement(node.Statement);

                Debug.Assert(currentScope.Parent == saveCurrentScope);
                currentScope = saveCurrentScope;
            }
Пример #45
0
        private BoundStatement BindDo(DoStatementSyntax node, DiagnosticBag diagnostics)
        {
            var loopBinder = this.GetBinder(node);
            Debug.Assert(loopBinder != null);

            return loopBinder.WrapWithVariablesIfAny(node, loopBinder.BindDoParts(diagnostics, loopBinder));
        }
 public override void VisitDoStatement(DoStatementSyntax node)
 {
     _builder.Add(node);
     base.VisitDoStatement(node);
 }
Пример #47
0
 public virtual void VisitDoStatement(DoStatementSyntax node)
 {
     DefaultVisit(node);
 }
Пример #48
0
 public BoundDoStatement BindDo(DoStatementSyntax node, DiagnosticBag diagnostics)
 {
     var loopBinder = this.GetBinder(node);
     Debug.Assert(loopBinder != null);
     return loopBinder.BindDoParts(diagnostics, loopBinder);
 }
Пример #49
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <remarks>
 /// Statements will cause an AST walker to be created, thus we don't need to go further deeper in the
 /// tree by visiting the node.
 /// </remarks>
 public override void VisitDoStatement(DoStatementSyntax node)
 {
     this.VisitStatement(node);
 }
Пример #50
0
 public override void VisitDoStatement(DoStatementSyntax node)
 {
     Visit(node.Condition);
 }
Пример #51
0
        public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            this.loopLevel++;

            var statement = base.VisitDoStatement (node
                                .WithStatement (GetLoopBlock (node.Statement)))
                            .WithAdditionalAnnotations (this.isLoop);

            this.loopLevel--;

            return statement;
        }
 public override void VisitDoStatement(DoStatementSyntax node) => CheckNesting(node.DoKeyword, () => base.VisitDoStatement(node));
Пример #53
0
        protected override SyntaxNode VisitDoStatement(DoStatementSyntax node)
        {
            node = node.Update (node.DoKeyword, GetLoopBlock (node.Statement), node.WhileKeyword,
                                node.OpenParenToken, node.Condition, node.CloseParenToken, node.SemicolonToken);

            this.loopLevel++;
            var statement = base.VisitDoStatement ((DoStatementSyntax) node.WithAdditionalAnnotations (this.isLoop));
            this.loopLevel--;
            return statement;
        }
Пример #54
0
 public BoundDoStatement(DoStatementSyntax syntax, BoundExpression condition, BoundStatement body)
     : base(BoundNodeKind.DoStatement, syntax)
 {
     Condition = condition;
     Body = body;
 }
Пример #55
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            Debug.Assert((object)_method == _enclosing.ContainingMemberOrLambda);
            var whileBinder = new WhileBinder(_enclosing, node);
            AddToMap(node, whileBinder);

            VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
        }
Пример #56
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
            var patternBinder = new PatternVariableBinder(node, _enclosing);
            var whileBinder = new WhileBinder(patternBinder, node);
            AddToMap(node, whileBinder);

            Visit(node.Condition, whileBinder);
            VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
        }
 private static bool AreEquivalentActiveStatements(DoStatementSyntax oldNode, DoStatementSyntax newNode)
 {
     // only check the condition, edits in the body are allowed:
     return AreEquivalentIgnoringLambdaBodies(oldNode.Condition, newNode.Condition);
 }
Пример #58
0
        /// <summary>
        /// Handles the given do statement.
        /// </summary>
        /// <param name="stmt">Statement</param>
        /// <param name="successor">Successor</param>
        private void HandleDoStatement(DoStatementSyntax stmt, ControlFlowGraphNode successor)
        {
            this.SyntaxNodes.Add(stmt.Condition);
            this.IsLoopHeadNode = true;

            if (successor != null)
            {
                this.ISuccessors.Add(successor);
                successor.IPredecessors.Add(this);
                this.LoopExitNode = successor;
            }

            var doNode = new ControlFlowGraphNode(this.Summary);
            this.ISuccessors.Add(doNode);
            doNode.IPredecessors.Add(this);

            if (stmt.Statement is BlockSyntax)
            {
                doNode.Construct((stmt.Statement as BlockSyntax).Statements, 0, false, this);
            }
            else
            {
                doNode.Construct(new SyntaxList<StatementSyntax> { stmt.Statement }, 0, false, this);
            }
        }
 private bool AnalyzeDoStatement(DoStatementSyntax doStatement) =>
     !doStatement.Statement.IsKind(SyntaxKind.Block);
Пример #60
0
        public override void VisitDoStatement(DoStatementSyntax node)
        {
            var whileBinder = new WhileBinder(this.method, enclosing, node);
            AddToMap(node, whileBinder);

            VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
        }