Lines 19-25
Link Here
|
19 |
package org.netbeans.spi.debugger.jpda; |
19 |
package org.netbeans.spi.debugger.jpda; |
20 |
|
20 |
|
21 |
import java.beans.PropertyChangeListener; |
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; |
22 |
import org.netbeans.api.debugger.jpda.LineBreakpoint; |
27 |
import org.netbeans.api.debugger.jpda.LineBreakpoint; |
|
|
28 |
import org.netbeans.api.debugger.jpda.Variable; |
23 |
|
29 |
|
24 |
/** |
30 |
/** |
25 |
* Defines bridge to editor and src hierarchy. It allows to use different |
31 |
* Defines bridge to editor and src hierarchy. It allows to use different |
Lines 41-46
Link Here
|
41 |
public static final String CURRENT_LINE_ANNOTATION_TYPE = "CurrentPC"; |
47 |
public static final String CURRENT_LINE_ANNOTATION_TYPE = "CurrentPC"; |
42 |
/** Annotation type constant. */ |
48 |
/** Annotation type constant. */ |
43 |
public static final String CALL_STACK_FRAME_ANNOTATION_TYPE = "CallSite"; |
49 |
public static final String CALL_STACK_FRAME_ANNOTATION_TYPE = "CallSite"; |
|
|
50 |
/** Annotation type constant. */ |
51 |
public static final String CURRENT_LAST_OPERATION_ANNOTATION_TYPE = "LastOperation"; |
52 |
/** Annotation type constant. */ |
53 |
public static final String CURRENT_EXPRESSION_SECONDARY_LINE_ANNOTATION_TYPE = "CurrentExpression"; |
54 |
/** Annotation type constant. */ |
55 |
public static final String CURRENT_EXPRESSION_CURRENT_LINE_ANNOTATION_TYPE = "CurrentExpressionLine"; |
44 |
|
56 |
|
45 |
/** Property name constant. */ |
57 |
/** Property name constant. */ |
46 |
public static final String PROP_LINE_NUMBER = "lineNumber"; |
58 |
public static final String PROP_LINE_NUMBER = "lineNumber"; |
Lines 100-105
Link Here
|
100 |
); |
112 |
); |
101 |
|
113 |
|
102 |
/** |
114 |
/** |
|
|
115 |
* Adds annotation to given url on given character range. |
116 |
* |
117 |
* @param url a url of source annotation should be set into |
118 |
* @param startPosition the offset of the starting position of the annotation |
119 |
* @param endPosition the offset of the ending position of the annotation |
120 |
* @param annotationType a type of annotation to be set |
121 |
|
122 |
* @return annotation or <code>null</code>, when the annotation can not be |
123 |
* created at the given URL or line number. |
124 |
*/ |
125 |
public Object annotate ( |
126 |
String url, |
127 |
int startPosition, |
128 |
int endPosition, |
129 |
String annotationType, |
130 |
Object timeStamp |
131 |
) { |
132 |
return null; |
133 |
} |
134 |
|
135 |
/** |
103 |
* Returns line number given annotation is associated with. |
136 |
* Returns line number given annotation is associated with. |
104 |
* |
137 |
* |
105 |
* @param annotation a annotation |
138 |
* @param annotation a annotation |
Lines 207-212
Link Here
|
207 |
public abstract String[] getImports (String url); |
240 |
public abstract String[] getImports (String url); |
208 |
|
241 |
|
209 |
/** |
242 |
/** |
|
|
243 |
* Creates an operation which is determined by starting and ending position. |
244 |
* |
245 |
protected final Operation createOperation(Position startPosition, |
246 |
Position endPosition, |
247 |
int bytecodeIndex) { |
248 |
return new Operation(startPosition, endPosition, bytecodeIndex); |
249 |
} |
250 |
*/ |
251 |
|
252 |
/** |
253 |
* Creates a method operation. |
254 |
* @param startPosition The starting position of the operation |
255 |
* @param endPosition The ending position of the operation |
256 |
* @param methodStartPosition The starting position of the method name |
257 |
* @param methodEndPosition The ending position of the method name |
258 |
* @param methodName The string representation of the method name |
259 |
* @param methodClassType The class type, which defines this method |
260 |
* @param bytecodeIndex The bytecode index of this method call |
261 |
*/ |
262 |
protected final Operation createMethodOperation(Position startPosition, |
263 |
Position endPosition, |
264 |
Position methodStartPosition, |
265 |
Position methodEndPosition, |
266 |
String methodName, |
267 |
String methodClassType, |
268 |
int bytecodeIndex) { |
269 |
return new Operation(startPosition, endPosition, |
270 |
methodStartPosition, methodEndPosition, |
271 |
methodName, methodClassType, bytecodeIndex); |
272 |
} |
273 |
|
274 |
/** |
275 |
* Assign a next operation, concatenates operations. |
276 |
* @param operation The first operation |
277 |
* @param next The next operation |
278 |
*/ |
279 |
protected final void addNextOperationTo(Operation operation, Operation next) { |
280 |
operation.addNextOperation(next); |
281 |
} |
282 |
|
283 |
/** |
284 |
* Creates a new {@link Position} object. |
285 |
* @param offset The offset |
286 |
* @param line The line number |
287 |
* @param column The column number |
288 |
*/ |
289 |
protected final Position createPosition( |
290 |
int offset, int line, int column) { |
291 |
|
292 |
return new Position(offset, line, column); |
293 |
} |
294 |
|
295 |
/** |
296 |
* Get the list of operations that are in expression(s) located at the given line. |
297 |
* @param url The file's URL |
298 |
* @param lineNumber The line number |
299 |
* @param bytecodeProvider The provider of method bytecodes. |
300 |
*/ |
301 |
public Operation[] getOperations(String url, int lineNumber, |
302 |
BytecodeProvider bytecodeProvider) { |
303 |
throw new UnsupportedOperationException("This method is not implemented."); |
304 |
} |
305 |
|
306 |
/** |
210 |
* Adds a property change listener. |
307 |
* Adds a property change listener. |
211 |
* |
308 |
* |
212 |
* @param l the listener to add |
309 |
* @param l the listener to add |
Lines 241-245
Link Here
|
241 |
String propertyName, |
338 |
String propertyName, |
242 |
PropertyChangeListener l |
339 |
PropertyChangeListener l |
243 |
); |
340 |
); |
|
|
341 |
|
342 |
/** |
343 |
* A provider of method bytecode information. |
344 |
*/ |
345 |
public interface BytecodeProvider { |
346 |
|
347 |
/** |
348 |
* Retrieve the class' constant pool. |
349 |
*/ |
350 |
byte[] constantPool(); |
351 |
|
352 |
/** |
353 |
* Retrieve the bytecodes of the method. |
354 |
*/ |
355 |
byte[] byteCodes(); |
356 |
|
357 |
/** |
358 |
* Get an array of bytecode indexes of operations between the starting |
359 |
* and ending line. |
360 |
* @param startLine The starting line |
361 |
* @param endLine The ending line |
362 |
*/ |
363 |
int[] indexAtLines(int startLine, int endLine); |
364 |
|
365 |
} |
366 |
|
367 |
/** |
368 |
* The operation definition. |
369 |
*/ |
370 |
public static final class Operation { |
371 |
|
372 |
private final Position startPosition; |
373 |
private final Position endPosition; |
374 |
private final int bytecodeIndex; |
375 |
|
376 |
private Position methodStartPosition; |
377 |
private Position methodEndPosition; |
378 |
private String methodName; |
379 |
private String methodClassType; |
380 |
private Variable returnValue; |
381 |
|
382 |
private List<Operation> nextOperations; |
383 |
|
384 |
/* |
385 |
Operation(Position startPosition, Position endPosition, |
386 |
int bytecodeIndex) { |
387 |
this.startPosition = startPosition; |
388 |
this.endPosition = endPosition; |
389 |
this.bytecodeIndex = bytecodeIndex; |
390 |
} |
391 |
*/ |
392 |
|
393 |
/** |
394 |
* Creates a new method operation. |
395 |
*/ |
396 |
Operation(Position startPosition, Position endPosition, |
397 |
Position methodStartPosition, Position methodEndPosition, |
398 |
String methodName, String methodClassType, |
399 |
int bytecodeIndex) { |
400 |
this.startPosition = startPosition; |
401 |
this.endPosition = endPosition; |
402 |
this.bytecodeIndex = bytecodeIndex; |
403 |
this.methodStartPosition = methodStartPosition; |
404 |
this.methodEndPosition = methodEndPosition; |
405 |
this.methodName = methodName; |
406 |
this.methodClassType = methodClassType; |
407 |
} |
408 |
|
409 |
synchronized void addNextOperation(Operation next) { |
410 |
if (nextOperations == null) { |
411 |
nextOperations = new ArrayList<Operation>(); |
412 |
} |
413 |
nextOperations.add(next); |
414 |
} |
415 |
|
416 |
/** |
417 |
* Get the starting position of this operation. |
418 |
*/ |
419 |
public Position getStartPosition() { |
420 |
return startPosition; |
421 |
} |
422 |
|
423 |
/** |
424 |
* Get the ending position of this operation. |
425 |
*/ |
426 |
public Position getEndPosition() { |
427 |
return endPosition; |
428 |
} |
429 |
|
430 |
/** |
431 |
* Get the starting position of the method call of this operation. |
432 |
*/ |
433 |
public Position getMethodStartPosition() { |
434 |
return methodStartPosition; |
435 |
} |
436 |
|
437 |
/** |
438 |
* Get the ending position of the method call of this operation. |
439 |
*/ |
440 |
public Position getMethodEndPosition() { |
441 |
return methodEndPosition; |
442 |
} |
443 |
|
444 |
/** |
445 |
* Get the method name. |
446 |
*/ |
447 |
public String getMethodName() { |
448 |
return methodName; |
449 |
} |
450 |
|
451 |
/** |
452 |
* Get the class type declaring the method. |
453 |
*/ |
454 |
public String getMethodClassType() { |
455 |
return methodClassType; |
456 |
} |
457 |
|
458 |
/** |
459 |
* Get the bytecode index of this operation. |
460 |
*/ |
461 |
public int getBytecodeIndex() { |
462 |
return bytecodeIndex; |
463 |
} |
464 |
|
465 |
/** |
466 |
* Set the return value of this operation. |
467 |
*/ |
468 |
public void setReturnValue(Variable returnValue) { |
469 |
this.returnValue = returnValue; |
470 |
} |
471 |
|
472 |
/** |
473 |
* Get the return value of this operation. |
474 |
*/ |
475 |
public Variable getReturnValue() { |
476 |
return returnValue; |
477 |
} |
478 |
|
479 |
/** |
480 |
* Get the list of following operations. |
481 |
*/ |
482 |
public List<Operation> getNextOperations() { |
483 |
if (nextOperations == null) { |
484 |
return Collections.emptyList(); |
485 |
} else { |
486 |
synchronized (this) { |
487 |
return Collections.unmodifiableList(nextOperations); |
488 |
} |
489 |
} |
490 |
} |
491 |
|
492 |
public boolean equals(Object obj) { |
493 |
if (obj instanceof Operation) { |
494 |
Operation op2 = (Operation) obj; |
495 |
return bytecodeIndex == op2.bytecodeIndex && |
496 |
((startPosition == null) ? |
497 |
op2.startPosition == null : |
498 |
startPosition.equals(op2.startPosition)) && |
499 |
((endPosition == null) ? |
500 |
op2.endPosition == null : |
501 |
endPosition.equals(op2.endPosition)); |
502 |
} |
503 |
return false; |
504 |
} |
505 |
|
506 |
public int hashCode() { |
507 |
return bytecodeIndex; |
508 |
} |
509 |
|
510 |
} |
511 |
|
512 |
/** |
513 |
* Representation of a position in a source code. |
514 |
*/ |
515 |
public static final class Position { |
516 |
|
517 |
private final int offset; |
518 |
private final int line; |
519 |
private final int column; |
520 |
|
521 |
Position(int offset, int line, int column) { |
522 |
this.offset = offset; |
523 |
this.line = line; |
524 |
this.column = column; |
525 |
} |
526 |
|
527 |
/** |
528 |
* Get the offset of this position. |
529 |
*/ |
530 |
public int getOffset() { |
531 |
return offset; |
532 |
} |
533 |
|
534 |
/** |
535 |
* Get the line number of this position. |
536 |
*/ |
537 |
public int getLine() { |
538 |
return line; |
539 |
} |
540 |
|
541 |
/** |
542 |
* Get the column number of this position. |
543 |
*/ |
544 |
public int getColumn() { |
545 |
return column; |
546 |
} |
547 |
|
548 |
public boolean equals(Object obj) { |
549 |
if (obj instanceof Position) { |
550 |
Position pos = (Position) obj; |
551 |
return pos.offset == offset; |
552 |
} |
553 |
return false; |
554 |
} |
555 |
|
556 |
public int hashCode() { |
557 |
return offset; |
558 |
} |
559 |
|
560 |
} |
561 |
|
244 |
} |
562 |
} |
245 |
|
563 |
|