1) Moved the hasRecursion and the updateVariableList to PHPStackframe class.
authorrobekras <robekras>
Thu, 20 Oct 2005 19:13:56 +0000 (19:13 +0000)
committerrobekras <robekras>
Thu, 20 Oct 2005 19:13:56 +0000 (19:13 +0000)
Because the variables list belongs to a specific stackframe and not to the interface.
2) Modified updateStackFrameList because equality of stackframes is determined by their description and not by their module number.

net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java

index 03a735f..fc5d18e 100644 (file)
@@ -394,136 +394,6 @@ public class PHPDBGInterface {
        }
 
        /**
-        * Go up the tree of PHPVariables
-        * look whether the PHPValue is a reference to a parent PHPValue
-        *
-        * TODO Check where this recursion can come from.
-        * Whether this back reference is legal or a bug.
-        *
-        * @param var
-        * @return
-        * <ul>
-        * <li> false if the PHPValue is not a child of itself
-        * <li> true if the PHPValue is
-        * </ul>
-        */
-
-       private boolean hasRecursion (PHPVariable var) {
-               PHPVariable parentVar;
-               PHPValue    val;
-
-               val = (PHPValue) var.getValue ();                                                       // Get the PHPValue from the current PHPVariable
-
-               while (var != null) {                                                                           // As long as we have PHPVariable
-                       parentVar = var.getParent ();                                                   // Get the parent PHPVariable
-
-                       if (parentVar != null) {                                // Is there a parent?
-                               if (parentVar.getValue ().equals (val)) {                       // Get the PHPValue for the parent PHPVariable and check
-                                                                                                                                       // whether it is the same
-                                       return true;                                                                    // Return, if we have recursion
-                               }
-                       }
-
-                       var = parentVar;
-               }
-
-               return false;                                                                                           // No recursion found
-       }
-
-       /**
-        * This method updates the 'static' variables list.
-        * It does a replication between the 'static' list (the variable list which
-        * is a member of this DBG interface object) and the DBG variable list
-        * (the list of variables which is received from PHP via DBG with the current suspend)
-        * Replication is done in the following way:
-        * <ul>
-        * <li> It looks for new variables within the DBG variables list and
-        *      adds them to the 'static' list.
-        * <li> It looks for changed variables copies the current value to the variable within
-        *              the 'static list' and mark these variables as 'hasChanged' (which uses the UI
-        *              for showing the variable with a different color).
-        * <li> It looks for variables within the 'static' list, and removes them
-        *              from the 'static' list in case the do not appear within the DBG list.
-        * </ul>
-        *
-        * @param varListOld The 'static' list of variables which are to be updated.
-        * @param varListNew The new list of (current) variables from DBG.
-        */
-       private void updateVariableList (Vector varListOld, Vector varListNew)
-       {
-               PHPVariable     varOld;                                                                                 // The variable from the 'static' list
-               PHPVariable varNew;                                                                                     // The variable from the DBG list
-               PHPValue    valOld;                                                                                     // The value of the current variable from 'static' list
-               PHPValue    valNew;                                                                                     // The value of the current variable from DBG list
-               int         n;                                                                                          // Index for the DBG list
-               int         o;                                                                                          // Index for the static list
-
-               // Add the variables (and childs) to the static list if they are new
-               //  and update the values of variables which are already existend within
-               //  the 'static' list.
-
-               for (n = 0; n < varListNew.size (); n++) {                  // For every variable in 'DBG list'
-                       varNew = (PHPVariable) varListNew.get (n);                              // Get the DBG variable
-
-                       for (o = 0; o < varListOld.size (); o++) {                              // For every variable in static list
-                               varOld = (PHPVariable) varListOld.get (o);                      // Get the static variable
-
-                               if (varNew.getName ().equals (varOld.getName ())) { // Did we found the variable within the 'static' list?
-                                       valOld = (PHPValue) varOld.getValue ();         // Get the value from 'static'
-                                       valNew = (PHPValue) varNew.getValue ();         // Get the value from DBG
-
-                                       try {
-                                               if (valOld.hasVariables () ||                           // If the 'static' value has child variables
-                                                   valNew.hasVariables ()) {                           //  or if the DBG value has child variables
-                                                       if (!hasRecursion (varOld) &&
-                                                           !hasRecursion (varNew)) {                   // Both branches should not have a recursion
-                                                               updateVariableList (valOld.getChildVariables (),        // Update the variable list for the child variables
-                                                                                                       valNew.getChildVariables ());
-                                                       }
-                                               }
-                                               else if (!valOld.getValueString ().equals (valNew.getValueString ())) { // Has the value changed?
-                                                       valOld.setValueString (valNew.getValueString ());                   // Yes, set the 'static' value (variable) to the new value
-                                                       varOld.setValueChanged (true);                                                                          // and set the 'has changed' flag, so that the variable view
-                                                                                                                                                                                               // could show the user the changed status with a different
-                                                                                                                                                                                               // color
-                                               }
-                                               else {
-                                                       varOld.setValueChanged (false);                                     // Reset the 'has changed' flag
-                                               }
-                                       }
-                                       catch (DebugException e) {                                                  // That's, because of the hasVariables method
-                                       }
-
-                                       break;                                          // Found the variable,
-                               }
-                       }
-
-                       if (o == varListOld.size ()) {                          // Did we found the variable within the static list?
-                               varListOld.add (varNew);                                                        //  No, then add the DBG variable to the static list
-                       }
-               }
-
-               // Look for the variables we can remove from the 'static' list
-
-               for (o = 0; o < varListOld.size (); o++) {                                              // For every variable in 'static' list
-                       varOld = (PHPVariable) varListOld.get (o);                                                      // Get the static variable
-
-                       for (n = 0; n < varListNew.size (); n++) {                                                      // For all variables in 'DBG' list
-                               varNew = (PHPVariable) varListNew.get (n);                                              // Get the variable from the 'DBG' list
-
-                               if (varNew.getName ().equals (varOld.getName ())) {                     // Did we found the 'static' list variable within the 'DBG' list?
-                                       break;                                                                                                          // Yes we found the variable, then leave the loop
-                               }
-                       }
-
-                       if (n == varListNew.size ()) {                                          // Did not find the 'static' list variable within the 'DBG' list?
-                                varListOld.remove (o);                                         // then remove the 'static' list variable from list
-                                o -= 1;                                                        // Adjust the 'static' list index
-                       }
-               }
-       }
-
-       /**
         * This method is called by the proxy.
         * It sends a request to DBG to get the current variables
         * with their values. It waits for the response and processes
@@ -555,7 +425,10 @@ public class PHPDBGInterface {
                flushAllPackets ();                                         // Read and process the response from DBG
 
                evalStr         = new PHPDBGEvalString (stack, serGlobals); // Process serialized variables
-               updateVariableList (DBGVarList, evalStr.getVariables ());       // Replicate the 'static' variable list and the via DBG received variable list
+               DBGVarList      = evalStr.getVariables ();
+
+               //resetHasChangedInfo (DBGVarList);                                                     // Reset the hasChanged info for all PHPVariables
+               //updateVariableList (DBGVarList, evalStr.getVariables ());     // Replicate the 'static' variable list and the via DBG received variable list
 
                return DBGVarList;                                                                                      // Return the variables as list
        }
@@ -748,9 +621,9 @@ public class PHPDBGInterface {
                        stackFrameNew = (PHPStackFrame) stackList.get(i);
 
                        for (n = 0; n < stackListOld.size (); n++) {                                    // For all StackFrames in the StackFrame list
-                               stackFrameOld = (PHPStackFrame) stackListOld.get (n);                   // ---
+                               stackFrameOld = (PHPStackFrame) stackListOld.get (n);                   //
 
-                               if (stackFrameNew.getModNo () == stackFrameOld.getModNo ()) {   // Did we find the sent stackframe within the list of old stackframes?
+                               if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ())) { // Did we find the sent stackframe within the list of old stackframes?
                                        stackFrameOld.setLineNumber (stackFrameNew.getLineNumber ());
                                        stackFrameOld.setIndex (stackFrameNew.getIndex ());
 
@@ -766,12 +639,12 @@ public class PHPDBGInterface {
                // And now for removing unused stackframes from list
 
                for (n = 0; n < stackListOld.size (); n++) {                                            // For all StackFrames in the StackFrame list
-                       stackFrameOld = (PHPStackFrame) stackListOld.get (n);                           // ---
+                       stackFrameOld = (PHPStackFrame) stackListOld.get (n);                           //
 
                        for (i = 0; i < stackList.size (); i++) {                                                       // For all stackList entries
                                stackFrameNew = (PHPStackFrame) stackList.get (i);
 
-                               if (stackFrameNew.getModNo () == stackFrameOld.getModNo ()) {   // Did we find the sent stackframe within the list of old stackframes?
+                               if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ())) { // Did we find the sent stackframe within the list of old stackframes?
                                        break;                                                                  //  Yes, then break;
                                }
                        }