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 1cda8a74bf PHP: mark a breakpoint as broken when an error is received 
when breakpoint_set is executed to set a breakpoint
     new e8b206ef64 Merge pull request #6876 from 
troizet/php_mark_breakpoint_as_broken
1cda8a74bf is described below

commit 1cda8a74bf464a16f4f3922c446d449eb120b211
Author: Alexey Borokhvostov <troi...@gmail.com>
AuthorDate: Sat Dec 23 17:50:08 2023 +0700

    PHP: mark a breakpoint as broken when an error is received when 
breakpoint_set is executed to set a breakpoint
---
 .../modules/php/dbgp/annotations/BrkpntAnnotation.java       |  4 ++--
 .../modules/php/dbgp/breakpoints/AbstractBreakpoint.java     |  4 ++++
 .../modules/php/dbgp/breakpoints/BreakpointModel.java        | 11 ++++++++---
 .../src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java |  5 +++++
 .../netbeans/modules/php/dbgp/packets/BrkpntSetResponse.java | 12 ++++++++++++
 5 files changed, 31 insertions(+), 5 deletions(-)

diff --git 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/BrkpntAnnotation.java
 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/BrkpntAnnotation.java
index 4eadb8192a..6575796dae 100644
--- 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/BrkpntAnnotation.java
+++ 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/BrkpntAnnotation.java
@@ -20,6 +20,7 @@ package org.netbeans.modules.php.dbgp.annotations;
 
 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;
@@ -41,8 +42,7 @@ public class BrkpntAnnotation extends BreakpointAnnotation {
 
     @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
     }
diff --git 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/AbstractBreakpoint.java
 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/AbstractBreakpoint.java
index ba60765454..832dd66a4b 100644
--- 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/AbstractBreakpoint.java
+++ 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/AbstractBreakpoint.java
@@ -84,6 +84,10 @@ public abstract class AbstractBreakpoint extends Breakpoint {
         setValidity(VALIDITY.INVALID, null);
     }
 
+    public void setInvalid(String reason) {
+        setValidity(VALIDITY.INVALID, reason);
+    }
+
     public void reset() {
         setValidity(VALIDITY.UNKNOWN, null);
         myId = null;
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 aea90c8684..e147d393f8 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
@@ -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
@@ -99,8 +100,7 @@ public class BreakpointModel extends ViewModelSupport 
implements NodeModel {
             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;
@@ -110,8 +110,13 @@ public class BreakpointModel extends ViewModelSupport 
implements NodeModel {
             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);
     }
diff --git 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java
index a247241a34..d7886a17f6 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java
@@ -23,6 +23,7 @@ import java.util.logging.Level;
 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;
@@ -238,4 +239,8 @@ public final class Utils {
         return mimeTypesOnLine.contains(MIME_TYPE);
     }
 
+    public static boolean isValid(Breakpoint breakpoint) {
+        VALIDITY validity = breakpoint.getValidity();
+        return validity == VALIDITY.VALID || validity == VALIDITY.UNKNOWN;
+    }
 }
diff --git 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/BrkpntSetResponse.java 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/BrkpntSetResponse.java
index bccf2f43a4..63b38c7ebe 100644
--- 
a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/BrkpntSetResponse.java
+++ 
b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/packets/BrkpntSetResponse.java
@@ -30,6 +30,8 @@ import org.w3c.dom.Node;
 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);
@@ -56,6 +58,16 @@ public class BrkpntSetResponse extends DbgpResponse {
             // 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();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to