Commit eb1c4e09 authored by wwigham's avatar wwigham Committed by Commit bot

use TextRange in UISourceCode.Message, allow addMessage to take a TextRange

Replacement for https://codereview.chromium.org/1416793005/

BUG=484261

Review URL: https://codereview.chromium.org/1456943003

Cr-Commit-Position: refs/heads/master@{#361243}
parent 167ac0ed
......@@ -178,7 +178,7 @@ WebInspector.PresentationConsoleMessage.prototype = {
{
if (this._uiMessage)
this._uiMessage.remove();
this._uiMessage = uiLocation.uiSourceCode.addMessage(this._level, this._text, uiLocation.lineNumber, uiLocation.columnNumber);
this._uiMessage = uiLocation.uiSourceCode.addLineMessage(this._level, this._text, uiLocation.lineNumber, uiLocation.columnNumber);
},
dispose: function()
......
......@@ -381,7 +381,7 @@ WebInspector.ResourceScriptFile.prototype = {
var compileError = errorData.compileError;
if (compileError) {
var messageText = WebInspector.UIString("LiveEdit compile failed: %s", compileError.message);
this._uiSourceCode.addMessage(WebInspector.UISourceCode.Message.Level.Error, messageText, compileError.lineNumber - 1, compileError.columnNumber + 1);
this._uiSourceCode.addLineMessage(WebInspector.UISourceCode.Message.Level.Error, messageText, compileError.lineNumber - 1, compileError.columnNumber + 1);
} else {
WebInspector.console.addMessage(WebInspector.UIString("Unknown LiveEdit error: %s; %s", JSON.stringify(errorData), error), warningLevel);
}
......
......@@ -73,7 +73,7 @@ WebInspector.JavaScriptCompiler.prototype = {
}
if (!exceptionDetails)
return;
this._sourceFrame.uiSourceCode().addMessage(WebInspector.UISourceCode.Message.Level.Error, exceptionDetails.text, exceptionDetails.line - 1, exceptionDetails.column + 1);
this._sourceFrame.uiSourceCode().addLineMessage(WebInspector.UISourceCode.Message.Level.Error, exceptionDetails.text, exceptionDetails.line - 1, exceptionDetails.column + 1);
this._compilationFinishedForTest();
}
},
......
......@@ -596,9 +596,20 @@ WebInspector.UISourceCode.prototype = {
* @param {number=} columnNumber
* @return {!WebInspector.UISourceCode.Message} message
*/
addMessage: function(level, text, lineNumber, columnNumber)
addLineMessage: function(level, text, lineNumber, columnNumber)
{
var message = new WebInspector.UISourceCode.Message(this, level, text, lineNumber, columnNumber);
return this.addMessage(level, text, new WebInspector.TextRange(lineNumber, columnNumber || 0, lineNumber, columnNumber || 0));
},
/**
* @param {!WebInspector.UISourceCode.Message.Level} level
* @param {string} text
* @param {!WebInspector.TextRange} range
* @return {!WebInspector.UISourceCode.Message} message
*/
addMessage: function(level, text, range)
{
var message = new WebInspector.UISourceCode.Message(this, level, text, range);
this._messages.push(message);
this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageAdded, message);
return message;
......@@ -765,16 +776,14 @@ WebInspector.Revision.prototype = {
* @param {!WebInspector.UISourceCode} uiSourceCode
* @param {!WebInspector.UISourceCode.Message.Level} level
* @param {string} text
* @param {number} lineNumber
* @param {number=} columnNumber
* @param {!WebInspector.TextRange} range
*/
WebInspector.UISourceCode.Message = function(uiSourceCode, level, text, lineNumber, columnNumber)
WebInspector.UISourceCode.Message = function(uiSourceCode, level, text, range)
{
this._uiSourceCode = uiSourceCode;
this._level = level;
this._text = text;
this._lineNumber = lineNumber;
this._columnNumber = columnNumber;
this._range = range;
}
/**
......@@ -810,12 +819,19 @@ WebInspector.UISourceCode.Message.prototype = {
return this._text;
},
/**
* @return {!WebInspector.TextRange}
*/
range: function() {
return this._range;
},
/**
* @return {number}
*/
lineNumber: function()
{
return this._lineNumber;
return this._range.startLine;
},
/**
......@@ -823,7 +839,7 @@ WebInspector.UISourceCode.Message.prototype = {
*/
columnNumber: function()
{
return this._columnNumber;
return this._range.startColumn;
},
/**
......@@ -832,7 +848,7 @@ WebInspector.UISourceCode.Message.prototype = {
*/
isEqual: function(another)
{
return this._uiSourceCode === another._uiSourceCode && this.text() === another.text() && this.level() === another.level() && this.lineNumber() === another.lineNumber() && this.columnNumber() === another.columnNumber();
return this._uiSourceCode === another._uiSourceCode && this.text() === another.text() && this.level() === another.level() && this.range().equal(another.range());
},
remove: function()
......
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