Clover coverage report - DrJava Test Coverage (drjava-20110828-r5448)
Coverage timestamp: Sun Aug 28 2011 03:13:33 CDT
file stats: LOC: 115   Methods: 3
NCLOC: 58   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
CompilerOptions.java 50% 58.6% 33.3% 54.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.drjava.model.compiler;
 38   
 39    import edu.rice.cs.drjava.config.*;
 40    import edu.rice.cs.drjava.DrJava;
 41   
 42    import java.util.HashMap;
 43   
 44    /** Represents the compiler warnings */
 45   
 46    public class CompilerOptions implements OptionConstants {
 47   
 48    private static boolean SHOW_UNCHECKED = DrJava.getConfig().getSetting(SHOW_UNCHECKED_WARNINGS);
 49    private static boolean SHOW_DEPRECATION = DrJava.getConfig().getSetting(SHOW_DEPRECATION_WARNINGS);
 50    private static boolean SHOW_PATH = DrJava.getConfig().getSetting(SHOW_PATH_WARNINGS);
 51    private static boolean SHOW_SERIAL = DrJava.getConfig().getSetting(SHOW_SERIAL_WARNINGS);
 52    private static boolean SHOW_FINALLY = DrJava.getConfig().getSetting(SHOW_FINALLY_WARNINGS);
 53    private static boolean SHOW_FALLTHROUGH = DrJava.getConfig().getSetting(SHOW_FALLTHROUGH_WARNINGS);
 54   
 55    private static WarningOptionListener wol = new WarningOptionListener();
 56   
 57    /** The OptionListener for the Warning Options */
 58    private static class WarningOptionListener implements OptionListener<Boolean> {
 59  0 public void optionChanged(OptionEvent<Boolean> oce) {
 60  0 updateWarnings();
 61    }
 62    }
 63   
 64  0 public static void updateWarnings() {
 65  0 SHOW_UNCHECKED = DrJava.getConfig().getSetting(SHOW_UNCHECKED_WARNINGS);
 66  0 SHOW_DEPRECATION = DrJava.getConfig().getSetting(SHOW_DEPRECATION_WARNINGS);
 67  0 SHOW_PATH = DrJava.getConfig().getSetting(SHOW_PATH_WARNINGS);
 68  0 SHOW_SERIAL = DrJava.getConfig().getSetting(SHOW_SERIAL_WARNINGS);
 69  0 SHOW_FINALLY = DrJava.getConfig().getSetting(SHOW_FINALLY_WARNINGS);
 70  0 SHOW_FALLTHROUGH = DrJava.getConfig().getSetting(SHOW_FALLTHROUGH_WARNINGS);
 71    }
 72   
 73   
 74    static {
 75  10 DrJava.getConfig().addOptionListener( OptionConstants.SHOW_UNCHECKED_WARNINGS, wol);
 76  10 DrJava.getConfig().addOptionListener( OptionConstants.SHOW_DEPRECATION_WARNINGS, wol);
 77  10 DrJava.getConfig().addOptionListener( OptionConstants.SHOW_PATH_WARNINGS, wol);
 78  10 DrJava.getConfig().addOptionListener( OptionConstants.SHOW_SERIAL_WARNINGS, wol);
 79  10 DrJava.getConfig().addOptionListener( OptionConstants.SHOW_FINALLY_WARNINGS, wol);
 80  10 DrJava.getConfig().addOptionListener( OptionConstants.SHOW_FALLTHROUGH_WARNINGS, wol);
 81    }
 82   
 83  56 public static HashMap<String,String> getOptions(boolean warningsEnabled) {
 84  56 HashMap<String,String> options = new HashMap<String,String>();
 85  56 if (warningsEnabled) {
 86  56 if (SHOW_UNCHECKED) {
 87  56 options.put("-Xlint:unchecked","");
 88    }
 89   
 90  56 if (SHOW_DEPRECATION) {
 91  56 options.put("-Xlint:deprecation","");
 92    }
 93   
 94  56 if (SHOW_PATH) {
 95  0 options.put("-Xlint:path","");
 96    }
 97   
 98  56 if (SHOW_SERIAL) {
 99  0 options.put("-Xlint:serial","");
 100    }
 101   
 102  56 if (SHOW_FINALLY) {
 103  0 options.put("-Xlint:finally","");
 104    }
 105   
 106  56 if (SHOW_FALLTHROUGH) {
 107  0 options.put("-Xlint:fallthrough","");
 108  0 options.put("-Xlint:switchcheck",""); //Some compilers appear to use this option instead. Anyone know anything about this?
 109    }
 110    }
 111   
 112    //Add any other options we want to add to the compiler in the future
 113  56 return options;
 114    }
 115    }