Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = "<font color=\"#7D694A\">"; //NOI18N
private static final String CLOSE_FONT = "</font>"; //NOI18N
private static final String OPEN_HTML = "<html>"; //NOI18N
private static final String CLOSE_HTML = "</html>"; //NOI18N
private final Map<DebugSession, AbstractBreakpoint> myCurrentBreakpoints;
private volatile boolean searchCurrentBreakpointById = false;

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -26,7 +29,13 @@
*
*/
public class ExceptionBreakpoint extends AbstractBreakpoint {
private static final String FONT_GRAY_COLOR = "<font color=\"#999999\">"; //NOI18N
private static final String CLOSE_FONT = "</font>"; //NOI18N
private final String exceptionName;
@NullAllowed
private volatile String message;
@NullAllowed
private volatile String code;

public ExceptionBreakpoint(String exceptionName) {
this.exceptionName = exceptionName;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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);
}
}
}
}

}
2 changes: 1 addition & 1 deletion php/php.editor/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
nbjavac.ignore.missing.enclosing=**/CUP$ASTPHP5Parser$actions.class
nbm.needs.restart=true
spec.version.base=2.37.0
spec.version.base=2.38.0
release.external/predefined_vars-1.0.zip=docs/predefined_vars.zip
sigtest.gen.fail.on.error=false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public final class CodeUtils {
public static final String EMPTY_STRING = ""; // NOI18N
public static final String NEW_LINE = "\n"; // NOI18N
public static final String THIS_VARIABLE = "$this"; // NOI18N
public static final String NS_SEPARATOR = "\\"; // NOI18N

public static final Pattern WHITE_SPACES_PATTERN = Pattern.compile("\\s+"); // NOI18N
public static final Pattern SPLIT_TYPES_PATTERN = Pattern.compile("[()|&]+"); // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ public interface Index extends ElementQuery {

Set<EnumElement> getEnums(NameKind query, Set<AliasedName> aliases, AliasedElement.Trait trait);

/**
* Get traits.
*
* @param query the query
* @param aliases aliased names
* @param trait the trait
* @return traits
* @since 2.38.0
*/
Set<TraitElement> getTraits(NameKind query, Set<AliasedName> aliases, AliasedElement.Trait trait);

Set<TraitElement> getTraits(final NameKind query);

Set<EnumElement> getEnums(final NameKind query);
Expand Down
Loading