1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Correct display of C++ keywords in the 'Variables' view.

This commit is contained in:
Mikhail Khodjaiants 2002-09-12 22:22:39 +00:00
parent 7622705eb4
commit ab927f790a
5 changed files with 39 additions and 9 deletions

View file

@ -25,6 +25,7 @@ public interface ICValue extends IValue
static final public int TYPE_ARRAY_PARTITION = 5;
static final public int TYPE_ARRAY_ENTRY = 7;
static final public int TYPE_CHAR = 8;
static final public int TYPE_KEYWORD = 9;
/**
* Returns the type of this value.

View file

@ -28,6 +28,11 @@ import org.eclipse.debug.core.model.IVariable;
*/
public class CValue extends CDebugElement implements ICValue
{
/**
* Parent variable.
*/
private CVariable fParent = null;
/**
* Cached value.
*/
@ -52,9 +57,10 @@ public class CValue extends CDebugElement implements ICValue
* Constructor for CValue.
* @param target
*/
public CValue( CDebugTarget target, ICDIValue cdiValue )
public CValue( CVariable parent, ICDIValue cdiValue )
{
super( target );
super( (CDebugTarget)parent.getDebugTarget() );
fParent = parent;
fCDIValue = cdiValue;
}
@ -186,10 +192,14 @@ public class CValue extends CDebugElement implements ICValue
protected void calculateType( String stringValue )
{
if ( stringValue != null && stringValue.trim().length() > 0 )
if ( stringValue != null )
{
stringValue = stringValue.trim();
if ( stringValue.charAt( stringValue.length() - 1 ) == '\'' )
if ( stringValue.length() == 0 )
{
fType = TYPE_KEYWORD;
}
else if ( stringValue.charAt( stringValue.length() - 1 ) == '\'' )
{
fType = TYPE_CHAR;
}
@ -291,4 +301,9 @@ public class CValue extends CDebugElement implements ICValue
}
return String.valueOf( result );
}
protected CVariable getParentVariable()
{
return fParent;
}
}

View file

@ -22,8 +22,8 @@ public class CValueFactory
* Creates the appropriate kind of value, or <code>null</code>.
*
*/
static public ICValue createValue( CDebugTarget target, ICDIValue cdiValue ) throws DebugException
static public ICValue createValue( CVariable parent, ICDIValue cdiValue ) throws DebugException
{
return new CValue( target, cdiValue );
return new CValue( parent, cdiValue );
}
}

View file

@ -84,7 +84,7 @@ public abstract class CVariable extends CDebugElement
ICDIValue currentValue = getCurrentValue();
if ( fValue == null )
{
fValue = CValueFactory.createValue( (CDebugTarget)getDebugTarget(), currentValue );
fValue = CValueFactory.createValue( this, currentValue );
}
return fValue;
}
@ -252,8 +252,13 @@ public abstract class CVariable extends CDebugElement
{
try
{
//setValue( getCurrentValue() );
setChanged( true );
if ( getValue() != null &&
((CValue)getValue()).getType() == ICValue.TYPE_CHAR &&
getParent() instanceof CValue )
{
updateParentVariable( (CValue)getParent() );
}
getParent().fireChangeEvent( DebugEvent.CONTENT );
}
catch( DebugException e )
@ -329,4 +334,10 @@ public abstract class CVariable extends CDebugElement
}
return type;
}
protected void updateParentVariable( CValue parentValue ) throws DebugException
{
parentValue.getParentVariable().setChanged( true );
parentValue.getParentVariable().fireChangeEvent( DebugEvent.STATE );
}
}

View file

@ -389,6 +389,8 @@ public class CDTDebugModelPresentation extends LabelProvider
break;
case ICValue.TYPE_STRUCTURE:
break;
case ICValue.TYPE_KEYWORD:
break;
default:
label += "= " + value.getValueString();
break;
@ -633,7 +635,8 @@ public class CDTDebugModelPresentation extends LabelProvider
if ( element != null )
{
if ( element.getType() == ICValue.TYPE_ARRAY ||
element.getType() == ICValue.TYPE_STRUCTURE )
element.getType() == ICValue.TYPE_STRUCTURE ||
element.getType() == ICValue.TYPE_KEYWORD )
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE, 0 ) );
else if ( element.getType() == ICValue.TYPE_POINTER )
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_POINTER, 0 ) );