Changeset 207358 in webkit


Ignore:
Timestamp:
Oct 14, 2016 4:04:04 PM (7 years ago)
Author:
commit-queue@webkit.org
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 <Joseph Pecoraro> 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.

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r207356 r207358  
     12016-10-14  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Improve debugger highlight when inside of getter/setter calls
     4        https://bugs.webkit.org/show_bug.cgi?id=163428
     5        <rdar://problem/28769061>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * UserInterface/Views/SourceCodeTextEditor.js:
     10        (WebInspector.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
     11        When in the middle of a member expression at a '.' or '[' get the best member
     12        expression range.
     13
     14        * UserInterface/Views/TextEditor.js:
     15        (WebInspector.TextEditor.prototype._updateExecutionRangeHighlight):
     16        Include the character at the current position. This is useful since AST Nodes
     17        don't give us token info but we would like to know if we are at particular tokens.
     18
    1192016-10-14  Joseph Pecoraro  <pecoraro@apple.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js

    r207354 r207358  
    12161216    }
    12171217
    1218     textEditorExecutionHighlightRange(offset, position, callback)
     1218    textEditorExecutionHighlightRange(offset, position, characterAtOffset, callback)
    12191219    {
    12201220        let script = this._getAssociatedScript(position);
     
    12841284            });
    12851285
     1286            let characterAtOffsetIsDotOrBracket = characterAtOffset === "." || characterAtOffset === "[";
     1287
    12861288            for (let i = 0; i < nodes.length; ++i) {
    12871289                let node = nodes[i];
     
    12941296                }
    12951297
    1296                 // In the middle of a member expression.
     1298                // In the middle of a member expression we want to highlight the best
     1299                // member expression range. We can end up in the middle when we are
     1300                // paused inside of a getter and select the parent call frame. For
     1301                // these cases we may be at a '.' or '[' and we can find the best member
     1302                // expression from there.
     1303                //
     1304                // Examples:
     1305                //
     1306                //     foo*.x.y.z => inside x looking at parent call frame => |foo.x|.y.z
     1307                //     foo.x*.y.z => inside y looking at parent call frame => |foo.x.y|.z
     1308                //
     1309                //     foo*["x"]["y"]["z"] => inside x looking at parent call frame => |foo["x"]|["y"]["z"]
     1310                //     foo["x"]*["y"]["z"] => inside y looking at parent call frame => |foo["x"]["y"]|["z"]
     1311                //
    12971312                if (node.type === WebInspector.ScriptSyntaxTree.NodeType.ThisExpression
    1298                     || node.type === WebInspector.ScriptSyntaxTree.NodeType.IdentifierExpression) {
    1299                     let nextNode = nodes[i + 1];
    1300                     if (nextNode && nextNode.type === WebInspector.ScriptSyntaxTree.NodeType.MemberExpression) {
    1301                         callback(convertRangeOffsetsToSourceCodeOffsets(nextNode.range));
     1313                    || (characterAtOffsetIsDotOrBracket && (node.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier || node.type === WebInspector.ScriptSyntaxTree.NodeType.MemberExpression))) {
     1314                    let memberExpressionNode = null;
     1315                    for (let j = i + 1; j < nodes.length; ++j) {
     1316                        let nextNode = nodes[j];
     1317                        if (nextNode.type === WebInspector.ScriptSyntaxTree.NodeType.MemberExpression) {
     1318                            memberExpressionNode = nextNode;
     1319                            if (offset === memberExpressionNode.range[1])
     1320                                continue;
     1321                        }
     1322                        break;
     1323                    }
     1324
     1325                    if (memberExpressionNode) {
     1326                        callback(convertRangeOffsetsToSourceCodeOffsets(memberExpressionNode.range));
    13021327                        return;
    13031328                    }
     1329
    13041330                    callback(convertRangeOffsetsToSourceCodeOffsets(node.range));
    13051331                    return;
  • trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js

    r207227 r207358  
    12421242        let originalCodeMirrorPosition = this.currentPositionToOriginalPosition(currentPosition);
    12431243        let originalPosition = new WebInspector.SourceCodePosition(originalCodeMirrorPosition.line, originalCodeMirrorPosition.ch);
    1244 
    1245         this._delegate.textEditorExecutionHighlightRange(originalOffset, originalPosition, (range) => {
     1244        let characterAtOffset = this._codeMirror.getRange(currentPosition, {line: this._executionLineNumber, ch: this._executionColumnNumber + 1});
     1245
     1246        this._delegate.textEditorExecutionHighlightRange(originalOffset, originalPosition, characterAtOffset, (range) => {
    12461247            let start, end;
    12471248            if (!range) {
Note: See TracChangeset for help on using the changeset viewer.