From 52f06ad88c686729e5a0e2b48c10ed6153c2512e Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 10 Jun 2003 22:33:56 +0000 Subject: [PATCH] Refactoring: moved the type and value related methods from ICVariable to ICType and ICValue. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 10 + .../eclipse/cdt/debug/core/model/ICType.java | 33 +++ .../eclipse/cdt/debug/core/model/ICValue.java | 6 + .../cdt/debug/core/model/ICVariable.java | 20 +- .../core/model/CArrayPartitionValue.java | 24 +++ .../cdt/debug/internal/core/model/CType.java | 129 +++++++++++ .../cdt/debug/internal/core/model/CValue.java | 77 ++++++- .../debug/internal/core/model/CVariable.java | 201 +++--------------- debug/org.eclipse.cdt.debug.ui/ChangeLog | 4 + .../ui/CDTDebugModelPresentation.java | 54 +++-- 10 files changed, 342 insertions(+), 216 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index b2b54a059ff..a65a0975bbb 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,13 @@ +2003-06-10 Mikhail Khodjaiants + Refactoring: moved the type and value related methods from ICVariable to ICType and ICValue. + * ICType.java: new + * ICVariable.java + * ICValue.java + * CArrayPartitionValue.java + * CType.java + * CValue.java + * CVariable.java + 2003-06-09 Mikhail Khodjaiants Added default format preferences for variables, registers and expressions. * CExpression.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java new file mode 100644 index 00000000000..782c002da55 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java @@ -0,0 +1,33 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.core.runtime.IAdaptable; + +/** + * Enter type comment. + * + * @since Jun 10, 2003 + */ +public interface ICType extends IAdaptable +{ + String getName(); + + boolean isArray(); + + int[] getArrayDimensions(); + + boolean isStructure(); + + boolean isCharacter(); + + boolean isFloatingPointType(); + + boolean isPointer(); + + void dispose(); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java index b798607026b..f077d2d0a9f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java @@ -31,4 +31,10 @@ public interface ICValue extends IValue String evaluateAsExpression(); void setChanged( boolean changed ) throws DebugException; + + boolean isNaN(); + + boolean isPositiveInfinity(); + + boolean isNegativeInfinity(); } 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 af87f4ac48c..63cdc7cd1a6 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 @@ -22,27 +22,11 @@ public interface ICVariable extends IVariable void reset() throws DebugException; + ICType getType() throws DebugException; + boolean isEditable(); boolean hasChildren(); - boolean isArray(); - - int[] getArrayDimensions(); - - boolean isStructure(); - - boolean isCharacter(); - - boolean isFloatingPointType(); - - boolean isNaN(); - - boolean isPositiveInfinity(); - - boolean isNegativeInfinity(); - - boolean isPointer(); - String getQualifiedName() throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java index 112d166e35d..d45a51e6d80 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java @@ -163,4 +163,28 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue { return fParent; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICValue#isNaN() + */ + public boolean isNaN() + { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICValue#isNegativeInfinity() + */ + public boolean isNegativeInfinity() + { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICValue#isPositiveInfinity() + */ + public boolean isPositiveInfinity() + { + return false; + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java new file mode 100644 index 00000000000..8f7d0751996 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java @@ -0,0 +1,129 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.core.model; + +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; +import org.eclipse.cdt.debug.core.model.ICType; + +/** + * Enter type comment. + * + * @since Jun 10, 2003 + */ +public class CType implements ICType +{ + private ICDIType fCDIType; + + public CType( ICDIType cdiType ) + { + setCDIType( cdiType ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#getName() + */ + public String getName() + { + return ( fCDIType != null ) ? fCDIType.getTypeName() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter( Class adapter ) + { + if ( ICType.class.equals( adapter ) ) + return this; + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#dispose() + */ + public void dispose() + { + fCDIType = null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#getArrayDimensions() + */ + public int[] getArrayDimensions() + { + int length = 0; + ICDIType type = getCDIType(); + while( type instanceof ICDIArrayType ) + { + ++length; + type = ( type instanceof ICDIDerivedType ) ? ((ICDIDerivedType)type).getComponentType() : null; + } + int[] dims = new int[length]; + type = getCDIType(); + for ( int i = length; i > 0; --i ) + { + dims[i - 1] = ((ICDIArrayType)type).getDimension(); + type = ((ICDIDerivedType)type).getComponentType(); + } + return dims; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#isArray() + */ + public boolean isArray() + { + return ( getCDIType() instanceof ICDIArrayType ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#isCharacter() + */ + public boolean isCharacter() + { + return ( getCDIType() instanceof ICDICharType ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#isFloatingPointType() + */ + public boolean isFloatingPointType() + { + return ( getCDIType() instanceof ICDIFloatingPointType ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#isPointer() + */ + public boolean isPointer() + { + return ( getCDIType() instanceof ICDIPointerType ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.type.ICType#isStructure() + */ + public boolean isStructure() + { + return ( getCDIType() instanceof ICDIStructType ); + } + + protected ICDIType getCDIType() + { + return fCDIType; + } + + protected void setCDIType( ICDIType type ) + { + fCDIType = type; + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java index 841db6ea7a5..e7360e287ee 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java @@ -79,9 +79,9 @@ public class CValue extends CDebugElement implements ICValue String typeName = null; try { - if ( fCDIValue != null ) + if ( getUnderlyingValue() != null ) { - typeName = fCDIValue.getTypeName(); + typeName = getUnderlyingValue().getTypeName(); } } catch( CDIException e ) @@ -567,4 +567,77 @@ public class CValue extends CDebugElement implements ICValue ((CVariable)it.next()).reset(); } } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICValue#isNaN() + */ + public boolean isNaN() + { + try + { + ICDIValue value = getUnderlyingValue(); + if ( value instanceof ICDIDoubleValue ) + { + return Double.isNaN( ((ICDIDoubleValue)value).doubleValue() ); + } + if ( value instanceof ICDIFloatValue ) + { + return Float.isNaN( ((ICDIFloatValue)value).floatValue() ); + } + } + catch( CDIException e ) + { + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICValue#isNegativeInfinity() + */ + public boolean isNegativeInfinity() + { + try + { + ICDIValue value = getUnderlyingValue(); + if ( value instanceof ICDIDoubleValue ) + { + double dbl = ((ICDIDoubleValue)value).doubleValue(); + return ( Double.isInfinite( dbl ) && Double.NEGATIVE_INFINITY == dbl ); + } + if ( value instanceof ICDIFloatValue ) + { + float flt = ((ICDIFloatValue)value).floatValue(); + return ( Float.isInfinite( flt ) && Float.NEGATIVE_INFINITY == flt ); + } + } + catch( CDIException e ) + { + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICValue#isPositiveInfinity() + */ + public boolean isPositiveInfinity() + { + try + { + ICDIValue value = getUnderlyingValue(); + if ( value instanceof ICDIDoubleValue ) + { + double dbl = ((ICDIDoubleValue)value).doubleValue(); + return ( Double.isInfinite( dbl ) && Double.POSITIVE_INFINITY == dbl ); + } + if ( value instanceof ICDIFloatValue ) + { + float flt = ((ICDIFloatValue)value).floatValue(); + return ( Float.isInfinite( flt ) && Float.POSITIVE_INFINITY == flt ); + } + } + catch( CDIException e ) + { + } + return false; + } } 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 9be457fadb1..f00ec93ce02 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 @@ -19,15 +19,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; +import org.eclipse.cdt.debug.core.model.ICType; import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICVariable; import org.eclipse.cdt.debug.core.model.ICastToArray; @@ -97,9 +89,9 @@ public abstract class CVariable extends CDebugElement protected boolean fChanged = false; /** - * The type name of this variable. + * The type of this variable. */ - private String fTypeName = null; + private ICType fType = null; /** * The current format of this variable. @@ -363,7 +355,7 @@ public abstract class CVariable extends CDebugElement { parent = parent.getParentVariable(); } - if ( parent instanceof CVariable && parent.getType() instanceof ICDIArrayType ) + if ( parent instanceof CVariable && parent.getType().isArray() ) { fName = parent.getName() + '[' + cdiName + ']'; } @@ -377,18 +369,7 @@ public abstract class CVariable extends CDebugElement */ public String getReferenceTypeName() throws DebugException { - if ( fTypeName == null ) - { - try - { - fTypeName = getCDIVariable().getTypeName(); - } - catch( CDIException e ) - { - targetRequestFailed( e.getMessage(), null ); - } - } - return fTypeName; + return getType().getName(); } protected void updateParentVariable( CValue parentValue ) throws DebugException @@ -447,7 +428,9 @@ public abstract class CVariable extends CDebugElement fValue = null; } fEditable = null; - fTypeName = null; + if ( fType != null ) + fType.dispose(); + fType = null; fireChangeEvent( DebugEvent.STATE ); } } @@ -483,7 +466,9 @@ public abstract class CVariable extends CDebugElement fValue = null; } fEditable = null; - fTypeName = null; + if ( fType != null ) + fType.dispose(); + fType = null; fireChangeEvent( DebugEvent.STATE ); } @@ -584,7 +569,9 @@ public abstract class CVariable extends CDebugElement fValue = null; } fEditable = null; - fTypeName = null; + if ( fType != null ) + fType.dispose(); + fType = null; fireChangeEvent( DebugEvent.STATE ); } } @@ -632,143 +619,6 @@ public abstract class CVariable extends CDebugElement } return ( fEditable != null ) ? fEditable.booleanValue() : false; } - - public boolean isPointer() - { - return ( getType() instanceof ICDIPointerType ); - } - - public boolean isArray() - { - return ( getType() instanceof ICDIArrayType ); - } - - public int[] getArrayDimensions() - { - int length = 0; - ICDIType type = getType(); - while( type instanceof ICDIArrayType ) - { - ++length; - type = ( type instanceof ICDIDerivedType ) ? ((ICDIDerivedType)type).getComponentType() : null; - } - int[] dims = new int[length]; - type = getType(); - for ( int i = length; i > 0; --i ) - { - dims[i - 1] = ((ICDIArrayType)type).getDimension(); - type = ((ICDIDerivedType)type).getComponentType(); - } - return dims; - } - - public boolean isStructure() - { - return ( getType() instanceof ICDIStructType ); - } - - private ICDIType getType() - { - ICDIType type = null; - try - { - if ( getCDIVariable() != null ) - type = getCDIVariable().getType(); - } - catch( CDIException e ) - { - } - return type; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICVariable#isCharacter() - */ - public boolean isCharacter() - { - return ( getType() instanceof ICDICharType ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICVariable#isNaN() - */ - public boolean isNaN() - { - try - { - ICDIValue value = getCDIVariable().getValue(); - if ( value instanceof ICDIDoubleValue ) - { - return Double.isNaN( ((ICDIDoubleValue)value).doubleValue() ); - } - if ( value instanceof ICDIFloatValue ) - { - return Float.isNaN( ((ICDIFloatValue)value).floatValue() ); - } - } - catch( CDIException e ) - { - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICVariable#isNegativeInfinity() - */ - public boolean isNegativeInfinity() - { - try - { - ICDIValue value = getCDIVariable().getValue(); - if ( value instanceof ICDIDoubleValue ) - { - double dbl = ((ICDIDoubleValue)value).doubleValue(); - return ( Double.isInfinite( dbl ) && Double.NEGATIVE_INFINITY == dbl ); - } - if ( value instanceof ICDIFloatValue ) - { - float flt = ((ICDIFloatValue)value).floatValue(); - return ( Float.isInfinite( flt ) && Float.NEGATIVE_INFINITY == flt ); - } - } - catch( CDIException e ) - { - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICVariable#isPositiveInfinity() - */ - public boolean isPositiveInfinity() - { - try - { - ICDIValue value = getCDIVariable().getValue(); - if ( value instanceof ICDIDoubleValue ) - { - double dbl = ((ICDIDoubleValue)value).doubleValue(); - return ( Double.isInfinite( dbl ) && Double.POSITIVE_INFINITY == dbl ); - } - if ( value instanceof ICDIFloatValue ) - { - float flt = ((ICDIFloatValue)value).floatValue(); - return ( Float.isInfinite( flt ) && Float.POSITIVE_INFINITY == flt ); - } - } - catch( CDIException e ) - { - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICVariable#isFloatingPointType() - */ - public boolean isFloatingPointType() - { - return ( getType() instanceof ICDIFloatingPointType ); - } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICVariable#getQualifiedName() @@ -782,7 +632,7 @@ public abstract class CVariable extends CDebugElement CVariable var = getParentVariable(); while( var != null ) { - if ( !( var.getType() instanceof ICDIArrayType ) && !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() ) + if ( !( var.getType().isArray() ) && !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() ) list.addFirst( var ); var = var.getParentVariable(); } @@ -793,7 +643,7 @@ public abstract class CVariable extends CDebugElement sb.insert( 0, '(' ); if ( i > 0 ) { - if ( vars[i - 1].isPointer() ) + if ( vars[i - 1].getType().isPointer() ) { if ( vars[i].getName().charAt( 0 ) == '*' && vars[i-1].getName().equals( vars[i].getName().substring( 1 ) ) ) { @@ -833,4 +683,23 @@ public abstract class CVariable extends CDebugElement return ((CArrayPartitionValue)getParent()).getParentVariable(); return null; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICVariable#getType() + */ + public ICType getType() throws DebugException + { + if ( fType == null && getCDIVariable() != null ) + { + try + { + fType = new CType( getCDIVariable().getType() ); + } + catch( CDIException e ) + { + requestFailed( "Type is not available.", e ); + } + } + return fType; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 6a324bb09f4..c95825bd49c 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2003-06-10 Mikhail Khodjaiants + Refactoring: moved the type and value related methods from ICVariable to ICType and ICValue. + * CDTDebugModelPresentation.java + 2003-06-09 Mikhail Khodjaiants Added default format preferences for variables, registers and expressions. * CDebugPreferencePage.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 3598ef40ec6..6ff8377ab39 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -25,6 +25,8 @@ import org.eclipse.cdt.debug.core.model.ICDebugTargetType; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICSharedLibrary; +import org.eclipse.cdt.debug.core.model.ICType; +import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICVariable; import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.IDummyStackFrame; @@ -542,15 +544,16 @@ public class CDTDebugModelPresentation extends LabelProvider StringBuffer label = new StringBuffer(); if ( var instanceof ICVariable ) { - if ( isShowVariableTypeNames() ) + ICType type = ((ICVariable)var).getType(); + if ( type != null && isShowVariableTypeNames() ) { - String type = getVariableTypeName( var ); - if ( type != null && type.length() > 0 ) + String typeName = getVariableTypeName( type ); + if ( typeName != null && typeName.length() > 0 ) { - label.append( type ); - if ( ((ICVariable)var).isArray() ) + label.append( typeName ); + if ( type.isArray() ) { - int[] dims = ((ICVariable)var).getArrayDimensions(); + int[] dims = type.getArrayDimensions(); for ( int i = 0; i < dims.length; ++i ) { label.append( '[' ); @@ -563,31 +566,29 @@ public class CDTDebugModelPresentation extends LabelProvider } label.append( var.getName() ); IValue value = var.getValue(); - if ( value != null ) + if ( value instanceof ICValue && value.getValueString() != null ) { - if ( ((ICVariable)var).isCharacter() && value.getValueString() != null ) + String valueString = value.getValueString().trim(); + if ( type != null && type.isCharacter() ) { - String valueString = value.getValueString().trim(); if ( valueString.length() == 0 ) valueString = "."; label.append( "= " ); label.append( valueString ); } - else if ( ((ICVariable)var).isFloatingPointType() && value.getValueString() != null ) + else if ( type != null && type.isFloatingPointType() ) { - String valueString = value.getValueString().trim(); - if ( ((ICVariable)var).isNaN() ) + if ( ((ICValue)value).isNaN() ) valueString = "NAN"; - if ( ((ICVariable)var).isPositiveInfinity() ) + if ( ((ICValue)value).isPositiveInfinity() ) valueString = "Infinity"; - if ( ((ICVariable)var).isNegativeInfinity() ) + if ( ((ICValue)value).isNegativeInfinity() ) valueString = "-Infinity"; label.append( "= " ); label.append( valueString ); } - else if ( !((ICVariable)var).isArray() && !((ICVariable)var).isStructure() && value.getValueString() != null ) + else if ( type == null || ( !type.isArray() && !type.isStructure() ) ) { - String valueString = value.getValueString().trim(); if ( valueString.length() > 0 ) { label.append( "= " ); @@ -937,23 +938,16 @@ public class CDTDebugModelPresentation extends LabelProvider return null; } - private String getVariableTypeName( IVariable variable ) + private String getVariableTypeName( ICType type ) { - String type = null; - try + String typeName = type.getName(); + if ( type.isArray() && typeName != null ) { - type = variable.getReferenceTypeName(); - if ( type != null ) - { - int index = type.indexOf( '[' ); - if ( index != -1 ) - return type.substring( 0, index ).trim(); - } + int index = typeName.indexOf( '[' ); + if ( index != -1 ) + return typeName.substring( 0, index ).trim(); } - catch( DebugException e ) - { - } - return type; + return typeName; } /* (non-Javadoc)