Граф коммитов

50 Коммитов

Автор SHA1 Сообщение Дата
Jason Laster 5f29a6d696 Bug 1622996 - Refactor devtools codebase to use optional chaining (automated changes). r=jdescottes
Depends on D67084

Differential Revision: https://phabricator.services.mozilla.com/D67537

--HG--
extra : moz-landing-system : lando
2020-03-19 21:13:38 +00:00
Aman Verma f61414d70a Bug 1616306 - Merge splitInputAtLastPropertyAccess into analyzeInputString, r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D63917

--HG--
extra : moz-landing-system : lando
2020-03-18 10:43:34 +00:00
Jason Laster 327279fdbf Bug 1580083 - Use eager evaluation in console autocomplete. r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D64456

--HG--
extra : moz-landing-system : lando
2020-03-04 15:36:04 +00:00
Nicolas Chevobbe bed183e1a6 Bug 1614914 - Fix TypeError in JsPropertyProvider for debugger keyword. r=Honza.
A check is added, as well as a test to ensure everything
is okay.

Differential Revision: https://phabricator.services.mozilla.com/D62599

--HG--
extra : moz-landing-system : lando
2020-02-13 10:58:52 +00:00
Nicolas Chevobbe 54a45e09dd Bug 1594009 - Add optional chaining support for console autocomplete. r=Honza.
The JsPropertyProvider parser is modified to accept optional chaining
syntax.

Differential Revision: https://phabricator.services.mozilla.com/D60654

--HG--
extra : moz-landing-system : lando
2020-02-11 14:29:09 +00:00
Oriol Brufau 0449ac6039 Bug 1543190 - Fix console autocomplete throwing for null. r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D55391

--HG--
extra : moz-landing-system : lando
2020-01-13 09:39:37 +00:00
Nicolas Chevobbe b4e6628c95 Bug 1604411 - Add expression variables in autocomplete popup. r=Honza.
Variables are retrieved from CodeMirror state and sent to the
webconsole actor, where the filtering is done.

Differential Revision: https://phabricator.services.mozilla.com/D57427

--HG--
extra : moz-landing-system : lando
2019-12-18 11:29:06 +00:00
Julian Descottes 222bc5ccde Bug 1593921 - Use eslint-disable-next-line to disable complexity checks in DevTools r=pbro
Using next-line is less error prone for refactorings than wrapping methods with enable/disable blocks.

Differential Revision: https://phabricator.services.mozilla.com/D51782

--HG--
extra : moz-landing-system : lando
2019-11-05 14:29:04 +00:00
Nicolas Chevobbe 99657d8d0b Bug 1580181 - Reorganize js-property-provider. r=ochameau.
Move analyzeInputString function below JSPropertyProvider, so
the exported function appears first in the file.

Differential Revision: https://phabricator.services.mozilla.com/D49107

--HG--
extra : moz-landing-system : lando
2019-10-15 14:24:48 +00:00
Nicolas Chevobbe 925311bc77 Bug 1568779 - Remove editors settings comments in devtools files. r=pbro.
Differential Revision: https://phabricator.services.mozilla.com/D42300

--HG--
extra : moz-landing-system : lando
2019-08-19 12:48:16 +00:00
Julian Descottes 0ab30c1e08 Bug 1568823 - Simplify parser.js and rename to parser-helper r=nchevobbe
Depends on D39335
Looking in details at get(), the implementation can also be simplified

Differential Revision: https://phabricator.services.mozilla.com/D39338

--HG--
rename : devtools/shared/webconsole/parser.js => devtools/shared/webconsole/parser-helper.js
extra : moz-landing-system : lando
2019-07-25 13:21:03 +00:00
Julian Descottes 5689ca6238 Bug 1568823 - Move Parser.jsm to a regular module in devtools/shared/webconsole r=nchevobbe
Depends on D39333

Differential Revision: https://phabricator.services.mozilla.com/D39335

