Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.javascript.ast;
 
While statement. Node type is org.mozilla.javascript.Token.WHILE.

WhileStatement:
     while ( Expression ) Statement
public class WhileLoop extends Loop {
    private AstNode condition;
    {
         = .;
    }
    public WhileLoop() {
    }
    public WhileLoop(int pos) {
        super(pos);
    }
    public WhileLoop(int posint len) {
        super(poslen);
    }

    
Returns loop condition
    public AstNode getCondition() {
        return ;
    }

    
Sets loop condition

Throws:
java.lang.IllegalArgumentException} if condition is null
    public void setCondition(AstNode condition) {
        assertNotNull(condition);
        this. = condition;
        condition.setParent(this);
    }
    @Override
    public String toSource(int depth) {
        StringBuilder sb = new StringBuilder();
        sb.append(makeIndent(depth));
        sb.append("while (");
        sb.append(.toSource(0));
        sb.append(") ");
        if (.getType() == .) {
            sb.append(.toSource(depth).trim());
            sb.append("\n");
        } else {
            sb.append("\n").append(.toSource(depth+1));
        }
        return sb.toString();
    }

    
Visits this node, the condition, then the body.
    @Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            .visit(v);
            .visit(v);
        }
    }
New to GrepCode? Check out our FAQ X