mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
new implementation getVariable.
This commit is contained in:
parent
e79d04d94e
commit
af96984a2d
1 changed files with 45 additions and 1 deletions
|
@ -16,11 +16,13 @@ import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||||
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.MIVarAssign;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarAssign;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIVarListChildren;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarSetFormat;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarSetFormat;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarShowAttributes;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarShowAttributes;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
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.MIVarListChildrenInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +32,7 @@ public class Variable extends CObject implements ICDIVariable {
|
||||||
MIVar miVar;
|
MIVar miVar;
|
||||||
Value value;
|
Value value;
|
||||||
VariableObject varObj;
|
VariableObject varObj;
|
||||||
|
ICDIVariable[] children = new ICDIVariable[0];
|
||||||
|
|
||||||
public Variable(VariableObject obj, MIVar v) {
|
public Variable(VariableObject obj, MIVar v) {
|
||||||
super(obj.getTarget());
|
super(obj.getTarget());
|
||||||
|
@ -45,6 +48,47 @@ public class Variable extends CObject implements ICDIVariable {
|
||||||
return varObj;
|
return varObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Variable getChild(String name) {
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
Variable variable = (Variable)children[i];
|
||||||
|
if (name.equals(variable.getMIVar().getVarName())) {
|
||||||
|
return variable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICDIVariable[] getChildren() throws CDIException {
|
||||||
|
Session session = (Session)(getTarget().getSession());
|
||||||
|
MISession mi = session.getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarListChildren var =
|
||||||
|
factory.createMIVarListChildren(getMIVar().getVarName());
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarListChildrenInfo info = var.getMIVarListChildrenInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
MIVar[] vars = info.getMIVars();
|
||||||
|
children = new Variable[vars.length];
|
||||||
|
for (int i = 0; i < vars.length; i++) {
|
||||||
|
VariableObject varObj = new VariableObject(getTarget(),
|
||||||
|
vars[i].getExp(), getStackFrame(),
|
||||||
|
getVariableObject().getPosition(),
|
||||||
|
getVariableObject().getStackDepth());
|
||||||
|
children[i] = new Variable(varObj, vars[i]);
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new MI2CDIException(e);
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChildrenNumber() throws CDIException {
|
||||||
|
return miVar.getNumChild();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +138,7 @@ public class Variable extends CObject implements ICDIVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the assign was succesfull fire a MIVarChangedEvent()
|
// If the assign was succesfull fire a MIVarChangedEvent()
|
||||||
MIVarChangedEvent change = new MIVarChangedEvent(var.getToken(), miVar.getVarName(), true);
|
MIVarChangedEvent change = new MIVarChangedEvent(var.getToken(), miVar.getVarName());
|
||||||
mi.fireEvent(change);
|
mi.fireEvent(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue