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