Closed Bug 1216668 Opened 9 years ago Closed 9 years ago

Implement console autocomplete for inline arrays and multiline strings

Categories

(DevTools :: Console, defect)

defect
Not set
normal

Tracking

(firefox44 fixed)

RESOLVED FIXED
Firefox 44
Tracking Status
firefox44 --- fixed

People

(Reporter: bgrins, Assigned: bgrins)

References

(Blocks 1 open bug)

Details

(Whiteboard: [polish-backlog])

Attachments

(2 files)

Right now, if you enter any of these you won't get autocompletion in the console:

[1,2,3].
1.
`foo`.

There's special casing for string literals, but I suspect that if we use Parser.jsm we can detect other types and do better autocompletion
Summary: Implement console autocomplete for inline arrays, numbers, and multiline strings → Implement console autocomplete for inline arrays and multiline strings
Bug 1216668 - Move Parser.jsm to devtools/shared so the webconsole server can use it;r=jryans
Attachment #8676431 - Flags: review?(jryans)
Bug 1216668 - Implement console autocomplete for inline arrays, numbers, and multiline strings;r=fitzgen
Attachment #8676432 - Flags: review?(nfitzgerald)
Comment on attachment 8676431 [details]
MozReview Request: Bug 1216668 - Move Parser.jsm to devtools/shared so the webconsole server can use it;r=jryans

https://reviewboard.mozilla.org/r/22693/#review20179

I am about to change how our resource:// URLs work in bug 1203159, so you'll have some conflicts if that lands before you.  I'll be sending a mail to the list about it later today.
Assignee: nobody → bgrinstead
Status: NEW → ASSIGNED
Attachment #8676432 - Flags: review?(nfitzgerald) → review+
Comment on attachment 8676432 [details]
MozReview Request: Bug 1216668 - Implement console autocomplete for inline arrays, numbers, and multiline strings;r=fitzgen

https://reviewboard.mozilla.org/r/22695/#review20183

r=me with comments below addressed

::: devtools/shared/webconsole/utils.js:878
(Diff revision 1)
> +    let lastTree = syntaxTree._trees[syntaxTree._trees.length - 1];

Accessing private members willy-nilly is a bit of a smell, can you add a .lastSubTree() or lastChild() or something method? As a reader, I'd like to be able to focus on what high level steps we are taking rather than the internal implementation of Parser.jsm.

::: devtools/shared/webconsole/utils.js:886
(Diff revision 1)
> +      if (expression.type === "ArrayExpression") {

Do we want to provide autocomplet suggestions for object literal expressions and Object.prototype? `({ foo: 1 }).`

Would be fine with a follow up.
(In reply to Nick Fitzgerald [:fitzgen][:nf] from comment #4)
> Comment on attachment 8676432 [details]
> MozReview Request: Bug 1216668 - Implement console autocomplete for inline
> arrays, numbers, and multiline strings;r=fitzgen
> 
> https://reviewboard.mozilla.org/r/22695/#review20183
> 
> r=me with comments below addressed
> 
> ::: devtools/shared/webconsole/utils.js:878
> (Diff revision 1)
> > +    let lastTree = syntaxTree._trees[syntaxTree._trees.length - 1];
> 
> Accessing private members willy-nilly is a bit of a smell, can you add a
> .lastSubTree() or lastChild() or something method? As a reader, I'd like to
> be able to focus on what high level steps we are taking rather than the
> internal implementation of Parser.jsm.
> 

Good point, I'll add a getLastSyntaxTree() method on that object (I believe that's the right term since SyntaxTree is the object that has the AST attached to it).

> ::: devtools/shared/webconsole/utils.js:886
> (Diff revision 1)
> > +      if (expression.type === "ArrayExpression") {
> 
> Do we want to provide autocomplet suggestions for object literal expressions
> and Object.prototype? `({ foo: 1 }).`
> 
> Would be fine with a follow up.

Yeah, let's move that into a follow up.  I think there are different expectations with object literals, where you might want to do something like `var foo = { bar: 1 }.` and expect to see 'bar' in that list (which this technique will never do).  But we could discuss this further in another bug.
I believe this will fix Bug 964631 too
Blocks: 964631
May also fix 624311
Blocks: 624311
Depends on: 1217198
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: