Commit ce719653 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[DevTools] Replace SetScriptSourceError with ExceptionDetails in protocol

BUG=591496
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2146333003
Cr-Commit-Position: refs/heads/master@{#405898}
parent 710345ad
......@@ -4,5 +4,5 @@ Function evaluate: {"type":"number","value":8,"description":"8"}
PASS, result value: 8
Has error reported: PASS
Reported error is a compile error: PASS
PASS, result value: 2
PASS, result value: 1
......@@ -143,9 +143,8 @@ function test()
var compileError = result.compileError;
logCheck("Has error reported", !!compileError);
logCheck("Reported error is a compile error", !!compileError);
if (compileError) {
logEqualsCheck(compileError.lineNumber, 2);
}
if (compileError)
logEqualsCheck(compileError.lineNumber, 1);
return next;
}
}
......
......@@ -358,28 +358,23 @@ WebInspector.ResourceScriptFile.prototype = {
/**
* @param {?string} error
* @param {!DebuggerAgent.SetScriptSourceError=} errorData
* @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails
* @this {WebInspector.ResourceScriptFile}
*/
function scriptSourceWasSet(error, errorData)
function scriptSourceWasSet(error, exceptionDetails)
{
if (!error && !errorData)
if (!error && !exceptionDetails)
this._scriptSource = source;
this._update();
if (!error && !errorData)
if (!error && !exceptionDetails)
return;
var warningLevel = WebInspector.Console.MessageLevel.Warning;
if (!errorData) {
WebInspector.console.addMessage(WebInspector.UIString("LiveEdit failed: %s", error), warningLevel);
if (!exceptionDetails) {
WebInspector.console.addMessage(WebInspector.UIString("LiveEdit failed: %s", error), WebInspector.Console.MessageLevel.Warning);
return;
}
if (errorData) {
var messageText = WebInspector.UIString("LiveEdit compile failed: %s", errorData.message);
this._uiSourceCode.addLineMessage(WebInspector.UISourceCode.Message.Level.Error, messageText, errorData.lineNumber - 1, errorData.columnNumber + 1);
} else {
WebInspector.console.addMessage(WebInspector.UIString("Unknown LiveEdit error: %s; %s", JSON.stringify(errorData), error), warningLevel);
}
var messageText = WebInspector.UIString("LiveEdit compile failed: %s", exceptionDetails.text);
this._uiSourceCode.addLineMessage(WebInspector.UISourceCode.Message.Level.Error, messageText, exceptionDetails.lineNumber, exceptionDetails.columnNumber);
}
},
......
......@@ -357,7 +357,7 @@ WebInspector.DebuggerModel.prototype = {
/**
* @param {!RuntimeAgent.ScriptId} scriptId
* @param {string} newSource
* @param {function(?Protocol.Error, !DebuggerAgent.SetScriptSourceError=)} callback
* @param {function(?Protocol.Error, !RuntimeAgent.ExceptionDetails=)} callback
*/
setScriptSource: function(scriptId, newSource, callback)
{
......@@ -367,24 +367,24 @@ WebInspector.DebuggerModel.prototype = {
/**
* @param {!RuntimeAgent.ScriptId} scriptId
* @param {string} newSource
* @param {function(?Protocol.Error, !DebuggerAgent.SetScriptSourceError=)} callback
* @param {function(?Protocol.Error, !RuntimeAgent.ExceptionDetails=)} callback
* @param {?Protocol.Error} error
* @param {!DebuggerAgent.SetScriptSourceError=} errorData
* @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails
* @param {!Array.<!DebuggerAgent.CallFrame>=} callFrames
* @param {!RuntimeAgent.StackTrace=} asyncStackTrace
* @param {boolean=} needsStepIn
*/
_didEditScriptSource: function(scriptId, newSource, callback, error, errorData, callFrames, asyncStackTrace, needsStepIn)
_didEditScriptSource: function(scriptId, newSource, callback, error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn)
{
if (needsStepIn) {
this.stepInto();
this._pendingLiveEditCallback = callback.bind(this, error, errorData);
this._pendingLiveEditCallback = callback.bind(this, error, exceptionDetails);
return;
}
if (!error && callFrames && callFrames.length)
this._pausedScript(callFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData, this._debuggerPausedDetails.breakpointIds, asyncStackTrace);
callback(error, errorData);
callback(error, exceptionDetails);
},
/**
......
......@@ -218,7 +218,7 @@ WebInspector.Script.prototype = {
/**
* @param {string} newSource
* @param {function(?Protocol.Error, !DebuggerAgent.SetScriptSourceError=, !Array.<!DebuggerAgent.CallFrame>=, !RuntimeAgent.StackTrace=, boolean=)} callback
* @param {function(?Protocol.Error, !RuntimeAgent.ExceptionDetails=, !Array.<!DebuggerAgent.CallFrame>=, !RuntimeAgent.StackTrace=, boolean=)} callback
*/
editSource: function(newSource, callback)
{
......@@ -228,7 +228,7 @@ WebInspector.Script.prototype = {
* @param {!Array.<!DebuggerAgent.CallFrame>=} callFrames
* @param {boolean=} stackChanged
* @param {!RuntimeAgent.StackTrace=} asyncStackTrace
* @param {!DebuggerAgent.SetScriptSourceError=} compileError
* @param {!RuntimeAgent.ExceptionDetails=} compileError
*/
function didEditScriptSource(error, callFrames, stackChanged, asyncStackTrace, compileError)
{
......
......@@ -530,7 +530,7 @@ void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString,
Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
Maybe<bool>* stackChanged,
Maybe<StackTrace>* asyncStackTrace,
Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError)
Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError)
{
if (!checkEnabled(errorString))
return;
......
......@@ -86,7 +86,7 @@ public:
Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames,
Maybe<bool>* optOutStackChanged,
Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace,
Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) override;
Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override;
void restartFrame(ErrorString*,
const String16& callFrameId,
std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
......
......@@ -367,7 +367,7 @@ void V8DebuggerImpl::clearStepping()
callDebuggerMethod("clearStepping", 0, argv);
}
bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScriptSourceError>* errorData, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged)
bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString* error, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged)
{
class EnableLiveEditScope {
public:
......@@ -427,10 +427,11 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local<v8::Str
// Compile error.
case 1:
{
*errorData = protocol::Debugger::SetScriptSourceError::create()
.setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2)))
.setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value())
.setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Value()).build();
*exceptionDetails = protocol::Runtime::ExceptionDetails::create()
.setText(toProtocolStringWithTypeCheck(resultTuple->Get(2)))
.setScriptId(String16("0"))
.setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value() - 1)
.setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Value() - 1).build();
return false;
}
}
......
......@@ -88,7 +88,7 @@ public:
void stepOutOfFunction();
void clearStepping();
bool setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString*, Maybe<protocol::Debugger::SetScriptSourceError>*, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged);
bool setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString*, Maybe<protocol::Runtime::ExceptionDetails>*, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged);
JavaScriptCallFrames currentCallFrames(int limit = 0);
// Each script inherits debug data from v8::Context where it has been compiled.
......
......@@ -418,17 +418,6 @@
],
"description": "Scope description."
},
{
"id": "SetScriptSourceError",
"type": "object",
"properties": [
{ "name": "message", "type": "string", "description": "Compiler error message" },
{ "name": "lineNumber", "type": "integer", "description": "Compile error line number (1-based)" },
{ "name": "columnNumber", "type": "integer", "description": "Compile error column number (1-based)" }
],
"description": "Error data for setScriptSource command. Contains uncompilable script source error.",
"hidden": true
},
{
"id": "SearchMatch",
"type": "object",
......@@ -557,7 +546,7 @@
{ "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "New stack trace in case editing has happened while VM was stopped." },
{ "name": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes.", "hidden": true },
{ "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true },
{ "name": "compileError", "optional": true, "$ref": "SetScriptSourceError", "description": "Error data if any." }
{ "name": "compileError", "optional": true, "$ref": "Runtime.ExceptionDetails", "description": "Error data if any." }
],
"description": "Edits JavaScript source live."
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment