Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 235   Methods: 10
NCLOC: 55   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ReducedToken.java 0% 52.9% 90% 54.5%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.model.definitions.reducedmodel;
 38   
 39    /** The representation of document text in the reduced model. ReducedToken :: = Brace | Gap
 40    * @version $Id: ReducedToken.java 5175 2010-01-20 08:46:32Z mgricken $
 41    */
 42    public abstract class ReducedToken implements ReducedModelStates {
 43    private volatile ReducedModelState _state;
 44   
 45  14488 public ReducedToken(ReducedModelState state) {
 46  14488 _state = state;
 47    }
 48   
 49    /** Get the size of the token.
 50    * @return the number of characters represented by the token
 51    */
 52    public abstract int getSize();
 53   
 54    /** Get the type of the token.
 55    * @return a String representation of the token type
 56    */
 57    public abstract String getType();
 58   
 59    /** Set the type of the token
 60    * @param type a String representation of the new token type
 61    */
 62    public abstract void setType(String type);
 63   
 64    /** Return the opposite of this ReducedToken in the same state. Valid only for braces. */
 65    public abstract void flip();
 66   
 67    /** Determine if the given token is a open/close match with this.
 68    * @param other another ReducedToken
 69    * @return true if there is a match
 70    */
 71    public abstract boolean isMatch(Brace other);
 72   
 73    /** Return true iff this ReducedToken is a matchable, i.e. is one of "{", "}", "(", ")", "[", "]" */
 74    public abstract boolean isMatchable();
 75   
 76    /** Get the shadowing state of the token.
 77    * @return FREE | INSIDE_SINGLE_QUOTE | INSIDE_DOUBLE_QUOTE | INSIDE_LINE_COMMENT| INSIDE_BLOCK_COMMENT
 78    */
 79  1149260 public ReducedModelState getState() { return _state; }
 80   
 81    /** Returns whether the current char is highlighted. / / beginning a comment would be highlighted but free, so its not
 82    * the same as getState.
 83    */
 84  0 public int getHighlightState() {
 85  0 String type = getType();
 86  0 if (type.equals("//") || (_state == INSIDE_LINE_COMMENT) || type.equals("/*")
 87    || type.equals("*/") || (_state == INSIDE_BLOCK_COMMENT)) {
 88  0 return HighlightStatus.COMMENTED;
 89    }
 90  0 if ((type.equals("'") && (_state == FREE)) || (_state == INSIDE_SINGLE_QUOTE)) {
 91  0 return HighlightStatus.SINGLE_QUOTED;
 92    }
 93  0 if ((type.equals("\"") && (_state == FREE)) || (_state == INSIDE_DOUBLE_QUOTE)) {
 94  0 return HighlightStatus.DOUBLE_QUOTED;
 95    }
 96  0 return HighlightStatus.NORMAL;
 97    }
 98   
 99    /** Set the shadowing state of the token.
 100    * @param state
 101    */
 102  6436 public void setState(ReducedModelState state) { _state = state; }
 103   
 104    /** Increases the size of the gap.
 105    * @param delta
 106    */
 107    public abstract void grow(int delta);
 108   
 109    /** Decreases the size of the gap.
 110    * @param delta
 111    */
 112    public abstract void shrink(int delta);
 113   
 114    /** Indicates whether this brace is shadowed. Shadowing occurs when a brace has been swallowed by a
 115    * comment or an open quote.
 116    * @return true if the brace is shadowed.
 117    */
 118  4 public boolean isShadowed() { return _state != FREE; }
 119   
 120    /** Indicates whether this brace is inside quotes.
 121    * @return true if the brace is inside quotes.
 122    */
 123  3 public boolean isQuoted() { return _state == INSIDE_DOUBLE_QUOTE; }
 124   
 125    /** Indicates whether this brace is commented out. Package visible for testing purposes.
 126    * @return true if the brace is hidden by comments.
 127    */
 128  3 boolean isCommented() { return inBlockComment() || inLineComment(); }
 129   
 130    /** Determines whether the current location is inside a block comment. (Excludes opening "brace"!)
 131    * @return true or false
 132    */
 133  3 private boolean inBlockComment() { return _state == INSIDE_BLOCK_COMMENT; }
 134   
 135    /** Determines whether the current location is inside a line comment. (Excludes opening "brace"!)
 136    * @return true or false
 137    */
 138  2 private boolean inLineComment() { return _state == INSIDE_LINE_COMMENT; }
 139   
 140    /** Determines whether the current location is part of a multiple char brace.
 141    * @return true or false
 142    */
 143    public abstract boolean isMultipleCharBrace();
 144   
 145    /** Determines whether the current location is within in gap.
 146    * @return true or false
 147    */
 148    public abstract boolean isGap();
 149   
 150    /** Determines whether the current location is a line comment
 151    * @return true or false
 152    */
 153    public abstract boolean isLineComment();
 154   
 155    /** Determines if current location is the beginning of a block comment
 156    * @return true or false
 157    */
 158    public abstract boolean isBlockCommentStart();
 159   
 160    /** Determines whether the current location is the end of a block comment
 161    * @return boolean
 162    */
 163    public abstract boolean isBlockCommentEnd();
 164   
 165    /** Determines whether the current location is a new line.
 166    * @return boolean
 167    */
 168    public abstract boolean isNewline();
 169   
 170    /** Returns whether the current location is a slash
 171    * @return boolean
 172    */
 173    public abstract boolean isSlash();
 174   
 175    /** Returns whether this is a star
 176    * @return boolean
 177    */
 178    public abstract boolean isStar();
 179   
 180    /** Returns whether this is a double quote
 181    * @return boolean
 182    */
 183    public abstract boolean isDoubleQuote();
 184   
 185    /** Returns whether this is a single quote
 186    * @return boolean
 187    */
 188    public abstract boolean isSingleQuote();
 189   
 190    /** Returns whether this is a double escape sequence
 191    * @return boolean
 192    */
 193    public abstract boolean isDoubleEscapeSequence();
 194   
 195    /** Returns whether this is a double escape
 196    * @return boolean
 197    */
 198    public abstract boolean isDoubleEscape();
 199   
 200    /** Returns whether this is an escaped single quote
 201    * @return boolean
 202    */
 203    public abstract boolean isEscapedSingleQuote();
 204   
 205    /** Return whether this is an escaped double quote
 206    * @return boolean
 207    */
 208    public abstract boolean isEscapedDoubleQuote();
 209   
 210    /** Determines whether the current location is an opening parenthesis.
 211    * @return boolean
 212    */
 213    public abstract boolean isOpen();
 214   
 215    /** Determines whether the current location is a closing parenthesis.
 216    * @return boolean
 217    */
 218    public abstract boolean isClosed();
 219   
 220    /** Determines whether the current location is an open brace.
 221    * @return boolean
 222    */
 223    public abstract boolean isOpenBrace();
 224   
 225    /** Determines whether the current location is a closed brace.
 226    * @return boolean
 227    */
 228    public abstract boolean isClosedBrace();
 229   
 230    /** Determine whether this token is a comment start "brace" ("//" or "/*') */
 231  7464 public boolean isCommentStart() { return isBlockCommentStart() || isLineComment(); }
 232    }
 233   
 234   
 235