1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 04:35:45 +02:00

add hasChildren to help the UI.

This commit is contained in:
Alain Magloire 2002-09-06 19:16:37 +00:00
parent 128f28c57c
commit fd0b0a20fe
3 changed files with 52 additions and 2 deletions

View file

@ -32,7 +32,12 @@ public interface ICDIValue extends ICDIObject
* @throws CDIException if this method fails. Reasons include:
*/
String getValueString() throws CDIException;
/**
* @return true if value is a container like structure.
*/
boolean hasChildren() throws CDIException;
/**
* Returns the variables in this value. An empty collection
* is returned if there are no variables.

View file

@ -12,9 +12,11 @@ import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIVarEvaluateExpression;
import org.eclipse.cdt.debug.mi.core.command.MIVarInfoNumChildren;
import org.eclipse.cdt.debug.mi.core.command.MIVarListChildren;
import org.eclipse.cdt.debug.mi.core.output.MIVar;
import org.eclipse.cdt.debug.mi.core.output.MIVarEvaluateExpressionInfo;
import org.eclipse.cdt.debug.mi.core.output.MIVarInfoNumChildrenInfo;
import org.eclipse.cdt.debug.mi.core.output.MIVarListChildrenInfo;
/**
@ -62,7 +64,29 @@ public class Value extends CObject implements ICDIValue {
}
return result;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
*/
public boolean hasChildren() throws CDIException {
int number = 0;
MISession mi = getCTarget().getCSession().getMISession();
CommandFactory factory = mi.getCommandFactory();
MIVarInfoNumChildren children =
factory.createMIVarInfoNumChildren(variable.getMIVar().getVarName());
try {
mi.postCommand(children);
MIVarInfoNumChildrenInfo info = children.getMIVarInfoNumChildrenInfo();
if (info == null) {
throw new CDIException("No answer");
}
number = info.getChildNumber();
} catch (MIException e) {
throw new CDIException(e.getMessage());
}
return (number > 0);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
*/

View file

@ -6,6 +6,11 @@
package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
import org.eclipse.cdt.debug.mi.core.output.MIVarInfoNumChildrenInfo;
/**
*
* -var-info-num-children NAME
@ -20,4 +25,20 @@ public class MIVarInfoNumChildren extends MICommand
public MIVarInfoNumChildren(String name) {
super("-var-info-num-children", new String[]{name});
}
public MIVarInfoNumChildrenInfo getMIVarInfoNumChildrenInfo() throws MIException {
return (MIVarInfoNumChildrenInfo)getMIInfo();
}
public MIInfo getMIInfo() throws MIException {
MIInfo info = null;
MIOutput out = getMIOutput();
if (out != null) {
info = new MIVarInfoNumChildrenInfo(out);
if (info.isError()) {
throw new MIException(info.getErrorMsg());
}
}
return info;
}
}