Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP: mark a breakpoint as broken when an error is received when breakpoint_set is executed to set a breakpoint #6876

Merged
merged 1 commit into from
Dec 25, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.netbeans.api.debugger.Breakpoint;
import org.netbeans.modules.php.dbgp.breakpoints.LineBreakpoint;
import org.netbeans.modules.php.dbgp.breakpoints.Utils;
import org.netbeans.spi.debugger.ui.BreakpointAnnotation;
import org.openide.text.Annotatable;
import org.openide.util.NbBundle;
Expand All @@ -41,8 +42,7 @@ public BrkpntAnnotation(Annotatable annotatable, LineBreakpoint breakpoint) {

@Override
public String getAnnotationType() {
Breakpoint.VALIDITY validity = breakpoint.getValidity();
return validity == Breakpoint.VALIDITY.VALID || validity == Breakpoint.VALIDITY.UNKNOWN
return Utils.isValid(breakpoint)
? BREAKPOINT_ANNOTATION_TYPE
: BREAKPOINT_ANNOTATION_TYPE + "_broken"; //NOI18N
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ void setInvalid() {
setValidity(VALIDITY.INVALID, null);
}

public void setInvalid(String reason) {
setValidity(VALIDITY.INVALID, reason);
}

public void reset() {
setValidity(VALIDITY.UNKNOWN, null);
myId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class BreakpointModel extends ViewModelSupport implements NodeModel {
public static final String CURRENT_LINE_CONDITIONAL_BREAKPOINT = "org/netbeans/modules/debugger/resources/breakpointsView/ConditionalBreakpointHit"; // NOI18N
public static final String DISABLED_LINE_CONDITIONAL_BREAKPOINT = "org/netbeans/modules/debugger/resources/breakpointsView/DisabledConditionalBreakpoint"; // NOI18N
public static final String BROKEN_LINE_BREAKPOINT = "org/netbeans/modules/debugger/resources/breakpointsView/Breakpoint_broken"; // NOI18N
public static final String BROKEN_BREAKPOINT = "org/netbeans/modules/debugger/resources/breakpointsView/NonLineBreakpoint_broken"; // NOI18N
private static final String METHOD = "TXT_Method"; // NOI18N
private static final String EXCEPTION = "TXT_Exception"; // NOI18N
private static final String PARENS = "()"; // NOI18N
Expand Down Expand Up @@ -99,8 +100,7 @@ public String getIconBase(Object node) throws UnknownTypeException {
if (!breakpoint.isEnabled()) {
return DISABLED_LINE_BREAKPOINT;
} else {
VALIDITY validity = breakpoint.getValidity();
if (validity.equals(VALIDITY.VALID) || validity.equals(VALIDITY.UNKNOWN)) {
if (Utils.isValid(breakpoint)) {
return LINE_BREAKPOINT;
} else {
return BROKEN_LINE_BREAKPOINT;
Expand All @@ -110,8 +110,13 @@ public String getIconBase(Object node) throws UnknownTypeException {
AbstractBreakpoint breakpoint = (AbstractBreakpoint) node;
if (!breakpoint.isEnabled()) {
return DISABLED_BREAKPOINT;
} else {
if (Utils.isValid(breakpoint)) {
return BREAKPOINT;
} else {
return BROKEN_BREAKPOINT;
}
}
return BREAKPOINT;
}
throw new UnknownTypeException(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.logging.Logger;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.debugger.Breakpoint;
import org.netbeans.api.debugger.Breakpoint.VALIDITY;
import org.netbeans.api.debugger.DebuggerManager;
import org.netbeans.api.options.OptionsDisplayer;
import org.netbeans.modules.php.dbgp.DebugSession;
Expand Down Expand Up @@ -238,4 +239,8 @@ public static boolean isInPhpScript(Line line) {
return mimeTypesOnLine.contains(MIME_TYPE);
}

public static boolean isValid(Breakpoint breakpoint) {
VALIDITY validity = breakpoint.getValidity();
return validity == VALIDITY.VALID || validity == VALIDITY.UNKNOWN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
public class BrkpntSetResponse extends DbgpResponse {
private static final String STATE = "state"; // NOI18N
private static final String ID = "id"; // NOI18N
private static final String ERROR = "error"; // NOI18N
private static final String MESSAGE = "message"; // NOI18N

BrkpntSetResponse(Node node) {
super(node);
Expand All @@ -56,6 +58,16 @@ public void process(DebugSession session, DbgpCommand command) {
// set f.e. for as temporary ( for run to cursor command ).
return;
}

Node error = getChild(getNode(), ERROR);
if (error != null) {
Node message = getChild(error, MESSAGE);
if (message != null) {
breakpoint.setInvalid(message.getTextContent());
return;
}
}

breakpoint.setBreakpointId(getBreakpointId());
if (getState() == State.DISABLED) {
breakpoint.disable();
Expand Down