From 03d085016c25785dda071017260cab2a8eae7176 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Wed, 6 Jun 2007 20:14:02 +0000 Subject: [PATCH] Bug 52100 - Patch for Sergey - Remove the private/public children from the variables view. --- .../cdt/debug/mi/core/cdi/model/Variable.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java index 5182cbeccfa..a382587078c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.cdi.model; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIFormat; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; @@ -79,11 +82,11 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo; /** */ public abstract class Variable extends VariableDescriptor implements ICDIVariable { - + private static final ICDIVariable[] NO_CHILDREN = new ICDIVariable[0]; protected MIVarCreate fVarCreateCMD; protected MIVar fMIVar; Value value; - public ICDIVariable[] children = new ICDIVariable[0]; + public ICDIVariable[] children = NO_CHILDREN; String editable = null; String language; boolean isFake = false; @@ -243,6 +246,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl * allow the override of the timeout. */ public ICDIVariable[] getChildren(int timeout) throws CDIException { + children = NO_CHILDREN; MISession mi = ((Target)getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarListChildren var = factory.createMIVarListChildren(getMIVar().getVarName()); @@ -257,9 +261,10 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } MIVar[] vars = info.getMIVars(); - children = new Variable[vars.length]; + List childrenList = new ArrayList(vars.length); +// children = new Variable[vars.length]; // For C++ in GDB the children of the - // the struture are the scope and the inherited classes. + // the structure are the scope and the inherited classes. // For example: // class foo: public bar { // int x; @@ -279,7 +284,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl boolean container = isStructureProvider(t); for (int i = 0; i < vars.length; i++) { String prefix = "(" + getFullName() + ")"; // parent qualified name - String childName = vars[i].getExp(); // chield simple name + String childName = vars[i].getExp(); // child simple name String childFullName = prefix + "." + childName; // fallback full name ICDIType childType = null; boolean childFake = false; @@ -322,8 +327,18 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl v.fType = childType; } v.setIsFake(childFake); - children[i] = v; + if (childFake && isAccessQualifier(childName)) { + // Replace a fake variable representing an access qualifier with its children. + ICDIVariable[] grandchildren = v.getChildren(timeout); + for (int j = 0; j < grandchildren.length; j++) { + childrenList.add(grandchildren[j]); + } + } else { + childrenList.add(v); + } } + if (!childrenList.isEmpty()) + children = (ICDIVariable[]) childrenList.toArray(new Variable[childrenList.size()]); } catch (MIException e) { throw new MI2CDIException(e); }