protected void consumeStatementWhile() { // WhileStatement ::= 'while' '(' Expression ')' Statement // WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf this.expressionLengthPtr--; Statement statement = (Statement) this.astStack[this.astPtr]; this.astStack[this.astPtr] = new WhileStatement( this.expressionStack[this.expressionPtr--], statement, this.intStack[this.intPtr--], this.endStatementPosition); }
@Override public void endVisit(WhileStatement x, BlockScope scope) { try { SourceInfo info = makeSourceInfo(x); JStatement action = pop(x.action); JExpression condition = pop(x.condition); push(new JWhileStatement(info, condition, action)); } catch (Throwable e) { throw translateException(x, e); } }
@Override public boolean visit(WhileStatement x, BlockScope scope) { // SEE NOTE ON JDT FORCED OPTIMIZATIONS if (isOptimizedFalse(x.condition)) { x.action = null; } return true; }
@Override public boolean visit(WhileStatement node, BlockScope scope) { fixPositions(setGeneratedBy(node, source)); return super.visit(node, scope); }
/** * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.WhileStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope) */ public boolean visit(WhileStatement whileStatement, BlockScope scope) { this.scribe.printNextToken(TerminalTokens.TokenNamewhile); final int line = this.scribe.line; this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while); if (this.preferences.insert_space_after_opening_paren_in_while) { this.scribe.space(); } whileStatement.condition.traverse(this, scope); this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while); final Statement action = whileStatement.action; if (action != null) { if (action instanceof Block) { formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); action.traverse(this, scope); } else if (action instanceof EmptyStatement) { /* * This is an empty statement */ formatNecessaryEmptyStatement(); } else { this.scribe.printNewLine(); this.scribe.indent(); action.traverse(this, scope); if (action instanceof Expression) { this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } this.scribe.unIndent(); } } else { /* * This is an empty statement */ formatNecessaryEmptyStatement(); } return false; }
@Override public boolean visit(WhileStatement node, BlockScope scope) { setGeneratedBy(node, source); applyOffsetASTNode(node); return super.visit(node, scope); }