From ab927f790aa4f727d5abcd7ce25847cd0cf9ce7b Mon Sep 17 00:00:00 2001
From: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
Date: Thu, 12 Sep 2002 22:22:39 +0000
Subject: [PATCH] Correct display of C++ keywords in the 'Variables' view.

---
 .../org/eclipse/cdt/debug/core/ICValue.java   |  1 +
 .../cdt/debug/internal/core/model/CValue.java | 23 +++++++++++++++----
 .../internal/core/model/CValueFactory.java    |  4 ++--
 .../debug/internal/core/model/CVariable.java  | 15 ++++++++++--
 .../ui/CDTDebugModelPresentation.java         |  5 +++-
 5 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java
index 36a10aff0a6..28f47453c7a 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java
@@ -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.
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 fed6a1babd9..74600902264 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
@@ -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;
+	}
 }
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java
index c3009a1eb5d..a1c74115cb1 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java
@@ -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 );
 	}
 }
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 c4418a8bf11..8b795c05556 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
@@ -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 );
+	}
 }
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 57a24cd4fbf..e7f5dab11e0 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
@@ -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 ) );
