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 700e49be832ff3b5337fa1282942f4107d146bd3..b98464bdf277dca5feb6e3e8a9e33d147f4a3d99 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.UISourceCode.Message>} */ |
| + this._messages = []; |
| } |
| /** |
| @@ -62,6 +65,8 @@ WebInspector.UISourceCode.Events = { |
| WorkingCopyCommitted: "WorkingCopyCommitted", |
| TitleChanged: "TitleChanged", |
| SourceMappingChanged: "SourceMappingChanged", |
| + MessageAdded: "MessageAdded", |
| + MessageRemoved: "MessageRemoved", |
| } |
| WebInspector.UISourceCode.prototype = { |
| @@ -566,6 +571,45 @@ WebInspector.UISourceCode.prototype = { |
| return new WebInspector.UILocation(this, lineNumber, columnNumber); |
| }, |
| + /** |
| + * @return {!Array<!WebInspector.UISourceCode.Message>} |
| + */ |
| + messages: function() |
| + { |
| + return this._messages.slice(); |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.UISourceCode.Message.Level} level |
| + * @param {string} text |
| + * @param {number} lineNumber |
| + * @param {number=} columnNumber |
| + * @return {!WebInspector.UISourceCode.Message} message |
| + */ |
| + addMessage: function(level, text, lineNumber, columnNumber) |
| + { |
| + var message = new WebInspector.UISourceCode.Message(this, level, text, lineNumber, columnNumber); |
| + this._messages.push(message); |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageAdded, message); |
| + return message; |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.UISourceCode.Message} message |
| + */ |
| + removeMessage: function(message) |
| + { |
| + if (this._messages.remove(message)) |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemoved, message); |
| + }, |
| + |
| + removeAllMessages: function() |
| + { |
| + for (var message of this._messages) |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemoved, message); |
|
dgozman
2015/10/27 21:43:49
For consistency, |message| should be removed from
pfeldman
2015/10/27 22:35:17
Done.
|
| + this._messages = []; |
| + }, |
| + |
| __proto__: WebInspector.Object.prototype |
| } |
| @@ -707,15 +751,17 @@ WebInspector.Revision.prototype = { |
| /** |
| * @constructor |
| + * @param {!WebInspector.UISourceCode} uiSourceCode |
| * @param {!WebInspector.UISourceCode.Message.Level} level |
| * @param {string} text |
| * @param {number} lineNumber |
| * @param {number=} columnNumber |
| */ |
| -WebInspector.UISourceCode.Message = function(level, text, lineNumber, columnNumber) |
| +WebInspector.UISourceCode.Message = function(uiSourceCode, level, text, lineNumber, columnNumber) |
| { |
| - this._text = text; |
| + this._uiSourceCode = uiSourceCode; |
| this._level = level; |
| + this._text = text; |
| this._lineNumber = lineNumber; |
| this._columnNumber = columnNumber; |
| } |
| @@ -730,11 +776,11 @@ WebInspector.UISourceCode.Message.Level = { |
| WebInspector.UISourceCode.Message.prototype = { |
| /** |
| - * @return {string} |
| + * @return {!WebInspector.UISourceCode} |
| */ |
| - text: function() |
| + uiSourceCode: function() |
| { |
| - return this._text; |
| + return this._uiSourceCode; |
| }, |
| /** |
| @@ -746,6 +792,14 @@ WebInspector.UISourceCode.Message.prototype = { |
| }, |
| /** |
| + * @return {string} |
| + */ |
| + text: function() |
| + { |
| + return this._text; |
| + }, |
| + |
| + /** |
| * @return {number} |
| */ |
| lineNumber: function() |
| @@ -767,6 +821,11 @@ WebInspector.UISourceCode.Message.prototype = { |
| */ |
| isEqual: function(another) |
| { |
| - return 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.lineNumber() === another.lineNumber() && this.columnNumber() === another.columnNumber(); |
| + }, |
| + |
| + remove: function() |
| + { |
| + this._uiSourceCode.removeMessage(this); |
| } |
| } |