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

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

[nongnu] elpa/typescript-mode f2761fb313 178/222: Extract type-name rege


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode f2761fb313 178/222: Extract type-name regexp into reusable constant.
Date: Sun, 6 Feb 2022 16:59:30 -0500 (EST)

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

    Extract type-name regexp into reusable constant.
---
 typescript-mode.el | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/typescript-mode.el b/typescript-mode.el
index 2943650868..a911f7f169 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -63,6 +63,9 @@
 
 ;;; Constants
 
+(defconst typescript--type-name-re "[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_$]"
   "Regexp matching the start of a typescript identifier, without grouping.")
 
@@ -2006,12 +2009,15 @@ This performs fontification according to 
`typescript--class-styles'."
     ;; - private generic: SomeType<Foo>
     ;; - private genericArray: SomeType<Foo>[]
     ;; - function testFunc(): SomeType<> {
-    
(":\\s-\\([A-Z][A-Za-z0-9]+\\)\\(<[A-Z][A-Za-z0-9]+>\\)?\\(\[\]\\)?\\([,;]\\)?\\s-*{?"
-     (1 'font-lock-type-face))
+    ;; TODO: namespaced classes!
+    ,(list
+      (concat ":\\s-\\(" typescript--type-name-re "\\)\\(<" 
typescript--type-name-re ">\\)?\\(\[\]\\)?\\([,;]\\)?\\s-*{?")
+      '(1 'font-lock-type-face))
 
     ;; type-casts
-    ("<\\([A-Z][A-Za-z0-9]+\\)>"
-     (1 'font-lock-type-face))
+    ,(list
+      (concat "<\\(" typescript--type-name-re "\\)>")
+      '(1 'font-lock-type-face))
 
     ;; highlights that append to previous levels
     ;;



reply via email to

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