Bug 68161 - Web Inspector: Provide completions for object literals, arrays and functions
Summary: Web Inspector: Provide completions for object literals, arrays and functions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-15 07:46 PDT by tonistiigi
Modified: 2014-12-13 18:43 PST (History)
10 users (show)

See Also:


Attachments
Patch (5.09 KB, patch)
2011-09-15 08:09 PDT, tonistiigi
pfeldman: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tonistiigi 2011-09-15 07:46:12 PDT
Currently completions are only shown for named objects and strings in the console. If expression contains [, ( or { no completions are shown.

Would be good if in all cases the value is known completions for the object would show up.

Some cases to test with:

[].
({'abc':'def'}).
(function(){}).b

Also "document." provides completions but "(document)." does not.
Comment 1 tonistiigi 2011-09-15 08:09:17 PDT
Created attachment 107497 [details]
Patch

Bit mixed feelings about adding this to the utils.rangeOfWord because it only makes sense on moving backwards. On the other hand, implementing the moving between textnodes again in a separate function wouldn't be good either.

There is also an edge case where expression could change the input value depending on the execution count. Then there would be possibility that expression is already run first when getting the completions. Other way would be to parse it so that all objects/function bodies remain empty {} and arrays empty []. Then we could at least get the completions for prototype properties. In my opinion while debugging it adds very much more if we get all completions for the actual object. I believe same kind of multi-execution also occures on watched expressions.

This should also fix a bug where previously "foo". provided completions but for example "foo{". didn't.
Comment 2 Pavel Feldman 2011-09-15 09:11:42 PDT
Comment on attachment 107497 [details]
Patch

Will it work with regex literals? Like /"/ or /[]]/. I don't think we should implement a JavaScript parser right here.
Comment 3 tonistiigi 2011-09-15 09:31:54 PDT
No it will not. Because / is in the ExpressionStopCharacters array.

RegExp("['\"]"). will work fine now though. 

I realize that there are probably many more constructs like this and they all can't be supported but arrays. objects and functions are very frequently used.

I think one of the best use cases for console is not to just type in variables but people use it to quickly try out some new ideas. The prompt should help them out as much as it can. For example I also think functions should complete to arguments array if it is available.
Comment 4 Brian Burg 2014-12-13 18:43:40 PST
This works now.