This is an automated email from the ASF dual-hosted git repository.
junichi11 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new b006691903 PHP: New way to set the current breakpoint
new a34e57050b Merge pull request #6891 from
troizet/php_improve_set_current_breakpoint
b006691903 is described below
commit b006691903e5d6188a9a176861782e12a305efb2
Author: Alexey Borokhvostov <[email protected]>
AuthorDate: Thu Dec 28 00:36:44 2023 +0700
PHP: New way to set the current breakpoint
---
.../php/dbgp/breakpoints/BreakpointModel.java | 53 +++++++++++++++----
.../php/dbgp/packets/FeatureGetCommand.java | 5 ++
.../php/dbgp/packets/FeatureSetResponse.java | 19 +++++++
.../modules/php/dbgp/packets/InitMessage.java | 5 ++
.../modules/php/dbgp/packets/MessageBuilder.java | 5 +-
.../modules/php/dbgp/packets/RunResponse.java | 60 ++++++++++++++++++++++
.../modules/php/dbgp/packets/StackGetResponse.java | 2 +-
7 files changed, 137 insertions(+), 12 deletions(-)
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java
index e147d393f8..2125444d93 100644
---
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java
+++
b/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 volatile boolean searchCurrentBreakpointById = false;
public BreakpointModel() {
myCurrentBreakpoints = new WeakHashMap<>();
@@ -179,21 +180,55 @@ public class BreakpointModel extends ViewModelSupport
implements NodeModel {
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 (canSetCurrentBreakPoint(session, breakpoint, id)) {
+ updateCurrentBreakpoint(session, breakpoint);
+ break;
+ }
+ }
+ }
+
+ private boolean canSetCurrentBreakPoint(DebugSession session, Breakpoint
breakpoint, 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;
+ }
+
+ 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) {
+ searchCurrentBreakpointById = flag;
+ }
+
+ public boolean isSearchCurrentBreakpointById() {
+ return searchCurrentBreakpointById;
+ }
+
private interface Acceptor {
boolean accept(Breakpoint breakpoint);
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureGetCommand.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureGetCommand.java
index a88c3f3daf..0fc28483c1 100644
---
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureGetCommand.java
+++
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureGetCommand.java
@@ -36,6 +36,7 @@ public class FeatureGetCommand extends DbgpCommand {
DATA_ENCODING,
BREAKPOINT_LANGUAGES,
BREAKPOINT_TYPES,
+ BREAKPOINT_DETAILS,
MULTIPLE_SESSIONS,
MAX_CHILDREN,
MAX_DATA,
@@ -88,6 +89,10 @@ public class FeatureGetCommand extends DbgpCommand {
myName = name;
}
+ public String getFeature() {
+ return myName;
+ }
+
@Override
protected String getArguments() {
return NAME_ARG + myName;
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureSetResponse.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureSetResponse.java
index ec34f73ab1..01174bce6e 100644
---
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureSetResponse.java
+++
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/FeatureSetResponse.java
@@ -19,6 +19,7 @@
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;
/**
@@ -28,6 +29,7 @@ import org.w3c.dom.Node;
public class FeatureSetResponse extends DbgpResponse {
private static final String SUCCESS = "success"; // NOI18N
private static final String FEATURE_NAME = "feature_name"; // NOI18N
+ private static final String ERROR = "error"; // NOI18N
FeatureSetResponse(Node node) {
super(node);
@@ -43,6 +45,23 @@ public class FeatureSetResponse extends DbgpResponse {
@Override
public void process(DebugSession session, DbgpCommand command) {
+ if (command instanceof FeatureSetCommand) {
+ String feature = ((FeatureSetCommand) command).getFeature();
+ if
(feature.equals(FeatureGetCommand.Feature.BREAKPOINT_DETAILS.toString())) {
+ Node error = getChild(getNode(), ERROR);
+ setSearchCurrentBreakpointById(session, error == null);
+ }
+ }
+ }
+
+ private void setSearchCurrentBreakpointById(DebugSession session, boolean
value) {
+ DebugSession.IDESessionBridge bridge = session.getBridge();
+ if (bridge != null) {
+ BreakpointModel breakpointModel = bridge.getBreakpointModel();
+ if (breakpointModel != null) {
+ breakpointModel.setSearchCurrentBreakpointById(value);
+ }
+ }
}
}
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/InitMessage.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/InitMessage.java
index 426de51421..71584df694 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/InitMessage.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/InitMessage.java
@@ -58,6 +58,7 @@ public class InitMessage extends DbgpMessage {
setMaxDepth(session);
setMaxChildren(session);
setMaxDataSize(session);
+ setBreakpointDetails(session);
setBreakpoints(session);
negotiateOutputStream(session);
negotiateRequestedUrls(session);
@@ -82,6 +83,10 @@ public class InitMessage extends DbgpMessage {
setFeature(session, Feature.SHOW_HIDDEN, "1"); //NOI18N
}
+ private void setBreakpointDetails(DebugSession session) {
+ setFeature(session, Feature.BREAKPOINT_DETAILS, "1"); //NOI18N
+ }
+
private void setBreakpointResolution(DebugSession session) {
if (DebuggerOptions.getGlobalInstance().resolveBreakpoints()) {
setFeature(session, Feature.RESOLVED_BREAKPOINTS, "1"); // NOI18N
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/MessageBuilder.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/MessageBuilder.java
index 8aa364a0e1..2e8f5fe065 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/MessageBuilder.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/MessageBuilder.java
@@ -50,13 +50,14 @@ final class MessageBuilder {
static DbgpMessage createResponse(Node node) {
String command = DbgpMessage.getAttribute(node, DbgpResponse.COMMAND);
- if (RunCommand.RUN.equals(command)
- || StatusCommand.STATUS.equals(command)
+ if (StatusCommand.STATUS.equals(command)
|| StepOutCommand.STEP_OUT.equals(command)
|| StepOverCommand.STEP_OVER.equals(command)
|| StepIntoCommand.STEP_INTO.equals(command)
|| StopCommand.COMMAND.equals(command)) {
return new StatusResponse(node);
+ } else if (RunCommand.RUN.equals(command)) {
+ return new RunResponse(node);
} else if (BrkpntSetCommand.BREAKPOINT_SET.equals(command)) {
return new BrkpntSetResponse(node);
} else if (BrkpntUpdateCommand.UPDATE.equals(command)) {
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/RunResponse.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/RunResponse.java
new file mode 100644
index 0000000000..b24bb489d2
--- /dev/null
+++ b/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()) {
+ breakpointModel.setCurrentBreakpoint(session, id);
+ }
+ }
+ }
+
+}
diff --git
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/StackGetResponse.java
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/StackGetResponse.java
index 904f2183cd..4b8496f4af 100644
---
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/StackGetResponse.java
+++
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/StackGetResponse.java
@@ -96,7 +96,7 @@ public class StackGetResponse extends DbgpResponse {
IDESessionBridge bridge = session.getBridge();
if (bridge != null) {
BreakpointModel breakpointModel = bridge.getBreakpointModel();
- if (breakpointModel != null) {
+ if (breakpointModel != null &&
!breakpointModel.isSearchCurrentBreakpointById()) {
breakpointModel.setCurrentStack(
stacks.get(0), session);
}
---------------------------------------------------------------------
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