Open Bug 1267140 Opened 3 years ago Updated 9 months ago
Allow auto-completing non-enumerable properties and member functions return types of known types
There should be auto-completion for global objects and known variable types to help while typing. Examples: Typing 'getElementById("foo").' (without single quotes, of course) into the command line should provide you with a list of suggestions for the HTMLElement or SVGElement interface. Typing '/foo/.source.' should show the suggestions for the String interface. The same is valid for the command line APIs $, $$, $0 and $_. I.e. when you type '$("div").' into the command line, you should see all options of the HTMLElement interface (in case it returns an element). Firebug has this feature implemented. It's list of known types can be seen here: https://github.com/firebug/firebug/blob/master/extension/content/firebug/console/autoCompleter.js#L1483-L1673 Sebastian
Summary: Allow auto-completion non-enumerable properties and member functions return types of known types → Allow auto-completing non-enumerable properties and member functions return types of known types
Nice idea, this would be a good enhancement
Priority: -- → P3
> Typing '/foo/.source.' should show the suggestions for the String interface. > The same is valid for the command line APIs [...] $0 and $_. I would argue that those are two separate bugs: the first about parsing JS more finely (as is already done for strings and arrays) and the second about the auto-completion code not knowing very much about the helper APIs. I can't find bugs for any of them, though. Not being able to auto-complete "$0." is definitely something that has bugged me. > https://github.com/firebug/firebug/blob/master/extension/content/firebug/console/autoCompleter.js#L1483-L1673 I think if I redid this, I would have gone with a list of pure functions instead, that were safe to call from auto-completion. One could do something like bug 943496 to make it safer. (Firebug naively assumes that functions starting with "get" and "$" are pure, which is less safe, but works nicely in practice and solves the "$" and "$$" cases as a side effect.) Anyway, I think nowadays the proper way to solve this would be to use tern.js's engine for auto-completion. (See e.g. http://ternjs.net/doc/demo/.)
Could this be something for the JsTerm enhancement milestones? Sebastian
We are looking at something similar to Chrome's eager evaluation for future js term milestones. Firebug's list approach might be an interesting stopgap or alternative data source. I added it to the enhancements backlog, but would like to hear Nicolas' thoughts on using the list approach.
It seems like something we could do indeed. We do have better parsing on the server now, which gives us an AST, so in some cases we could choose to retrieve things from prototypes (like we do for string, array and number literals for now).
You need to log in before you can comment on or make changes to this bug.