Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] New implementation of the 'getName' method of CVariable

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.198
diff -u -r1.198 ChangeLog
--- ChangeLog 5 Jun 2003 21:18:21 -0000 1.198
+++ ChangeLog 6 Jun 2003 19:26:25 -0000
@@ -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
Index: src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java,v
retrieving revision 1.5
diff -u -r1.5 CArrayPartition.java
--- src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java 18 Mar 2003 21:06:23 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java 6 Jun 2003 19:26:25 -0000
@@ -91,7 +91,7 @@
  {
   if ( fArrayPartitionValue == null )
   {
-   fArrayPartitionValue = new CArrayPartitionValue( (CDebugTarget)getDebugTarget(), fCDIVariables, getStart(), getEnd() );
+   fArrayPartitionValue = new CArrayPartitionValue( this, fCDIVariables, getStart(), getEnd() );
   }
   return fArrayPartitionValue;
  }
Index: src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java,v
retrieving revision 1.8
diff -u -r1.8 CArrayPartitionValue.java
--- src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java 5 Jun 2003 20:44:45 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java 6 Jun 2003 19:26:25 -0000
@@ -31,6 +31,11 @@
  private List fCDIVariables;
 
  /**
+  * Parent variable.
+  */
+ private CVariable fParent = null;
+
+ /**
   * List of child variables.
   */
  private List fVariables = Collections.EMPTY_LIST;
@@ -43,10 +48,11 @@
   * 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;
  }
@@ -151,5 +157,10 @@
  public String evaluateAsExpression()
  {
   return null;
+ }
+
+ public CVariable getParentVariable()
+ {
+  return fParent;
  }
 }
Index: src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java,v
retrieving revision 1.30
diff -u -r1.30 CVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 5 Jun 2003 21:18:21 -0000 1.30
+++ src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 6 Jun 2003 19:26:26 -0000
@@ -68,6 +68,11 @@
   */
  protected ICValue fValue;
 
+ /**
+  * The name of this variable.
+  */
+ private String fName = null;
+
  private Boolean fEditable = null;
 
  /**
@@ -350,7 +355,27 @@
   */
  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 @@
  {
   LinkedList list = new LinkedList();
   list.add( this );
-  CVariable var = null;
-  CDebugElement element = getParent();
-  while ( element instanceof CValue )
-  {
-   var = ((CValue)element).getParentVariable();
-   if ( var == null )
-    break;
-   if ( !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() )
+  CVariable var = getParentVariable();
+  while( var != null )
+  {
+   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()] );
@@ -785,5 +806,14 @@
  protected boolean isAccessSpecifier() throws DebugException
  {
   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;
  }
 }

Back to the top