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

COVERAGE SUMMARY FOR SOURCE FILE [LabeledStmtWrapper.java]

nameclass, %method, %block, %line, %
LabeledStmtWrapper.java100% (1/1)89%  (8/9)94%  (68/72)95%  (20/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LabeledStmtWrapper100% (1/1)89%  (8/9)94%  (68/72)95%  (20/21)
LabeledStmtWrapper (FilePosition, String, List): void 100% (1/1)100% (9/9)100% (2/2)
LabeledStmtWrapper (FilePosition, String, Statement): void 100% (1/1)100% (9/9)100% (3/3)
childrenChanged (): void 100% (1/1)100% (10/10)100% (3/3)
getBody (): Statement 100% (1/1)100% (3/3)100% (1/1)
hasHangingConditional (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
isTargetForContinue (): boolean 100% (1/1)100% (2/2)100% (1/1)
isTerminal (): boolean 100% (1/1)100% (4/4)100% (1/1)
render (RenderContext): void 100% (1/1)100% (25/25)100% (8/8)
toJsonML (): JsonML 100% (1/1)100% (6/6)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;
22 
23import java.util.List;
24 
25/**
26 * A labeled statement implementation that can apply to any statement.
27 * Javascript allows labels on statements other than loops.
28 *
29 * @author mikesamuel@gmail.com
30 */
31public final class LabeledStmtWrapper extends LabeledStatement {
32  // TODO(mikesamuel): Investigate whether use of continue to a non loop
33  // functions as goto, and whether that can introduces vulnerabilities.
34  // TODO(mikesamuel): Do we want to remove labelling of non-loop statements
35  // from Caja?
36  // TODO(mikesamuel): Erase the distinction between LabeledStmtWrapper and
37  // LabeledStatement.
38  private Statement body;
39 
40  @ReflectiveCtor
41  public LabeledStmtWrapper(
42      FilePosition pos, String value, List<? extends ParseTreeNode> children) {
43    this(pos, value, (Statement)children.get(0));
44  }
45 
46  public LabeledStmtWrapper(FilePosition pos, String label, Statement body) {
47    super(pos, label, Statement.class);
48    appendChild(body);
49  }
50 
51  public Statement getBody() { return body; }
52 
53  @Override
54  public boolean isTargetForContinue() { return false; }
55 
56  @Override
57  protected void childrenChanged() {
58    super.childrenChanged();
59    this.body = (Statement) children().get(0);
60  }
61 
62  public void render(RenderContext rc) {
63    TokenConsumer out = rc.getOut();
64    out.mark(getFilePosition());
65    String label = getRenderedLabel(rc);
66    if (null != label) {
67      out.consume(label);
68      out.consume(":");
69    }
70    body.render(rc);
71  }
72 
73  @Override
74  public boolean isTerminal() {
75    return body.isTerminal();
76  }
77 
78  public boolean hasHangingConditional() {
79    return body.hasHangingConditional();
80  }
81 
82  public JsonML toJsonML() {
83    return wrapIfLabelled(body.toJsonML());
84  }
85}

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