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

COVERAGE SUMMARY FOR SOURCE FILE [BreakStmt.java]

nameclass, %method, %block, %line, %
BreakStmt.java100% (1/1)88%  (7/8)70%  (55/79)75%  (15/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BreakStmt100% (1/1)88%  (7/8)70%  (55/79)75%  (15/20)
BreakStmt (FilePosition, String): void 100% (1/1)100% (8/8)100% (3/3)
BreakStmt (FilePosition, String, List): void 100% (1/1)100% (5/5)100% (2/2)
breaks (Map): void 0%   (0/1)0%   (0/24)0%   (0/5)
getLabel (): String 100% (1/1)100% (3/3)100% (1/1)
getValue (): String 100% (1/1)100% (3/3)100% (1/1)
hasHangingConditional (): boolean 100% (1/1)100% (2/2)100% (1/1)
render (RenderContext): void 100% (1/1)100% (24/24)100% (6/6)
toJsonML (): JsonML 100% (1/1)100% (10/10)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.reporting.RenderContext;
18import com.google.caja.lexer.FilePosition;
19import com.google.caja.lexer.TokenConsumer;
20import com.google.caja.parser.ParseTreeNode;
21import com.google.javascript.jscomp.jsonml.JsonML;
22import com.google.javascript.jscomp.jsonml.TagAttr;
23import com.google.javascript.jscomp.jsonml.TagType;
24 
25import java.util.ArrayList;
26import java.util.List;
27import java.util.Map;
28 
29/**
30 *
31 * @author mikesamuel@gmail.com
32 */
33public final class BreakStmt extends AbstractStatement {
34  private final String label;
35 
36  /** @param children unused.  This ctor is provided for reflection. */
37  @ReflectiveCtor
38  public BreakStmt(
39      FilePosition pos, String value, List<? extends ParseTreeNode> children) {
40    this(pos, value);
41  }
42 
43  public BreakStmt(FilePosition pos, String label) {
44    super(pos, Statement.class);
45    this.label = label;
46  }
47 
48  @Override
49  public void breaks(Map<String, List<BreakStmt>> breaksReaching) {
50    List<BreakStmt> breaks = breaksReaching.get(this.label);
51    if (null == breaks) {
52      breaksReaching.put(label, breaks = new ArrayList<BreakStmt>());
53    }
54    breaks.add(this);
55  }
56 
57  @Override
58  public String getValue() { return label; }
59 
60  public String getLabel() { return label; }
61 
62  public void render(RenderContext rc) {
63    TokenConsumer out = rc.getOut();
64    out.mark(getFilePosition());
65    out.consume("break");
66    if (null != label && !"".equals(label)) {
67      out.consume(label);
68    }
69  }
70 
71  public boolean hasHangingConditional() { return false; }
72 
73  public JsonML toJsonML() {
74    return JsonMLBuilder.builder(TagType.BreakStmt, getFilePosition())
75        .setAttributeIfNotBlank(TagAttr.LABEL, label).build();
76  }
77}

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