Web Inspector: Line error widget showed in the wrong resource
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Apr 2016 00:44:45 +0000 (00:44 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Apr 2016 00:44:45 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150009
<rdar://problem/23062199>

Reviewed by Timothy Hatcher.

This addresses a few long standing issues:

    - IssueMessage and ConsoleMessage should not fight eachother
    - Displayed issue messages now correctly have format string formatting, e.g. console.error("Foo %s", str)
    - IssueMessage wraps a ConsoleMessage, so we don't duplicate everything
    - Gives ConsoleMessage a sourceCodeLocation (lazy)
        - Since a sourceCodeLocation can have the exact SourceCode, if it was a Script
          without a Resource, we can only show the error in the Script's editor.

* UserInterface/Models/CallFrame.js:
(WebInspector.CallFrame.fromPayload):
Prefer the script identifier lookup first. And from the Script go
to a resource if possible. This allows us to distinguish a location
that should be in a Script that doesn't have a Resource when there
exists a Resource with the same URL. This will soon be the case
for dyanamic <script> elements append to a document.

* UserInterface/Controllers/IssueManager.js:
(WebInspector.IssueManager.issueMatchSourceCode):
Consolidate all the different checks to this one function.

(WebInspector.IssueManager.prototype.issueWasAdded):
Create IssueMessages with ConsoleMessages.

(WebInspector.IssueManager.prototype.issuesForSourceCode):
Simplify now that we have the better check.

* UserInterface/Controllers/LogManager.js:
(WebInspector.LogManager.prototype.messageWasAdded):
Once a ConsoleMessage has been created (and modified `parameters` for us)
create the IssueMessage if it was an issue.

* UserInterface/Models/ConsoleMessage.js:
(WebInspector.ConsoleMessage.prototype.get sourceCodeLocation):
Lazily create a source code from the best possible location. This can
be the top call frame or the url/line/column combination.

* UserInterface/Models/IssueMessage.js:
(WebInspector.IssueMessage):
Creation and most properties just call through to a ConsoleMessage.
The `type` and `text` are Issue specific. Anything that uses location
data should use the sourceCodeLocation.

(WebInspector.IssueMessage.prototype.saveIdentityToCookie):
Fix implementation that didn't account for a null sourceCodeLocation.

(WebInspector.IssueMessage.prototype._formatTextIfNecessary):
Basic text format message formatting.

* UserInterface/Protocol/ConsoleObserver.js:
(WebInspector.ConsoleObserver.prototype.messageAdded):
No longer call IssueMessage from the observer. Let LogManager trigger issues.

* UserInterface/Views/ContentView.js:
(WebInspector.ContentView.createFromRepresentedObject):
(WebInspector.ContentView.resolvedRepresentedObjectForRepresentedObject):
(WebInspector.ContentView.isViewable):
An IssueMessage represented object for an IssueMessageTreeElement should be
restorable by just going to the sourceCodeLocation it references. This is
identical to a Breakpoint.

* UserInterface/Views/IssueTreeElement.js:
(WebInspector.IssueTreeElement.prototype._updateTitles):
(WebInspector.IssueTreeElement):
* UserInterface/Views/ResourceContentView.js:
(WebInspector.ResourceContentView.prototype._issueWasAdded):
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._issueWasAdded):
(WebInspector.SourceCodeTextEditor.prototype._addIssue):
(WebInspector.SourceCodeTextEditor.prototype._reinsertAllIssues):
(WebInspector.SourceCodeTextEditor.prototype._matchesIssue): Deleted.
Update to use Issue's sourceCodeLocation or IssueManager's new APIs.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200064 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/IssueManager.js
Source/WebInspectorUI/UserInterface/Controllers/LogManager.js
Source/WebInspectorUI/UserInterface/Models/CallFrame.js
Source/WebInspectorUI/UserInterface/Models/ConsoleMessage.js
Source/WebInspectorUI/UserInterface/Models/IssueMessage.js
Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js
Source/WebInspectorUI/UserInterface/Views/ContentView.js
Source/WebInspectorUI/UserInterface/Views/IssueTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js

index 9e7a856..e509fac 100644 (file)
@@ -1,3 +1,84 @@
+2016-04-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Line error widget showed in the wrong resource
+        https://bugs.webkit.org/show_bug.cgi?id=150009
+        <rdar://problem/23062199>
+
+        Reviewed by Timothy Hatcher.
+
+        This addresses a few long standing issues:
+
+            - IssueMessage and ConsoleMessage should not fight eachother
+            - Displayed issue messages now correctly have format string formatting, e.g. console.error("Foo %s", str)
+            - IssueMessage wraps a ConsoleMessage, so we don't duplicate everything
+            - Gives ConsoleMessage a sourceCodeLocation (lazy)
+                - Since a sourceCodeLocation can have the exact SourceCode, if it was a Script
+                  without a Resource, we can only show the error in the Script's editor.            
+
+        * UserInterface/Models/CallFrame.js:
+        (WebInspector.CallFrame.fromPayload):
+        Prefer the script identifier lookup first. And from the Script go
+        to a resource if possible. This allows us to distinguish a location
+        that should be in a Script that doesn't have a Resource when there
+        exists a Resource with the same URL. This will soon be the case
+        for dyanamic <script> elements append to a document.
+
+        * UserInterface/Controllers/IssueManager.js:
+        (WebInspector.IssueManager.issueMatchSourceCode):
+        Consolidate all the different checks to this one function.
+
+        (WebInspector.IssueManager.prototype.issueWasAdded):
+        Create IssueMessages with ConsoleMessages.
+
+        (WebInspector.IssueManager.prototype.issuesForSourceCode):
+        Simplify now that we have the better check.
+
+        * UserInterface/Controllers/LogManager.js:
+        (WebInspector.LogManager.prototype.messageWasAdded):
+        Once a ConsoleMessage has been created (and modified `parameters` for us)
+        create the IssueMessage if it was an issue.
+
+        * UserInterface/Models/ConsoleMessage.js:
+        (WebInspector.ConsoleMessage.prototype.get sourceCodeLocation):
+        Lazily create a source code from the best possible location. This can
+        be the top call frame or the url/line/column combination.
+
+        * UserInterface/Models/IssueMessage.js:
+        (WebInspector.IssueMessage):
+        Creation and most properties just call through to a ConsoleMessage.
+        The `type` and `text` are Issue specific. Anything that uses location
+        data should use the sourceCodeLocation.
+        
+        (WebInspector.IssueMessage.prototype.saveIdentityToCookie):
+        Fix implementation that didn't account for a null sourceCodeLocation.
+
+        (WebInspector.IssueMessage.prototype._formatTextIfNecessary):
+        Basic text format message formatting.
+
+        * UserInterface/Protocol/ConsoleObserver.js:
+        (WebInspector.ConsoleObserver.prototype.messageAdded):
+        No longer call IssueMessage from the observer. Let LogManager trigger issues.
+
+        * UserInterface/Views/ContentView.js:
+        (WebInspector.ContentView.createFromRepresentedObject):
+        (WebInspector.ContentView.resolvedRepresentedObjectForRepresentedObject):
+        (WebInspector.ContentView.isViewable):
+        An IssueMessage represented object for an IssueMessageTreeElement should be
+        restorable by just going to the sourceCodeLocation it references. This is
+        identical to a Breakpoint.
+
+        * UserInterface/Views/IssueTreeElement.js:
+        (WebInspector.IssueTreeElement.prototype._updateTitles):
+        (WebInspector.IssueTreeElement):
+        * UserInterface/Views/ResourceContentView.js:
+        (WebInspector.ResourceContentView.prototype._issueWasAdded):
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype._issueWasAdded):
+        (WebInspector.SourceCodeTextEditor.prototype._addIssue):
+        (WebInspector.SourceCodeTextEditor.prototype._reinsertAllIssues):
+        (WebInspector.SourceCodeTextEditor.prototype._matchesIssue): Deleted.
+        Update to use Issue's sourceCodeLocation or IssueManager's new APIs.
+
 2016-04-24  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Can't sort by name/source code location columns in Timeline data grids
index 1bdd83c..c7fb4d3 100644 (file)
@@ -35,6 +35,17 @@ WebInspector.IssueManager = class IssueManager extends WebInspector.Object
         this.initialize();
     }
 
+    static issueMatchSourceCode(issue, sourceCode)
+    {
+        if (sourceCode instanceof WebInspector.SourceMapResource)
+            return issue.sourceCodeLocation && issue.sourceCodeLocation.displaySourceCode === sourceCode;
+        if (sourceCode instanceof WebInspector.Resource)
+            return issue.url === sourceCode.url && (!issue.sourceCodeLocation || issue.sourceCodeLocation.sourceCode === sourceCode);
+        if (sourceCode instanceof WebInspector.Script)
+            return (issue.sourceCodeLocation && issue.sourceCodeLocation.sourceCode === sourceCode) || (!issue.sourceCodeLocation && issue.url === sourceCode.url);
+        return false;
+    }
+
     // Public
 
     initialize()
@@ -44,15 +55,10 @@ WebInspector.IssueManager = class IssueManager extends WebInspector.Object
         this.dispatchEventToListeners(WebInspector.IssueManager.Event.Cleared);
     }
 
-    issueWasAdded(source, level, text, url, lineNumber, columnNumber, parameters)
+    issueWasAdded(consoleMessage)
     {
-        var modifiedLineNumber;
-        if (lineNumber) {
-            console.assert(typeof lineNumber === "number");
-            modifiedLineNumber = lineNumber - 1;
-        }
+        let issue = new WebInspector.IssueMessage(consoleMessage);
 
-        var issue = new WebInspector.IssueMessage(source, level, text, url, modifiedLineNumber, columnNumber, parameters);
         this._issues.push(issue);
 
         this.dispatchEventToListeners(WebInspector.IssueManager.Event.IssueWasAdded, {issue});
@@ -63,9 +69,8 @@ WebInspector.IssueManager = class IssueManager extends WebInspector.Object
         var issues = [];
 
         for (var i = 0; i < this._issues.length; ++i) {
-            // FIXME: Support issues based on Script identifiers too.
             var issue = this._issues[i];
-            if (issue.url === sourceCode.url)
+            if (WebInspector.IssueManager.issueMatchSourceCode(issue, sourceCode))
                 issues.push(issue);
         }
 
index 1567638..a653723 100644 (file)
@@ -49,8 +49,12 @@ WebInspector.LogManager = class LogManager extends WebInspector.Object
         if (parameters)
             parameters = parameters.map(WebInspector.RemoteObject.fromPayload);
 
-        var message = new WebInspector.ConsoleMessage(source, level, text, type, url, line, column, repeatCount, parameters, stackTrace, null);
+        let message = new WebInspector.ConsoleMessage(source, level, text, type, url, line, column, repeatCount, parameters, stackTrace, null);
+
         this.dispatchEventToListeners(WebInspector.LogManager.Event.MessageAdded, {message});
+
+        if (message.level === "warning" || message.level === "error")
+            WebInspector.issueManager.issueWasAdded(message);
     }
 
     messagesCleared()
index 1ad903a..b31fb7a 100644 (file)
@@ -150,11 +150,16 @@ WebInspector.CallFrame = class CallFrame extends WebInspector.Object
             nativeCode = true;
             url = null;
         } else if (url || scriptId) {
-            let sourceCode = WebInspector.frameResourceManager.resourceForURL(url);
+            let sourceCode = null;
+            if (scriptId) {
+                sourceCode = WebInspector.debuggerManager.scriptForIdentifier(scriptId);
+                if (sourceCode && sourceCode.resource)
+                    sourceCode = sourceCode.resource;
+            }
+            if (!sourceCode)
+                sourceCode = WebInspector.frameResourceManager.resourceForURL(url);
             if (!sourceCode)
                 sourceCode = WebInspector.debuggerManager.scriptsForURL(url)[0];
-            if (!sourceCode && scriptId)
-                sourceCode = WebInspector.debuggerManager.scriptForIdentifier(scriptId);
 
             if (sourceCode) {
                 // The lineNumber is 1-based, but we expect 0-based.
index 32b2744..7e1c4a6 100644 (file)
@@ -32,15 +32,17 @@ WebInspector.ConsoleMessage = class ConsoleMessage extends WebInspector.Object
         console.assert(typeof source === "string");
         console.assert(typeof level === "string");
         console.assert(typeof message === "string");
-        console.assert(!parameters || parameters.every(function(x) { return x instanceof WebInspector.RemoteObject; }));
+        console.assert(!parameters || parameters.every((x) => x instanceof WebInspector.RemoteObject));
 
         this._source = source;
         this._level = level;
         this._messageText = message;
         this._type = type || WebInspector.ConsoleMessage.MessageType.Log;
+
         this._url = url || null;
         this._line = line || 0;
         this._column = column || 0;
+        this._sourceCodeLocation = undefined;
 
         this._repeatCount = repeatCount || 0;
         this._parameters = parameters;
@@ -52,59 +54,44 @@ WebInspector.ConsoleMessage = class ConsoleMessage extends WebInspector.Object
 
     // Public
 
-    get source()
-    {
-        return this._source;
-    }
-
-    get level()
-    {
-        return this._level;
-    }
-
-    get messageText()
-    {
-        return this._messageText;
-    }
-
-    get type()
-    {
-        return this._type;
-    }
-
-    get url()
-    {
-        return this._url;
-    }
-
-    get line()
-    {
-        return this._line;
-    }
-
-    get column()
-    {
-        return this._column;
-    }
-
-    get repeatCount()
-    {
-        return this._repeatCount;
-    }
-
-    get parameters()
-    {
-        return this._parameters;
-    }
-
-    get stackTrace()
-    {
-        return this._stackTrace;
-    }
-
-    get request()
+    get source() { return this._source; }
+    get level() { return this._level; }
+    get messageText() { return this._messageText; }
+    get type() { return this._type; }
+    get url() { return this._url; }
+    get line() { return this._line; }
+    get column() { return this._column; }
+    get repeatCount() { return this._repeatCount; }
+    get parameters() { return this._parameters; }
+    get stackTrace() { return this._stackTrace; }
+    get request() { return this._request; }
+
+    get sourceCodeLocation()
     {
-        return this._request;
+        if (this._sourceCodeLocation !== undefined)
+            return this._sourceCodeLocation;
+
+        // First try to get the location from the top frame of the stack trace.
+        let topCallFrame = this._stackTrace.callFrames[0];
+        if (topCallFrame && topCallFrame.sourceCodeLocation) {
+            this._sourceCodeLocation = topCallFrame.sourceCodeLocation;
+            return this._sourceCodeLocation;
+        }
+
+        // If that doesn't exist try to get a location from the url/line/column in the ConsoleMessage.
+        // FIXME <http://webkit.org/b/76404>: Remove the string equality checks for undefined once we don't get that value anymore.
+        if (this._url && this._url !== "undefined") {
+            let sourceCode = WebInspector.frameResourceManager.resourceForURL(this._url);
+            if (sourceCode) {
+                let lineNumber = this._line > 0 ? this._line - 1 : 0;
+                let columnNumber = this._column > 0 ? this._column - 1 : 0;
+                this._sourceCodeLocation = new WebInspector.SourceCodeLocation(sourceCode, lineNumber, columnNumber);
+                return this._sourceCodeLocation;
+            }
+        }
+
+        this._sourceCodeLocation = null;
+        return this._sourceCodeLocation;
     }
 };
 
index 82151e9..efd8747 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 WebInspector.IssueMessage = class IssueMessage extends WebInspector.Object
 {
-    constructor(source, level, text, url, lineNumber, columnNumber, parameters)
+    constructor(consoleMessage)
     {
         super();
 
-        this._level = level;
-        this._text = text;
-        this._source = source;
+        console.assert(consoleMessage instanceof WebInspector.ConsoleMessage);
 
-        // FIXME <http://webkit.org/b/76404>: Remove the string equality checks for undefined
-        // once we don't get that value anymore from WebCore.
+        this._consoleMessage = consoleMessage;
 
-        // FIXME: If the URL is undefined, get the URL from the stacktrace.
-        if (url && url !== "undefined")
-            this._url = url;
+        this._text = this._issueText();
 
-        if (typeof lineNumber === "number" && lineNumber >= 0 && this._url)
-            this._sourceCodeLocation = new WebInspector.SourceCodeLocation(WebInspector.frameResourceManager.resourceForURL(url), lineNumber, columnNumber);
-
-        // FIXME: <https://webkit.org/b/142553> Web Inspector: Merge IssueMessage/ConsoleMessage - both attempt to modify the Console Messages parameter independently
-
-        if (parameters && parameters !== "undefined") {
-            this._parameters = [];
-            for (var i = 0; i < parameters.length; ++i) {
-                if (parameters[i] instanceof WebInspector.RemoteObject) {
-                    this._parameters.push(parameters[i]);
-                    continue;
-                }
-
-                if (typeof parameters[i] === "object")
-                    this._parameters.push(WebInspector.RemoteObject.fromPayload(parameters[i]));
-                else
-                    this._parameters.push(WebInspector.RemoteObject.fromPrimitiveValue(parameters[i]));
-            }
-        }
-
-        this._formatTextIfNecessary();
-
-        switch (source) {
+        switch (this._consoleMessage.source) {
         case "javascript":
             // FIXME: It would be nice if we had this information (the specific type of JavaScript error)
             // as part of the data passed from WebCore, instead of having to determine it ourselves.
@@ -101,6 +74,7 @@ WebInspector.IssueMessage = class IssueMessage extends WebInspector.Object
             this._type = WebInspector.IssueMessage.Type.OtherIssue;
         }
 
+        this._sourceCodeLocation = consoleMessage.sourceCodeLocation;
         if (this._sourceCodeLocation)
             this._sourceCodeLocation.addEventListener(WebInspector.SourceCodeLocation.Event.DisplayLocationChanged, this._sourceCodeLocationDisplayLocationChanged, this);
     }
@@ -134,83 +108,39 @@ WebInspector.IssueMessage = class IssueMessage extends WebInspector.Object
 
     // Public
 
-    get type()
-    {
-        return this._type;
-    }
-
-    get level()
-    {
-        return this._level;
-    }
-
-    get text()
-    {
-        return this._text;
-    }
-
-    get source()
-    {
-        return this._source;
-    }
-
-    get url()
-    {
-        return this._url;
-    }
-
-    get lineNumber()
-    {
-        if (this._sourceCodeLocation)
-            return this._sourceCodeLocation.lineNumber;
-    }
-
-    get columnNumber()
-    {
-        if (this._sourceCodeLocation)
-            return this._sourceCodeLocation.columnNumber;
-    }
+    get text() { return this._text; }
+    get type() { return this._type; }
+    get level() { return this._consoleMessage.level; }
+    get source() { return this._consoleMessage.source; }
+    get url() { return this._consoleMessage.url; }
+    get sourceCodeLocation() { return this._sourceCodeLocation; }
 
-    get displayLineNumber()
-    {
-        if (this._sourceCodeLocation)
-            return this._sourceCodeLocation.displayLineNumber;
-    }
-
-    get displayColumnNumber()
-    {
-        if (this._sourceCodeLocation)
-            return this._sourceCodeLocation.displayColumnNumber;
-    }
-
-    get sourceCodeLocation()
-    {
-        return this._sourceCodeLocation;
-    }
+    // Protected
 
     saveIdentityToCookie(cookie)
     {
         cookie[WebInspector.IssueMessage.URLCookieKey] = this.url;
-        cookie[WebInspector.IssueMessage.LineNumberCookieKey] = this.sourceCodeLocation.lineNumber;
-        cookie[WebInspector.IssueMessage.ColumnNumberCookieKey] = this.sourceCodeLocation.columnNumber;
+        cookie[WebInspector.IssueMessage.LineNumberCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.lineNumber : 0;
+        cookie[WebInspector.IssueMessage.ColumnNumberCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.columnNumber : 0;
     }
 
     // Private
 
-    _formatTextIfNecessary()
+    _issueText()
     {
-        if (!this._parameters)
-            return;
+        let parameters = this._consoleMessage.parameters;
+        if (!parameters)
+            return this._consoleMessage.messageText;
 
-        if (WebInspector.RemoteObject.type(this._parameters[0]) !== "string")
-            return;
+        if (WebInspector.RemoteObject.type(parameters[0]) !== "string")
+            return this._consoleMessage.messageText;
 
         function valueFormatter(obj)
         {
             return obj.description;
         }
 
-        var formatters = {};
+        let formatters = {};
         formatters.o = valueFormatter;
         formatters.s = valueFormatter;
         formatters.f = valueFormatter;
@@ -223,13 +153,13 @@ WebInspector.IssueMessage = class IssueMessage extends WebInspector.Object
             return a;
         }
 
-        var result = String.format(this._parameters[0].description, this._parameters.slice(1), formatters, "", append);
-        var resultText = result.formattedResult;
+        let result = String.format(parameters[0].description, parameters.slice(1), formatters, "", append);
+        let resultText = result.formattedResult;
 
-        for (var i = 0; i < result.unusedSubstitutions.length; ++i)
+        for (let i = 0; i < result.unusedSubstitutions.length; ++i)
             resultText += " " + result.unusedSubstitutions[i].description;
 
-        this._text = resultText;
+        return resultText;
     }
 
     _sourceCodeLocationDisplayLocationChanged(event)
index c42dc80..6ee4e69 100644 (file)
@@ -29,17 +29,12 @@ WebInspector.ConsoleObserver = class ConsoleObserver
 
     messageAdded(message)
     {
-        if (message.type === "assert" && !message.text)
-            message.text = WebInspector.UIString("Assertion");
-
-        if (message.level === "warning" || message.level === "error") {
-            // FIXME: <https://webkit.org/b/142553> Web Inspector: Merge IssueMessage/ConsoleMessage - both attempt to modify the Console Messages parameter independently
-            WebInspector.issueManager.issueWasAdded(message.source, message.level, message.text, message.url, message.line, message.column || 0);
-        }
-
         if (message.source === "console-api" && message.type === "clear")
             return;
 
+        if (message.type === "assert" && !message.text)
+            message.text = WebInspector.UIString("Assertion");
+
         WebInspector.logManager.messageWasAdded(message.source, message.level, message.text, message.type, message.url, message.line, message.column || 0, message.repeatCount, message.parameters, message.stackTrace, message.networkRequestId);
     }
 
index a5d77fb..5c03df5 100644 (file)
@@ -78,7 +78,7 @@ WebInspector.ContentView = class ContentView extends WebInspector.View
                 return new WebInspector.HeapAllocationsTimelineView(representedObject, extraArguments);
         }
 
-        if (representedObject instanceof WebInspector.Breakpoint) {
+        if (representedObject instanceof WebInspector.Breakpoint || representedObject instanceof WebInspector.IssueMessage) {
             if (representedObject.sourceCodeLocation)
                 return WebInspector.ContentView.createFromRepresentedObject(representedObject.sourceCodeLocation.displaySourceCode, extraArguments);
         }
@@ -188,7 +188,7 @@ WebInspector.ContentView = class ContentView extends WebInspector.View
         if (representedObject instanceof WebInspector.Frame)
             return representedObject.mainResource;
 
-        if (representedObject instanceof WebInspector.Breakpoint) {
+        if (representedObject instanceof WebInspector.Breakpoint || representedObject instanceof WebInspector.IssueMessage) {
             if (representedObject.sourceCodeLocation)
                 return representedObject.sourceCodeLocation.displaySourceCode;
         }
@@ -214,7 +214,7 @@ WebInspector.ContentView = class ContentView extends WebInspector.View
             return true;
         if (representedObject instanceof WebInspector.Timeline)
             return true;
-        if (representedObject instanceof WebInspector.Breakpoint)
+        if (representedObject instanceof WebInspector.Breakpoint || representedObject instanceof WebInspector.IssueMessage)
             return representedObject.sourceCodeLocation;
         if (representedObject instanceof WebInspector.DOMStorageObject)
             return true;
index 78581a1..666c085 100644 (file)
@@ -56,8 +56,8 @@ WebInspector.IssueTreeElement = class IssueTreeElement extends WebInspector.Debu
 
     _updateTitles()
     {
-        var displayLineNumber = this._issueMessage.displayLineNumber;
-        var displayColumnNumber = this._issueMessage.displayColumnNumber;
+        var displayLineNumber = this._issueMessage.sourceCodeLocation.displayLineNumber;
+        var displayColumnNumber = this._issueMessage.sourceCodeLocation.displayColumnNumber;
         var title;
         if (displayColumnNumber > 0)
             title = WebInspector.UIString("Line %d:%d").format(displayLineNumber + 1, displayColumnNumber + 1); // The user visible line and column numbers are 1-based.
index 9f83b1a..bbc8606 100644 (file)
@@ -119,9 +119,7 @@ WebInspector.ResourceContentView = class ResourceContentView extends WebInspecto
         console.assert(!this.managesOwnIssues);
 
         var issue = event.data.issue;
-
-        // FIXME: Check more than just the issue URL (the document could have multiple resources with the same URL).
-        if (issue.url !== this.resource.url)
+        if (!WebInspector.IssueManager.issueMatchSourceCode(issue, this.resource))
             return;
 
         this.addIssue(issue);
index e1d6749..81de329 100644 (file)
@@ -790,20 +790,10 @@ WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspec
         return false;
     }
 
-    _matchesIssue(issue)
-    {
-        if (this._sourceCode instanceof WebInspector.Resource)
-            return issue.url === this._sourceCode.url;
-        // FIXME: Support issues for Scripts based on id, not only by URL.
-        if (this._sourceCode instanceof WebInspector.Script)
-            return issue.url === this._sourceCode.url;
-        return false;
-    }
-
     _issueWasAdded(event)
     {
         var issue = event.data.issue;
-        if (!this._matchesIssue(issue))
+        if (!WebInspector.IssueManager.issueMatchSourceCode(issue, this._sourceCode))
             return;
 
         this._addIssue(issue);
@@ -811,8 +801,7 @@ WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspec
 
     _addIssue(issue)
     {
-        // FIXME: Issue should have a SourceCodeLocation.
-        var sourceCodeLocation = this._sourceCode.createSourceCodeLocation(issue.lineNumber, issue.columnNumber);
+        var sourceCodeLocation = issue.sourceCodeLocation;
         var lineNumber = sourceCodeLocation.formattedLineNumber;
 
         var lineNumberIssues = this._issuesLineNumberMap.get(lineNumber);
@@ -823,7 +812,7 @@ WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspec
 
         // Avoid displaying duplicate issues on the same line.
         for (var existingIssue of lineNumberIssues) {
-            if (existingIssue.columnNumber === issue.columnNumber && existingIssue.text === issue.text)
+            if (existingIssue.sourceCodeLocation.columnNumber === sourceCodeLocation.columnNumber && existingIssue.text === issue.text)
                 return;
         }
 
@@ -1208,10 +1197,8 @@ WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspec
         this._clearWidgets();
 
         var issues = WebInspector.issueManager.issuesForSourceCode(this._sourceCode);
-        for (var issue of issues) {
-            console.assert(this._matchesIssue(issue));
+        for (var issue of issues)
             this._addIssue(issue);
-        }
     }
 
     _debuggerDidPause(event)