emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/typescript-mode e38492f1cd 179/222: Extend Type-name to su


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode e38492f1cd 179/222: Extend Type-name to support namespace-prefixes.
Date: Sun, 6 Feb 2022 16:59:30 -0500 (EST)

branch: elpa/typescript-mode
commit e38492f1cd4559bc7ba06b4d844e7efe6bcf5354
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Extend Type-name to support namespace-prefixes.
---
 typescript-mode-general-tests.el | 26 ++++++++++++++++++++++++++
 typescript-mode.el               |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 7fdb1bcc8d..6e3f098aa7 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -512,6 +512,32 @@ function foo<Z, Y, Z & Y, Z | Y | Z, Y<X<X, Y>>>()\n"
     (should (eq (get-face-at "SomeType") 'font-lock-type-face))
     (should (eq (get-face-at "Foo") 'font-lock-type-face))))
 
+(ert-deftest font-lock/type-names-level4-namespaces ()
+  "Namespaced Typenames should be highlighted in declarations"
+  (test-with-fontified-buffer
+      "private b: Namespaced.ClassName;"
+    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
+    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))
+  (test-with-fontified-buffer
+      "function test(var1: Namespaced.ClassName): RetType {\n}"
+    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
+    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "class Foo { test(var1: Namespaced.ClassName): RetType {\n}"
+    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
+    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "function test(var1: Type): Namespaced.ClassName {\n}"
+    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
+    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "class Foo { test(var1: Type): Namespaced.ClassName {\n}"
+    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
+    (should (eq (get-face-at "ClassName") 'font-lock-type-face))))
+
 (defun flyspell-predicate-test (search-for)
   "This function runs a test on
 `typescript--flyspell-mode-predicate'.  `SEARCH-FOR' is a string
diff --git a/typescript-mode.el b/typescript-mode.el
index a911f7f169..53f12c02c3 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -63,7 +63,7 @@
 
 ;;; Constants
 
-(defconst typescript--type-name-re "[A-Z][A-Za-z0-9]+"
+(defconst typescript--type-name-re 
"\\(?:[A-Z][A-Za-z0-9]+\\.\\)\\{0,\\}\\(?:[A-Z][A-Za-z0-9]+\\)"
   "Regexp matching a conventional TypeScript type-name.  Must start with 
upper-case letter!")
 
 (defconst typescript--name-start-re "[a-zA-Z_$]"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]