1 19 20 package org.netbeans.modules.debugger.jpda.ui; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.util.HashSet ; 25 import java.util.Set ; 26 27 import org.netbeans.api.debugger.jpda.JPDAThread; 28 import org.netbeans.api.debugger.jpda.SmartSteppingFilter; 29 import org.netbeans.spi.debugger.jpda.SourcePathProvider; 30 import org.netbeans.api.debugger.DebuggerEngine; 31 import org.netbeans.spi.debugger.ContextProvider; 32 import org.netbeans.api.debugger.Session; 33 import org.netbeans.spi.debugger.jpda.SmartSteppingCallback; 34 35 36 public class SmartSteppingImpl extends SmartSteppingCallback implements 37 PropertyChangeListener { 38 39 40 private Set exclusionPatterns = new HashSet (); 41 private SmartSteppingFilter smartSteppingFilter; 42 43 44 50 public void initFilter (SmartSteppingFilter f) { 51 smartSteppingFilter = f; 52 } 53 54 64 public boolean stopHere ( 65 ContextProvider lookupProvider, 66 JPDAThread thread, 67 SmartSteppingFilter f 68 ) { 69 String className = thread.getClassName (); 70 if (className == null) return false; 71 72 SourcePath ectx = getEngineContext (lookupProvider); 73 boolean b = ectx.sourceAvailable (thread, null, false); 74 if (b) return true; 75 76 String name, n1 = className.replace ('.', '/'); 78 do { 79 name = n1; 80 int i = name.lastIndexOf ('/'); 81 if (i < 0) break; 82 n1 = name.substring (0, i); 83 } while (!ectx.sourceAvailable (n1, false)); 84 HashSet s = new HashSet (); 85 s.add (name.replace ('/', '.') + ".*"); 86 addExclusionPatterns (s); 87 return false; 88 } 89 90 private void addExclusionPatterns ( 91 Set ep 92 ) { 93 smartSteppingFilter.addExclusionPatterns (ep); 94 exclusionPatterns.addAll (ep); 95 } 96 97 private void removeExclusionPatterns () { 98 smartSteppingFilter.removeExclusionPatterns (exclusionPatterns); 99 exclusionPatterns = new HashSet (); 100 } 101 102 private SourcePath engineContext; 103 104 private SourcePath getEngineContext (ContextProvider lookupProvider) { 105 if (engineContext == null) { 106 engineContext = (SourcePath) lookupProvider.lookupFirst 107 (null, SourcePath.class); 108 engineContext.addPropertyChangeListener (this); 109 } 110 return engineContext; 111 } 112 113 public void propertyChange (PropertyChangeEvent evt) { 114 if (evt.getPropertyName () == SourcePathProvider.PROP_SOURCE_ROOTS) { 115 removeExclusionPatterns (); 116 } 117 } 118 } 119 | Popular Tags |