Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 272   Methods: 16
NCLOC: 162   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DebugEventNotifier.java 0% 0% 0% 0%
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.debug;
 38   
 39    import edu.rice.cs.drjava.model.EventNotifier;
 40    import edu.rice.cs.drjava.model.OpenDefinitionsDocument;
 41   
 42    import java.awt.EventQueue;
 43   
 44    /** Keeps track of all listeners to a Debugger, and has the ability to notify them of some event.
 45    * <p>
 46    * This class has a specific role of managing DebugListeners. Other classes with similar names use similar code to
 47    * perform the same function for other interfaces, e.g. InteractionsEventNotifier and GlobalEventNotifier. These
 48    * classes implement the appropriate interface definition so that they can be used transparently as composite packaging
 49    * for a particular listener interface.
 50    * <p>
 51    * Components which might otherwise manage their own list of listeners use EventNotifiers instead to simplify their
 52    * internal implementation. Notifiers should therefore be considered a private implementation detail of the
 53    * components, and should not be used directly outside of the "host" component.
 54    * <p>
 55    * All methods in this class must use the synchronization methods provided by ReaderWriterLock. This ensures that
 56    * multiple notifications (reads) can occur simultaneously, but only one thread can be adding or removing listeners
 57    * (writing) at a time, and no reads can occur during a write.
 58    * <p>
 59    * <i>No</i> methods on this class should be synchronized using traditional Java synchronization!
 60    * <p>
 61    *
 62    * @version $Id: DebugEventNotifier.java 5442 2011-08-16 09:11:12Z rcartwright $
 63    */
 64    public class DebugEventNotifier extends EventNotifier<DebugListener> implements DebugListener {
 65   
 66    /** Called when debugger mode has been enabled. Must be executed in event thread. */
 67  0 public void debuggerStarted() {
 68  0 assert EventQueue.isDispatchThread();
 69  0 _lock.startRead();
 70  0 try {
 71  0 int size = _listeners.size();
 72  0 for (int i = 0; i < size; i++) {
 73  0 _listeners.get(i).debuggerStarted();
 74    }
 75    }
 76  0 finally { _lock.endRead(); }
 77    }
 78   
 79    /** Called when debugger mode has been disabled. Must be executed in event thread. */
 80  0 public void debuggerShutdown() {
 81  0 assert EventQueue.isDispatchThread();
 82  0 _lock.startRead();
 83  0 try {
 84  0 int size = _listeners.size();
 85  0 for (int i = 0; i < size; i++) {
 86  0 _listeners.get(i).debuggerShutdown();
 87    }
 88    }
 89  0 finally { _lock.endRead(); }
 90    }
 91   
 92    /** Called when the given line is reached by the current thread in the debugger, to request that the line be
 93    * displayed. Must be executed only in the event thread.
 94    * @param doc Document to display
 95    * @param lineNumber Line to display or highlight
 96    * @param shouldHighlight true iff the line should be highlighted.
 97    */
 98  0 public void threadLocationUpdated(OpenDefinitionsDocument doc, int lineNumber, boolean shouldHighlight) {
 99  0 assert EventQueue.isDispatchThread();
 100  0 _lock.startRead();
 101  0 try {
 102  0 int size = _listeners.size();
 103  0 for (int i = 0; i < size; i++) {
 104  0 _listeners.get(i).threadLocationUpdated(doc, lineNumber, shouldHighlight);
 105    }
 106    }
 107  0 finally { _lock.endRead(); }
 108    }
 109   
 110    /** Called when a breakpoint is set in a document. Must be executed in event thread.
 111    * @param bp the breakpoint
 112    */
 113  0 public void regionAdded(Breakpoint bp) {
 114  0 assert EventQueue.isDispatchThread();
 115  0 _lock.startRead();
 116  0 try {
 117  0 int size = _listeners.size();
 118  0 for (int i = 0; i < size; i++) { _listeners.get(i).regionAdded(bp); }
 119    }
 120  0 finally { _lock.endRead(); }
 121    }
 122   
 123    /** Called when a breakpoint is reached during execution. Must be executed in event thread.
 124    * @param bp the breakpoint
 125    */
 126  0 public void breakpointReached(Breakpoint bp) {
 127  0 assert EventQueue.isDispatchThread();
 128  0 _lock.startRead();
 129  0 try {
 130  0 int size = _listeners.size();
 131  0 for (int i = 0; i < size; i++) {
 132  0 _listeners.get(i).breakpointReached(bp);
 133    }
 134    }
 135  0 finally { _lock.endRead(); }
 136    }
 137   
 138    /** Called when a breakpoint is changed during execution. Must be executed in event thread.
 139    * @param bp the breakpoint
 140    */
 141  0 public void regionChanged(Breakpoint bp) {
 142  0 assert EventQueue.isDispatchThread();
 143  0 _lock.startRead();
 144  0 try {
 145  0 int size = _listeners.size();
 146  0 for (int i = 0; i < size; i++) {
 147  0 _listeners.get(i).regionChanged(bp);
 148    }
 149    }
 150    finally {
 151  0 _lock.endRead();
 152    }
 153    }
 154   
 155    /** Called when a watch is set. Must be executed in event thread.
 156    * @param w the watch
 157    */
 158  0 public void watchSet(DebugWatchData w) {
 159  0 assert EventQueue.isDispatchThread();
 160  0 _lock.startRead();
 161  0 try {
 162  0 int size = _listeners.size();
 163  0 for (int i = 0; i < size; i++) { _listeners.get(i).watchSet(w); }
 164    }
 165  0 finally { _lock.endRead(); }
 166    }
 167   
 168    /** Called when a watch is removed. Must be executed in event thread.
 169    * @param w the watch
 170    */
 171  0 public void watchRemoved(DebugWatchData w) {
 172  0 assert EventQueue.isDispatchThread();
 173  0 _lock.startRead();
 174  0 try {
 175  0 int size = _listeners.size();
 176  0 for (int i = 0; i < size; i++) { _listeners.get(i).watchRemoved(w); }
 177    }
 178  0 finally { _lock.endRead(); }
 179    }
 180   
 181    /** Called when a breakpoint is removed from a document. Must be executed in event thread.
 182    * @param bp the breakpoint
 183    */
 184  0 public void regionRemoved(Breakpoint bp) {
 185  0 assert EventQueue.isDispatchThread();
 186  0 _lock.startRead();
 187  0 try {
 188  0 int size = _listeners.size();
 189  0 for (int i = 0; i < size; i++) _listeners.get(i).regionRemoved(bp);
 190    }
 191  0 finally { _lock.endRead(); }
 192    }
 193   
 194    /** Called when a step is requested on the current thread. Must be executed in event thread. */
 195  0 public void stepRequested() {
 196  0 assert EventQueue.isDispatchThread();
 197  0 _lock.startRead();
 198  0 try {
 199  0 int size = _listeners.size();
 200  0 for (int i = 0; i < size; i++) _listeners.get(i).stepRequested();
 201    }
 202  0 finally { _lock.endRead(); }
 203    }
 204   
 205    /** Called when the current thread is suspended. */
 206  0 public void currThreadSuspended() {
 207  0 _lock.startRead();
 208  0 try {
 209  0 int size = _listeners.size();
 210  0 for (int i = 0; i < size; i++) _listeners.get(i).currThreadSuspended();
 211    }
 212  0 finally { _lock.endRead(); }
 213    }
 214   
 215    /** Called when the current thread is resumed. Must be executed in event thread. */
 216  0 public void currThreadResumed() {
 217  0 assert EventQueue.isDispatchThread();
 218  0 _lock.startRead();
 219  0 try {
 220  0 int size = _listeners.size();
 221  0 for (int i = 0; i < size; i++) _listeners.get(i).currThreadResumed();
 222    }
 223  0 finally { _lock.endRead(); }
 224    }
 225   
 226    /** Called when a thread starts. Must be executed in event thread. */
 227  0 public void threadStarted() {
 228  0 assert EventQueue.isDispatchThread();
 229  0 _lock.startRead();
 230  0 try {
 231  0 int size = _listeners.size();
 232  0 for (int i = 0; i < size; i++) _listeners.get(i).threadStarted();
 233    }
 234  0 finally { _lock.endRead(); }
 235    }
 236   
 237    /** Called when the current thread dies. Must be executed in event thread. */
 238  0 public void currThreadDied() {
 239  0 assert EventQueue.isDispatchThread();
 240  0 _lock.startRead();
 241  0 try {
 242  0 int size = _listeners.size();
 243  0 for (int i = 0; i < size; i++) _listeners.get(i).currThreadDied();
 244    }
 245  0 finally { _lock.endRead(); }
 246    }
 247   
 248    /** Called when any thread other than the current thread dies. Must be executed in event thread. */
 249  0 public void nonCurrThreadDied() {
 250  0 assert EventQueue.isDispatchThread();
 251  0 _lock.startRead();
 252  0 try {
 253  0 int size = _listeners.size();
 254  0 for (int i = 0; i < size; i++) _listeners.get(i).nonCurrThreadDied();
 255    }
 256  0 finally { _lock.endRead(); }
 257    }
 258   
 259    /** Called when the current (selected) thread is set in the debugger.
 260    * @param thread the thread that was set as current
 261    */
 262  0 public void currThreadSet(DebugThreadData thread) {
 263  0 _lock.startRead();
 264  0 try {
 265  0 int size = _listeners.size();
 266  0 for (int i = 0; i < size; i++) {
 267  0 _listeners.get(i).currThreadSet(thread);
 268    }
 269    }
 270  0 finally { _lock.endRead(); }
 271    }
 272    }