--HG--
rename : devtools/shared/Parser.jsm => devtools/shared/webconsole/parser.js
extra : moz-landing-system : lando
2019-07-25 13:17:11 +00:00
Nicolas Chevobbe 997f0e4621 Bug 1563761 - Handle comments in analyzeInput. r=ochameau.
We weren't handling comments at all, which means that having
any in the console would probably make the autocomplete not
working.
This patch handles both inline and multiline javascript comments,
and adds test cases to ensure we don't regress.

Depends on D36573

Differential Revision: https://phabricator.services.mozilla.com/D37196

--HG--
extra : moz-landing-system : lando
2019-07-10 08:00:32 +00:00
Nicolas Chevobbe c0c38fd4a3 Bug 1557305 - Speed up JsPropertyProvider analyzeInput function. r=ochameau.
We were using Array.from to get an array of all the characters, and
be able to slice parts of the strings to run some checks.
This had the disadvantage of being quite slow on very large strings,
at a point where we introduced a bail out mechanism into the function
to not block the content page.
This patch switches to `String.prototype[Symbol.iterator]` to loop
over all the character, and removes lots of array and string manipulations.
On the same, super-large, string, the function cost went from 6700ms to
less than 200ms.

Differential Revision: https://phabricator.services.mozilla.com/D36572

--HG--
extra : moz-landing-system : lando
2019-07-08 06:24:38 +00:00
Victor Porof b8157dfaaf Bug 1561435 - Format remaining devtools/, a=automatic-formatting, CLOSED TREE
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D35894

--HG--
extra : source : 4722b924e08478f5337ab509718bd66906bf472f
extra : amend_source : a5baa1aab21639fdba44537e3a10b179b0073cb4
2019-07-05 11:29:32 +02:00
Nicolas Chevobbe 74f4a28c13 Bug 1556068 - Track JsPropertyProvider's analyzeInput string and bail if it's taking too long. r=Honza.
It can happen that the string we receive is quite large
and as a result takes a long time to analyze, freezing
the process.
This patch simply tracks for how long the for loop is running,
and bail out if it's greater than a given time (set to 2500 ms
for now).
This is mostly a safeguard, a future patch should try to improve
the performance of the function itself.

Differential Revision: https://phabricator.services.mozilla.com/D33791

--HG--
extra : moz-landing-system : lando
2019-06-06 13:08:21 +00:00
Patrick Brosset a365f19d19 Bug 1553451 - Lower the eslint complexity level to 20 for devtools and exlude more complex functions; r=jdescottes
We want to go back to ESLint's default complexity level so that newly introduced code is checked for complexity.
At the same time, to make that work, we're excluding all of the more complex functions for now.
We should fix them: make them less complex, and remove the eslint-disable comment.
See bug 1553449 for more information about this.

Differential Revision: https://phabricator.services.mozilla.com/D32139

--HG--
extra : moz-landing-system : lando
2019-05-23 09:06:16 +00:00
Mihai Alexandru Michis 2ae5a4bb01 Backed out changeset 0f9626b48a66 (bug 1553451) for linting failures. CLOSED TREE 2019-05-23 10:58:22 +03:00
Patrick Brosset 28f446d619 Bug 1553451 - Lower the eslint complexity level to 20 for devtools and exlude more complex functions; r=jdescottes
We want to go back to ESLint's default complexity level so that newly introduced code is checked for complexity.
At the same time, to make that work, we're excluding all of the more complex functions for now.
We should fix them: make them less complex, and remove the eslint-disable comment.
See bug 1553449 for more information about this.

Differential Revision: https://phabricator.services.mozilla.com/D32139

--HG--
extra : moz-landing-system : lando
2019-05-23 07:07:49 +00:00
Patrick Brosset babd28f5c6 Bug 1544223 - Disable a few high complexity functions and lower the limit to prevent more complexity; r=jdescottes
Depends on D31973

Differential Revision: https://phabricator.services.mozilla.com/D32120

