[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b035bd0 006/110: Extract contextual keyword highlighting p
From: |
Dmitry Gutov |
Subject: |
[elpa] master b035bd0 006/110: Extract contextual keyword highlighting process from a predicate function |
Date: |
Thu, 23 Jun 2016 01:12:52 +0000 (UTC) |
branch: master
commit b035bd06cba3e2c27353e27136130920e083901d
Author: Masafumi Oyamada (mooz) <address@hidden>
Commit: Masafumi Oyamada (mooz) <address@hidden>
Extract contextual keyword highlighting process from a predicate function
---
js2-mode.el | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 0a40fff..fd55d98 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -7568,29 +7568,42 @@ string is NAME. Returns nil and keeps current token
otherwise."
(if (js2-contextual-kwd-p (progn (js2-get-token)
(js2-current-token))
name)
- t
+ (progn (js2-record-face 'font-lock-keyword-face) t)
(js2-unget-token)
nil))
-(defun js2-contextual-kwd-p (token name &optional no-record-face)
+(defun js2-contextual-kwd-p (token name)
"Return t if TOKEN is `js2-NAME', and its string is NAME."
(and (= (js2-token-type token) js2-NAME)
- (string= (js2-token-string token) name)
- (prog1 t (or no-record-face
- (js2-record-face 'font-lock-keyword-face)))))
+ (string= (js2-token-string token) name)))
(defun js2-match-async-function ()
(when (and (js2-contextual-kwd-p (js2-current-token) "async")
(= (js2-peek-token) js2-FUNCTION))
+ (js2-record-face 'font-lock-keyword-face)
(js2-get-token)
t))
(defun js2-match-async-arrow-function ()
(when (and (js2-contextual-kwd-p (js2-current-token) "async")
(/= (js2-peek-token) js2-FUNCTION))
+ (js2-record-face 'font-lock-keyword-face)
(js2-get-token)
t))
+(defun js2-match-await ()
+ (when (and (= tt js2-NAME)
+ (js2-contextual-kwd-p (js2-current-token) "await"))
+ (js2-record-face 'font-lock-keyword-face)
+ (let ((beg (js2-current-token-beg))
+ (end (js2-current-token-end)))
+ (js2-get-token)
+ (unless (and (js2-inside-function)
+ (js2-function-node-async js2-current-script-or-fn))
+ (js2-report-error "msg.bad.await" nil
+ beg (- end beg))))
+ t))
+
(defun js2-get-prop-name-token ()
(js2-get-token (and (>= js2-language-version 170) 'KEYWORD_IS_NAME)))
@@ -9619,15 +9632,7 @@ to parse the operand (for prefix operators)."
((= tt js2-DELPROP)
(js2-get-token)
(js2-make-unary js2-DELPROP 'js2-parse-unary-expr))
- ((and (= tt js2-NAME)
- (js2-contextual-kwd-p (js2-current-token) "await"))
- (setq beg (js2-current-token-beg)
- end (js2-current-token-end))
- (js2-get-token)
- (unless (and (js2-inside-function)
- (js2-function-node-async js2-current-script-or-fn))
- (js2-report-error "msg.bad.await" nil
- beg (- end beg)))
+ ((js2-match-await)
(js2-make-await))
((= tt js2-ERROR)
(js2-get-token)
- [elpa] master updated (7a2deff -> 04f3d4b), Dmitry Gutov, 2016/06/22
- [elpa] master f85abdd 005/110: Fix docstring to conform to the Elisp guideline, Dmitry Gutov, 2016/06/22
- [elpa] master b035bd0 006/110: Extract contextual keyword highlighting process from a predicate function,
Dmitry Gutov <=
- [elpa] master cef7731 016/110: Handle open-curlies after newline, Dmitry Gutov, 2016/06/22
- [elpa] master 84379dd 004/110: Treat async/await as contextual keywords; Refs #185, Dmitry Gutov, 2016/06/22
- [elpa] master a2be944 014/110: Add a test for the latest change, Dmitry Gutov, 2016/06/22
- [elpa] master 34245fe 008/110: Don't treat getter / setter pairs as duplicates, Dmitry Gutov, 2016/06/22
- [elpa] master fb3f5b6 010/110: Fix 'make all' on older emacsen, Dmitry Gutov, 2016/06/22
- [elpa] master 37867af 020/110: Add NEWS entry about rename to method-node, Dmitry Gutov, 2016/06/22
- [elpa] master b904d10 023/110: Merge pull request #279 from XeCycle/class-semicolon-elem, Dmitry Gutov, 2016/06/22
- [elpa] master 8abf087 025/110: Report error for binding initializer outside destructuring, Dmitry Gutov, 2016/06/22
- [elpa] master 4c0408b 032/110: Add NEWS entry for js2-jsx-mode, Dmitry Gutov, 2016/06/22
- [elpa] master bfb83dd 017/110: Refactor: unify computed property name handling, Dmitry Gutov, 2016/06/22