private static WhileStatementSyntax ExtractExpressionToNestedIf( ExpressionSyntax expression, WhileStatementSyntax whileStatement, WhileStatementSyntax newWhileStatement) { if (newWhileStatement.Statement.IsKind(SyntaxKind.Block)) { var block = (BlockSyntax)newWhileStatement.Statement; IfStatementSyntax nestedIf = IfStatement( expression.WithoutTrivia(), Block(block.Statements)); return(newWhileStatement.ReplaceNode( block, block.WithStatements(SingletonList <StatementSyntax>(nestedIf)))); } else { IfStatementSyntax nestedIf = IfStatement( expression.WithoutTrivia(), whileStatement.Statement.WithoutTrivia()); BlockSyntax block = Block(nestedIf).WithTriviaFrom(whileStatement.Statement); return(newWhileStatement.WithStatement(block)); } }
public static WhileStatementSyntax AddBraces(WhileStatementSyntax whileStatement) { Debug.Assert(whileStatement != null && NeedsBraces(whileStatement)); return whileStatement .WithStatement(SyntaxFactory.Block(whileStatement.Statement)) .WithAdditionalAnnotations(Formatter.Annotation); }
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node) { var blockResumeLocation = GetBlockResumeLocation(node.Statement); node = (WhileStatementSyntax)base.VisitWhileStatement(node); node = node.WithStatement(InjectedBlock(node.Statement, blockResumeLocation)); return(node); }
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node) { var body = node.Statement; var bodyBlock = ToBlockSyntax(body); if (!bodyBlock.Equals(body)) { node = node.WithStatement(bodyBlock); } return(node); }
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node) { this.loopLevel++; var statement = base.VisitWhileStatement(node .WithStatement(GetLoopBlock(node.Statement))) .WithAdditionalAnnotations(this.isLoop); this.loopLevel--; return(statement); }
private static SyntaxNode RepeatStatement(RParser.RepeatStatementContext repeatStatement, Func <ParserRuleContext, Scope, SyntaxNode> transform, Scope scope) { if (!topLevel(repeatStatement)) { throw new NotImplementedException(); } BlockSyntax body = parseBlock(repeatStatement.expr(), transform, scope); return(repeat .WithStatement(body)); }
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node) { WhileStatementSyntax newNode = (WhileStatementSyntax)base.VisitWhileStatement(node); if (!(newNode.Statement is BlockSyntax)) { BlockSyntax block = SyntaxFactory.Block(newNode.Statement); newNode = node.WithStatement(block); } return(newNode); }
public override void VisitWhileStatement(WhileStatementSyntax node) { if (!YieldChecker.HasSpecialStatement(node)) { currentState.Add(StateMachineThisFixer.Fix(node)); } else { MaybeCreateNewState(); var nextState = GetNextState(node); var iterationState = currentState; iterationState.NextState = nextState; iterationState.BreakState = nextState; node = node.WithStatement(SyntaxFactory.Block(CaptureState(node.Statement, iterationState, nextState))); iterationState.Statements.Add(node); Close(iterationState); currentState = nextState; } }
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node) { this.loopLevel++; var statement = base.VisitWhileStatement (node .WithStatement (GetLoopBlock (node.Statement))) .WithAdditionalAnnotations (this.isLoop); this.loopLevel--; return statement; }
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node) { node = (WhileStatementSyntax)base.VisitWhileStatement(node); if (!node.Statement.IsKind(SyntaxKind.Block)) { this.addedAnnotations = true; node = node.WithStatement(SyntaxFactory.Block(node.Statement)); } return node; }