fix setVariable support in debuggers

pull/477/head
nightwing 2018-01-08 17:52:22 +04:00
rodzic d41562a5ac
commit 247a2ae9e3
6 zmienionych plików z 21 dodań i 37 usunięć

Wyświetl plik

@ -461,7 +461,7 @@ define(function(require, exports, module) {
});
}
function setVariable(variable, parents, value, frame, callback) {
function setVariable(variable, value, frame, callback) {
var args = {
"frame": frame.id,
"name": variable.name,
@ -775,7 +775,6 @@ define(function(require, exports, module) {
/**
* Sets the value of a variable.
* @param {debugger.Variable} variable The variable to set the value of.
* @param {debugger.Variable[]} parents The parent variables (i.e. the objects of which the variable is the property).
* @param {Mixed} value The new value of the variable.
* @param {debugger.Frame} frame The frame to which the variable belongs.
* @param {Function} callback

Wyświetl plik

@ -430,7 +430,7 @@ define(function(require, exports, module) {
callback(null, emit("getBreakpoints"));
}
function setVariable(variable, parents, value, frame, callback) {
function setVariable(variable, value, frame, callback) {
var scope = findScope(variable);
session.setPropertyValue(variable.ref, frame.index, scope.index, value, function(err) {
@ -779,7 +779,6 @@ define(function(require, exports, module) {
/**
* Sets the value of a variable.
* @param {debugger.Variable} variable The variable to set the value of.
* @param {debugger.Variable[]} parents The parent variables (i.e. the objects of which the variable is the property).
* @param {Mixed} value The new value of the variable.
* @param {debugger.Frame} frame The frame to which the variable belongs.
* @param {Function} callback

Wyświetl plik

@ -469,7 +469,7 @@ define(function(require, exports, module) {
});
}
function setVariable(variable, parents, value, frame, callback) {
function setVariable(variable, value, frame, callback) {
var args = {
"name": variable.ref,
"val": value

Wyświetl plik

@ -960,17 +960,13 @@ define(function(require, exports, module) {
});
}
function setVariable(variable, parents, value, frame, callback) {
function setVariable(variable, value, frame, callback) {
// Get variable name
var names = [], scopeNumber, frameIndex = frame.index;
parents.reverse().forEach(function(p) {
// Assuming scopes are accessible
if (p.tagName == "variable")
names.push(p.name.replace(/"/g, '\\"'));
else if (p.tagName == "scope")
scopeNumber = p.index;
});
names.push(variable.name);
var isScope = false, scopeNumber, frameIndex = frame.index;
if (variable.parent && !variable.parent.ref) {
scopeNumber = variable.parent.index;
isScope = true;
}
function handler(err, body) {
if (err)
@ -982,12 +978,6 @@ define(function(require, exports, module) {
variable.properties = body.properties || [];
variable.children = (body.properties || "").length ? true : false;
// @todo - and make this consistent with getProperties
// if (body.constructorFunction)
// value.contructor = body.constructorFunction.ref;
// if (body.prototypeObject)
// value.prototype = body.prototypeObject.ref;
if (variable.children) {
lookup(body.properties, false, function(err, properties) {
variable.properties = properties;
@ -1000,11 +990,11 @@ define(function(require, exports, module) {
}
// If it's a local variable set it directly
if (parents.length == (typeof scopeNumber == "number" ? 1 : 0))
if (isScope)
setLocalVariable(variable, value, scopeNumber || 0, frameIndex, handler);
// Otherwise set a variable or property
else
setAnyVariable(variable, parents[0], value, handler);
setAnyVariable(variable, frame, value, handler);
}
function setLocalVariable(variable, value, scopeNumber, frameIndex, callback) {
@ -1035,14 +1025,14 @@ define(function(require, exports, module) {
});
}
function setAnyVariable(variable, parent, value, callback) {
function setAnyVariable(variable, frame, value, callback) {
var expression = "(function(a, b) { this[a] = b; })"
+ ".call(__cloud9_debugger_self__, \""
+ variable.name + "\", " + value + ")";
v8dbg.simpleevaluate(expression, null, true, [{
v8dbg.simpleevaluate(expression, frame, false, [{
name: "__cloud9_debugger_self__",
handle: parent.ref
handle: variable.parent.ref
}], function(body, refs, error) {
if (error) {
var err = new Error(error.message);

Wyświetl plik

@ -154,8 +154,7 @@ define(function(require, exports, module) {
var node = e.node;
var value = e.value;
var parents = [];
var variable = activeFrame.findVariable(node, null, parents);
var variable = node;
var oldValue = variable.value;
model.setAttribute(variable, "value", value);
@ -165,14 +164,13 @@ define(function(require, exports, module) {
}
// Set new value
dbg.setVariable(variable, parents,
value, debug.activeFrame, function(err) {
if (err)
dbg.setVariable(variable, value, debug.activeFrame, function(err) {
if (err)
return undo();
// Reload properties of the variable
// dbg.getProperties(variable, function(err, properties) {
updateVariable(variable, variable.properties, node);
dbg.getProperties(variable.parent, function() {
updateVariable(variable.parent);
emit("variableEdit", {
value: value,
@ -180,9 +178,8 @@ define(function(require, exports, module) {
node: node,
variable: variable,
frame: activeFrame,
parents: parents
});
// });
});
});
});

Wyświetl plik

@ -389,8 +389,7 @@ define(function(require, exports, module) {
}
// Set new value of a property
else {
dbg.setVariable(variable, parents,
value, debug.activeFrame, function(err) {
dbg.setVariable(variable, value, debug.activeFrame, function(err) {
if (err) {
variable.value = oldValue;
updateVariable(variable, [], node, true);