1 19 package org.netbeans.spi.debugger.jpda; 20 21 import java.beans.PropertyChangeListener ; 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 import java.util.Collections ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import org.netbeans.api.debugger.jpda.LineBreakpoint; 28 import org.netbeans.api.debugger.jpda.Variable; 29 30 36 public abstract class EditorContext { 37 38 39 public static final String BREAKPOINT_ANNOTATION_TYPE = "Breakpoint"; 40 41 public static final String DISABLED_BREAKPOINT_ANNOTATION_TYPE = "DisabledBreakpoint"; 42 43 public static final String CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE = "CondBreakpoint"; 44 45 public static final String DISABLED_CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE = "DisabledCondBreakpoint"; 46 47 public static final String CURRENT_LINE_ANNOTATION_TYPE = "CurrentPC"; 48 49 public static final String CALL_STACK_FRAME_ANNOTATION_TYPE = "CallSite"; 50 51 public static final String CURRENT_LAST_OPERATION_ANNOTATION_TYPE = "LastOperation"; 52 53 public static final String CURRENT_OUT_OPERATION_ANNOTATION_TYPE = "StepOutOperation"; 54 55 public static final String CURRENT_EXPRESSION_SECONDARY_LINE_ANNOTATION_TYPE = "CurrentExpression"; 56 57 public static final String CURRENT_EXPRESSION_CURRENT_LINE_ANNOTATION_TYPE = "CurrentExpressionLine"; 58 59 60 public static final String PROP_LINE_NUMBER = "lineNumber"; 61 62 63 70 public abstract boolean showSource ( 71 String url, 72 int lineNumber, 73 Object timeStamp 74 ); 75 76 81 public abstract void createTimeStamp (Object timeStamp); 82 83 88 public abstract void disposeTimeStamp (Object timeStamp); 89 90 96 public abstract void updateTimeStamp (Object timeStamp, String url); 97 98 109 public abstract Object annotate ( 110 String url, 111 int lineNumber, 112 String annotationType, 113 Object timeStamp 114 ); 115 116 127 public Object annotate ( 128 String url, 129 int startPosition, 130 int endPosition, 131 String annotationType, 132 Object timeStamp 133 ) { 134 return null; 135 } 136 137 145 public abstract int getLineNumber ( 146 Object annotation, 147 Object timeStamp 148 ); 149 150 153 public abstract void removeAnnotation ( 154 Object annotation 155 ); 156 157 162 public abstract int getCurrentLineNumber (); 163 164 169 public abstract String getCurrentClassName (); 170 171 176 public abstract String getCurrentURL (); 177 178 183 public abstract String getCurrentMethodName (); 184 185 190 public abstract String getCurrentFieldName (); 191 192 197 public abstract String getSelectedIdentifier (); 198 199 204 public abstract String getSelectedMethodName (); 205 206 216 public abstract int getFieldLineNumber ( 217 String url, 218 String className, 219 String fieldName 220 ); 221 222 230 public abstract String getClassName ( 231 String url, 232 int lineNumber 233 ); 234 235 242 public abstract String [] getImports (String url); 243 244 253 254 264 protected final Operation createMethodOperation(Position startPosition, 265 Position endPosition, 266 Position methodStartPosition, 267 Position methodEndPosition, 268 String methodName, 269 String methodClassType, 270 int bytecodeIndex) { 271 return new Operation(startPosition, endPosition, 272 methodStartPosition, methodEndPosition, 273 methodName, methodClassType, bytecodeIndex); 274 } 275 276 281 protected final void addNextOperationTo(Operation operation, Operation next) { 282 operation.addNextOperation(next); 283 } 284 285 291 protected final Position createPosition( 292 int offset, int line, int column) { 293 294 return new Position(offset, line, column); 295 } 296 297 303 public Operation[] getOperations(String url, int lineNumber, 304 BytecodeProvider bytecodeProvider) { 305 throw new UnsupportedOperationException ("This method is not implemented."); 306 } 307 308 313 public abstract void addPropertyChangeListener (PropertyChangeListener l); 314 315 320 public abstract void removePropertyChangeListener (PropertyChangeListener l); 321 322 328 public abstract void addPropertyChangeListener ( 329 String propertyName, 330 PropertyChangeListener l 331 ); 332 333 339 public abstract void removePropertyChangeListener ( 340 String propertyName, 341 PropertyChangeListener l 342 ); 343 344 347 public interface BytecodeProvider { 348 349 352 byte[] constantPool(); 353 354 357 byte[] byteCodes(); 358 359 365 int[] indexAtLines(int startLine, int endLine); 366 367 } 368 369 372 public static final class Operation { 373 374 private final Position startPosition; 375 private final Position endPosition; 376 private final int bytecodeIndex; 377 378 private Position methodStartPosition; 379 private Position methodEndPosition; 380 private String methodName; 381 private String methodClassType; 382 private Variable returnValue; 383 384 private List <Operation> nextOperations; 385 386 394 395 398 Operation(Position startPosition, Position endPosition, 399 Position methodStartPosition, Position methodEndPosition, 400 String methodName, String methodClassType, 401 int bytecodeIndex) { 402 this.startPosition = startPosition; 403 this.endPosition = endPosition; 404 this.bytecodeIndex = bytecodeIndex; 405 this.methodStartPosition = methodStartPosition; 406 this.methodEndPosition = methodEndPosition; 407 this.methodName = methodName; 408 this.methodClassType = methodClassType; 409 } 410 411 synchronized void addNextOperation(Operation next) { 412 if (nextOperations == null) { 413 nextOperations = new ArrayList <Operation>(); 414 } 415 nextOperations.add(next); 416 } 417 418 421 public Position getStartPosition() { 422 return startPosition; 423 } 424 425 428 public Position getEndPosition() { 429 return endPosition; 430 } 431 432 435 public Position getMethodStartPosition() { 436 return methodStartPosition; 437 } 438 439 442 public Position getMethodEndPosition() { 443 return methodEndPosition; 444 } 445 446 449 public String getMethodName() { 450 return methodName; 451 } 452 453 456 public String getMethodClassType() { 457 return methodClassType; 458 } 459 460 463 public int getBytecodeIndex() { 464 return bytecodeIndex; 465 } 466 467 470 public void setReturnValue(Variable returnValue) { 471 this.returnValue = returnValue; 472 } 473 474 477 public Variable getReturnValue() { 478 return returnValue; 479 } 480 481 484 public List <Operation> getNextOperations() { 485 if (nextOperations == null) { 486 return Collections.emptyList(); 487 } else { 488 synchronized (this) { 489 return Collections.unmodifiableList(nextOperations); 490 } 491 } 492 } 493 494 public boolean equals(Object obj) { 495 if (obj instanceof Operation) { 496 Operation op2 = (Operation) obj; 497 return bytecodeIndex == op2.bytecodeIndex && 498 ((startPosition == null) ? 499 op2.startPosition == null : 500 startPosition.equals(op2.startPosition)) && 501 ((endPosition == null) ? 502 op2.endPosition == null : 503 endPosition.equals(op2.endPosition)); 504 } 505 return false; 506 } 507 508 public int hashCode() { 509 return bytecodeIndex; 510 } 511 512 } 513 514 517 public static final class Position { 518 519 private final int offset; 520 private final int line; 521 private final int column; 522 523 Position(int offset, int line, int column) { 524 this.offset = offset; 525 this.line = line; 526 this.column = column; 527 } 528 529 532 public int getOffset() { 533 return offset; 534 } 535 536 539 public int getLine() { 540 return line; 541 } 542 543 546 public int getColumn() { 547 return column; 548 } 549 550 public boolean equals(Object obj) { 551 if (obj instanceof Position) { 552 Position pos = (Position) obj; 553 return pos.offset == offset; 554 } 555 return false; 556 } 557 558 public int hashCode() { 559 return offset; 560 } 561 562 } 563 564 } 565 566 | Popular Tags |