junichi11 commented on code in PR #6891:
URL: https://github.com/apache/netbeans/pull/6891#discussion_r1437770396
##########
php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java:
##########
@@ -179,21 +180,56 @@ private boolean foundBreakpoint(DebugSession session,
Acceptor acceptor) {
continue;
}
if (acceptor.accept(breakpoint)) {
- AbstractBreakpoint abpnt = (AbstractBreakpoint) breakpoint;
- synchronized (myCurrentBreakpoints) {
- AbstractBreakpoint bpnt =
myCurrentBreakpoints.get(session);
- myCurrentBreakpoints.put(session, abpnt);
- fireChangeEvents(new ModelEvent[]{
- new ModelEvent.NodeChanged(this, bpnt),
- new ModelEvent.NodeChanged(this, abpnt)
- });
- }
+ updateCurrentBreakpoint(session, breakpoint);
return true;
}
}
return false;
}
+ public void setCurrentBreakpoint(DebugSession session, String id) {
+ Breakpoint[] breakpoints =
DebuggerManager.getDebuggerManager().getBreakpoints();
+ for (Breakpoint breakpoint : breakpoints) {
+ if (!(breakpoint instanceof AbstractBreakpoint)) {
+ continue;
+ }
+ if (breakpoint.getValidity().equals(VALIDITY.INVALID)) {
+ continue;
+ }
+ if (!((AbstractBreakpoint) breakpoint).isSessionRelated(session)) {
+ continue;
+ }
+ if (!((AbstractBreakpoint) breakpoint).isEnabled()) {
+ continue;
+ }
+ if (((AbstractBreakpoint)
breakpoint).getBreakpointId().equals(id)) {
+ updateCurrentBreakpoint(session, breakpoint);
+ }
Review Comment:
I would prefer the following:
```java
if (canSetCurrentBreakPoint(breakpoint, id)) {
updateCurrentBreakpoint(session, breakpoint);
// can add `break;` here? or do multiple ids match?
}
```
```java
private boolean canSetCurrentBreakPoint(Breakpoint breakpoint,
DebugSession session, String id) {
if (Utils.isValid(breakpoint) && breakpoint instanceof
AbstractBreakpoint) {
AbstractBreakpoint abstractBreakpoint = (AbstractBreakpoint)
breakpoint;
if (abstractBreakpoint.isSessionRelated(session)
&& abstractBreakpoint.isEnabled()
&& abstractBreakpoint.getBreakpointId().equals(id)) {
return true;
}
}
return false;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists