Title: [207358] trunk/Source/WebInspectorUI
Revision
207358
Author
commit-qu...@webkit.org
Date
2016-10-14 16:04:04 -0700 (Fri, 14 Oct 2016)

Log Message

Web Inspector: Improve debugger highlight when inside of getter/setter calls
https://bugs.webkit.org/show_bug.cgi?id=163428
<rdar://problem/28769061>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2016-10-14
Reviewed by Timothy Hatcher.

* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
When in the middle of a member _expression_ at a '.' or '[' get the best member
_expression_ range.

* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor.prototype._updateExecutionRangeHighlight):
Include the character at the current position. This is useful since AST Nodes
don't give us token info but we would like to know if we are at particular tokens.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (207357 => 207358)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-10-14 22:42:14 UTC (rev 207357)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-10-14 23:04:04 UTC (rev 207358)
@@ -1,5 +1,23 @@
 2016-10-14  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: Improve debugger highlight when inside of getter/setter calls
+        https://bugs.webkit.org/show_bug.cgi?id=163428
+        <rdar://problem/28769061>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
+        When in the middle of a member _expression_ at a '.' or '[' get the best member
+        _expression_ range.
+
+        * UserInterface/Views/TextEditor.js:
+        (WebInspector.TextEditor.prototype._updateExecutionRangeHighlight):
+        Include the character at the current position. This is useful since AST Nodes
+        don't give us token info but we would like to know if we are at particular tokens.
+
+2016-10-14  Joseph Pecoraro  <pecor...@apple.com>
+
         Web Inspector: Unused Breakpoint getter/setter for "id" - should be "identifier"
         https://bugs.webkit.org/show_bug.cgi?id=163395
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (207357 => 207358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2016-10-14 22:42:14 UTC (rev 207357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2016-10-14 23:04:04 UTC (rev 207358)
@@ -1215,7 +1215,7 @@
         this._reinsertAllIssues();
     }
 
-    textEditorExecutionHighlightRange(offset, position, callback)
+    textEditorExecutionHighlightRange(offset, position, characterAtOffset, callback)
     {
         let script = this._getAssociatedScript(position);
         if (!script) {
@@ -1283,6 +1283,8 @@
                 return aLength - bLength;
             });
 
+            let characterAtOffsetIsDotOrBracket = characterAtOffset === "." || characterAtOffset === "[";
+
             for (let i = 0; i < nodes.length; ++i) {
                 let node = nodes[i];
 
@@ -1293,14 +1295,38 @@
                     return;
                 }
 
-                // In the middle of a member _expression_.
+                // In the middle of a member _expression_ we want to highlight the best
+                // member _expression_ range. We can end up in the middle when we are
+                // paused inside of a getter and select the parent call frame. For
+                // these cases we may be at a '.' or '[' and we can find the best member
+                // _expression_ from there.
+                //
+                // Examples:
+                //
+                //     foo*.x.y.z => inside x looking at parent call frame => |foo.x|.y.z
+                //     foo.x*.y.z => inside y looking at parent call frame => |foo.x.y|.z
+                //
+                //     foo*["x"]["y"]["z"] => inside x looking at parent call frame => |foo["x"]|["y"]["z"]
+                //     foo["x"]*["y"]["z"] => inside y looking at parent call frame => |foo["x"]["y"]|["z"]
+                //
                 if (node.type === WebInspector.ScriptSyntaxTree.NodeType.ThisExpression
-                    || node.type === WebInspector.ScriptSyntaxTree.NodeType.IdentifierExpression) {
-                    let nextNode = nodes[i + 1];
-                    if (nextNode && nextNode.type === WebInspector.ScriptSyntaxTree.NodeType.MemberExpression) {
-                        callback(convertRangeOffsetsToSourceCodeOffsets(nextNode.range));
+                    || (characterAtOffsetIsDotOrBracket && (node.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier || node.type === WebInspector.ScriptSyntaxTree.NodeType.MemberExpression))) {
+                    let memberExpressionNode = null;
+                    for (let j = i + 1; j < nodes.length; ++j) {
+                        let nextNode = nodes[j];
+                        if (nextNode.type === WebInspector.ScriptSyntaxTree.NodeType.MemberExpression) {
+                            memberExpressionNode = nextNode;
+                            if (offset === memberExpressionNode.range[1])
+                                continue;
+                        }
+                        break;
+                    }
+
+                    if (memberExpressionNode) {
+                        callback(convertRangeOffsetsToSourceCodeOffsets(memberExpressionNode.range));
                         return;
                     }
+
                     callback(convertRangeOffsetsToSourceCodeOffsets(node.range));
                     return;
                 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (207357 => 207358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2016-10-14 22:42:14 UTC (rev 207357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2016-10-14 23:04:04 UTC (rev 207358)
@@ -1241,8 +1241,9 @@
         let originalOffset = this.currentPositionToOriginalOffset(currentPosition);
         let originalCodeMirrorPosition = this.currentPositionToOriginalPosition(currentPosition);
         let originalPosition = new WebInspector.SourceCodePosition(originalCodeMirrorPosition.line, originalCodeMirrorPosition.ch);
+        let characterAtOffset = this._codeMirror.getRange(currentPosition, {line: this._executionLineNumber, ch: this._executionColumnNumber + 1});
 
-        this._delegate.textEditorExecutionHighlightRange(originalOffset, originalPosition, (range) => {
+        this._delegate.textEditorExecutionHighlightRange(originalOffset, originalPosition, characterAtOffset, (range) => {
             let start, end;
             if (!range) {
                 // Highlight the rest of the line.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to