use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method doInfoScopeChain.
void doInfoScopeChain() throws PlayerDebugException {
waitTilHalted();
// dump the scope chain
StringBuilder sb = new StringBuilder();
// use our expression cache formatting routine
try {
// get the scope chainfrom the requested frame
int num = propertyGet(DISPLAY_FRAME_NUMBER);
Frame[] ar = m_session.getFrames();
Frame ctx = ar[num];
Variable[] scopes = ctx.getScopeChain(m_session);
for (int i = 0; i < scopes.length; i++) {
Variable scope = scopes[i];
ExpressionCache.appendVariable(sb, scope);
sb.append(m_newline);
}
} catch (NullPointerException npe) {
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("noScopeChain"));
} catch (ArrayIndexOutOfBoundsException aix) {
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("notInValidFrame"));
}
out(sb.toString());
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class ExpressionCache method appendVariableValue.
/**
* Given any arbitrary constant value, such as a Double, a String, etc.,
* format its value appropriately. For example, strings will be quoted.
*
* @param sb
* a StringBuilder to which the formatted value will be appended.
* @param o
* the value to format.
*/
public static void appendVariableValue(StringBuilder sb, final Object o) {
Value v;
if (o instanceof Value) {
v = (Value) o;
} else {
v = new Value() {
public int getAttributes() {
return 0;
}
public String[] getClassHierarchy(boolean allLevels) {
return new String[0];
}
public String getClassName() {
//$NON-NLS-1$
return "";
}
public long getId() {
return UNKNOWN_ID;
}
public int getMemberCount(Session s) throws NotSuspendedException, NoResponseException, NotConnectedException {
return 0;
}
public Variable getMemberNamed(Session s, String name) throws NotSuspendedException, NoResponseException, NotConnectedException {
return null;
}
public Variable[] getMembers(Session s) throws NotSuspendedException, NoResponseException, NotConnectedException {
return new Variable[0];
}
public int getType() {
if (o instanceof Number)
return VariableType.NUMBER;
else if (o instanceof Boolean)
return VariableType.BOOLEAN;
else if (o instanceof String)
return VariableType.STRING;
else if (o == Value.UNDEFINED)
return VariableType.UNDEFINED;
else if (o == null)
return VariableType.NULL;
assert false;
return VariableType.UNKNOWN;
}
public String getTypeName() {
//$NON-NLS-1$
return "";
}
public Object getValueAsObject() {
return o;
}
public String getValueAsString() {
return DValue.getValueAsString(o);
}
public boolean isAttributeSet(int variableAttribute) {
return false;
}
public Variable[] getPrivateInheritedMembers() {
return new Variable[0];
}
public Variable[] getPrivateInheritedMemberNamed(String name) {
return new Variable[0];
}
};
}
appendVariableValue(sb, v);
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method treeResults.
StringBuffer treeResults(StringBuffer sb, List e, String memName, boolean fullName) {
// walk the list
Iterator i = e.iterator();
while (i.hasNext()) {
String name = (String) i.next();
Variable key = (Variable) i.next();
Variable val = (Variable) i.next();
// sb.append(val.getName());
if (fullName)
sb.append(name);
ExpressionCache.appendVariableValue(sb, key.getValue(), key.getName());
//$NON-NLS-1$
sb.append(".");
sb.append(memName);
//$NON-NLS-1$
sb.append(" = ");
ExpressionCache.appendVariableValue(sb, val.getValue(), val.getName());
sb.append(m_newline);
}
return sb;
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method appendFrameInfo.
/**
* Spit out frame information for a given frame number
*/
boolean appendFrameInfo(StringBuilder sb, Frame ctx, int frameNumber, boolean showThis, boolean showFileId) throws PlayerDebugException {
boolean validFrame = true;
// some formatting properties
int i = frameNumber;
Location loc = ctx.getLocation();
SourceFile file = loc.getFile();
int line = loc.getLine();
//$NON-NLS-1$
String name = (file == null) ? "<null>" : file.getName();
String sig = ctx.getCallSignature();
String func = extractFunctionName(sig);
// file == null or line < 0 appears to be a terminator for stack info
if (file == null && line < 0) {
validFrame = false;
} else {
Variable[] var = ctx.getArguments(m_session);
Variable dis = ctx.getThis(m_session);
boolean displayArgs = (func != null) || (var != null);
sb.append('#');
FieldFormat.formatLong(sb, i, 3);
sb.append(' ');
if (showThis && dis != null) {
ExpressionCache.appendVariable(sb, dis);
//$NON-NLS-1$
sb.append(".");
}
if (func != null)
sb.append(func);
if (displayArgs) {
sb.append('(');
for (int j = 0; j < var.length; j++) {
Variable v = var[j];
sb.append(v.getName());
sb.append('=');
ExpressionCache.appendVariableValue(sb, v.getValue());
if ((j + 1) < var.length)
//$NON-NLS-1$
sb.append(", ");
}
//$NON-NLS-1$
sb.append(")");
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("atFilename"));
}
sb.append(name);
// if this file is currently being filtered put the source file id after it
if (file != null && (showFileId || !m_fileInfo.inFileList(file))) {
sb.append('#');
sb.append(file.getId());
}
sb.append(':');
sb.append(line);
}
return validFrame;
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method dumpTree.
/**
* Traverse the given variables dumping any Movieclips we find that
* contain a member called 'member'
* @throws NotConnectedException
* @throws NoResponseException
* @throws NotSuspendedException
*/
void dumpTree(Map<Object, String> tree, List<Object> e, String name, Value result, String member) throws NotSuspendedException, NoResponseException, NotConnectedException {
// name for this variable
if (name == null)
//$NON-NLS-1$
name = "";
// have we seen it already
if (tree.containsKey(result))
return;
// place it
tree.put(result, name);
// first iterate over our members looking for 'member'
Value proto = result;
boolean done = false;
while (!done && proto != null) {
Variable[] members = proto.getMembers(m_session);
proto = null;
// see if we find one called 'member'
for (int i = 0; i < members.length; i++) {
Variable m = members[i];
String memName = m.getName();
if (memName.equals(member) && !tree.containsKey(m)) {
e.add(name);
e.add(result);
e.add(m);
//$NON-NLS-1$
tree.put(m, name + "." + memName);
done = true;
} else if (//$NON-NLS-1$
memName.equals("__proto__"))
proto = members[i].getValue();
}
}
// now traverse other mcs recursively
done = false;
proto = result;
while (!done && proto != null) {
Variable[] members = proto.getMembers(m_session);
proto = null;
// see if we find an mc
for (int i = 0; i < members.length; i++) {
Variable m = members[i];
String memName = m.getName();
// if our type is NOT object or movieclip then we are done
if (m.getValue().getType() != VariableType.OBJECT && m.getValue().getType() != VariableType.MOVIECLIP)
;
else if (m.getValue().getId() != Value.UNKNOWN_ID)
dumpTree(tree, e, name, m.getValue(), member);
else if (//$NON-NLS-1$
memName.equals("__proto__")) {
proto = m.getValue();
// name = name + ".__proto__";
}
}
}
}
Aggregations