Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| index b712caec39202e087977898903fd4721db843ef4..99eb4d6ad375101a10531da96b08b93fde96c9a4 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| @@ -52,6 +52,9 @@ WebInspector.UISourceCode = function(project, parentPath, name, originURL, conte |
| /** @type {!Array.<!WebInspector.Revision>} */ |
| this.history = []; |
| this._hasUnsavedCommittedChanges = false; |
| + |
| + /** @type {!Array<!WebInspector.UISourceCodeMessage>} */ |
| + this._messages = []; |
| } |
| /** |
| @@ -62,6 +65,8 @@ WebInspector.UISourceCode.Events = { |
| WorkingCopyCommitted: "WorkingCopyCommitted", |
| TitleChanged: "TitleChanged", |
| SourceMappingChanged: "SourceMappingChanged", |
| + LineMessageAdded: "LineMessageAdded", |
|
pfeldman
2015/10/27 17:37:34
These are not exactly line messages, MessageAdded?
wes
2015/10/27 21:59:16
MessageAdded is more succinct, so if its meaning i
|
| + LineMessageRemoved: "LineMessageRemoved" |
| } |
| WebInspector.UISourceCode.prototype = { |
| @@ -566,6 +571,34 @@ WebInspector.UISourceCode.prototype = { |
| return new WebInspector.UILocation(this, lineNumber, columnNumber); |
| }, |
| + /** |
| + * @param {!WebInspector.UISourceCodeMessage} message |
| + */ |
| + addLineMessage: function(message) { |
|
pfeldman
2015/10/27 17:37:34
addLineMessage: function(level, text, location)
{
wes
2015/10/27 21:59:16
Seems fine.
|
| + for (var i = 0; i < this._messages.length; i++) { |
| + var m = this._messages[i]; |
| + if (m.equal(message)) { |
|
pfeldman
2015/10/27 17:44:04
There is no reason to dedupe them here.
wes
2015/10/27 21:59:16
Alright - we do still dedupe them in the display p
|
| + return; |
| + } |
| + } |
| + this._messages.push(message); |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineMessageAdded, message); |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.UISourceCodeMessage} message |
| + */ |
| + removeLineMessage: function(message) { |
|
pfeldman
2015/10/27 17:37:34
Should we remove messages by identity objects?
wes
2015/10/27 21:59:16
If we don't dedupe them on entry, then we should p
|
| + for (var i = 0; i < this._messages.length; i++) { |
| + var m = this._messages[i]; |
| + if (m.equal(message)) { |
| + this._messages.splice(i, 1); |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineMessageRemoved, message); |
| + break; |
| + } |
| + } |
| + }, |
| + |
| __proto__: WebInspector.Object.prototype |
|
pfeldman
2015/10/27 17:37:34
messages() accessor and clearMessages() would come
wes
2015/10/27 21:59:16
For sure. clearMessages() is going to fire many me
|
| } |
| @@ -704,3 +737,51 @@ WebInspector.Revision.prototype = { |
| callback([]); |
| } |
| } |
| + |
| +/** |
| + * @constructor |
| + * @param {string} text |
| + * @param {string} kind |
| + * @param {!WebInspector.TextRange} location |
| + */ |
| +WebInspector.UISourceCodeMessage = function(text, kind, location) { |
| + this._text = text; |
| + this._kind = kind; |
| + this._location = location; |
| +} |
| + |
| +WebInspector.UISourceCodeMessage.prototype = { |
| + /** |
| + * @return {string} |
| + */ |
| + text: function() |
| + { |
| + return this._text; |
| + }, |
| + |
| + /** |
| + * @return {string} |
| + */ |
| + kind: function() |
| + { |
| + return this._kind; |
| + }, |
| + |
| + /** |
| + * @return {!WebInspector.TextRange} |
| + */ |
| + location: function() |
| + { |
| + return this._location; |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.UISourceCodeMessage} another |
| + * @return {boolean} |
| + */ |
| + equal: function(another) { |
| + return this.kind() === another.kind() && |
| + this.text() === another.text() && |
| + this.location().equal(another.location()); |
| + } |
| +} |