X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java index f8c54bd..240ec9c 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java @@ -8,34 +8,19 @@ package net.sourceforge.phpeclipse.xdebug.php.model; import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils; -//import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugException; -//import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IVariable; import org.w3c.dom.Node; -//import org.eclipse.debug.core.model.IWatchExpressionDelegate; + /** * @author Axel * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ -public class XDebugVariable extends XDebugElement implements IVariable/*, IWatchExpressionFactoryAdapter*/ { - /*public static final int VARTYPE_UNKNOWN = -1; - public static final int VARTYPE_UNINITIALIZED = 0; - public static final int VARTYPE_STRING = 1; - public static final int VARTYPE_INT = 2; - public static final int VARTYPE_FLOAT = 3; - public static final int VARTYPE_ARRAY = 8; - public static final int VARTYPE_HASH = 9; - public static final int VARTYPE_OBJECT = 10; - public static final int VARTYPE_RESOURCE = 11;*/ - - private int fNumChildren; +public class XDebugVariable extends XDebugElement implements IVariable { private String fName; - private String fFullName; - private String fEncoding; private XDebugStackFrame fFrame; private XDebugAbstractValue fValue; private String fFacet; @@ -47,51 +32,37 @@ public class XDebugVariable extends XDebugElement implements IVariable/*, IWatc * @param frame owning stack frame * @param name variable name */ - public XDebugVariable(XDebugStackFrame frame, Node property) { + public XDebugVariable(XDebugStackFrame frame, Node property) throws DebugException { + super((XDebugTarget) frame.getDebugTarget()); if (frame != null ) { - //super((XDebugTarget) frame.getDebugTarget()); fFrame = frame; } - String address = PHPDebugUtils.getAttributeValue(property,"address"); - fName = PHPDebugUtils.getAttributeValue(property,"name"); if ("".equals(fName)) { - fName = address; - } /*else { - varName = Name; - }*/ - - fFullName = PHPDebugUtils.getAttributeValue(property,"fullname"); - fEncoding = PHPDebugUtils.getAttributeValue(property,"encoding"); - if (PHPDebugUtils.getAttributeValue(property,"numchildren").equals("")) { - fNumChildren = 0; - } else { - fNumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(property, "numchildren")); + fName = PHPDebugUtils.getAttributeValue(property,"address"); } + + fFacet = PHPDebugUtils.getAttributeValue(property, "facet"); String typeName = PHPDebugUtils.getAttributeValue(property, "type"); - fFacet = PHPDebugUtils.getAttributeValue(property, "facet"); - if (typeName.equals("int") ) - fValue= new XDebugIntValue(this,property,typeName); + fValue = new XDebugIntValue(frame, property); else if (typeName.equals("float") ) - fValue= new XDebugFloatValue(this,property,typeName); + fValue = new XDebugFloatValue(frame, property); else if (typeName.equals("bool") ) - fValue= new XDebugBooleanValue(this,property,typeName); + fValue = new XDebugBooleanValue(frame, property); else if (typeName.equals("string") ) - fValue= new XDebugStringValue(this,property,typeName); + fValue = new XDebugStringValue(frame, property); else if (typeName.equals("array") ) - fValue= new XDebugArrayValue(this,property,typeName); - else if (typeName.equals("hash") ) - fValue= new XDebugArrayValue(this,property,typeName); + fValue = new XDebugArrayValue(frame, property); else if (typeName.equals("object") ) - fValue= new XDebugArrayValue(this,property,typeName); + fValue = new XDebugObjectValue(frame, property); else if (typeName.equals("resource") ) - fValue= new XDebugResourceValue(this, property, typeName); + fValue = new XDebugResourceValue(frame, property); else - fValue= new XDebugValue(this,property,typeName); + fValue = new XDebugValue(frame, property); } /* (non-Javadoc) @@ -99,17 +70,13 @@ public class XDebugVariable extends XDebugElement implements IVariable/*, IWatc */ public IValue getValue() throws DebugException { return fValue; -// return ((XDebugTarget)getDebugTarget()).getVariableValue(this); } /* (non-Javadoc) * @see org.eclipse.debug.core.model.IVariable#getName() */ public String getName() throws DebugException { - if (fFullName.endsWith("]")) - return fFullName.substring(fFullName.lastIndexOf('[')); - else - return fName; + return fName; } /* (non-Javadoc) @@ -130,18 +97,15 @@ public class XDebugVariable extends XDebugElement implements IVariable/*, IWatc * @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) @@ -155,7 +119,7 @@ public class XDebugVariable extends XDebugElement implements IVariable/*, IWatc * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String) */ public boolean verifyValue(String expression) throws DebugException { - return fValue.verifyValue(expression); + /*return true; */return fValue.verifyValue(expression); } /* (non-Javadoc) @@ -165,116 +129,11 @@ public class XDebugVariable extends XDebugElement implements IVariable/*, IWatc return false; } - /** - * Returns the stack frame owning this variable. - * - * @return the stack frame owning this variable - */ - protected XDebugStackFrame getStackFrame() { - return fFrame; - } - -// public int getType() { -// return fType; -// } - public String getValueString() throws DebugException { return fValue.getValueString(); } - /*public setValueString(String newValueStrig) throws DebugException { - fValue.setValueString getValueString(); - }*/ - - public boolean hasChildren() { - return (fNumChildren > 0); - } - - public String getEncoding() { - return fEncoding; - } - public String getVisibility() { return fFacet; } - - public void setEncoding(String encoding) { - fEncoding = encoding; - } - - public String toString() { - return null; - } - - public String getFullName() { - return fFullName; - } - - public int getNumChildren() { - return fNumChildren; - } - - public void setChange(IVariable oldVariable) throws DebugException { - XDebugAbstractValue oldValue = null; - IVariable[] newVariable = null; - IVariable[] oldVariable1 = null; - - try { - oldValue = (XDebugAbstractValue) oldVariable.getValue(); - } catch (DebugException e) { - } - - try { - oldVariable1 = ((XDebugVariable)oldVariable).getValue().getVariables(); - newVariable = fValue.getVariables(); - } catch (DebugException e) { - } - - - if(((XDebugVariable) oldVariable).getNumChildren() > 0) { - if ( this.getNumChildren() == 0) { - try { - if (!fValue.getValueString().equals(((XDebugAbstractValue)oldValue).getValueString())) { - fValue.sethasChanged(true); - } else { - fValue.sethasChanged(false); - } - } catch (DebugException e) { - } - } else { - for(int i = 0; i < newVariable.length; i++) { - ((XDebugVariable)newVariable[i]).setChange(((XDebugVariable)oldVariable1[i])); - } - } - } else { - if ( this.getNumChildren() == 0) { - // controllare anche il tipo (unknow) - //if (!fValue.getValueString().equals("uninitialized")) { - if (!fValue.getValueString().equals(oldValue.getValueString())) { - fValue.sethasChanged(true); - } else { - fValue.sethasChanged(false); - } - } else { - //IVariable dummy = new XDebugVariable("UNKNOWN", ""); - /*dummy.setValue("uninitialized"); - for(int i = 0; i < newVariable.length; i++) { - ((XDebugVariable)newVariable[i]).setChange(dummy); - } - fValue.sethasChanged(true);*/ - } - } - } - /** - * Creates and returns an expression for the specified variable - * which is used to created an {@link org.eclipse.debug.core.model.IWatchExpression}. - * - * @param variable variable a watch expression is required for - * @return text used to create a watch expression - * @exception org.eclipse.core.runtime.CoreException if unable to create a watch - * expression - */ - /*public String createWatchExpression(IVariable variable) throws CoreException { - - }*/ } \ No newline at end of file