From e05bf9e1819e284bfcbe7575d4fa972375329442 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 14 Mar 2003 23:12:21 +0000 Subject: [PATCH] Added the 'isEditable' and 'hasChildren' methods to the 'ICVariable' interface. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 6 +++ .../cdt/debug/core/model/ICVariable.java | 4 ++ .../core/model/CModificationVariable.java | 24 +--------- .../debug/internal/core/model/CVariable.java | 44 ++++++++++++++++--- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 6c1ee6b84d5..5e22d0d4823 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2003-03-14 Mikhail Khodjaiants + Added the 'isEditable' and 'hasChildren' methods to the 'ICVariable' interface. + * ICVariable.java + * CVariable.java + * CModificationVariable.java + 2003-03-14 Mikhail Khodjaiants Cross-referencing projects cause the debugger to go into a stack overflow exception. Make sure that there is only one source location for each referenced project. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICVariable.java index 66cd16da22b..6f29b010317 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICVariable.java @@ -21,4 +21,8 @@ public interface ICVariable extends IVariable void setFormat( int format ) throws DebugException; void refresh() throws DebugException; + + boolean isEditable(); + + boolean hasChildren(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java index 0842eccb2b7..04665a00679 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java @@ -24,8 +24,6 @@ import org.eclipse.debug.core.model.IValue; */ public abstract class CModificationVariable extends CVariable { - private Boolean fEditable = null; - /** * Constructor for CModificationVariable. * @param parent @@ -41,26 +39,8 @@ public abstract class CModificationVariable extends CVariable */ public boolean supportsValueModification() { - if ( fEditable == null ) - { - CDebugTarget target = (CDebugTarget)getDebugTarget().getAdapter( CDebugTarget.class ); - if ( target != null && !target.isCoreDumpTarget() ) - { - try - { - fEditable = new Boolean( getCDIVariable().isEditable() ); - } - catch( CDIException e ) - { - logError( e ); - } - } - else - { - fEditable = new Boolean( false ); - } - } - return ( fEditable != null ) ? fEditable.booleanValue() : false; + CDebugTarget target = (CDebugTarget)getDebugTarget().getAdapter( CDebugTarget.class ); + return ( target != null && !target.isCoreDumpTarget() && isEditable() ); } /** diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index 4b34e7e75ca..e302db25269 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -57,6 +57,8 @@ public abstract class CVariable extends CDebugElement */ protected ICValue fValue; + private Boolean fEditable = null; + /** * Counter corresponding to this variable's debug target * suspend count indicating the last time this value @@ -436,6 +438,7 @@ public abstract class CVariable extends CDebugElement ((CValue)fValue).dispose(); fValue = null; } + fEditable = null; fTypeName = null; fireChangeEvent( DebugEvent.STATE ); } @@ -471,6 +474,7 @@ public abstract class CVariable extends CDebugElement ((CValue)fValue).dispose(); fValue = null; } + fEditable = null; fTypeName = null; fireChangeEvent( DebugEvent.STATE ); } @@ -480,7 +484,8 @@ public abstract class CVariable extends CDebugElement */ public boolean supportsCasting() { - return supportsValueModification(); + CDebugTarget target = (CDebugTarget)getDebugTarget().getAdapter( CDebugTarget.class ); + return ( target != null && isEditable() ); } protected ICDIVariable getOriginalCDIVariable() @@ -502,8 +507,7 @@ public abstract class CVariable extends CDebugElement { try { - ICDIVariableObject originalVarObject = getCDISession().getVariableManager().getVariableObject( cdiFrame, getOriginalCDIVariable().getName() ); - ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsType( originalVarObject, type ); + ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsType( getOriginalCDIVariable(), type ); return getCDISession().getVariableManager().createVariable( varObject ); } catch( CDIException e ) @@ -517,8 +521,7 @@ public abstract class CVariable extends CDebugElement { try { - ICDIVariableObject originalVarObject = getCDISession().getVariableManager().getVariableObject( cdiFrame, getOriginalCDIVariable().getName() ); - ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsArray( originalVarObject, type, start, end ); + ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsArray( getOriginalCDIVariable(), type, start, end ); return getCDISession().getVariableManager().createVariable( varObject ); } catch( CDIException e ) @@ -572,6 +575,7 @@ public abstract class CVariable extends CDebugElement ((CValue)fValue).dispose(); fValue = null; } + fEditable = null; fTypeName = null; fireChangeEvent( DebugEvent.STATE ); } @@ -581,10 +585,19 @@ public abstract class CVariable extends CDebugElement * @see org.eclipse.cdt.debug.core.model.ICastToArray#supportsCastToArray() */ public boolean supportsCastToArray() + { + CDebugTarget target = (CDebugTarget)getDebugTarget().getAdapter( CDebugTarget.class ); + return ( target != null && isEditable() && hasChildren() ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICVariable#hasChildren() + */ + public boolean hasChildren() { try { - return ( supportsValueModification() && getValue().hasVariables() ); + return ( getValue() != null && getValue().hasVariables() ); } catch( DebugException e ) { @@ -592,4 +605,23 @@ public abstract class CVariable extends CDebugElement } return false; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICVariable#isEditable() + */ + public boolean isEditable() + { + if ( fEditable == null ) + { + try + { + fEditable = new Boolean( getCDIVariable().isEditable() ); + } + catch( CDIException e ) + { + logError( e ); + } + } + return ( fEditable != null ) ? fEditable.booleanValue() : false; + } }