Clover coverage report - Java Language Levels Test Coverage (javalanglevels-20120305-r5436)
Coverage timestamp: Sun Mar 4 2012 22:02:46 CST
file stats: LOC: 144   Methods: 10
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SourceInfo.java 11.1% 35.7% 70% 34.3%
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.javalanglevels;
 38   
 39    import java.io.*;
 40    import edu.rice.cs.javalanglevels.parser.JExprParser;
 41   
 42    /** A simple tuple class to represent source location for pieces of the AST. */
 43    public final class SourceInfo {
 44   
 45    /** A constant is code generated by javacc that belongs here!. */
 46    public static final SourceInfo NONE = new SourceInfo(null, -1, -1, -1, -1);
 47    public static final SourceInfo NO_INFO = NONE;
 48    public static final SourceInfo TEST_0 = new SourceInfo(null, 0, 0, 0, 0);
 49    public static final SourceInfo TEST_1 = new SourceInfo(null, 1, 1, 1, 1);
 50   
 51    /**The file this SourceInfo belongs to*/
 52    private final File _file;
 53   
 54    /**The line this piece of the AST starts on*/
 55    private final int _startLine;
 56   
 57    /**The column this piece of the AST starts on*/
 58    private final int _startColumn;
 59   
 60    /**The line this piece of the AST ends on*/
 61    private final int _endLine;
 62   
 63    /** The column this piece of the AST ends on*/
 64    private final int _endColumn;
 65   
 66    /** Constructs a SourceInfo, given a value for the file and the coordinates. */
 67  70663 public SourceInfo(File file, int startLine, int startColumn, int endLine, int endColumn) {
 68  70663 _file = file;
 69  70663 _startLine = startLine;
 70  70663 _startColumn = startColumn;
 71  70663 _endLine = endLine;
 72  70663 _endColumn = endColumn;
 73    }
 74   
 75    /**@return the file*/
 76  0 final public File getFile() { return _file; }
 77   
 78    /**@return the start line*/
 79  1530 final public int getStartLine() { return _startLine; }
 80   
 81    /**@return the start column*/
 82  1622 final public int getStartColumn() { return _startColumn; }
 83   
 84    /**@return the end line*/
 85  158 final public int getEndLine() { return _endLine; }
 86   
 87    /**@return the end column*/
 88  158 final public int getEndColumn() { return _endColumn; }
 89   
 90    /**@return a readable representation of the information stored in this SourceInfo*/
 91  3209 public String toString() {
 92  3209 String fileName;
 93  24 if (_file == null) fileName = "(no file)";
 94  3185 else fileName = _file.getName();
 95   
 96  3209 return "[" + fileName + ": " + "(" + _startLine + "," + _startColumn + ")-" +
 97    "(" + _endLine + "," + _endColumn + ")]";
 98    }
 99   
 100    /**All fields must match for these to be equal*/
 101  0 public boolean equals(Object obj) {
 102  0 if (obj == null) return false;
 103   
 104  0 if (obj.getClass() != this.getClass()) {
 105  0 return false;
 106    }
 107    else {
 108  0 SourceInfo casted = (SourceInfo) obj;
 109   
 110  0 File tF = getFile();
 111  0 File oF = casted.getFile();
 112   
 113  0 if ( (tF == null && oF != null) || (tF != null && ! tF.equals(oF))) return false;
 114  0 if (! (getStartLine() == casted.getStartLine())) return false;
 115  0 if (! (getStartColumn() == casted.getStartColumn())) return false;
 116  0 if (! (getEndLine() == casted.getEndLine())) return false;
 117  0 if (! (getEndColumn() == casted.getEndColumn())) return false;
 118  0 return true;
 119    }
 120    }
 121   
 122    /** Implementation of hashCode that is consistent with equals. The value of the hashCode is formed by
 123    * XORing the hashcode of the class object with the hashcodes of all the fields of the object.
 124    */
 125  0 public final int hashCode() {
 126  0 int code = getClass().hashCode();
 127   
 128  0 if (getFile() != null) {
 129  0 code ^= getFile().hashCode();
 130    }
 131   
 132  0 code ^= getStartLine();
 133  0 code ^= getStartColumn();
 134  0 code ^= getEndLine();
 135  0 code ^= getEndColumn();
 136  0 return code;
 137    }
 138   
 139    /** Build a SourceInfo corresponding to the specified class name, with -1 as the value for row, column, start, finish.
 140    */
 141  63554 public static SourceInfo make(String qualifiedClassName) {
 142  63554 return new SourceInfo(new File(qualifiedClassName), -1, -1, -1, -1);
 143    }
 144    }