Dmitry Gutov [Fri, 21 Nov 2014 14:11:34 +0000 (16:11 +0200)]
Simplify parsing of destructuring literals
js2-parse-named-prop: Drop the "in destructuring" case, parse as abbreviated props.
js2-define-destruct-symbols: Don't expect js2-name nodes directly in js2-object-node.
js2-object-prop-node: Document `SHORTHAND'.
Stephen Hicks [Tue, 11 Nov 2014 02:13:42 +0000 (18:13 -0800)]
Fix string literals in parser.el test harness.
Previously all string literals in tests would fail, because they referred to a temporary buffer that no longer exists. This fix works around this by extending the life of the temporary input buffer.
Stephen Hicks [Tue, 11 Nov 2014 02:05:31 +0000 (18:05 -0800)]
Support parsing the ES6 'super' keyword.
This is basically implemented by imitating the handling of 'this', since they behave in very similar ways. The keyword is defined in the various productions in §12.3 of the draft ES6 spec: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-left-hand-side-expressions, and usage examples are available at e.g. https://github.com/lukehoban/es6features#classes.
Stephen Hicks [Tue, 11 Nov 2014 01:59:47 +0000 (17:59 -0800)]
Support parsing the ES6 'static' keyword.
This is defined in the ClassElement production in §14.5 of the draft ES6 spec: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-class-definitions, and usage examples are available at e.g. https://github.com/lukehoban/es6features#classes.
Stephen Hicks [Tue, 11 Nov 2014 01:54:25 +0000 (17:54 -0800)]
Support ES6 class statements/expressions.
This is specified in §14.5 of the draft ES6 spec: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-class-definitions, and described via examples at https://github.com/lukehoban/es6features#enhanced-object-literals. This commit does not yet add support for the 'static' keyword.
Dmitry Gutov [Thu, 13 Nov 2014 06:34:06 +0000 (08:34 +0200)]
Support orphan functions on the right side of assignments
* js2-imenu-extras.el (js2-imenu-extras-setup): Use the new hook
instead of `js2-post-parse-callbacks'.
(js2-imenu-record-orphan-function): Rename, update the caller.
(js2-imenu-record-orphan-assign-node-function): New function, to
handle orphan functions on the right side of assignments.
(js2-imenu-walk-ast): Use it.
* js2-mode.el (js2-build-imenu-callbacks): New hook variable.
(js2-browse-postprocess-chains): Use it. Make it take no
arguments and be aware of `js2-imenu-recorder'.
(js2-wrapper-function-p): Check that the wrapped function is the
call's target.
(js2-build-imenu-index): Run `js2-browse-postprocess-chains' even
when `js2-imenu-recorder' is empty. It might get modified in
callbacks.
(js2-browse-postprocess-chains): When skipping a function, remove
its entry from `js2-imenu-function-map'.
Stephen Hicks [Tue, 11 Nov 2014 01:42:57 +0000 (17:42 -0800)]
Support ES6 computed property names.
This is specified by the ComputedPropertyName production in §12.2.5 of the draft ES6 spec: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer, and discussed at https://github.com/lukehoban/es6features\#enhanced-object-literals.
Stephen Hicks [Tue, 11 Nov 2014 01:25:28 +0000 (17:25 -0800)]
Add support for 'u' and 'y' RegExp flags in ES6 mode.
These flags are defined in §12.2.7.1 of the draft spec: http://people.mozilla.org/\~jorendorff/es6-draft.html\#sec-primary-expression-regular-expression-literals-static-semantics-early-errors (narrowing the RegularExpressionFlags production defined in §11.8.5). The new flags are described at https://mathiasbynens.be/notes/es6-unicode-regex.
Stephen Hicks [Tue, 11 Nov 2014 01:17:08 +0000 (17:17 -0800)]
Support method definitions in object literals.
This is specified in §14.3 of the current draft spec http://people.mozilla.org/~jorendorff/es6-draft.html#sec-method-definitions, and discussed with examples at http://ariya.ofilabs.com/2013/03/es6-and-method-definitions.html.
Stephen Hicks [Tue, 11 Nov 2014 00:59:04 +0000 (16:59 -0800)]
Add ES6 class externs
These are delineated in §18.3 of the draft spec, Constructor Properties of the Global Object: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-constructor-properties-of-the-global-object.
Stephen Hicks [Tue, 11 Nov 2014 00:14:14 +0000 (16:14 -0800)]
Support short-hand object literals {foo, bar} everywhere.
This is specified in §12.2.5 of the draft spec (http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer) by the production [PropertyDefinition : IdentifierReference], and discussed e.g. in http://ariya.ofilabs.com/2013/02/es6-and-object-literal-property-value-shorthand.html.
Dmitry Gutov [Wed, 5 Nov 2014 09:45:15 +0000 (11:45 +0200)]
Support object destructuring inside arrow function args
* js2-mode.el (js2-parse-plain-property): Don't move too far when
there's no colon.
(js2-parse-assign-expr): Restore the previous value of
`js2-parsed-errors' after arrow token is found.
Dmitry Gutov [Sat, 1 Nov 2014 11:47:01 +0000 (14:47 +0300)]
Fix #171
* js2-mode.el (js2-parse-primary-expr): Use
`js2-current-token-end' to retrieve the end of the current token.
This works better if parsing errored on EOF.
(js2-read-regexp): Don't try to set `syntax-table' property (it
didn't work anyway, `syntax-class' is bogus).
John Mastro [Sun, 19 Jan 2014 20:29:17 +0000 (12:29 -0800)]
Add support for React classes in js2-imenu-extras
Reuse the recorder function already present for Backbone extends. Rename
that function to js2-imenu-record-backbone-or-react and define
js2-imenu-record-backbone-extend and js2-imenu-record-react-class as
aliases of it.
Stefan Monnier [Fri, 6 Sep 2013 02:47:32 +0000 (05:47 +0300)]
* packages/js2-mode/js2-mode.el: Remove unused variables. Use posix
character classes. Do a bit of CSE simplification.
(js2-parse-highlight-member-expr-node): Flip test order to simplify code.
(js2-re-search-forward, js2-re-search-backward): Don't quote code.
(js2-echo-help): Defalias applies to symbol, not functions.
Extract js2-parse-function-stmt and js2-parse-function-expr
* Fix printing of js2-function-nodes with member-expr.
* Prohibit unnamed function expressions where statement is expected.
* Omit the case of "random-member-expr", whatever that is.
Anyone who misses it is welcome to file an issue.