branch: elpa/typescript-mode
commit f2761fb313037ebf23a1dd0f2a3a273be5fc644c
Author: Jostein Kjønigsen <[email protected]>
Commit: Jostein Kjønigsen <[email protected]>
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
;;