mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 20:55:44 +02:00
add hasChildren to help the UI.
This commit is contained in:
parent
128f28c57c
commit
fd0b0a20fe
3 changed files with 52 additions and 2 deletions
|
@ -33,6 +33,11 @@ public interface ICDIValue extends ICDIObject
|
||||||
*/
|
*/
|
||||||
String getValueString() throws CDIException;
|
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
|
* Returns the variables in this value. An empty collection
|
||||||
* is returned if there are no variables.
|
* is returned if there are no variables.
|
||||||
|
|
|
@ -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.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
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.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.command.MIVarListChildren;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
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.MIVarEvaluateExpressionInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarInfoNumChildrenInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVarListChildrenInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIVarListChildrenInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,6 +65,28 @@ public class Value extends CObject implements ICDIValue {
|
||||||
return result;
|
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()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.mi.core.command;
|
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
|
* -var-info-num-children NAME
|
||||||
|
@ -20,4 +25,20 @@ public class MIVarInfoNumChildren extends MICommand
|
||||||
public MIVarInfoNumChildren(String name) {
|
public MIVarInfoNumChildren(String name) {
|
||||||
super("-var-info-num-children", new 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue