Lines 63-76
Link Here
|
63 |
import org.netbeans.api.debugger.Breakpoint.VALIDITY; |
63 |
import org.netbeans.api.debugger.Breakpoint.VALIDITY; |
64 |
import org.netbeans.api.debugger.DebuggerEngine; |
64 |
import org.netbeans.api.debugger.DebuggerEngine; |
65 |
import org.netbeans.api.debugger.DebuggerManager; |
65 |
import org.netbeans.api.debugger.DebuggerManager; |
|
|
66 |
import org.netbeans.api.debugger.DebuggerManagerAdapter; |
66 |
import org.netbeans.api.debugger.DebuggerManagerListener; |
67 |
import org.netbeans.api.debugger.DebuggerManagerListener; |
|
|
68 |
import org.netbeans.api.debugger.LazyDebuggerManagerListener; |
67 |
import org.netbeans.api.debugger.Session; |
69 |
import org.netbeans.api.debugger.Session; |
68 |
import org.netbeans.api.debugger.Watch; |
70 |
import org.netbeans.api.debugger.Watch; |
69 |
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint; |
71 |
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint; |
70 |
import org.netbeans.api.debugger.jpda.FieldBreakpoint; |
72 |
import org.netbeans.api.debugger.jpda.FieldBreakpoint; |
71 |
import org.netbeans.api.debugger.jpda.JPDABreakpoint; |
73 |
import org.netbeans.api.debugger.jpda.JPDABreakpoint; |
|
|
74 |
import org.netbeans.api.debugger.jpda.JPDADebugger; |
72 |
import org.netbeans.api.debugger.jpda.LineBreakpoint; |
75 |
import org.netbeans.api.debugger.jpda.LineBreakpoint; |
73 |
import org.netbeans.api.debugger.jpda.MethodBreakpoint; |
76 |
import org.netbeans.api.debugger.jpda.MethodBreakpoint; |
|
|
77 |
import org.netbeans.spi.debugger.DebuggerServiceRegistration; |
74 |
import org.netbeans.spi.debugger.jpda.EditorContext; |
78 |
import org.netbeans.spi.debugger.jpda.EditorContext; |
75 |
|
79 |
|
76 |
import org.openide.cookies.LineCookie; |
80 |
import org.openide.cookies.LineCookie; |
Lines 94-107
Link Here
|
94 |
* @author Jan Jancura, Martin Entlicher |
98 |
* @author Jan Jancura, Martin Entlicher |
95 |
*/ |
99 |
*/ |
96 |
@org.openide.util.lookup.ServiceProvider(service=org.openide.text.AnnotationProvider.class) |
100 |
@org.openide.util.lookup.ServiceProvider(service=org.openide.text.AnnotationProvider.class) |
97 |
public class BreakpointAnnotationProvider implements AnnotationProvider, |
101 |
@DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class) |
98 |
DebuggerManagerListener { |
102 |
public class BreakpointAnnotationProvider extends DebuggerManagerAdapter |
|
|
103 |
implements AnnotationProvider/*, |
104 |
DebuggerManagerListener*/ { |
99 |
|
105 |
|
100 |
private final Map<JPDABreakpoint, Set<Annotation>> breakpointToAnnotations = |
106 |
private final Map<JPDABreakpoint, Set<Annotation>> breakpointToAnnotations = |
101 |
new IdentityHashMap<JPDABreakpoint, Set<Annotation>>(); |
107 |
new IdentityHashMap<JPDABreakpoint, Set<Annotation>>(); |
102 |
private final Set<FileObject> annotatedFiles = new WeakSet<FileObject>(); |
108 |
private final Set<FileObject> annotatedFiles = new WeakSet<FileObject>(); |
103 |
private Set<PropertyChangeListener> dataObjectListeners; |
109 |
private Set<PropertyChangeListener> dataObjectListeners; |
104 |
private boolean attachManagerListener = true; |
110 |
private boolean attachManagerListener = true; |
|
|
111 |
private volatile JPDADebugger currentDebugger = null; |
112 |
private volatile boolean breakpointsActive = true; |
105 |
private RequestProcessor annotationProcessor = new RequestProcessor("Annotation Refresh", 1); |
113 |
private RequestProcessor annotationProcessor = new RequestProcessor("Annotation Refresh", 1); |
106 |
private RequestProcessor contextWaitingProcessor = new RequestProcessor("Annotation Refresh Context Waiting", 1); |
114 |
private RequestProcessor contextWaitingProcessor = new RequestProcessor("Annotation Refresh Context Waiting", 1); |
107 |
|
115 |
|
Lines 176-181
Link Here
|
176 |
} |
184 |
} |
177 |
|
185 |
|
178 |
@Override |
186 |
@Override |
|
|
187 |
public String[] getProperties() { |
188 |
return new String[] { DebuggerManager.PROP_BREAKPOINTS, DebuggerManager.PROP_DEBUGGER_ENGINES }; |
189 |
} |
190 |
|
191 |
@Override |
179 |
public void breakpointAdded(Breakpoint breakpoint) { |
192 |
public void breakpointAdded(Breakpoint breakpoint) { |
180 |
if (isAnnotatable(breakpoint)) { |
193 |
if (isAnnotatable(breakpoint)) { |
181 |
JPDABreakpoint b = (JPDABreakpoint) breakpoint; |
194 |
JPDABreakpoint b = (JPDABreakpoint) breakpoint; |
Lines 207-212
Link Here
|
207 |
if (propertyName == null) { |
220 |
if (propertyName == null) { |
208 |
return; |
221 |
return; |
209 |
} |
222 |
} |
|
|
223 |
if (DebuggerManager.PROP_CURRENT_ENGINE.equals(propertyName)) { |
224 |
JPDADebugger oldDebugger = currentDebugger; |
225 |
if (oldDebugger != null) { |
226 |
oldDebugger.removePropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, this); |
227 |
} |
228 |
DebuggerEngine engine = DebuggerManager.getDebuggerManager().getCurrentEngine(); |
229 |
boolean active = true; |
230 |
JPDADebugger debugger = null; |
231 |
if (engine != null) { |
232 |
debugger = engine.lookupFirst(null, JPDADebugger.class); |
233 |
if (debugger != null) { |
234 |
debugger.addPropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, this); |
235 |
active = debugger.areBreakpointsActive(); |
236 |
} |
237 |
} |
238 |
currentDebugger = debugger; |
239 |
setBreakpointsActive(active); |
240 |
} |
241 |
if (JPDADebugger.PROP_BREAKPOINTS_ACTIVE.equals(propertyName)) { |
242 |
JPDADebugger debugger = currentDebugger; |
243 |
if (debugger != null) { |
244 |
setBreakpointsActive(debugger.areBreakpointsActive()); |
245 |
} |
246 |
} |
210 |
if ( (!JPDABreakpoint.PROP_ENABLED.equals (propertyName)) && |
247 |
if ( (!JPDABreakpoint.PROP_ENABLED.equals (propertyName)) && |
211 |
(!JPDABreakpoint.PROP_VALIDITY.equals (propertyName)) && |
248 |
(!JPDABreakpoint.PROP_VALIDITY.equals (propertyName)) && |
212 |
(!LineBreakpoint.PROP_CONDITION.equals (propertyName)) && |
249 |
(!LineBreakpoint.PROP_CONDITION.equals (propertyName)) && |
Lines 238-243
Link Here
|
238 |
annotationProcessor.post(new AnnotationRefresh(b, true, true)); |
275 |
annotationProcessor.post(new AnnotationRefresh(b, true, true)); |
239 |
} |
276 |
} |
240 |
|
277 |
|
|
|
278 |
private void setBreakpointsActive(boolean active) { |
279 |
if (breakpointsActive == active) { |
280 |
return ; |
281 |
} |
282 |
annotationProcessor.post(new AnnotationRefresh(null, true, true)); |
283 |
} |
284 |
|
241 |
private final class AnnotationRefresh implements Runnable { |
285 |
private final class AnnotationRefresh implements Runnable { |
242 |
|
286 |
|
243 |
private JPDABreakpoint b; |
287 |
private JPDABreakpoint b; |
Lines 252-268
Link Here
|
252 |
@Override |
296 |
@Override |
253 |
public void run() { |
297 |
public void run() { |
254 |
synchronized (breakpointToAnnotations) { |
298 |
synchronized (breakpointToAnnotations) { |
255 |
if (remove) { |
299 |
if (b != null) { |
256 |
removeAnnotations(b); |
300 |
refreshAnnotation(b); |
257 |
if (!add) { |
301 |
} else { |
258 |
breakpointToAnnotations.remove(b); |
302 |
List<JPDABreakpoint> bpts = new ArrayList<JPDABreakpoint>(breakpointToAnnotations.keySet()); |
|
|
303 |
for (JPDABreakpoint bp : bpts) { |
304 |
refreshAnnotation(bp); |
259 |
} |
305 |
} |
260 |
} |
306 |
} |
261 |
if (add) { |
307 |
} |
262 |
breakpointToAnnotations.put(b, new WeakSet<Annotation>()); |
308 |
} |
263 |
for (FileObject fo : annotatedFiles) { |
309 |
|
264 |
addAnnotationTo(b, fo); |
310 |
private void refreshAnnotation(JPDABreakpoint b) { |
265 |
} |
311 |
if (remove) { |
|
|
312 |
removeAnnotations(b); |
313 |
if (!add) { |
314 |
breakpointToAnnotations.remove(b); |
315 |
} |
316 |
} |
317 |
if (add) { |
318 |
breakpointToAnnotations.put(b, new WeakSet<Annotation>()); |
319 |
for (FileObject fo : annotatedFiles) { |
320 |
addAnnotationTo(b, fo); |
266 |
} |
321 |
} |
267 |
} |
322 |
} |
268 |
} |
323 |
} |
Lines 277-283
Link Here
|
277 |
!((JPDABreakpoint) b).isHidden(); |
332 |
!((JPDABreakpoint) b).isHidden(); |
278 |
} |
333 |
} |
279 |
|
334 |
|
280 |
private static String getAnnotationType(JPDABreakpoint b, boolean isConditional) { |
335 |
private static String getAnnotationType(JPDABreakpoint b, boolean isConditional, |
|
|
336 |
boolean active) { |
281 |
boolean isInvalid = b.getValidity() == VALIDITY.INVALID; |
337 |
boolean isInvalid = b.getValidity() == VALIDITY.INVALID; |
282 |
String annotationType; |
338 |
String annotationType; |
283 |
if (b instanceof LineBreakpoint) { |
339 |
if (b instanceof LineBreakpoint) { |
Lines 301-308
Link Here
|
301 |
} else { |
357 |
} else { |
302 |
throw new IllegalStateException(b.toString()); |
358 |
throw new IllegalStateException(b.toString()); |
303 |
} |
359 |
} |
304 |
if (isInvalid && b.isEnabled ()) { |
360 |
if (!active) { |
305 |
annotationType += "_broken"; |
361 |
annotationType = annotationType + "_stroke"; // NOI18N |
|
|
362 |
} else if (isInvalid && b.isEnabled ()) { |
363 |
annotationType += "_broken"; // NOI18N |
306 |
} |
364 |
} |
307 |
return annotationType; |
365 |
return annotationType; |
308 |
} |
366 |
} |
Lines 481-487
Link Here
|
481 |
throw new IllegalStateException(b.toString()); |
539 |
throw new IllegalStateException(b.toString()); |
482 |
} |
540 |
} |
483 |
boolean isConditional = (condition != null) && condition.trim().length() > 0; |
541 |
boolean isConditional = (condition != null) && condition.trim().length() > 0; |
484 |
String annotationType = getAnnotationType(b, isConditional); |
542 |
String annotationType = getAnnotationType(b, isConditional, breakpointsActive); |
485 |
DataObject dataObject; |
543 |
DataObject dataObject; |
486 |
try { |
544 |
try { |
487 |
dataObject = DataObject.find(fo); |
545 |
dataObject = DataObject.find(fo); |
Lines 526-532
Link Here
|
526 |
} |
584 |
} |
527 |
} |
585 |
} |
528 |
|
586 |
|
529 |
|
587 |
/* |
530 |
// Not used |
588 |
// Not used |
531 |
@Override |
589 |
@Override |
532 |
public Breakpoint[] initBreakpoints() { return new Breakpoint[] {}; } |
590 |
public Breakpoint[] initBreakpoints() { return new Breakpoint[] {}; } |
Lines 558-562
Link Here
|
558 |
// Not used |
616 |
// Not used |
559 |
@Override |
617 |
@Override |
560 |
public void engineRemoved(DebuggerEngine engine) {} |
618 |
public void engineRemoved(DebuggerEngine engine) {} |
561 |
|
619 |
*/ |
562 |
} |
620 |
} |