tmysik commented on code in PR #6891:
URL: https://github.com/apache/netbeans/pull/6891#discussion_r1437674130
##########
php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java:
##########
@@ -54,6 +54,7 @@ public class BreakpointModel extends ViewModelSupport
implements NodeModel {
private static final String EXCEPTION = "TXT_Exception"; // NOI18N
private static final String PARENS = "()"; // NOI18N
private final Map<DebugSession, AbstractBreakpoint> myCurrentBreakpoints;
+ private Boolean searchCurrentBreakpointById = false;
Review Comment:
Inconsistent threading - you are writing it under lock but read it without
it. I guess that simple `volatile` should be fine in this case, so without any
further locking.
##########
php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/StackGetResponse.java:
##########
@@ -96,7 +96,7 @@ private void updateBreakpointsView(DebugSession session,
List<Stack> stacks) {
IDESessionBridge bridge = session.getBridge();
if (bridge != null) {
BreakpointModel breakpointModel = bridge.getBreakpointModel();
- if (breakpointModel != null) {
+ if (breakpointModel != null &&
!breakpointModel.isSearchCurrentBreakpointById()) {
Review Comment:
If I am not wrong, `breakpointModel.isSearchCurrentBreakpointById()` can
produce a NPE, right?
##########
php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/RunResponse.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.dbgp.packets;
+
+import org.netbeans.modules.php.dbgp.DebugSession;
+import org.netbeans.modules.php.dbgp.breakpoints.BreakpointModel;
+import org.w3c.dom.Node;
+
+public class RunResponse extends StatusResponse {
+ private static final String BREAKPOINT = "breakpoint"; //NOI18N
+ private static final String BREAKPOINT_ID = "id"; //NOI18N
+
+ RunResponse(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void process(DebugSession dbgSession, DbgpCommand command) {
+ Status status = getStatus();
+ Reason reason = getReason();
+ if (status != null && reason != null) {
+ dbgSession.processStatus(status, reason, command);
+ }
+
+ Node breakpoint = getChild(getNode(), BREAKPOINT);
+ if (breakpoint != null) {
+ String id = DbgpMessage.getAttribute(breakpoint, BREAKPOINT_ID);
+ if (id != null) {
+ updateBreakpointsView(dbgSession, id);
+ }
+ }
+ }
+
+ private void updateBreakpointsView(DebugSession session, String id) {
+ DebugSession.IDESessionBridge bridge = session.getBridge();
+ if (bridge != null) {
+ BreakpointModel breakpointModel = bridge.getBreakpointModel();
+ if (breakpointModel != null &&
breakpointModel.isSearchCurrentBreakpointById()) {
Review Comment:
If I am not wrong, `breakpointModel.isSearchCurrentBreakpointById()` can
produce a NPE, right?
##########
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);
+ }
+ }
+ }
+
+ private void updateCurrentBreakpoint(DebugSession session, Breakpoint
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)
+ });
+ }
+ }
+
+ public void setSearchCurrentBreakpointById(Boolean flag) {
+ synchronized (this) {
+ searchCurrentBreakpointById = flag;
+ }
+ }
+
+ public Boolean isSearchCurrentBreakpointById() {
Review Comment:
BTW, do we need to allow `null` for this field? I mean, cannot it be simply
a `boolean`?
##########
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);
+ }
+ }
+ }
+
+ private void updateCurrentBreakpoint(DebugSession session, Breakpoint
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)
+ });
+ }
+ }
+
+ public void setSearchCurrentBreakpointById(Boolean flag) {
+ synchronized (this) {
+ searchCurrentBreakpointById = flag;
+ }
+ }
+
+ public Boolean isSearchCurrentBreakpointById() {
Review Comment:
```suggestion
@CheckForNull
public Boolean isSearchCurrentBreakpointById() {
```
--
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