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

COVERAGE SUMMARY FOR SOURCE FILE [Indent.java]

nameclass, %method, %block, %line, %
Indent.java100% (1/1)80%  (4/5)70%  (52/74)92%  (11/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Indent100% (1/1)80%  (4/5)70%  (52/74)92%  (11/12)
Indent (int, boolean): void 100% (1/1)100% (6/6)100% (2/2)
Indent (int, boolean, boolean): void 100% (1/1)100% (12/12)100% (5/5)
getIndentLevel (): int 100% (1/1)100% (10/10)100% (1/1)
toString (): String 0%   (0/1)0%   (0/22)0%   (0/1)
withInStatement (boolean): Indent 100% (1/1)100% (24/24)100% (3/3)

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.render;
16 
17/**
18 * Encapsulates information necessary to decide how to indent a line-break at a
19 * point in a stream of tokens.
20 */
21final class Indent {
22  final int spaces;
23  /**
24   * Are we in a () or [] block.
25   * Semicolons are not treated as statement separators in that context.
26   */
27  final boolean parenthetical;
28  /**
29   * True iff we are in a statement.
30   * E.g. in {@code
31   *    var foo = x
32   *        + y;
33   * }
34   * the <code>+</code> is indented past the beginning of the previous line
35   * because we have not yet seen a semicolon.
36   */
37  final boolean inStatement;
38 
39  Indent(int spaces, boolean parenthetical) {
40    this(spaces, parenthetical, false);
41  }
42 
43  Indent(int spaces, boolean parenthetical, boolean inStatement) {
44    this.spaces = spaces;
45    this.parenthetical = parenthetical;
46    this.inStatement = inStatement;
47  }
48 
49  int getIndentLevel() {
50    return this.spaces + (this.inStatement ? 2 : 0);
51  }
52 
53  Indent withInStatement(boolean inStatement) {
54    inStatement = inStatement && !parenthetical;
55    if (inStatement == this.inStatement) { return this; }
56    return new Indent(this.spaces, this.parenthetical, inStatement);
57  }
58 
59  @Override
60  public String toString() {
61    return "[Indent sp=" + spaces + ", paren=" + parenthetical + ", ins="
62        + inStatement + "]";
63  }
64}

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