--HG--
extra : moz-landing-system : lando
2019-05-22 12:08:59 +00:00
Oriol Brufau 0c1218e4d5 Bug 1541422 - Escape special characters in autocomplete. r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D26617

--HG--
extra : moz-landing-system : lando
2019-04-09 16:46:34 +00:00
Nicolas Chevobbe 2884ad3d7c Bug 1527238 - Speed up webconsole server's autocomplete function; r=Honza.
There are 2 changes in this patch.

In js-property-provider, we iterate over a Set
and delete item we don't want into instead of
turning the Set into an array, filter on it, and
convert it back to a new Set.

In the autocomplete function, we don't use regexp
anymore in the sort callback as we already have
a way to tell if we're performing an element access.

Differential Revision: https://phabricator.services.mozilla.com/D19471

--HG--
extra : moz-landing-system : lando
2019-02-15 15:02:51 +00:00
Nicolas Chevobbe 415af1ba97 Bug 1499289 - Change how we deal with getter evaluation in JsPropertyProvider; r=bgrins.
While trying to implement the invoke getter from
autocomplete popup, it became clear to me that the
initial implementation in js-property-provider wasn't
good enough, as we need to keep track of all the
authorizations the user gave when working on a given
expression.

In order to handle this, JsPropertyProvider now
returns an array of strings representing the path
to the unsafe getter when no matching authorizations
are provided.

If authorizations are provided, we can check for each
properties that the user authorized the execution.
This way, we can handle deep object access after a getter
(e.g. `x.myGetter.foo.bar.baz.entries`) without asking
the user if they want to invoke `myGetter` on each
step of the completion.

This makes handling intermediary getters (e.g.
`x.myGetter.foo.myOtherGetter.bar`) way easier as well.
In the UI, the user will be prompted to invoke the getter one
after the other (if for example they try to complete a pasted
expression which contains multiple getters, they will have
prompts for `myGetter`, and then for `myOtherGetter`).

We wire-up the webconsole client and the webconsole actor for
the autocomplete function, to make them ready for frontend
use.

The existing JsPropertyProvider getters test are updated to
match the change of parameter (invokeGetter -> authorizedEvaluations),
and some tests are added to make sure everything work as intended.

Differential Revision: https://phabricator.services.mozilla.com/D12940

--HG--
extra : moz-landing-system : lando
2019-01-07 09:49:10 +00:00
Nicolas Chevobbe 09c8a73d83 Bug 1231489 - Use content prototype for autocompletion of String, Number and Array literals; r=bgrins.
When provided a string, number or array literals, we use to
simply return the properties from String.prototype, Number.prototype
and Array.prototype.
This is working fine unless the content prototypes are modified.
In order to make it work properly, we retrieve the actual content
prototype.
The js-property-provider unit test is modified to ensure this is
working as expected.

Differential Revision: https://phabricator.services.mozilla.com/D15843

--HG--
extra : moz-landing-system : lando
2019-01-08 07:59:24 +00:00
Nicolas Chevobbe 047f13303a Bug 1510422 - Fix autocomplete cache handling; r=Honza.
In Bug 1462394, we moved the autocomplete data handling
out of the JsTerm to the Redux store. In the process, we
regress some cases like `await n`, which should display
`navigator`, but isn't anymore when the user types the
whole sequence. Ctrl+Space would still show the popup,
which indicates that the issue is not on the server-side.

This issue is caused because our new code decides that
we should hit the cache when typing the `n`, and there's
nothing in the cache.

Previously, we were clearing the cache as soon as the input
last string wasn't alphanumeric, which we don't anymore.
To fix that, instead of relying on the last string of the
input (which could be wrong in cases like `x.["hello `), we
clear the cache when the autocomplete service returns a null
`matches` property.

In the JsPropertyProvider, we use to return null whenever
there isn't any search done (incorrect input, empty match prop, …).
So it seems like a good idea to bust the cache when the
server returns null.

This requires some changes to the autocomplete service, as well
as some in jsPropertyProvider (e.g. to handle `await `).

Tests are added both on the client and the frontend to make sure
we don't regress this (those tests fail without the actual fix).

Differential Revision: https://phabricator.services.mozilla.com/D13231

--HG--
extra : moz-landing-system : lando
2018-11-29 13:58:57 +00:00
Nicolas Chevobbe 0689e637de Bug 1473841 - Don't return dot-notation invalid properties; r=Honza.
In JsPropertyProvider, if doing a property access (with a dot),
check that the results are suited for a dot notation (e.g. `data`
is, while `data-test` is not).
In case, of an element access, we can return everything.

This implies making some changes to some tests which were using
invalid dot notation access in some case, which revealed a
bug with bracket autocomplete and spaces.

So the bracket autocomplete with spaces is now also fixed, and
a test case was added for that as well.

Differential Revision: https://phabricator.services.mozilla.com/D12726

--HG--
extra : moz-landing-system : lando
2018-11-27 13:46:46 +00:00
Nicolas Chevobbe 701560ca88 Bug 1506867 - Use AST to get the properties-access chain; r=bgrins.
Differential Revision: https://phabricator.services.mozilla.com/D11893

--HG--
extra : moz-landing-system : lando
2018-11-20 06:43:03 +00:00
Nicolas Chevobbe 78252467c2 Bug 1216632 - Make autocompletion work on $_ and $0; r=bgrins.
To make $0 autocompletion work, we need to pass the current
selectedNode actor from the frontend, so we can retrieve the
object reference later.
For $_, we need the webconsole actor reference to be able
to retrieve the last input result.
Since the list of parameters of JsPropertyProviders was
getting a bit long, we transform them in an object so it's
more legible on the consumer side.
Mochitests are added for both helpers to ensure this work
as expected.

Differential Revision: https://phabricator.services.mozilla.com/D11866

--HG--
extra : moz-landing-system : lando
2018-11-15 09:49:14 +00:00
Nicolas Chevobbe 4708654a02 Bug 1479366 - Handle Number literals in JsPropertyProvider; r=bgrins.
When provided a number literal, JsPropertyProvider would
not return anything.
This patch solves this issue by adding an if case for those
objects.
Numerous test cases are added in test_js_property_provider to
make sure we handle this as expected and that we don't have
false positives.

Differential Revision: https://phabricator.services.mozilla.com/D11483

--HG--
extra : moz-landing-system : lando
2018-11-12 07:39:38 +00:00
Nicolas Chevobbe 8886ca62e0 Bug 1505393 - Add better handling of unsafe getters in JsPropertyProvider; r=bgrins.
This patch adds two things to JsPropertyProvider:
- when provided an input which try to access an unsafe
getter properties, the function will indicate that an
unsafe getter should be invoked, with its name.
- a new boolean argument that when set to true would
invoke any unsafe getter that might be in the expression
to be completed.

For simplicity sake, the function only warns the user
of the presence of an unsafe getter when it's the last
property of the expression:

`object.myGetter.` will return that `myGetter` should be invoked
`object.myGetter.a.b.` will not (because then, a and b could
also be getters, and it's getting complex to handle both in
the function itself as in the UI).

Tests are added to ensure this works as expected.

Differential Revision: https://phabricator.services.mozilla.com/D11170

--HG--
extra : moz-landing-system : lando
2018-11-08 15:47:53 +00:00
Mark Banner ceaeb93550 Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D8389

--HG--
extra : moz-landing-system : lando
2018-10-19 12:55:39 +00:00
Nicolas Chevobbe c6c345bff2 Bug 1498598 - Make js-property-provider better; r=bgrins.
This patches solves 2 issues:
- it doesn't return any result when the user is trying to
perform a variable, function or class declaration (e.g.
var d).
- js-property-provider used to compute the last statement
by only looking for space or ; chars. But there are a lot
of cases (basically each time using an operator), where we
should return results and we weren't.
Test cases are added to cover those fixes.

Differential Revision: https://phabricator.services.mozilla.com/D8968

--HG--
extra : moz-landing-system : lando
2018-10-17 15:02:41 +00:00
Nicolas Chevobbe 14ff2e3235 Bug 1476656 - Trigger autocomplete on bracket; r=Honza.
This patch adds the ability to open the autocomplete popup when
typing an opening bracket (i.e. `[`]) in the console input.
This impacts a significant amount of function where we assumed
that the only way to get a completion was to use a dot.
We uses the rename `anylyzeInputString` function to get the
completion part from an input, as well as if the user is performing
an element access (i.e., using the bracket).
We then send that information to the webconsole actor, which send
it to the client.
This allows us to rely on a single parse of the input and gives us
access to this information everywhere we need to, be it on the client
or on the server.

We allow the user to type property name without quotes, and we add
them when the user accept an autocompletion.
We also automatically add a closing bracket (i.e. `]`), when it's needed.

Some test are added. On the server side to make sure the actor's autocomplete
function returns what's expected.
We take that as an opportunity to add test for commands.
On the client side, tests are added to ensure the different behavior works
as expected (check the completion text and the input  after accepting
the completion when the user entered some letters, or not, with or without
quotes, with different quotes, hitting the autocomplete cache, …).

A test which accesses the autocomplete cache was modified since the shape
of the cache changed to include the last matchProp as well as the
isElementAccess boolean.

Differential Revision: https://phabricator.services.mozilla.com/D6128

--HG--
extra : moz-landing-system : lando
2018-09-26 13:54:35 +00:00
Nicolas Chevobbe f0d64d744d Bug 1217198 - Better autocompletion for template literals; r=Honza.
Add a new template literal state to findCompletionBeginning so we can
better handle the autocompletion for them.

Differential Revision: https://phabricator.services.mozilla.com/D4853

--HG--
extra : moz-landing-system : lando
2018-09-05 11:37:33 +00:00
Nicolas Chevobbe f9b5460bf2 Bug 672733 - Make autocomplete search case insensitive; r=Honza.
This patch adds a smarter heuristic for autocompletion results:
if the input first letter is lowercased, then we'll filter
matching properties case insensitively. But if the user starts
with an uppercase, we assume they know the property they want
and thus respect the casing.
For example: `win` will return both `window` and `Window`, but
`Win` will return `Window` only.
Due to this behavior, we change the order of the autocomplete
results so lowercased property are displayed before the uppercased
one.
If we take are example again, it's likely that if a user type `win`,
they want `window`, but the alphabetical order would return `Window`
first which would annoy user.

Now, since we return results that does not match exactly the user
input, we need to modify the frontend.

Usually, we only show the autocompletion popup if there are
at least 2 matching items, since 1 matching item will still
be displayed using the autocompletion text. But now, since the
input might not match, we want to still display the popup if
there is one matching item, but starts differentely than what
the user entered.
For example, the user typed `window.addeve`, which matches
`addEventListener`. The completion text will make it looks like
it will be completed to `window.addeventListener`, which would
be undefined. So showing the popup with the actual matching
property might avoid some confusion for the user.

A test was added to make sure the frontend works as expected.
Some test cases were added in the server test to make sure
the actor returns expected results. Other tests needed some
adjustement because of the insensitive case matches and the
new order of results.

Differential Revision: https://phabricator.services.mozilla.com/D4061

