Bug 1315242 - Part 2: Display line number and column number in error message for console input. r=bgrins

This commit is contained in:
Tooru Fujisawa 2016-11-11 01:06:26 +09:00
Родитель 61de62099e
Коммит 1aace015d6
5 изменённых файлов: 29 добавлений и 17 удалений

Просмотреть файл

@ -147,14 +147,8 @@ module.exports = createClass({
let tooltip = long;
// If the source is linkable and line > 0
const shouldDisplayLine = isLinkable && line;
// Exclude all falsy values, including `0`, as even
// a number 0 for line doesn't make sense, and should not be displayed.
// If source isn't linkable, don't attempt to append line and column
// info, as this probably doesn't make sense.
if (shouldDisplayLine) {
// Exclude all falsy values, including `0`, as line numbers start with 1.
if (line) {
tooltip += `:${line}`;
// Intentionally exclude 0
if (column) {
@ -193,8 +187,8 @@ module.exports = createClass({
className: "frame-link-filename",
}, displaySource));
// If source is linkable, and we have a line number > 0
if (shouldDisplayLine) {
// If we have a line number > 0.
if (line) {
let lineInfo = `:${line}`;
// Add `data-line` attribute for testing
attributes["data-line"] = line;

Просмотреть файл

@ -33,6 +33,7 @@ function EvaluationResult(props) {
level,
id: messageId,
exceptionDocURL,
frame,
} = message;
let messageBody;
@ -55,6 +56,7 @@ function EvaluationResult(props) {
scrollToMessage: props.autoscroll,
serviceContainer,
exceptionDocURL,
frame,
};
return Message(childProps);
}

Просмотреть файл

@ -130,13 +130,12 @@ const Message = createClass({
const repeat = this.props.repeat ? MessageRepeat({repeat: this.props.repeat}) : null;
// Configure the location.
const shouldRenderFrame = frame && frame.source !== "debugger eval code";
const location = dom.span({ className: "message-location devtools-monospace" },
shouldRenderFrame ? FrameView({
frame ? FrameView({
frame,
onClick: serviceContainer.onViewSourceInDebugger,
onClick: serviceContainer ? serviceContainer.onViewSourceInDebugger : undefined,
showEmptyPathAsHost: true,
sourceMapService: serviceContainer.sourceMapService
sourceMapService: serviceContainer ? serviceContainer.sourceMapService : undefined
}) : null
);

Просмотреть файл

@ -184,6 +184,7 @@ function transformPacket(packet) {
let {
exceptionMessage: messageText,
exceptionDocURL,
frame,
result: parameters
} = packet;
@ -195,6 +196,7 @@ function transformPacket(packet) {
messageText,
parameters,
exceptionDocURL,
frame,
});
}
}

Просмотреть файл

@ -888,7 +888,7 @@ WebConsoleActor.prototype =
let evalResult = evalInfo.result;
let helperResult = evalInfo.helperResult;
let result, errorDocURL, errorMessage, errorGrip = null;
let result, errorDocURL, errorMessage, errorGrip = null, frame = null;
if (evalResult) {
if ("return" in evalResult) {
result = evalResult.return;
@ -929,6 +929,20 @@ WebConsoleActor.prototype =
try {
errorDocURL = ErrorDocs.GetURL(error);
} catch (ex) {}
try {
let line = error.errorLineNumber;
let column = error.errorColumnNumber;
if (typeof line === "number" && typeof column === "number") {
// Set frame only if we have line/column numbers.
frame = {
source: "debugger eval code",
line,
column
};
}
} catch (ex) {}
}
}
@ -951,6 +965,7 @@ WebConsoleActor.prototype =
exception: errorGrip,
exceptionMessage: this._createStringGrip(errorMessage),
exceptionDocURL: errorDocURL,
frame,
helperResult: helperResult,
};
},
@ -1203,6 +1218,8 @@ WebConsoleActor.prototype =
* in the Inspector (or null, if there is no selection). This is used
* for helper functions that make reference to the currently selected
* node, like $0.
* - url: the url to evaluate the script as. Defaults to
* "debugger eval code".
* @return object
* An object that holds the following properties:
* - dbg: the debugger where the string was evaluated.
@ -1212,8 +1229,6 @@ WebConsoleActor.prototype =
* - result: the result of the evaluation.
* - helperResult: any result coming from a Web Console commands
* function.
* - url: the url to evaluate the script as. Defaults to
* "debugger eval code".
*/
evalWithDebugger: function WCA_evalWithDebugger(aString, aOptions = {})
{