[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master fa419df 093/110: Merge pull request #327 from XeCycle/ckw-
From: |
Dmitry Gutov |
Subject: |
[elpa] master fa419df 093/110: Merge pull request #327 from XeCycle/ckw-as |
Date: |
Thu, 23 Jun 2016 01:13:02 +0000 (UTC) |
branch: master
commit fa419dfbb7d7029f0e6916b43623886e2ad92c5d
Merge: 812df51 c162f35
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Merge pull request #327 from XeCycle/ckw-as
Colorize contextual keyword as in import & export
---
js2-mode.el | 162 ++++++++++++++++++++++++++++-------------------------------
1 file changed, 77 insertions(+), 85 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 292af25..ed0ff68 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -8632,50 +8632,47 @@ imports or a namespace import that follows it.
"Parse a namespace import expression such as '* as bar'.
The current token must be js2-MUL."
(let ((beg (js2-current-token-beg)))
- (when (js2-must-match js2-NAME "msg.syntax")
- (if (equal "as" (js2-current-token-string))
- (when (js2-must-match-prop-name "msg.syntax")
- (let ((node (make-js2-namespace-import-node
- :pos beg
- :len (- (js2-current-token-end) beg)
- :name (make-js2-name-node
- :pos (js2-current-token-beg)
- :len (js2-current-token-end)
- :name (js2-current-token-string)))))
- (js2-node-add-children node (js2-namespace-import-node-name
node))
- node))
- (js2-unget-token)
- (js2-report-error "msg.syntax")))))
+ (if (js2-match-contextual-kwd "as")
+ (when (js2-must-match-prop-name "msg.syntax")
+ (let ((node (make-js2-namespace-import-node
+ :pos beg
+ :len (- (js2-current-token-end) beg)
+ :name (make-js2-name-node
+ :pos (js2-current-token-beg)
+ :len (js2-current-token-end)
+ :name (js2-current-token-string)))))
+ (js2-node-add-children node (js2-namespace-import-node-name node))
+ node))
+ (js2-unget-token)
+ (js2-report-error "msg.syntax"))))
(defun js2-parse-from-clause ()
"Parse the from clause in an import or export statement. E.g. from 'src/lib'"
- (when (js2-must-match-name "msg.mod.from.after.import.spec.set")
- (let ((beg (js2-current-token-beg)))
- (if (equal "from" (js2-current-token-string))
- (cond
- ((js2-match-token js2-STRING)
- (make-js2-from-clause-node
- :pos beg
- :len (- (js2-current-token-end) beg)
- :module-id (js2-current-token-string)
- :metadata-p nil))
- ((js2-match-token js2-THIS)
- (when (js2-must-match-name "msg.mod.spec.after.from")
- (if (equal "module" (js2-current-token-string))
- (make-js2-from-clause-node
- :pos beg
- :len (- (js2-current-token-end) beg)
- :module-id "this"
- :metadata-p t)
- (js2-unget-token)
- (js2-unget-token)
- (js2-report-error "msg.mod.spec.after.from")
- nil)))
- (t (js2-report-error "msg.mod.spec.after.from") nil))
- (js2-unget-token)
- (js2-report-error "msg.mod.from.after.import.spec.set")
- nil))))
+ (if (js2-match-contextual-kwd "from")
+ (let ((beg (js2-current-token-beg)))
+ (cond
+ ((js2-match-token js2-STRING)
+ (make-js2-from-clause-node
+ :pos beg
+ :len (- (js2-current-token-end) beg)
+ :module-id (js2-current-token-string)
+ :metadata-p nil))
+ ((js2-match-token js2-THIS)
+ (when (js2-must-match-name "msg.mod.spec.after.from")
+ (if (equal "module" (js2-current-token-string))
+ (make-js2-from-clause-node
+ :pos beg
+ :len (- (js2-current-token-end) beg)
+ :module-id "this"
+ :metadata-p t)
+ (js2-unget-token)
+ (js2-unget-token)
+ (js2-report-error "msg.mod.spec.after.from")
+ nil)))
+ (t (js2-report-error "msg.mod.spec.after.from") nil)))
+ (js2-report-error "msg.mod.from.after.import.spec.set")
+ nil))
(defun js2-parse-export-bindings (&optional import-p)
"Parse a list of export binding expressions such as {}, {foo, bar}, and
@@ -8704,45 +8701,43 @@ consumes no tokens."
(is-reserved-name (or (= (js2-current-token-type) js2-RESERVED)
(aref js2-kwd-tokens (js2-current-token-type)))))
(if extern-name
- (let ((as (and (js2-match-token js2-NAME) (js2-current-token-string))))
- (if (and as (equal "as" (js2-current-token-string)))
- (let ((name
- (or
- (and (js2-match-token js2-DEFAULT) "default")
- (and (js2-match-token js2-NAME)
(js2-current-token-string)))))
- (if name
- (let ((node (make-js2-export-binding-node
- :pos beg
- :len (- (js2-current-token-end) beg)
- :local-name (make-js2-name-node
- :name name
- :pos (js2-current-token-beg)
- :len (js2-current-token-len))
- :extern-name (make-js2-name-node
- :name extern-name
- :pos beg
- :len extern-name-len))))
- (js2-node-add-children
- node
- (js2-export-binding-node-local-name node)
- (js2-export-binding-node-extern-name node))
- node)
- (js2-unget-token)
- nil))
- (when as (js2-unget-token))
- (let* ((name-node (make-js2-name-node
- :name (js2-current-token-string)
- :pos (js2-current-token-beg)
- :len (js2-current-token-len)))
- (node (make-js2-export-binding-node
- :pos (js2-current-token-beg)
- :len (js2-current-token-len)
- :local-name name-node
- :extern-name name-node)))
- (when is-reserved-name
- (js2-report-error "msg.mod.as.after.reserved.word"
extern-name))
- (js2-node-add-children node name-node)
- node)))
+ (if (js2-match-contextual-kwd "as")
+ (let ((name
+ (or
+ (and (js2-match-token js2-DEFAULT) "default")
+ (and (js2-match-token js2-NAME)
(js2-current-token-string)))))
+ (if name
+ (let ((node (make-js2-export-binding-node
+ :pos beg
+ :len (- (js2-current-token-end) beg)
+ :local-name (make-js2-name-node
+ :name name
+ :pos (js2-current-token-beg)
+ :len (js2-current-token-len))
+ :extern-name (make-js2-name-node
+ :name extern-name
+ :pos beg
+ :len extern-name-len))))
+ (js2-node-add-children
+ node
+ (js2-export-binding-node-local-name node)
+ (js2-export-binding-node-extern-name node))
+ node)
+ (js2-unget-token)
+ nil))
+ (let* ((name-node (make-js2-name-node
+ :name (js2-current-token-string)
+ :pos (js2-current-token-beg)
+ :len (js2-current-token-len)))
+ (node (make-js2-export-binding-node
+ :pos (js2-current-token-beg)
+ :len (js2-current-token-len)
+ :local-name name-node
+ :extern-name name-node)))
+ (when is-reserved-name
+ (js2-report-error "msg.mod.as.after.reserved.word" extern-name))
+ (js2-node-add-children node name-node)
+ node))
nil)))
(defun js2-parse-switch ()
@@ -8870,12 +8865,9 @@ invalid export statements."
(when exports-list
(dolist (export exports-list)
(push export children)))
- (when (js2-match-token js2-NAME)
- (if (equal "from" (js2-current-token-string))
- (progn
- (js2-unget-token)
- (setq from-clause (js2-parse-from-clause)))
- (js2-unget-token))))
+ (when (js2-match-contextual-kwd "from")
+ (js2-unget-token)
+ (setq from-clause (js2-parse-from-clause))))
((js2-match-token js2-DEFAULT)
(setq default (cond ((js2-match-token js2-CLASS)
(js2-parse-class-stmt))
- [elpa] master 849e061 081/110: js2-indent-operator-re, js2-declaration-keyword-re: Use symbols boundaries, (continued)
- [elpa] master 849e061 081/110: js2-indent-operator-re, js2-declaration-keyword-re: Use symbols boundaries, Dmitry Gutov, 2016/06/22
- [elpa] master b2af331 083/110: Special-case unary + and -, Dmitry Gutov, 2016/06/22
- [elpa] master 7e7b6da 076/110: Simplify await parsing, Dmitry Gutov, 2016/06/22
- [elpa] master b57d129 077/110: Merge pull request #304 from jacksonrayhamilton/fix-void-async-await, Dmitry Gutov, 2016/06/22
- [elpa] master 645d129 078/110: Add support for JSDoc @callback, @func and @method tags, Dmitry Gutov, 2016/06/22
- [elpa] master b576cef 097/110: Declare vars created with renaming destructuring, Dmitry Gutov, 2016/06/22
- [elpa] master 12586e5 098/110: Allow space before global declaration, Dmitry Gutov, 2016/06/22
- [elpa] master 910520e 100/110: Merge pull request #333 from daniellandau/master, Dmitry Gutov, 2016/06/22
- [elpa] master 5ebc7b8 099/110: Change warning message to not conflict with spec, Dmitry Gutov, 2016/06/22
- [elpa] master ae3ed93 102/110: Backport for fix for #335, Dmitry Gutov, 2016/06/22
- [elpa] master fa419df 093/110: Merge pull request #327 from XeCycle/ckw-as,
Dmitry Gutov <=
- [elpa] master b78d224 045/110: Parse async methods, Dmitry Gutov, 2016/06/22
- [elpa] master 5f00a97 059/110: Use SVG for Travis CI badge, Dmitry Gutov, 2016/06/22
- [elpa] master 4fc6ef8 064/110: js2-class-node: Inherit from js2-object-node, Dmitry Gutov, 2016/06/22
- [elpa] master ae922a3 067/110: Remove js2-make-await as unused, Dmitry Gutov, 2016/06/22
- [elpa] master 502c14a 003/110: Use = instead of eq; Refs #185, Dmitry Gutov, 2016/06/22
- [elpa] master 73c0348 062/110: Merge pull request #297 from Christoph-D/master, Dmitry Gutov, 2016/06/22
- [elpa] master 49954ea 084/110: Use idle timer to reparse, even when the buffer's just been opened, Dmitry Gutov, 2016/06/22
- [elpa] master 1e1e410 082/110: Merge pull request #289 from dgreensp/fix-array-rest, Dmitry Gutov, 2016/06/22
- [elpa] master 16c42ce 087/110: Run all tests on 'make test', Dmitry Gutov, 2016/06/22
- [elpa] master e265b69 090/110: Fix a byte compilation warning on Emacs 25, Dmitry Gutov, 2016/06/22