### Eclipse Workspace Patch 1.0 #P org.eclipse.cdt.debug.mi.core Index: cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java,v retrieving revision 1.24 diff -u -r1.24 Variable.java --- cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java 16 May 2007 19:11:49 -0000 1.24 +++ cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java 3 Jun 2007 01:26:50 -0000 @@ -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 @@ /** */ 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 @@ * 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 @@ 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 @@ 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 @@ 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); }