Stephen Hicks [Mon, 27 Apr 2015 02:17:57 +0000 (19:17 -0700)]
Generalize object literal parsing to support short-hand function/generator/getter/setter declarations with all kinds of keys (string, named, computed, numeric).
Previously only a subset of combinations were supported, but appear to be allowed by the spec.
Stefan Monnier [Wed, 15 Apr 2015 21:18:37 +0000 (17:18 -0400)]
* js2-mode.el (js2-mode): Use cursor-sensor-mode if available.
(js2-export-node): Fix apparent paren typo.
(js2-get-token-internal-1): Remove unused var `quote-char'.
(js2-clear-face): Also remove cursor-sensor-functions.
(js2-parse-primary-expr): Remove unused var `pn'.
(js2-parse-legacy-array-comp): Remove unused var `first'.
(js2-mode-show-node, js2-mode-show-warn-or-err): Use cursor-sensor-functions
if available.
(js2-mode-hide-overlay, js2-echo-error): Adapt to new calling convention.
(js2-echo-help): Declare obsolete.
(js2-mode-extend-comment): Look for the appropriate property.
Jackson Ray Hamilton [Sun, 1 Mar 2015 07:23:23 +0000 (23:23 -0800)]
Fix js2-node-get-enclosing-scope
Previously this function discriminated against nodes that did not have
parents. For such nodes, nil should have been returned, but instead an
error was emitted because a parentless node would produce the initial
parent nil, which would cause js2-node-parent to blow up. This fixes
that.
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).