[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 926cb45 05/45: Support ES6 computed property names.
From: |
Dmitry Gutov |
Subject: |
[elpa] master 926cb45 05/45: Support ES6 computed property names. |
Date: |
Mon, 02 Feb 2015 03:18:33 +0000 |
branch: master
commit 926cb455eca15f05264d2b0192e96de28d1ba986
Author: Stephen Hicks <address@hidden>
Commit: Stephen Hicks <address@hidden>
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.
---
js2-mode.el | 11 +++++++++++
tests/parser.el | 5 ++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 33d45bd..c53c5b6 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -1955,6 +1955,10 @@ the correct number of ARGS must be provided."
(js2-msg "msg.yield.closing"
"Yield from closing generator")
+;; Classes
+(js2-msg "msg.missing.computed.rb" ; added by js2-mode
+ "missing ']' after computed property expression")
+
;;; Tokens Buffer
(defconst js2-ti-max-lookahead 2)
@@ -9554,6 +9558,13 @@ If ONLY-OF-P is non-nil, only the 'for (foo of bar)'
form is allowed."
(not js2-recover-from-parse-errors))
(setq continue nil)
(push result elems)))
+ ;; {[Symbol.iterator]: ...}
+ ((and (= tt js2-LB)
+ (>= js2-language-version 200))
+ (let ((expr (js2-parse-expr)))
+ (js2-must-match js2-RB "msg.missing.computed.rb")
+ (setq after-comma nil)
+ (push (js2-parse-plain-property expr) elems)))
;; {12: x} or {10.7: x}
((= tt js2-NUMBER)
(setq after-comma nil)
diff --git a/tests/parser.el b/tests/parser.el
index 3804ce8..fe66d36 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -181,7 +181,7 @@ the test."
;;; Object literals
-(js2-deftest-parse abbreviated-object
+(js2-deftest-parse object-literal-shorthand
"var x = {a: 1, b, c: 1, d};")
(js2-deftest-parse object-literal-method
@@ -193,6 +193,9 @@ the test."
(js2-deftest-parse object-literal-setter-method
"var x = {set f(y) { x = y;\n}};")
+(js2-deftest-parse object-literal-computed-keys
+ "var x = {[Symbol.iterator]: function() {}};")
+
;;; Function parameters
(js2-deftest-parse function-with-default-parameters
- [elpa] master updated (d47c872 -> a1ac1e0), Dmitry Gutov, 2015/02/01
- [elpa] master 6037c0f 04/45: Add support for 'u' and 'y' RegExp flags in ES6 mode., Dmitry Gutov, 2015/02/01
- [elpa] master dad2f12 03/45: Support method definitions in object literals., Dmitry Gutov, 2015/02/01
- [elpa] master 926cb45 05/45: Support ES6 computed property names.,
Dmitry Gutov <=
- [elpa] master 30249fa 07/45: Support parsing the ES6 'static' keyword., Dmitry Gutov, 2015/02/01
- [elpa] master c79d426 06/45: Support ES6 class statements/expressions., Dmitry Gutov, 2015/02/01
- [elpa] master 2b0f5ba 08/45: Support parsing the ES6 'super' keyword., Dmitry Gutov, 2015/02/01
- [elpa] master dd344ff 01/45: Support short-hand object literals {foo, bar} everywhere., Dmitry Gutov, 2015/02/01
- [elpa] master b1f7e6c 11/45: Simplify parsing of destructuring literals, Dmitry Gutov, 2015/02/01
- [elpa] master 68b4abd 02/45: Add ES6 class externs, Dmitry Gutov, 2015/02/01
- [elpa] master ee17084 13/45: js2-parse-plain-property: Disallow numbers as abbreviated props, Dmitry Gutov, 2015/02/01
- [elpa] master b19ea52 12/45: js2-parse-named-prop: Highlight externals in abbreviated props, Dmitry Gutov, 2015/02/01
- [elpa] master 31c49e0 14/45: js2-imenu-extension-styles: Turn into defvar, Dmitry Gutov, 2015/02/01
- [elpa] master 9b77d64 15/45: Implement template strings, ignoring substitutions, Dmitry Gutov, 2015/02/01