1 19 20 package org.netbeans.api.debugger.jpda.test; 21 22 import java.io.File ; 23 import java.net.MalformedURLException ; 24 import java.net.URI ; 25 import java.net.URISyntaxException ; 26 import java.net.URL ; 27 import org.netbeans.spi.debugger.jpda.EditorContext; 28 29 import java.beans.PropertyChangeListener ; 30 import java.beans.PropertyChangeSupport ; 31 import org.openide.filesystems.URLMapper; 32 33 38 public class TestContextProvider extends EditorContext { 39 40 private String sourceRoot = System.getProperty ("test.dir.src"); 41 private PropertyChangeSupport pcs; 42 43 public TestContextProvider() { 44 pcs = new PropertyChangeSupport (this); 45 } 46 47 public boolean showSource(String url, int lineNumber, Object timeStamp) { 48 return false; 49 } 50 51 public void createTimeStamp (Object timeStamp) { 52 } 53 54 public void disposeTimeStamp (Object timeStamp) { 55 } 56 57 public void updateTimeStamp (Object timeStamp, String url) { 58 } 59 60 public Object annotate(String url, int lineNumber, String annotationType, Object timeStamp) { 61 return null; 62 } 63 64 public void removeAnnotation(Object annotation) { 65 } 66 67 public int getLineNumber (Object annotation, Object timeStamp) { 68 return -1; 69 } 70 71 public int getCurrentLineNumber() { 72 return -1; 73 } 74 75 public String getCurrentClassName() { 76 return ""; 77 } 78 79 public String getCurrentURL() { 80 return ""; 81 } 82 83 public String getCurrentMethodName() { 84 return ""; 85 } 86 87 public String getCurrentFieldName() { 88 return null; 89 } 90 91 public String getSelectedIdentifier() { 92 return null; 93 } 94 95 public String getSelectedMethodName() { 96 return ""; 97 } 98 99 public int getFieldLineNumber(String url, String className, String fieldName) { 100 return -1; 101 } 102 103 public String getClassName ( 104 String url, 105 int lineNumber 106 ) { 107 URI uri = null; 108 try { 109 url = new File (uri = new URL (url).toURI()).getAbsolutePath(); 110 } catch (MalformedURLException ex) { 111 ex.printStackTrace(); 112 } catch (URISyntaxException ex) { 113 ex.printStackTrace(); 114 } catch (IllegalArgumentException iaex) { 115 System.err.println("Illegal url: "+url+", URI = "+uri); 116 throw iaex; 117 } 118 if (!url.startsWith (sourceRoot)) return null; 119 url = url.substring (sourceRoot.length ()); 120 int i = url.lastIndexOf ('.'); 121 if (i > 0) 122 url = url.substring (0, i); 123 url = url.replace ('/', '.'); 124 return url; 125 } 126 127 public Operation[] getOperations(String url, final int lineNumber, 128 final BytecodeProvider bytecodeProvider) { 129 if (url.endsWith("ExpressionStepApp.java")) { 133 Operation[] ops = createExpressionSteppAppOperations(lineNumber); 134 if (ops == null) { 135 throw new IllegalStateException (url+":"+lineNumber); 136 } 137 return ops; 138 } 139 return new Operation[] {}; } 142 143 private Operation[] createExpressionSteppAppOperations(int lineNumber) { 144 if (lineNumber == 30) { 145 return new Operation[] { 146 createMethodOperation(createPosition(1124, 30, 14), 147 createPosition(1137, 30, 27), 148 createPosition(1124, 30, 14), 149 createPosition(1133, 30, 23), 150 "factorial", 151 "debuggertest1.ExpressionStepApp", 152 5) 153 }; 154 } 155 if (lineNumber == 31) { 156 return new Operation[] { 157 createMethodOperation(createPosition(1152, 31, 14), 158 createPosition(1165, 31, 27), 159 createPosition(1152, 31, 14), 160 createPosition(1161, 31, 23), 161 "factorial", 162 "debuggertest1.ExpressionStepApp", 163 17), 164 createMethodOperation(createPosition(1168, 31, 30), 165 createPosition(1181, 31, 43), 166 createPosition(1168, 31, 30), 167 createPosition(1177, 31, 39), 168 "factorial", 169 "debuggertest1.ExpressionStepApp", 170 22) 171 }; 172 } 173 if (lineNumber == 32) { 174 return new Operation[] { 175 createMethodOperation(createPosition(1196, 32, 14), 176 createPosition(1209, 32, 27), 177 createPosition(1196, 32, 14), 178 createPosition(1205, 32, 23), 179 "factorial", 180 "debuggertest1.ExpressionStepApp", 181 35), 182 createMethodOperation(createPosition(1216, 32, 34), 183 createPosition(1229, 32, 47), 184 createPosition(1216, 32, 34), 185 createPosition(1225, 32, 43), 186 "factorial", 187 "debuggertest1.ExpressionStepApp", 188 47) 189 }; 190 } 191 if (lineNumber == 33) { 192 return new Operation[] { 193 createMethodOperation(createPosition(1263, 33, 33), 194 createPosition(1286, 33, 56), 195 createPosition(1267, 33, 37), 196 createPosition(1284, 33, 54), 197 "<init>", 198 "debuggertest1.ExpressionStepApp", 199 58) 200 }; 201 } 202 if (lineNumber == 34) { 203 return new Operation[] { 204 createMethodOperation(createPosition(1307, 34, 20), 205 createPosition(1322, 34, 35), 206 createPosition(1307, 34, 20), 207 createPosition(1313, 34, 26), 208 "m2", 209 "debuggertest1.ExpressionStepApp", 210 68), 211 createMethodOperation(createPosition(1300, 34, 13), 212 createPosition(1323, 34, 36), 213 createPosition(1300, 34, 13), 214 createPosition(1306, 34, 19), 215 "m1", 216 "debuggertest1.ExpressionStepApp", 217 71) 218 }; 219 } 220 if (lineNumber == 35) { 221 return new Operation[] { 222 createMethodOperation(createPosition(1351, 35, 27), 223 createPosition(1366, 35, 42), 224 createPosition(1351, 35, 27), 225 createPosition(1357, 35, 33), 226 "m2", 227 "debuggertest1.ExpressionStepApp", 228 85), 229 createMethodOperation(createPosition(1344, 35, 20), 230 createPosition(1367, 35, 43), 231 createPosition(1344, 35, 20), 232 createPosition(1350, 35, 26), 233 "m1", 234 "debuggertest1.ExpressionStepApp", 235 88), 236 createMethodOperation(createPosition(1395, 36, 27), 237 createPosition(1410, 36, 42), 238 createPosition(1395, 36, 27), 239 createPosition(1401, 36, 33), 240 "m1", 241 "debuggertest1.ExpressionStepApp", 242 96), 243 createMethodOperation(createPosition(1337, 35, 13), 244 createPosition(1411, 35, 43), 245 createPosition(1337, 35, 13), 246 createPosition(1343, 35, 19), 247 "m3", 248 "debuggertest1.ExpressionStepApp", 249 99), 250 createMethodOperation(createPosition(1337, 35, 13), 251 createPosition(1422, 36, 54), 252 createPosition(1337, 35, 13), 253 createPosition(1420, 36, 52), 254 "intValue", 255 "debuggertest1.ExpressionStepApp", 256 102) 257 }; 258 } 259 return null; 260 } 261 262 public String [] getImports(String url) { 263 return new String [0]; 264 } 265 266 public void addPropertyChangeListener(PropertyChangeListener l) { 267 pcs.addPropertyChangeListener (l); 268 } 269 270 public void removePropertyChangeListener(PropertyChangeListener l) { 271 pcs.removePropertyChangeListener (l); 272 } 273 274 public void addPropertyChangeListener(String propertyName, PropertyChangeListener l) { 275 pcs.addPropertyChangeListener (propertyName, l); 276 } 277 278 public void removePropertyChangeListener(String propertyName, PropertyChangeListener l) { 279 pcs.removePropertyChangeListener (propertyName, l); 280 } 281 } 282 | Popular Tags |