--HG--
extra : moz-landing-system : lando
2018-08-27 16:08:56 +00:00
Nicolas Chevobbe c1e79affbb Bug 1472117 - Fix autocompletion with "." surrounded by spaces; r=bgrins.
Expressions like `window . addEventListener` are perfectly valid in JS,
but our autocompletion provider wasn't working well in such case.
We modify the JSPropertyProvider to make sure to handle this kind of
syntax and add test cases to make sure it works as intended.`

Differential Revision: https://phabricator.services.mozilla.com/D2988

--HG--
extra : moz-landing-system : lando
2018-08-14 13:40:08 +00:00
Julian Descottes 640fe52298 Bug 1454696 - Run eslint --fix for prefer-const;r=yulia
MozReview-Commit-ID: F6xUXCgdRE4

--HG--
extra : rebase_source : 65de1b0aba412d9044b5196115f74276caa058f2
2018-06-01 12:36:09 +02:00
Oriol Brufau eeeaa16395 Bug 1457711 - Catch errors thrown by console's property previewer; r=nchevobbe
MozReview-Commit-ID: LKsYn5gSn58

--HG--
extra : rebase_source : c6290683d3959a06df517c84c9f30a4c10255b60
2018-04-28 22:29:43 +02:00
J. Ryan Stinnett 23ff4cc75d Bug 1443081 - Apply spacing via `eslint --fix` for DevTools. r=jdescottes
MozReview-Commit-ID: 2RVNt140Zte
2018-03-12 13:44:41 -05:00
Florian Quèze 2b1c8dccb6 Bug 1339461 - script-generated patch to convert foo.indexOf(...) == -1 to foo.includes(), r=Mossop. 2018-02-01 20:45:22 +01:00
Mark Banner 0370057096 Bug 1371293 - Fix various devtools warnings after upgrading to ESLint 4. r=miker
ESLint 4 will turn on all rules after an eslint-enable with no arguments. Therefore be more specific about which rules are being disabled.

MozReview-Commit-ID: IoPBG72zySm

--HG--
extra : rebase_source : f0095f7a9bc3020c1a36387cd033d1b1238a61cf
2017-11-06 14:01:33 +00:00
Sebastian Hengst cb76f56d60 Backed out changeset 6bc38f188ef2 (bug 1330099) for devtools failures. r=backout 2017-01-11 23:21:56 +01:00
Tim Nguyen d7ea1c1605 Bug 1330099 - Enable object-shorthand eslint rule. r=jryans
MozReview-Commit-ID: 3wA25rfznBv
2017-01-11 21:22:15 +00:00
J. Ryan Stinnett 0b07b90aa6 Bug 1263258 - Require space before paren for anonymous functions. r=pbro
MozReview-Commit-ID: 2F0j45Vxn2I
2016-04-27 09:06:15 -05:00
Dave Townsend fc4c4ab84a Bug 1257246: Update devtools for eslint 2. r=pbro
ESLint 2 now flags anonymous generator functions according to
generator-star-spacing. Most of the changes here are correcting that.

MozReview-Commit-ID: 9xg2Gmlaz94

--HG--
extra : rebase_source : e6db0fd0ef477cd4fd2196b1036783f0974c586b
extra : histedit_source : 03eea033884969cc2a340316377318b0487ebdf2
2016-04-05 11:31:19 -07:00
Tom Tromey fbafa60ad1 Bug 1255799 - make devtools/client/webconsole eslint-clean; r=odvarko
MozReview-Commit-ID: AnaXFFHlNLM
2016-03-16 08:16:00 +01:00
Lin Clark 3e48b93fed Bug 1241956 - Use standard license boilerplate in webconsole js files. r=bgrins
--HG--
extra : commitid : 9KHzQR1VrHq
2016-01-25 11:19:58 -08:00
Brian Grinstead 69db7d4a63 Bug 1207868 - Fix lexical scope autocomplete for global 'let' and 'const';r=past
--HG--
extra : commitid : 7UugPolKfrw
2015-12-03 11:35:33 -08:00
Brian Grinstead c35cd26b68 Bug 1218455 - Special case 'this' to include in console autocompletion;r=fitzgen
--HG--
extra : commitid : 5DSbxvVyd3w
2015-12-02 09:24:16 -08:00
Brian Grinstead f2795041dc Bug 1217591 - Make JS autocompletion in the console work inside of a worker toolbox;r=fitzgen
--HG--
rename : devtools/shared/webconsole/utils.js => devtools/shared/webconsole/js-property-provider.js
extra : commitid : Am93ZaJlGjE
2015-10-26 11:55:40 -07:00