Allow auto-completing non-enumerable properties and member functions return types of known types

NEW
Unassigned

Status

enhancement
P3
normal
3 years ago
5 months ago

People

(Reporter: sebo, Unassigned)

Tracking

(Blocks 3 bugs)

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [btpp-backlog])

(Reporter)

Description

3 years ago
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
(Reporter)

Updated

3 years ago
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
Whiteboard: [btpp-backlog]

Comment 2

3 years ago
> 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/.)
(Reporter)

Updated

2 years ago
Depends on: 1216632
(Reporter)

Updated

2 years ago
Blocks: 1111089

Updated

11 months ago
Product: Firefox → DevTools
(Reporter)

Comment 3

10 months ago
Could this be something for the JsTerm enhancement milestones?

Sebastian
Flags: needinfo?(nchevobbe)
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).
Flags: needinfo?(nchevobbe)
You need to log in before you can comment on or make changes to this bug.