RESOLVED FIXED 148603
Web Inspector: Debugger Popovers should work for object literal shorthand variables
https://bugs.webkit.org/show_bug.cgi?id=148603
Summary Web Inspector: Debugger Popovers should work for object literal shorthand var...
Joseph Pecoraro
Reported 2015-08-28 20:07:56 PDT
* SUMMARY Debugger Popovers should work for object literal shorthand variables. * TEST > 1. var lineNumber = 10; > 2. var columnNumber = 20; > 3. var o0 = { lineNumber: lineNumber, columnNumber: columnNumber }; > 4. var o1 = { lineNumber, columnNumber }; > 5. var o2 = { lineNumber , columnNumber }; > 6. var o2 = { > 7. lineNumber > 8. , > 9. columnNumber > 10. }; > 11. console.log(o1, o2); * STEPS TO REPRODUCE 1. Pause on line 11 in the test case. 2. Hover lineNumber/columnNumber anywhere it is treated as a variable => Expected to see their values, but got nothing on lines 4-10 * NOTES - We should really eventually move to having an Esprima AST where it makes sense, like here. The AST Node for this position would just give us the info we want!
Attachments
[PATCH] Proposed Fix (5.00 KB, patch)
2015-08-28 20:10 PDT, Joseph Pecoraro
no flags
Radar WebKit Bug Importer
Comment 1 2015-08-28 20:08:36 PDT
Joseph Pecoraro
Comment 2 2015-08-28 20:10:18 PDT
Created attachment 260206 [details] [PATCH] Proposed Fix
Timothy Hatcher
Comment 3 2015-08-31 10:12:18 PDT
Comment on attachment 260206 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=260206&action=review > Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:558 > + let state = CodeMirror.copyState(mode, cm.getTokenAt(initialPosition).state); Why does it need to be a copy? Because you use StringStream? Why can't we walk the existing tokens that are already parsed by the CodeMirror instance? CodeMirrorCompletionController and CodeMirrorTokenTrackingController loop using getTokenAt.
Joseph Pecoraro
Comment 4 2015-08-31 12:23:35 PDT
Comment on attachment 260206 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=260206&action=review >> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:558 >> + let state = CodeMirror.copyState(mode, cm.getTokenAt(initialPosition).state); > > Why does it need to be a copy? Because you use StringStream? > > Why can't we walk the existing tokens that are already parsed by the CodeMirror instance? CodeMirrorCompletionController and CodeMirrorTokenTrackingController loop using getTokenAt. I suppose it doesn't need to be a copy, but as a generic algorithm I wanted it to be safe. When I tried getTokenAt(...) it was skipping over whitespace and just giving me the next token. In this case, it wasn't giving me a token for the comma. mode.token() gives me the token type but more importantly each substring, so I could detect the "," or "}" needed here.
WebKit Commit Bot
Comment 5 2015-08-31 15:50:02 PDT
Comment on attachment 260206 [details] [PATCH] Proposed Fix Clearing flags on attachment: 260206 Committed r189190: <http://trac.webkit.org/changeset/189190>
WebKit Commit Bot
Comment 6 2015-08-31 15:50:05 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.