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 2125444d932d..43248063c683 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
@@ -20,9 +20,10 @@
import java.util.Map;
import java.util.WeakHashMap;
+import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.api.debugger.Breakpoint;
-import org.netbeans.api.debugger.Breakpoint.VALIDITY;
import org.netbeans.api.debugger.DebuggerManager;
+import org.netbeans.modules.php.api.util.StringUtils;
import org.netbeans.modules.php.dbgp.DebugSession;
import org.netbeans.modules.php.dbgp.models.ViewModelSupport;
import org.netbeans.modules.php.dbgp.packets.Stack;
@@ -53,6 +54,12 @@ public class BreakpointModel extends ViewModelSupport implements NodeModel {
private static final String METHOD = "TXT_Method"; // NOI18N
private static final String EXCEPTION = "TXT_Exception"; // NOI18N
private static final String PARENS = "()"; // NOI18N
+ private static final String MESSAGE = "Message: "; // NOI18N
+ private static final String CODE = "Code: "; // NOI18N
+ private static final String FONT_COLOR = ""; //NOI18N
+ private static final String CLOSE_FONT = ""; //NOI18N
+ private static final String OPEN_HTML = ""; //NOI18N
+ private static final String CLOSE_HTML = ""; //NOI18N
private final Map myCurrentBreakpoints;
private volatile boolean searchCurrentBreakpointById = false;
@@ -79,14 +86,37 @@ public String getDisplayName(Object node) throws UnknownTypeException {
return builder.toString();
} else if (node instanceof ExceptionBreakpoint) {
ExceptionBreakpoint breakpoint = (ExceptionBreakpoint) node;
- StringBuilder builder = new StringBuilder(NbBundle.getMessage(BreakpointModel.class, EXCEPTION));
- builder.append(" "); // NOI18N
- builder.append(breakpoint.getException());
+ StringBuilder builder = new StringBuilder()
+ .append(OPEN_HTML)
+ .append(NbBundle.getMessage(BreakpointModel.class, EXCEPTION))
+ .append(" ") // NOI18N
+ .append(breakpoint.getException());
+ String message = breakpoint.getExceptionMessage();
+ String code = breakpoint.getExceptionCode();
+ synchronized (myCurrentBreakpoints) {
+ for (AbstractBreakpoint brkp : myCurrentBreakpoints.values()) {
+ if (breakpoint.equals(brkp)) {
+ buildAppend(builder, MESSAGE, message);
+ buildAppend(builder, CODE, code);
+ }
+ }
+ }
+ builder.append(CLOSE_HTML);
return builder.toString();
}
throw new UnknownTypeException(node);
}
+ private void buildAppend(StringBuilder builder, String prepend, @NullAllowed String text) {
+ if (!StringUtils.isEmpty(text)) {
+ builder.append(" ") // NOI18N
+ .append(FONT_COLOR)
+ .append(prepend)
+ .append(text)
+ .append(CLOSE_FONT);
+ }
+ }
+
@Override
public String getIconBase(Object node) throws UnknownTypeException {
synchronized (myCurrentBreakpoints) {
@@ -221,6 +251,12 @@ private void updateCurrentBreakpoint(DebugSession session, Breakpoint breakpoint
}
}
+ public AbstractBreakpoint getCurrentBreakpoint(DebugSession session) {
+ synchronized (myCurrentBreakpoints) {
+ return myCurrentBreakpoints.get(session);
+ }
+ }
+
public void setSearchCurrentBreakpointById(boolean flag) {
searchCurrentBreakpointById = flag;
}
diff --git a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/ExceptionBreakpoint.java b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/ExceptionBreakpoint.java
index 0c421ef92e71..1bb35cd50d2b 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/ExceptionBreakpoint.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/ExceptionBreakpoint.java
@@ -18,6 +18,9 @@
*/
package org.netbeans.modules.php.dbgp.breakpoints;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+import org.netbeans.modules.php.api.util.StringUtils;
import org.netbeans.modules.php.dbgp.DebugSession;
/**
@@ -26,7 +29,13 @@
*
*/
public class ExceptionBreakpoint extends AbstractBreakpoint {
+ private static final String FONT_GRAY_COLOR = ""; //NOI18N
+ private static final String CLOSE_FONT = ""; //NOI18N
private final String exceptionName;
+ @NullAllowed
+ private volatile String message;
+ @NullAllowed
+ private volatile String code;
public ExceptionBreakpoint(String exceptionName) {
this.exceptionName = exceptionName;
@@ -36,6 +45,37 @@ public String getException() {
return exceptionName;
}
+ public void setExceptionMessage(String message) {
+ this.message = message;
+ }
+
+ @CheckForNull
+ public String getExceptionMessage() {
+ return buildText(message);
+ }
+
+ public void setExceptionCode(String code) {
+ this.code = code;
+ }
+
+ @CheckForNull
+ public String getExceptionCode() {
+ return buildText(code);
+ }
+
+ @CheckForNull
+ private String buildText(String text) {
+ if (!StringUtils.isEmpty(text)) {
+ StringBuilder builder = new StringBuilder()
+ .append(FONT_GRAY_COLOR)
+ .append(text)
+ .append(CLOSE_FONT);
+ return builder.toString();
+ }
+
+ return null;
+ }
+
@Override
public boolean isSessionRelated(DebugSession session) {
return true;
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
index b24bb489d241..26362a984a1d 100644
--- 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
@@ -19,12 +19,16 @@
package org.netbeans.modules.php.dbgp.packets;
import org.netbeans.modules.php.dbgp.DebugSession;
+import org.netbeans.modules.php.dbgp.breakpoints.AbstractBreakpoint;
import org.netbeans.modules.php.dbgp.breakpoints.BreakpointModel;
+import org.netbeans.modules.php.dbgp.breakpoints.ExceptionBreakpoint;
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
+ private static final String MESSAGE = "xdebug:message"; //NOI18N
+ private static final String CODE = "code"; //NOI18N
RunResponse(Node node) {
super(node);
@@ -38,16 +42,25 @@ public void process(DebugSession dbgSession, DbgpCommand command) {
dbgSession.processStatus(status, reason, command);
}
+ Node message = getChild(getNode(), MESSAGE);
+ String code = null;
+ if (message != null) {
+ code = getAttribute(message, CODE);
+ }
+
Node breakpoint = getChild(getNode(), BREAKPOINT);
if (breakpoint != null) {
String id = DbgpMessage.getAttribute(breakpoint, BREAKPOINT_ID);
if (id != null) {
- updateBreakpointsView(dbgSession, id);
+ setCurrentBreakpoint(dbgSession, id);
+ if (message != null) {
+ setCurrentBreakpointText(dbgSession, message.getTextContent(), code);
+ }
}
}
}
- private void updateBreakpointsView(DebugSession session, String id) {
+ private void setCurrentBreakpoint(DebugSession session, String id) {
DebugSession.IDESessionBridge bridge = session.getBridge();
if (bridge != null) {
BreakpointModel breakpointModel = bridge.getBreakpointModel();
@@ -57,4 +70,18 @@ private void updateBreakpointsView(DebugSession session, String id) {
}
}
+ private void setCurrentBreakpointText(DebugSession session, String message, String code) {
+ DebugSession.IDESessionBridge bridge = session.getBridge();
+ if (bridge != null) {
+ BreakpointModel breakpointModel = bridge.getBreakpointModel();
+ if (breakpointModel != null && breakpointModel.isSearchCurrentBreakpointById()) {
+ AbstractBreakpoint bp = breakpointModel.getCurrentBreakpoint(session);
+ if (bp instanceof ExceptionBreakpoint) {
+ ((ExceptionBreakpoint) bp).setExceptionMessage(message);
+ ((ExceptionBreakpoint) bp).setExceptionCode(code);
+ }
+ }
+ }
+ }
+
}