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.
Dmitry Gutov [Thu, 29 Aug 2013 22:58:33 +0000 (01:58 +0300)]
Implement two-token lookahead
* Use `js2-token' defstruct to store token info.
* Cache tokens in a vector buffer `js2-ti-tokens'.
* Obviously, a deoptimization, gives us performance hit:
- ~60% slower in interpreted mode (Emacs 24.3.50.1).
- ~50% slower in compiled mode.
* `mod' is actually slightly faster than `logand' for our usage.
* Optimizations tried:
- Cache the current token.
- Cache the current token type.
- Reuse the token structs, instead of creating new one each time.
- Set the js2-token struct's type to `vector' or `list', disabling
the usage of the tag symbol, and thus getting rid of type checking.
Gives us ~15% improvement in interpreted mode, but no significant
change in compiled mode.