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..8d08a26da203301e2973c23ecd1b81a2b5fffd11 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", |
+ MessageAdded: "MessageAdded", |
+ MessageRemoved: "MessageRemoved" |
} |
WebInspector.UISourceCode.prototype = { |
@@ -566,6 +571,50 @@ WebInspector.UISourceCode.prototype = { |
return new WebInspector.UILocation(this, lineNumber, columnNumber); |
}, |
+ /** |
+ * @param {string} text |
+ * @param {!WebInspector.UISourceCodeMessage.Level} level |
+ * @param {!WebInspector.TextRange} location |
+ * @return {!WebInspector.UISourceCodeMessage} |
+ */ |
+ addMessage: function(text, level, location) |
+ { |
+ var message = new WebInspector.UISourceCodeMessage(text, level, location); |
+ this._messages.push(message); |
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageAdded, message); |
+ return message; |
+ }, |
+ |
+ /** |
+ * @param {!WebInspector.UISourceCodeMessage} message |
+ */ |
+ removeMessage: function(message) |
+ { |
+ for (var i = 0; i < this._messages.length; i++) { |
+ if (message === this._messages[i]) { |
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemoved, this._messages.splice(i, 1)); |
+ return; |
+ } |
+ } |
+ }, |
+ |
+ /** |
+ * @return {!Array<!WebInspector.UISourceCodeMessage>} |
+ */ |
+ messages: function() |
+ { |
+ return this._messages; |
+ }, |
+ |
+ clearMessages: function() |
+ { |
+ var messages = this._messages.slice(0); |
+ this._messages.length = 0; |
+ for (var i = 0; i < messages.length; i++) { |
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemoved, messages[i]); |
+ } |
+ }, |
+ |
__proto__: WebInspector.Object.prototype |
} |
@@ -704,3 +753,59 @@ WebInspector.Revision.prototype = { |
callback([]); |
} |
} |
+ |
+/** |
+ * @constructor |
+ * @param {string} text |
+ * @param {!WebInspector.UISourceCodeMessage.Level} level |
+ * @param {!WebInspector.TextRange} location |
+ */ |
+WebInspector.UISourceCodeMessage = function(text, level, location) { |
+ this._text = text; |
+ this._level = level; |
+ this._location = location; |
+} |
+ |
+WebInspector.UISourceCodeMessage.prototype = { |
+ /** |
+ * @return {string} |
+ */ |
+ text: function() |
+ { |
+ return this._text; |
+ }, |
+ |
+ /** |
+ * @return {!WebInspector.UISourceCodeMessage.Level} |
+ */ |
+ level: function() |
+ { |
+ return this._level; |
+ }, |
+ |
+ /** |
+ * @return {!WebInspector.TextRange} |
+ */ |
+ location: function() |
+ { |
+ return this._location; |
+ }, |
+ |
+ /** |
+ * @param {!WebInspector.UISourceCodeMessage} another |
+ * @return {boolean} |
+ */ |
+ equal: function(another) { |
+ return this.level() === another.level() && |
+ this.text() === another.text() && |
+ this.location().equal(another.location()); |
+ } |
+} |
+ |
+/** |
+ * @enum {string} |
+ */ |
+WebInspector.UISourceCodeMessage.Level = { |
+ Error: "Error", |
+ Warning: "Warning" |
+} |