*/
package net.sourceforge.phpeclipse.xdebug.php.model;
+//import java.io.ByteArrayInputStream;
+//import java.io.IOException;
import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import net.sourceforge.phpeclipse.xdebug.core.IPHPDebugEvent;
import net.sourceforge.phpeclipse.xdebug.core.IProxyEventListener;
import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IThread;
+import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+//import org.xml.sax.SAXException;
import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener;
import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugResponse;
/**
* @author Christian
fSuspended = false;
XDebugCorePlugin.getBreakpointManager().removeBreakpointListener(this);
- fThread.fireTerminateEvent();
+ fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
DebugPlugin.getDefault().removeDebugEventListener(this);
}
}
*/
public boolean isDisconnected() {
return (false);
-// return (fDebugConnection==null);
}
/* (non-Javadoc)
}
}
- public Node eval(String expression) {
- int id = fDebugConnection.eval(expression);
- XDebugResponse response = getResponse(id);
-
- Node evalResponse = response.getParentNode();
- Node evalProperty = evalResponse.getFirstChild();
+ public Node eval(String expression) throws DebugException {
+ Node evalProperty = null;
+ if (fDebugConnection != null) {
+ int id = fDebugConnection.eval(expression);
+ //Node evalProperty = new Node("");
+ //if (id > 0) {
+ XDebugResponse response = getResponse(id);
+
+ Node evalResponse = response.getParentNode();
+ /*Node*/ evalProperty = evalResponse.getFirstChild();
+ //} /*else {
+
+ //}*/
+ } else {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = null;
+ Document doc = null;
+
+ try {
+ builder = factory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ }
+ //try {
+ doc = builder.newDocument(); // .parse("");
+ evalProperty = doc.createElement("value");
+ /*} catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }*/
+ }
return evalProperty;
}
fThreads = new IThread[0];
}
- public void handleProxyEvent(/*String ideKey,*/ XDebugConnection connection) {
- setDebugConnection(connection);
- System.out.println("* New Connection - XDebug.Target: " + fDebugConnection.getSessionID());
+ public void handleProxyEvent(XDebugConnection connection) {
+ //System.out.println("* New Connection - XDebug.Target: " + fDebugConnection.getSessionID());
- fThread = new XDebugThread(this);
- fThreads = new IThread[] {fThread};
- fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
- try {
- started();
- } catch( DebugException e ){
- e.printStackTrace();
- }
+ if (setDebugConnection(connection)) {
+ fThread = new XDebugThread(this);
+ fThreads = new IThread[] {fThread};
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
+ try {
+ started();
+ } catch( DebugException e ){
+ e.printStackTrace();
+ }
+ }
}
- private void setDebugConnection(XDebugConnection connection) {
- if (connection != null) {
+ private boolean setDebugConnection(XDebugConnection connection) {
+ if (connection != null && fDebugConnection == null) {
fDebugConnection = connection;
fResponseListener = new ResponseListener(connection);
startListener();
+
+ return true;
+ } else {
+ connection.close();
+
+ return false;
}
}