Refactory.
authorincastrix <incastrix>
Sat, 27 Sep 2008 04:17:53 +0000 (04:17 +0000)
committerincastrix <incastrix>
Sat, 27 Sep 2008 04:17:53 +0000 (04:17 +0000)
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/XDebugConnection.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java

index aa5793d..96ae5c9 100644 (file)
@@ -1,6 +1,3 @@
-/**
- * 
- */
 package net.sourceforge.phpeclipse.xdebug.core.xdebug;
 
 import java.io.DataInputStream;
@@ -13,7 +10,6 @@ import java.net.Socket;
 import net.sourceforge.phpeclipse.xdebug.core.Base64;
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
-//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
 
 import org.eclipse.core.runtime.IStatus;
 
@@ -116,13 +112,7 @@ public class XDebugConnection {
        }
        
        private /*XDebugResponse*/ int sendRequest(String command, String arguments) {
-               int id = -1;
-               
-               id = _sendRequest(command, arguments);
-
-               //XDebugResponse response = getResponse(id);
-
-               return /*response*/ id;
+               return _sendRequest(command, arguments);
        }
 
        private synchronized int _sendRequest(String command, String arguments) {
@@ -153,39 +143,17 @@ public class XDebugConnection {
                return sendRequest("feature_get","-n "+featureName);
        }
 
-       public /*boolean*/ int  featureSet(String featureName, String value) {
-               //XDebugResponse id = sendRequest("feature_set","-n "+featureName + " -v " + value);
-
-               int id = sendRequest("feature_set","-n "+featureName + " -v " + value);
-               
-               return id;
-               /*XDebugResponse response = getResponse(id);
-
-               if (response.getAttributeValue("success").equals("1") )
-                       return true;
-               else
-                       return false;*/
-       }
-
-       /*protected XDebugResponse getResponse(int id) {
-               return fResponseList.get(id);
+       public int  featureSet(String featureName, String value) {
+               return sendRequest("feature_set","-n "+featureName + " -v " + value);
        }
 
-       protected void addResponse(XDebugResponse response, int id) {
-               fResponseList.add(response, id);
-       }*/
-       
        public /*XDebugResponse*/ int  breakpointSetOld(String file, int lineNumber) {
-               String arg;
-               
-               arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
+               String arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
                return sendRequest("breakpoint_set", arg);              
        }
        
        public /*XDebugResponse*/ int  breakpointSet(String file, int lineNumber, int hitCount) {
-               String arg;
-               
-               arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
+               String arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
                if (hitCount > 0) {
                        arg += " -h " + hitCount;       
                }
@@ -193,9 +161,8 @@ public class XDebugConnection {
        }
        
        public int  breakpointGet(int id) {
-               String arg;
+               String arg = "-d " + id;
                
-               arg = "-d " + id;
                return sendRequest("breakpoint_get", arg);              
        }
        
@@ -204,11 +171,7 @@ public class XDebugConnection {
        }
 
        public /*XDebugResponse*/ int  stackGet(/*int Level*/) {
-               /*if (Level > -1) {
-                       return sendRequest("stack_get", "-d " + Level);
-               } else {*/
-                       return sendRequest("stack_get", "");                    
-               //}
+               return sendRequest("stack_get", "");                    
        }
        
        public void stepOver() {
@@ -235,49 +198,28 @@ public class XDebugConnection {
                String str = Base64.encodeBytes(Value.getBytes());
                int len = str.length();
 
-               return sendRequest("property_set", "-n " + Name + " -l " + len + " -- " + str);
+               return sendRequest("property_set", "-n " + Name + " -d 0 -l " + len + " -- " + str);
        }
 
        public /*XDebugResponse*/ int  contextGet(int Level, int Type) {
                return sendRequest("context_get", "-d " + Level + " -c " + Type);
        }
 
-       public /*boolean*/int setVarValue(String Name, String Value) {
-               //XDebugResponse dr = propertySet(Name, Value);
-
-               int id = propertySet(Name, Value);
-               //XDebugResponse response = getResponse(id);
-               return id;
-               
-               /*if ((response.getAttributeValue("success")).equals("1"))
-                       return true;
-               
-               return false;*/
-       }
-       
-       /*public void startListener() {
-               fResponseListener.schedule();
+       public int setVarValue(String Name, String Value) {
+               return propertySet(Name, Value);
        }
        
-       public boolean stopListener() {
-               return fResponseListener.cancel();
-       }*/
-       
        public void close() {
                if (!fIsClosed) {
                        fIsClosed = true;
-                       //fResponseListener.cancel();
-                       //fResponseListener = null;
                        try {
                                fDebugSocket.close();
                                fDebugReader.close();
-                               fDebugReader = null;
+                               //fDebugReader = null;
                                fDebugWriter.close();
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
                }
-               //fResponseListener.cancel();
-               //fIsClosed=true;
        }       
 }
\ No newline at end of file
index b292684..4cacdd9 100644 (file)
@@ -6,13 +6,9 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
+import java.net.MalformedURLException;
 import java.net.URL;
 
-//import net.sourceforge.phpeclipse.xdebug.core.Base64;
-//import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
-//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
-//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
-
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.DebugException;
@@ -52,10 +48,21 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * @param data frame data
         * @param id stack frame id (0 is the bottom of the stack)
         */
-       public XDebugStackFrame(XDebugThread thread, int id) {
+       public XDebugStackFrame(XDebugThread thread, int id, String type, int lineNumber, String where, /*URL*/String filename) {
                super(thread == null ? null : (XDebugTarget) thread.getDebugTarget());
+               
                fId = id;
+               fLevel = id;
                fThread = thread;
+               fType = type;
+               fLineNumber = lineNumber;
+               fWhere = where;
+               
+               try {
+               fName = new URL(filename);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+               }
        }
        
        public void incrementStepCounter() {
@@ -139,8 +146,6 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * @see org.eclipse.debug.core.model.IStackFrame#getName()
         */
        public String getName() throws DebugException {
-               //String a = fName.getFile();
-               //return fName.lastSegment().toString()+"::"+fWhere+ " line: "+ fLineNumber;
                return fName.toString()+"::"+fWhere+ " line: "+ fLineNumber;
        }
        
@@ -339,7 +344,6 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * @see java.lang.Object#hashCode()
         */
        public int hashCode() {
-//             return getSourceName().hashCode() + fId;
                return getSourceName().hashCode() + fLevel;
        }
        
@@ -347,15 +351,9 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * 
         * @return this stack frame's unique identifier within its thread
         */
-       protected int getIdentifier() {
+       /*protected int getIdentifier() {
                return fId;
-       }
-
-
-       public void setFullName(URL name) {
-               fName = name;
-       }
-
+       }*/
 
        public URL getFullName() {
                return fName;
@@ -366,28 +364,15 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
                return fLevel;
        }
 
-       public void setLevel(int level) {
-               fLevel = level;
-               fId = level;
-       }
-
        public String getType() {
                return fType;
        }
 
-       public void setType(String type) {
-               fType = type;
-       }
-
        public String getWhere() {
                return fWhere;
        }
 
-       public void setWhere(String where) {
-               fWhere = where;
-       }
-
-       public void setLineNumber(int newlineNumber) {
-               fLineNumber = newlineNumber;
+       public boolean setVariableValue(XDebugVariable variable, String expression)  throws DebugException {
+               return ((XDebugTarget) getDebugTarget()).setVarValue("$" + variable.getName(), expression);
        }
 }
\ No newline at end of file
index 2257e84..c8de10f 100644 (file)
@@ -359,7 +359,6 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
         */
        public boolean isDisconnected() {
                return (false);
-//             return (fDebugConnection==null);
        }
 
        /* (non-Javadoc)
@@ -566,9 +565,9 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                fThreads = new IThread[0];
        }
        
-       public void handleProxyEvent(/*String ideKey,*/ XDebugConnection connection) {
+       public void handleProxyEvent(XDebugConnection connection) {
                setDebugConnection(connection);
-               System.out.println("* New Connection - XDebug.Target: " + fDebugConnection.getSessionID());
+               //System.out.println("* New Connection - XDebug.Target: " + fDebugConnection.getSessionID());
                
                fThread = new XDebugThread(this);
                fThreads = new IThread[] {fThread};
index a2a0f36..f169ccc 100644 (file)
@@ -102,18 +102,15 @@ public class XDebugVariable extends XDebugElement implements IVariable {
         * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
         */
        public void setValue(String expression) throws DebugException {
-               if(fValue.setValue(expression)) {
-                       
+               if (fFrame.setVariableValue(this, expression)) {
+                       fValue.setValue(expression);
                }
-                       //fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
-               //fValue.setValueA(expression);
        }
        
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
         */
        public void setValue(IValue value) throws DebugException {
-               //fValue.setValueB(value);
        }
 
        /* (non-Javadoc)