1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Correct presentation of the full names of variables that contain pointers.

This commit is contained in:
Mikhail Khodjaiants 2003-06-06 20:00:22 +00:00
parent 08ab887f65
commit e52ae1fe5a

View file

@ -73,6 +73,11 @@ public abstract class CVariable extends CDebugElement
*/ */
private String fName = null; private String fName = null;
/**
* The full name of this variable.
*/
private String fQualifiedName = null;
private Boolean fEditable = null; private Boolean fEditable = null;
/** /**
@ -778,45 +783,49 @@ public abstract class CVariable extends CDebugElement
*/ */
public String getQualifiedName() throws DebugException public String getQualifiedName() throws DebugException
{ {
LinkedList list = new LinkedList(); if ( fQualifiedName == null )
list.add( this );
CVariable var = getParentVariable();
while( var != null )
{ {
if ( !( var.getType() instanceof ICDIArrayType ) && !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() ) LinkedList list = new LinkedList();
list.addFirst( var ); list.add( this );
var = var.getParentVariable(); CVariable var = getParentVariable();
} while( var != null )
StringBuffer sb = new StringBuffer();
CVariable[] vars = (CVariable[])list.toArray( new CVariable[list.size()] );
for ( int i = 0; i < vars.length; ++i )
{
sb.insert( 0, '(' );
if ( i > 0 )
{ {
if ( vars[i - 1].isPointer() ) if ( !( var.getType() instanceof ICDIArrayType ) && !( var instanceof CArrayPartition ) && !var.isAccessSpecifier() )
list.addFirst( var );
var = var.getParentVariable();
}
StringBuffer sb = new StringBuffer();
CVariable[] vars = (CVariable[])list.toArray( new CVariable[list.size()] );
for ( int i = 0; i < vars.length; ++i )
{
sb.insert( 0, '(' );
if ( i > 0 )
{ {
if ( vars[i].getName().charAt( 0 ) == '*' && vars[i-1].getName().equals( vars[i].getName().substring( 1 ) ) ) if ( vars[i - 1].isPointer() )
{ {
sb.insert( 0, '*' ); if ( vars[i].getName().charAt( 0 ) == '*' && vars[i-1].getName().equals( vars[i].getName().substring( 1 ) ) )
{
sb.insert( 0, '*' );
}
else
{
sb.append( "->" );
sb.append( vars[i].getName() );
}
} }
else else
{ {
sb.append( "->" ); sb.append( '.' );
sb.append( vars[i].getName() ); sb.append( vars[i].getName() );
} }
} }
else else
{
sb.append( '.' );
sb.append( vars[i].getName() ); sb.append( vars[i].getName() );
} sb.append( ')' );
} }
else fQualifiedName = sb.toString();
sb.append( vars[i].getName() );
sb.append( ')' );
} }
return sb.toString(); return fQualifiedName;
} }
protected boolean isAccessSpecifier() throws DebugException protected boolean isAccessSpecifier() throws DebugException