From 5243e5bd71dfbe3c9519d1ca35b2c33ba616c2ce Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 6 Jun 2003 19:27:17 +0000 Subject: [PATCH] Changed the implementation of the'getName' method of CVariable to return the actual names of array members. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 7 +++ .../internal/core/model/CArrayPartition.java | 2 +- .../core/model/CArrayPartitionValue.java | 15 +++++- .../debug/internal/core/model/CVariable.java | 48 +++++++++++++++---- 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 356865e1654..0b168f33963 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,10 @@ +2003-06-06 Mikhail Khodjaiants + Changed the implementation of the'getName' method of CVariable to return + the actual names of array members. + * CArrayPartition.java + * CArrayPartitionValue.java + * CVariable.java + 2003-06-05 Mikhail Khodjaiants Core support of infinite values of the floating point types. * ICVariable.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java index 5740dc22dec..ac4de4435f4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java @@ -91,7 +91,7 @@ public class CArrayPartition extends CVariable { if ( fArrayPartitionValue == null ) { - fArrayPartitionValue = new CArrayPartitionValue( (CDebugTarget)getDebugTarget(), fCDIVariables, getStart(), getEnd() ); + fArrayPartitionValue = new CArrayPartitionValue( this, fCDIVariables, getStart(), getEnd() ); } return fArrayPartitionValue; } 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 9e685b33743..112d166e35d 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 @@ -30,6 +30,11 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue */ private List fCDIVariables; + /** + * Parent variable. + */ + private CVariable fParent = null; + /** * List of child variables. */ @@ -43,10 +48,11 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue * Constructor for CArrayPartitionValue. * @param target */ - public CArrayPartitionValue( CDebugTarget target, List cdiVariables, int start, int end ) + public CArrayPartitionValue( CVariable parent, List cdiVariables, int start, int end ) { - super( target ); + super( (CDebugTarget)parent.getDebugTarget() ); fCDIVariables = cdiVariables; + fParent = parent; fStart = start; fEnd = end; } @@ -152,4 +158,9 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue { return null; } + + public CVariable getParentVariable() + { + return fParent; + } } 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 74569b0df6c..a1da77c89e2 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 @@ -68,6 +68,11 @@ public abstract class CVariable extends CDebugElement */ protected ICValue fValue; + /** + * The name of this variable. + */ + private String fName = null; + private Boolean fEditable = null; /** @@ -350,7 +355,27 @@ public abstract class CVariable extends CDebugElement */ public String getName() throws DebugException { - return ( getOriginalCDIVariable() != null ) ? getOriginalCDIVariable().getName() : null; + if ( fName == null ) + { + String cdiName = ( getOriginalCDIVariable() != null ) ? getOriginalCDIVariable().getName() : null; + if ( cdiName != null && getParent() instanceof ICValue ) + { + CVariable parent = getParentVariable(); + while( parent instanceof CArrayPartition ) + { + parent = parent.getParentVariable(); + } + if ( parent instanceof CVariable && parent.getType() instanceof ICDIArrayType ) + { + fName = parent.getName() + '[' + cdiName + ']'; + } + } + else + { + fName = cdiName; + } + } + return fName; } /* (non-Javadoc) @@ -758,16 +783,12 @@ public abstract class CVariable extends CDebugElement { LinkedList list = new LinkedList(); list.add( this ); - CVariable var = null; - CDebugElement element = getParent(); - while ( element instanceof CValue ) + CVariable var = getParentVariable(); + while( var != null ) { - var = ((CValue)element).getParentVariable(); - if ( var == null ) - break; - if ( !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() ) + if ( !( var.getType() instanceof ICDIArrayType ) && !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() ) list.addFirst( var ); - element = var.getParent(); + var = var.getParentVariable(); } StringBuffer sb = new StringBuffer(); CVariable[] vars = (CVariable[])list.toArray( new CVariable[list.size()] ); @@ -786,4 +807,13 @@ public abstract class CVariable extends CDebugElement { return ( "public".equals( getName() ) || "protected".equals( getName() ) || "private".equals( getName() ) ); } + + private CVariable getParentVariable() throws DebugException + { + if ( getParent() instanceof CValue ) + return ((CValue)getParent()).getParentVariable(); + if ( getParent() instanceof CArrayPartitionValue ) + return ((CArrayPartitionValue)getParent()).getParentVariable(); + return null; + } }