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

COVERAGE SUMMARY FOR SOURCE FILE [UncajoledModule.java]

nameclass, %method, %block, %line, %
UncajoledModule.java100% (1/1)80%  (8/10)54%  (64/119)59%  (16.5/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UncajoledModule100% (1/1)80%  (8/10)54%  (64/119)59%  (16.5/28)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
UncajoledModule (Block): void 100% (1/1)100% (5/5)100% (2/2)
UncajoledModule (FilePosition, Block): void 100% (1/1)100% (10/10)100% (3/3)
UncajoledModule (FilePosition, Void, List): void 100% (1/1)78%  (14/18)92%  (2.8/3)
children (): List 100% (1/1)100% (4/4)100% (1/1)
childrenChanged (): void 100% (1/1)50%  (17/34)71%  (5/7)
getModuleBody (): Block 100% (1/1)100% (6/6)100% (1/1)
getValue (): Object 100% (1/1)100% (2/2)100% (1/1)
makeRenderer (Appendable, Callback): TokenConsumer 0%   (0/1)0%   (0/9)0%   (0/1)
render (RenderContext): void 0%   (0/1)0%   (0/23)0%   (0/8)

1// Copyright (C) 2008 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.AbstractParseTreeNode;
20import com.google.caja.parser.ParseTreeNode;
21import com.google.caja.render.Concatenator;
22import com.google.caja.render.JsPrettyPrinter;
23import com.google.caja.reporting.RenderContext;
24import com.google.caja.util.Callback;
25 
26import java.io.IOException;
27import java.util.List;
28 
29/**
30 * Translates to a cajoled module which renders as: <tt>___.loadModule...</tt>.
31 * This is not a core JavaScript parse tree node &mdash; it is never produced by
32 * {@link Parser}.
33 *
34 * @author erights@gmail.com
35 * @author ihab.awad@gmail.com
36 */
37public final class UncajoledModule extends AbstractParseTreeNode {
38  /** @param value unused.  This ctor is provided for reflection. */
39  @ReflectiveCtor
40  public UncajoledModule(FilePosition pos,
41                         Void value,
42                         List<? extends Block> children) {
43    this(pos, children.get(0));
44    assert children.size() == 1;
45  }
46 
47  public UncajoledModule(FilePosition pos, Block body) {
48    super(pos, Block.class);
49    createMutation().appendChild(body).execute();
50  }
51 
52  public UncajoledModule(Block body) {
53    this(FilePosition.UNKNOWN, body);
54  }
55 
56  @Override
57  protected void childrenChanged() {
58    super.childrenChanged();
59    if (children().size() != 1) {
60      throw new IllegalStateException(
61          "An UncajoledModule may only have one child");
62    }
63    ParseTreeNode module = children().get(0);
64    if (!(module instanceof Block)) {
65      throw new ClassCastException("Expected block, not " + module);
66    }
67  }
68 
69  @Override
70  public Object getValue() { return null; }
71 
72  @Override
73  public List<? extends Block> children() {
74    return childrenAs(Block.class);
75  }
76 
77  public Block getModuleBody() { return children().get(0); }
78 
79  public final TokenConsumer makeRenderer(
80      Appendable out, Callback<IOException> exHandler) {
81    return new JsPrettyPrinter(new Concatenator(out, exHandler));
82  }
83 
84  public void render(RenderContext rc) {
85    TokenConsumer out = rc.getOut();
86    out.consume("/* Start Uncajoled Module */");
87    out.consume("throw");
88    out.consume("'Uncajoled Module must never be executed'");
89    out.consume(";");
90    getModuleBody().render(rc);
91    out.consume("/* End Uncajoled Module */");
92  }
93}

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