From: cperkonig Date: Sat, 10 Jul 2004 08:08:51 +0000 (+0000) Subject: Changes for variablemodificatin X-Git-Url: http://git.phpeclipse.com Changes for variablemodificatin --- diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java index 0f574b7..e0e19cc 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java @@ -22,7 +22,7 @@ import org.eclipse.debug.core.DebugException; import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame; import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable; -import net.sourceforge.phpdt.internal.debug.core.model.PHPValue; +import net.sourceforge.phpdt.internal.debug.core.model.PHPDBGEvalString; public class PHPDBGInterface { @@ -38,15 +38,12 @@ public class PHPDBGInterface { private PHPStackFrame[] DBGStackList; private PHPVariable[] DBGVariableList; private Vector DBGMods= new Vector(); - private Vector DBGVars= new Vector(); private BufferedReader in; private OutputStream os; - private boolean shouldStop= false, isRef= false, hasChildren= false, isObject= false; + private boolean shouldStop= false; private String evalRet= new String(""); private String serGlobals= new String(""); - private String typeRead= new String(""); - private String className= new String(""); - private int finalPos=0, refCounter=0, rawCounter=1000; + private int rawCounter=1000; private PHPDBGProxy proxy= null; private int lastCmd=-1; @@ -271,7 +268,9 @@ public class PHPDBGInterface { flushAllPackets(); // Process serialized variables - DBGVariableList= procVars(stack); + PHPDBGEvalString evalStr=new PHPDBGEvalString(stack,serGlobals); + + DBGVariableList= evalStr.getVars(); return DBGVariableList; } @@ -306,14 +305,14 @@ public class PHPDBGInterface { flushAllPackets(); } - public void evalBlock(String evalString) throws IOException, DebugException { + public PHPVariable[] evalBlock(PHPStackFrame stack, String evalString) throws IOException, DebugException { PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST); PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_EVAL); PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA); rawCounter++; DBGFrame1.addInt(rawCounter); // istr = raw data ID - DBGFrame1.addInt(-1); // scope_id = -1 means current location, 0 never used, +1 first depth + DBGFrame1.addInt(1); // scope_id = -1 means current location, 0 never used, +1 first depth DBGFrame2.addInt(rawCounter); // FRAME_RAWDATA ID DBGFrame2.addInt(evalString.length() + 1); // length of rawdata (+ null char) @@ -325,11 +324,16 @@ public class PHPDBGInterface { // Add command data DBGPacket.addFrame(DBGFrame1); - if(proxy.getSocket().isClosed()) return; + if(proxy.getSocket().isClosed()) return null; DBGPacket.sendPacket(os); waitResponse(1000); flushAllPackets(); + + PHPDBGEvalString evalStr=new PHPDBGEvalString(stack,evalRet); + + return evalStr.getVars(); + } public void flushAllPackets() throws IOException { @@ -389,227 +393,6 @@ public class PHPDBGInterface { return ""; } - public PHPVariable[] getInstVars(PHPVariable phpVar) throws DebugException { - Vector vecVars= new Vector(); - PHPVariable localPHPVar; - int i=0; - - // already unserialized - for(i=0; i < DBGVars.size(); i++) { - localPHPVar= (PHPVariable)DBGVars.get(i); - if(localPHPVar.getParent() == phpVar) { - vecVars.add(localPHPVar); - } - } - PHPVariable[] arrVars= new PHPVariable[vecVars.size()]; - arrVars= (PHPVariable[]) vecVars.toArray(arrVars); - - return arrVars; - } - - private PHPVariable[] procVars(PHPStackFrame stack) throws DebugException { - Vector vecVars= new Vector(); - - // unserialize - finalPos= 0; - refCounter= 0; - doUnserialize(stack, vecVars, null); - - DBGVars= vecVars; - - return(getInstVars(null)); - } - - private String readValue(String serialVars) throws DebugException { - int startPos=0, endPos=0, lenStr=0, i=0, elements=0; - String ret= new String(""); - - switch(serialVars.charAt(0)) { - case 'a': // associative array, a:elements:{[index][value]...} - typeRead= "hash"; - startPos= 1; - endPos= serialVars.indexOf(':', startPos + 1); - if(endPos == -1) return ""; - finalPos += endPos + 2; - ret= new String(serialVars.substring(startPos + 1, endPos)); - - hasChildren= true; - break; - case 'O': // object, O:name_len:"name":elements:{[attribute][value]...} - typeRead= "object"; - - startPos= 1; - endPos= serialVars.indexOf(':', startPos + 1); - if(endPos == -1) return ""; - - // get object class - lenStr= Integer.parseInt(serialVars.substring(startPos + 1, endPos)); - startPos= endPos + 2; - endPos= lenStr + startPos; - className= new String(serialVars.substring(startPos, endPos).toString()); - - // get num of elements - startPos= endPos + 1; - endPos= serialVars.indexOf(':', startPos + 1); - if(endPos == -1) return ""; - finalPos += endPos + 2; - ret= new String(serialVars.substring(startPos + 1, endPos)); - - isObject= true; - hasChildren= true; - break; - case 's': // string, s:length:"data"; - typeRead= "string"; - startPos= 1; - endPos= serialVars.indexOf(':', startPos + 1); - if(endPos == -1) return ""; - - lenStr= Integer.parseInt(serialVars.substring(startPos + 1, endPos)); - startPos= endPos + 2; - endPos= lenStr + startPos; - ret= new String(serialVars.substring(startPos, endPos).toString()); - finalPos += endPos + 2; - break; - case 'i': // integer, i:123; - typeRead= "integer"; - startPos= 1; - endPos= serialVars.indexOf(';', startPos + 1); - if(endPos == -1) return ""; - - ret= new String(serialVars.substring(startPos + 1, endPos).toString()); - finalPos += endPos + 1; - break; - case 'd': // double (float), d:1.23; - typeRead= "double"; - startPos= 1; - endPos= serialVars.indexOf(';', startPos + 1); - if(endPos == -1) return ""; - - ret= new String(serialVars.substring(startPos + 1, endPos).toString()); - finalPos += endPos + 1; - break; - case 'N': // NULL, N; - typeRead= "null"; - ret= "nil"; - finalPos += 2; - break; - case 'b': // bool, b:0 or 1 - typeRead= "boolean"; - ret= (serialVars.charAt(2) == '1')?"true":"false"; - finalPos += endPos + 4; - break; - case 'z': // resource, z:typename_len:"typename":valres; - typeRead= "resource"; - - startPos= 1; - endPos= serialVars.indexOf(':', startPos + 1); - if(endPos == -1) return ""; - - // get resource type name - lenStr= Integer.parseInt(serialVars.substring(startPos + 1, endPos)); - startPos= endPos + 2; - endPos= lenStr + startPos; - className= new String(serialVars.substring(startPos, endPos).toString()); - - // get resource value - startPos= endPos + 1; - endPos= serialVars.indexOf(';', startPos + 1); - if(endPos == -1) return ""; - ret= new String(serialVars.substring(startPos + 1, endPos)); - finalPos += endPos + 1; - break; - case 'r': - case 'R': - typeRead= "reference"; - startPos= 1; - endPos= serialVars.indexOf(';', startPos + 1); - if(endPos == -1) return "0"; - - ret= new String(serialVars.substring(startPos + 1, endPos)); - finalPos += endPos + 1; - isRef= true; - break; - case ';': - typeRead= "unknown"; - finalPos+= 1; - break; - case '?': - finalPos+= 1; - default: - finalPos+= 1; - typeRead= "unknown"; - break; - } - return ret; - } - - private void doUnserialize(PHPStackFrame stack, Vector vecVars, PHPVariable parent) throws DebugException { - int i, elements= 0; - PHPVariable newVar= null; - String value= new String(""); - String name= new String(""); - String tmp= new String(""); - String[] tmpSplit; - - if(finalPos > serGlobals.length() || serGlobals.equals("") || serGlobals.substring(finalPos).equals("")) return; - - isRef= false; - hasChildren= false; - isObject= false; - name= readValue(serGlobals.substring(finalPos)); - - if(hasChildren) { - // main array - if(refCounter == 0) { - value= name; - name= ""; - } - } else { - hasChildren= false; - isRef= false; - value= readValue(serGlobals.substring(finalPos)); - // replaceAll doesn't work, why??? - tmpSplit= value.split("\\\\"); - value= ""; - for(i= 0; i < tmpSplit.length; i++) { - value= value + tmpSplit[i]; - if(!tmpSplit[i].equals("")) { - if(i < (tmpSplit.length - 1)) { - value= value + "\\"; - } - } - } - } - - if(!name.equals("")) { - if(isRef) { - PHPVariable varPHP; - for(i=0; i < vecVars.size(); i++) { - varPHP= (PHPVariable) vecVars.get(i); - if(varPHP.getObjectId().equals(value)) { - newVar= new PHPVariable(stack, name, "local", true, (PHPValue)varPHP.getValue()); - break; - } - } - if(newVar == null) { - newVar= new PHPVariable(stack, name, "local", false, null); - } - } else { - refCounter++; - newVar= new PHPVariable(stack, name, "local", value, typeRead, hasChildren, Integer.toString(refCounter), className); - } - newVar.setParent(parent); - vecVars.add(newVar); - } - if(hasChildren) { - elements= Integer.parseInt(value); - for(i=0; i < elements; i++) - doUnserialize(stack, vecVars, newVar); - - // skip "}" - finalPos += 1; - } - } public int readResponse() throws IOException { int bytesToRead=0, nextFrame=0, i=0, cmdReceived=0, stackIndex=0; @@ -747,11 +530,11 @@ public class PHPDBGInterface { // TODO: Find a better way???? String codeExec= ""; codeExec= "fwrite(fopen('php://stderr', 'w'),\\\"" + error + "\\\");"; - try { - evalBlock("eval(\"" + codeExec + "\");"); - } catch (DebugException e) { - PHPDebugCorePlugin.log(e); - } +// try { +// evalBlock("eval(\"" + codeExec + "\");"); +// } catch (DebugException e) { +// PHPDebugCorePlugin.log(e); +// } if(!stopOnError) { if(lastCommand.equals(PHPDBGBase.DBGA_CONTINUE)) { continueExecution(); diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java index ad51716..1c73cf9 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java @@ -228,15 +228,18 @@ public class PHPDBGProxy { throw new RuntimeException(ex.getMessage()); } } - - public PHPVariable[] readInstanceVariables(PHPVariable variable) { + + public PHPVariable[] eval(PHPStackFrame frame,String evalString) { try { - return DBGInt.getInstVars(variable); + return DBGInt.evalBlock(frame,evalString); + // return DBGInt.getVariables(frame); + } catch (IOException ioex) { + ioex.printStackTrace(); + throw new RuntimeException(ioex.getMessage()); } catch (DebugException ex) { ex.printStackTrace(); throw new RuntimeException(ex.getMessage()); } - } public void readStepOverEnd(PHPStackFrame stackFrame) { diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java index beca6a3..ba349af 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java @@ -8,55 +8,93 @@ http://www.eclipse.org/legal/cpl-v10.html Contributors: IBM Corporation - Initial implementation Vicente Fernando - www.alfersoft.com.ar + Christian Perkonig - cperkonig@gmx.at **********************************************************************/ package net.sourceforge.phpdt.internal.debug.core.model; + +import java.util.Iterator; +import java.util.Vector; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IVariable; -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class PHPValue implements IValue { - private String valueString ; - private String referenceTypeName ; - private boolean hasChildren= false ; - private PHPVariable owner ; - private PHPVariable[] variables ; +public class PHPValue implements IValue { + + final static String[] PEV_NAMES={"undefined","long","double","string","array", + "object","boolean","resource","reference","soft reference"}; + final static int PEVT_UNKNOWN =0; + final static int PEVT_LONG = 1; + final static int PEVT_DOUBLE=2; + final static int PEVT_STRING=3; + final static int PEVT_ARRAY=4; + final static int PEVT_OBJECT=5; + final static int PEVT_BOOLEAN=6; + final static int PEVT_RESOURCE=7; + final static int PEVT_REF=8; + final static int PEVT_SOFTREF=9; + + private int fValueType; + private boolean hasChildren; + private String fValueString; + private Vector fVariables; + private PHPStackFrame fStackFrame; - public PHPValue(PHPVariable owner) { - this(owner, "nil", null, false) ; - } + PHPValue() { + this(null,"",PEVT_UNKNOWN,null); + } + + PHPValue(PHPStackFrame frame,String value,int fValueType,Vector subitems) + { + this.fValueType=fValueType; + this.fValueString=value; + this.fStackFrame=frame; + if (subitems !=null) + this.fVariables=new Vector(subitems); + else + this.fVariables = new Vector(); + } - public PHPValue(PHPVariable owner, String valueString, String type, boolean hasChildren) { - this.valueString = valueString ; - this.owner = owner ; - this.hasChildren = hasChildren ; - this.referenceTypeName = type ; + Vector addVariable(Vector item) + { + if (item!=null) + this.fVariables.addAll(item); + return this.fVariables; } + public void setParent(PHPVariable parent) { + if (!fVariables.isEmpty()) { + Iterator iter=fVariables.iterator(); + while (iter.hasNext()) { + ((PHPVariable)iter.next()).setParent(parent); + } + + } + } /** * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName() */ - public String getReferenceTypeName() { - return this.referenceTypeName; + public String getReferenceTypeName(){ + return PEV_NAMES[fValueType]; + } + + public int getReferenceType(){ + return fValueType; + } + + public int setReferenceType(int type){ + return fValueType=type; } /** - * @see org.eclipse.debug.core.model.IValue#getValueString() + * @see org.eclipse.debug.core.model.IValue#getfValueString() */ public String getValueString() { - return valueString; + return fValueString; } /** @@ -69,56 +107,45 @@ public class PHPValue implements IValue { /** * @see org.eclipse.debug.core.model.IValue#getVariables() */ - public IVariable[] getVariables() throws DebugException { - if (!hasChildren) { - return new PHPVariable[0] ; - } - if (variables == null) { - variables = ((PHPDebugTarget) this.getDebugTarget()).getPHPDBGProxy().readInstanceVariables(owner); - } - return variables; + public IVariable[] getVariables() { + return (PHPVariable[])fVariables.toArray(new PHPVariable[fVariables.size()]); +// return (IVariable[])fVariables.toArray(); } /** * @see org.eclipse.debug.core.model.IValue#hasVariables() */ public boolean hasVariables() throws DebugException { - return hasChildren; + return (!fVariables.isEmpty()); } /** * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() */ public String getModelIdentifier() { - return owner.getModelIdentifier(); + // TODO Auto-generated method stub + return null; } - /** + /** * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() */ public IDebugTarget getDebugTarget() { - return owner.getDebugTarget(); + return fStackFrame.getDebugTarget(); } /** * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() */ public ILaunch getLaunch() { - return this.getDebugTarget().getLaunch(); + return getDebugTarget().getLaunch(); } /** - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class adapter) { return null; } - - public String toString() { - if (this.getReferenceTypeName() == null) { - return this.getValueString() ; - } - return this.getValueString() ; - } } diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java index 7534052..fdb3b81 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java @@ -8,9 +8,12 @@ http://www.eclipse.org/legal/cpl-v10.html Contributors: IBM Corporation - Initial implementation Vicente Fernando - www.alfersoft.com.ar + Christian Perkonig - cperkonig@gmx.at **********************************************************************/ package net.sourceforge.phpdt.internal.debug.core.model; +import java.util.Vector; + import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; @@ -20,130 +23,163 @@ import org.eclipse.debug.core.model.IVariable; public class PHPVariable implements IVariable { - private boolean isBoolean; - private boolean isString; - private boolean isResource; - private boolean isObject; - private boolean isLocal; - private PHPStackFrame stackFrame; - private String name; - private String objectId; - private String className; - private PHPValue value; - private PHPVariable parent; - - public PHPVariable(PHPStackFrame stackFrame, String name, String scope) { - this.initialize(stackFrame, name, scope, null, new PHPValue(this), "", "string"); - } - - public PHPVariable(PHPStackFrame stackFrame, String name, String scope, String value, String type, boolean hasChildren, String objectId, String className) { - this.initialize(stackFrame, name, scope, objectId, new PHPValue(this, value, type, hasChildren), className, type); - } - - public PHPVariable(PHPStackFrame stackFrame, String name, String scope, boolean isRef, PHPValue varPHP) { - if(isRef) - this.initialize(stackFrame, name, scope, "-1", varPHP, "", "string"); - else - this.initialize(stackFrame, name, scope, "-1", new PHPValue(this), "", "string"); - } - - protected final void initialize(PHPStackFrame stackFrame, String name, String scope, String objectId, PHPValue value, String className, String typeName) { - this.stackFrame = stackFrame; - this.value = value; - this.name = name; - this.objectId = objectId; - // scope - this.isLocal = scope.equals("local"); - // type - this.isObject = typeName.equals("object"); - this.isResource = typeName.equals("resource"); - this.isBoolean = typeName.equals("boolean"); - this.isString = typeName.equals("string"); - - this.className = className; - } - - /** - * @see org.eclipse.debug.core.model.IVariable#getValue() - */ - public IValue getValue() { - return value; - } - - /** - * @see org.eclipse.debug.core.model.IVariable#getName() - */ - public String getName() { - return name; - } + + private PHPValue fValue; + private String fName; + private PHPStackFrame fStackFrame; + private PHPVariable fParent; + private String fLongName; + + PHPVariable(){ + this(null,"",null,"",PHPValue.PEVT_UNKNOWN,null); + } + + PHPVariable(PHPStackFrame frame,String name, PHPVariable parent,String value,int valueType,Vector subitems) + { + this.fStackFrame=frame; + this.fValue=new PHPValue(frame,value,valueType,subitems); + this.fParent=parent; + setName(name); + } + + private void setName(String name) { + if ((fParent==null) || (fParent.getName()=="")) { + fLongName=name; + fName=name; + return; + } + switch (fParent.getReferenceType()) { + case PHPValue.PEVT_ARRAY : + fName="['"+name+"']"; + fLongName=fParent.getLongName()+fName; + break; + case PHPValue.PEVT_OBJECT : + fName=name; + fLongName=fParent.getLongName()+"."+fName; + break; + default : + fName=name; + fLongName=name; + break; + } + } + /** + * @see org.eclipse.debug.core.model.IVariable#getValue() + */ + public IValue getValue() { + return fValue; + } - /** - * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName() - */ - public String getReferenceTypeName() { - return "RefTypeName"; - } + /** + * @see org.eclipse.debug.core.model.IVariable#getfName() + */ + public String getName() { + return fName; + } + + public PHPVariable getParent() + { + return fParent; + } + + public void setParent(PHPVariable parent) + { + this.fParent=parent; + fLongName=parent.getLongName()+fName; + } + + public String getLongName() { + return fLongName; + } - /** - * @see org.eclipse.debug.core.model.IVariable#hasValueChanged() - */ - public boolean hasValueChanged() throws DebugException { - return false; - } + /** + * @see org.eclipse.debug.core.model.IVariable#getReferenceTypefName() + */ + public String getReferenceTypeName() { + return fValue.getReferenceTypeName(); + } + + public int getReferenceType() { + return fValue.getReferenceType(); + } + + public int setReferenceType(int type) { + return ((PHPValue) getValue()).setReferenceType(type); + } - /** + /** + * @see org.eclipse.debug.core.model.IVariable#hasValueChanged() + */ + public boolean hasValueChanged() throws DebugException { + // TODO Auto-generated method stub + return false; + } + + /** * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() */ public String getModelIdentifier() { - return this.getDebugTarget().getModelIdentifier(); + return getDebugTarget().getModelIdentifier(); } /** * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() */ public IDebugTarget getDebugTarget() { - return stackFrame.getDebugTarget(); + return fStackFrame.getDebugTarget(); } /** * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() */ public ILaunch getLaunch() { - return this.getDebugTarget().getLaunch(); + return getDebugTarget().getLaunch(); } - /** - * @see org.eclipse.debug.core.model.IValueModification#setValue(String) - */ - public void setValue(String expression) throws DebugException { - } - /** - * @see org.eclipse.debug.core.model.IValueModification#setValue(IValue) - */ - public void setValue(IValue value) throws DebugException { - } + /** + * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String) + */ + public void setValue(String expression) throws DebugException { + String evalString; + if(fValue.getReferenceType()==PHPValue.PEVT_STRING) + evalString=fLongName+"=\""+expression+"\""; + else + evalString=fLongName+"="+expression; + PHPVariable[] vars=fStackFrame.getPHPDBGProxy().eval(fStackFrame,evalString); + setValue(vars[0].fValue); + } - /** - * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification() - */ - public boolean supportsValueModification() { - return false; - } + /** + * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue) + */ + public void setValue(IValue value) throws DebugException { + // TODO Auto-generated method stub + this.fValue=(PHPValue)value; + } - /** - * @see org.eclipse.debug.core.model.IValueModification#verifyValue(String) - */ - public boolean verifyValue(String expression) throws DebugException { - return false; - } + /** + * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification() + */ + public boolean supportsValueModification() { + return true; + } - /** - * @see org.eclipse.debug.core.model.IValueModification#verifyValue(IValue) - */ - public boolean verifyValue(IValue value) throws DebugException { - return false; - } + /** + * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String) + */ + public boolean verifyValue(String expression) throws DebugException { + // TODO Auto-generated method stub + return true; + } + + /** + * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue) + */ + public boolean verifyValue(IValue value) throws DebugException { + // TODO Auto-generated method stub + return false; + } /** * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) @@ -151,78 +187,40 @@ public class PHPVariable implements IVariable { public Object getAdapter(Class adapter) { return Platform.getAdapterManager().getAdapter(this, adapter); } - + public String toString() { + int type=-1; + String str=""; - if(this.isObject()) { - return this.getName() + " [class: " + this.getClassName() + "]"; - } else if(this.isResource()) { - return this.getName() + " [resource: " + this.getClassName() + "] = " + ((PHPValue) this.getValue()); - } else if (this.isHashValue()) { - int elements= Integer.parseInt(((PHPValue) this.getValue()).getValueString()); - switch (elements) { + switch (getReferenceType()) + { + case PHPValue.PEVT_ARRAY : + int elements=fValue.getVariables().length; + switch (elements) { case 0: - return this.getName() + " [no elements]"; + str= this.getName() + " [no elements]"; + break; case 1: - return this.getName() + " [1 element]"; + str= this.getName() + " [1 element]"; + break; default: - return this.getName() + " [" + elements + " elements]"; - } - } else { - return this.getName() + " = " + ((PHPValue) this.getValue()); - } - - } - - public PHPStackFrame getStackFrame() { - return stackFrame; - } - - public PHPVariable getParent() { - return parent; - } - - public void setParent(PHPVariable parent) { - this.parent = parent; - } - - public String getQualifiedName() { - return this.getName(); - } - - public boolean isBoolean() { - return isBoolean; - } - - public boolean isResource() { - return isResource; - } - - public boolean isString() { - return isString; - } - - public boolean isLocal() { - return isLocal; - } - - public boolean isObject() { - return isObject; - } - - public String getObjectId() { - return objectId; - } - - public boolean isHashValue() { - try { - return ((PHPValue) this.getValue()).hasVariables(); - } catch (DebugException e) { - return false; - } + str= this.getName() + " [" + elements + " elements]"; + break; + } + break; + case PHPValue.PEVT_OBJECT : + str =this.getName() + " [class: " + fValue.getValueString() + "]"; + break; + case PHPValue.PEVT_STRING : + str =this.getName() + " = \"" + fValue.getValueString() +"\"" ; + break; + case PHPValue.PEVT_SOFTREF : + default : + str =this.getName() + " = " + fValue.getValueString(); + break; + } + + return str; + } - - public String getClassName() { - return className; - } }