[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/js2-mode dd7abb2884: Recognize static initialization bl
From: |
ELPA Syncer |
Subject: |
[elpa] externals/js2-mode dd7abb2884: Recognize static initialization blocks |
Date: |
Tue, 9 May 2023 18:58:30 -0400 (EDT) |
branch: externals/js2-mode
commit dd7abb28844f745f7520db87695b7aa579cbe683
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Recognize static initialization blocks
Closes #594
---
NEWS.md | 5 +++++
js2-mode.el | 6 +++++-
tests/parser.el | 3 +++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index f237758d68..92cd99732f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,10 @@
# History of user-visible changes
+## Next
+
+* Support for static initialization blocks
+ ([#594](https://github.com/mooz/js2-mode/issues/594)).
+
## 2023-04-08
* Support top-level await
diff --git a/js2-mode.el b/js2-mode.el
index e8f34cd78e..11ebb37340 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -2339,7 +2339,7 @@ If any given node in NODES is nil, doesn't record that
link."
top) ; top-level `js2-scope' (script/function)
(js2--struct-put 'js2-scope 'js2-visitor 'js2-visit-block)
-(js2--struct-put 'js2-scope 'js2-printer 'js2-print-none)
+(js2--struct-put 'js2-scope 'js2-printer 'js2-print-block)
(defun js2-node-get-enclosing-scope (node)
"Return the innermost `js2-scope' node surrounding NODE.
@@ -11146,6 +11146,10 @@ expression)."
((and class-p
(= tt js2-SEMI))
nil)
+ ((and class-p
+ (eq tt js2-LC))
+ (setq after-comma nil
+ elem (js2-parse-block)))
(t
(js2-report-error "msg.bad.prop")
(unless js2-recover-from-parse-errors
diff --git a/tests/parser.el b/tests/parser.el
index 8c2c7d04dd..32c33e55d7 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -1058,6 +1058,9 @@ the test."
(js2-deftest-parse parse-class-static-fields-no-semi
"class C {\n static a\n static b = 42\n}")
+(js2-deftest-parse parse-class-static-block
+ "class Foo {\n static {\n a = 4;\n}\n}")
+
;;; Private names
(js2-deftest-parse parse-class-private-field-with-init
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/js2-mode dd7abb2884: Recognize static initialization blocks,
ELPA Syncer <=