EMMA Coverage Report (generated Mon Nov 01 16:48:29 PDT 2010)
[all classes][com.google.caja.parser.js]

COVERAGE SUMMARY FOR SOURCE FILE [WhileLoop.java]

nameclass, %method, %block, %line, %
WhileLoop.java100% (1/1)100% (8/8)100% (106/106)100% (25/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class WhileLoop100% (1/1)100% (8/8)100% (106/106)100% (25/25)
WhileLoop (FilePosition, String, Expression, Statement): void 100% (1/1)100% (13/13)100% (3/3)
WhileLoop (FilePosition, String, List): void 100% (1/1)100% (13/13)100% (2/2)
childrenChanged (): void 100% (1/1)100% (17/17)100% (4/4)
getBody (): Statement 100% (1/1)100% (3/3)100% (1/1)
getCondition (): Expression 100% (1/1)100% (3/3)100% (1/1)
hasHangingConditional (): boolean 100% (1/1)100% (4/4)100% (1/1)
render (RenderContext): void 100% (1/1)100% (39/39)100% (12/12)
toJsonML (): JsonML 100% (1/1)100% (14/14)100% (1/1)

1// Copyright (C) 2005 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package com.google.caja.parser.js;
16 
17import com.google.caja.lexer.FilePosition;
18import com.google.caja.lexer.TokenConsumer;
19import com.google.caja.parser.ParseTreeNode;
20import com.google.caja.reporting.RenderContext;
21import com.google.javascript.jscomp.jsonml.JsonML;
22import com.google.javascript.jscomp.jsonml.TagType;
23 
24import java.util.List;
25 
26/**
27 *
28 * @author mikesamuel@gmail.com
29 */
30public class WhileLoop extends Loop {
31  private Expression condition;
32  private Statement body;
33 
34  @ReflectiveCtor
35  public WhileLoop(
36      FilePosition pos, String label, List<? extends ParseTreeNode> children) {
37    this(pos, label, (Expression) children.get(0), (Statement) children.get(1));
38  }
39 
40  public WhileLoop(
41      FilePosition pos, String label, Expression condition, Statement body) {
42    super(pos, label, ParseTreeNode.class);
43    createMutation().appendChild(condition).appendChild(body).execute();
44  }
45 
46  @Override
47  protected void childrenChanged() {
48    super.childrenChanged();
49    this.condition = (Expression) children().get(0);
50    this.body = (Statement) children().get(1);
51  }
52 
53  @Override
54  public Expression getCondition() { return condition; }
55  @Override
56  public Statement getBody() { return body; }
57 
58  public void render(RenderContext rc) {
59    TokenConsumer out = rc.getOut();
60    out.mark(getFilePosition());
61    String label = getRenderedLabel(rc);
62    if (null != label) {
63      out.consume(label);
64      out.consume(":");
65    }
66    out.consume("while");
67    out.consume("(");
68    condition.render(rc);
69    out.consume(")");
70    body.renderBlock(rc, false);
71  }
72 
73  public boolean hasHangingConditional() {
74    return body.hasHangingConditional();
75  }
76 
77  public JsonML toJsonML() {
78    return wrapIfLabelled(
79        JsonMLBuilder.builder(TagType.WhileStmt, getFilePosition())
80        .addChild(condition).addChild(body).build());
81  }
82}

[all classes][com.google.caja.parser.js]
EMMA 2.0.5312 (C) Vladimir Roubtsov