[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d82f357 199/271: Merge branch 'feature/name-nodes' into de
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master d82f357 199/271: Merge branch 'feature/name-nodes' into develop |
Date: |
Thu, 05 Feb 2015 18:31:11 +0000 |
branch: master
commit d82f357968c13f98afaef37593ed8dbec7b3cc2f
Merge: eba74ae 1f06301
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Merge branch 'feature/name-nodes' into develop
---
context-coloring.el | 20 ++++++-----------
test/context-coloring-test.el | 43 ++++++++++++++++++++++++++++++++++++-
test/fixtures/key-names.js | 6 +++++
test/fixtures/property-lookup.js | 5 ++++
4 files changed, 59 insertions(+), 15 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index ea62a28..283bddd 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -227,6 +227,7 @@ END (exclusive) with the face corresponding to LEVEL."
;;; js2-mode colorization
+;; TODO: Consider `js2-node-top-level-decl-p' as an optimization.
(defsubst context-coloring-js2-scope-level (scope)
"Gets the level of SCOPE."
(let ((level 0)
@@ -243,23 +244,16 @@ END (exclusive) with the face corresponding to LEVEL."
(setq scope enclosing-scope))
level))
-;; Adapted from js2-refactor.el/js2r-vars.el.
-;; FIXME: This fails if there is whitespace between the name and the colon.
(defsubst context-coloring-js2-local-name-node-p (node)
"Determines if NODE is a js2-name-node representing a local
variable."
(and (js2-name-node-p node)
- (let ((start (js2-node-abs-pos node)))
- (and
- (let ((end (+ start (js2-node-len node))))
- (not (string-match "[\n\t ]*:" (buffer-substring-no-properties
- end
- (+ end 1)))))
- (not (string-match "\\.[\n\t ]*" (buffer-substring-no-properties
- (max 1 (- start 1)) ; 0 throws an
- ; error. ""
will
- ; fail the
test.
- start)))))))
+ (let ((parent (js2-node-parent node)))
+ (not (or (js2-object-prop-node-p parent)
+ (and (js2-prop-get-node-p parent)
+ ;; For nested property lookup, the node on the left is a
+ ;; `js2-prop-get-node', so this always works.
+ (eq node (js2-prop-get-node-right parent))))))))
(defsubst context-coloring-js2-colorize-node (node level)
"Colors NODE with the color for LEVEL."
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 88b556e..3fa7953 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -94,8 +94,8 @@ invoke when it is done."
(match-beginning 1)
(match-end 1))))
(= level actual-level)))))
- (ert-fail (format "Expected level at point %s to be %s; was %s"
- point level actual-level))))
+ (ert-fail (format "Expected level in region [%s, %s), which is
\"%s\", to be %s; but at point %s, it was %s"
+ start end (buffer-substring-no-properties start
end) level point actual-level))))
(setq i (+ i 1)))))
(defun context-coloring-test-assert-message (expected)
@@ -196,4 +196,43 @@ invoke when it is done."
"./fixtures/catch.js"
(context-coloring-test-js-catch)))
+(defun context-coloring-test-js-key-names ()
+ (context-coloring-test-assert-region-level 20 63 1))
+
+(ert-deftest-async context-coloring-test-js-mode-key-names (done)
+ (context-coloring-test-js-mode
+ "./fixtures/key-names.js"
+ (lambda (teardown)
+ (unwind-protect
+ (context-coloring-test-js-key-names)
+ (funcall teardown))
+ (funcall done))))
+
+(ert-deftest context-coloring-test-js2-mode-key-names ()
+ (context-coloring-test-js2-mode
+ "./fixtures/key-names.js"
+ (context-coloring-test-js-key-names)))
+
+(defun context-coloring-test-js-property-lookup ()
+ (context-coloring-test-assert-region-level 20 26 0)
+ (context-coloring-test-assert-region-level 26 38 1)
+ (context-coloring-test-assert-region-level 38 44 0)
+ (context-coloring-test-assert-region-level 44 52 1)
+ (context-coloring-test-assert-region-level 57 63 0)
+ (context-coloring-test-assert-region-level 63 74 1))
+
+(ert-deftest-async context-coloring-test-js-mode-property-lookup (done)
+ (context-coloring-test-js-mode
+ "./fixtures/property-lookup.js"
+ (lambda (teardown)
+ (unwind-protect
+ (context-coloring-test-js-property-lookup)
+ (funcall teardown))
+ (funcall done))))
+
+(ert-deftest context-coloring-test-js2-mode-property-lookup ()
+ (context-coloring-test-js2-mode
+ "./fixtures/property-lookup.js"
+ (context-coloring-test-js-property-lookup)))
+
(provide 'context-coloring-test)
diff --git a/test/fixtures/key-names.js b/test/fixtures/key-names.js
new file mode 100644
index 0000000..d8ad17c
--- /dev/null
+++ b/test/fixtures/key-names.js
@@ -0,0 +1,6 @@
+(function () {
+ return {
+ a: 0,
+ b : 2
+ };
+}());
diff --git a/test/fixtures/property-lookup.js b/test/fixtures/property-lookup.js
new file mode 100644
index 0000000..4edcb41
--- /dev/null
+++ b/test/fixtures/property-lookup.js
@@ -0,0 +1,5 @@
+(function () {
+ window.foo();
+ window. bar();
+ window.foo.bar();
+}());
- [elpa] master 221b583 156/271: Update hooking strategy., (continued)
- [elpa] master 221b583 156/271: Update hooking strategy., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e2ee311 183/271: Fix timer existence check., Jackson Ray Hamilton, 2015/02/05
- [elpa] master a2ba1ef 213/271: Version 2.0.1., Jackson Ray Hamilton, 2015/02/05
- [elpa] master bef41e1 205/271: Merge branch 'feature/optimize-js2-mode' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master a14be3c 270/271: Merge commit 'fedf88552990afa269366dfa4c3f5af6d1cdb7c2' from context-coloring, Jackson Ray Hamilton, 2015/02/05
- [elpa] master 32fa415 226/271: Use `font-lock' for comments and strings., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 450aa85 236/271: Use macros to clean up tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 555820b 247/271: Merge branch 'master' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master 43bb3c1 261/271: Remove unnecessary file from .elpaignore., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 195fbe7 196/271: Improve assertion message., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d82f357 199/271: Merge branch 'feature/name-nodes' into develop,
Jackson Ray Hamilton <=
- [elpa] master 310aca4 228/271: Use `save-excursion' before fontifying., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 5cc5224 249/271: Update sentence spacing., Jackson Ray Hamilton, 2015/02/05
- [elpa] master de8eacd 204/271: Update benchmarks in readme., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f15c193 189/271: Escape., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 31ee972 197/271: Improve property lookup test., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 3d034f9 262/271: Merge branch 'develop', Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6d24750 206/271: Update docs., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6059dca 179/271: Add Travis CI., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f2ace00 224/271: Add faces dynamically. Stop looping around at the last level., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d44b426 208/271: Merge branch 'master' into develop, Jackson Ray Hamilton, 2015/02/05