[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode a09e9c78f9 108/222: Highlight class names.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode a09e9c78f9 108/222: Highlight class names. |
Date: |
Sun, 6 Feb 2022 16:59:22 -0500 (EST) |
branch: elpa/typescript-mode
commit a09e9c78f947fc85b243a2743da60b86a1082867
Author: Wilfred Hughes <Wilfred.Hughes@man.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Highlight class names.
---
typescript-mode-tests.el | 22 ++++++++++++++++++++++
typescript-mode.el | 19 +++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index d82956a7eb..656553944d 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -398,6 +398,28 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3):
ret3;"
"=/foo\\\\/g something // comment"
(should (eq (get-face-at "g something") nil))))
+(ert-deftest font-lock/type-names ()
+ "Type names should be highlighted in definitions."
+ ;; Typical case.
+ (test-with-fontified-buffer
+ "export class Foo extends Bar implements Qux {}"
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))
+ (should (eq (get-face-at "Qux") 'font-lock-type-face)))
+ ;; Ensure we require symbol boundaries.
+ (test-with-fontified-buffer
+ "Notclass Foo"
+ (should (not (eq (get-face-at "Foo") 'font-lock-type-face))))
+ ;; Other common ways of defining types.
+ (test-with-fontified-buffer
+ "interface Thing {}"
+ (should (eq (get-face-at "Thing") 'font-lock-type-face)))
+ (test-with-fontified-buffer
+ "enum Thing {}"
+ (should (eq (get-face-at "Thing") 'font-lock-type-face)))
+ (test-with-fontified-buffer
+ "type Thing = number;"
+ (should (eq (get-face-at "Thing") 'font-lock-type-face))))
(defun flyspell-predicate-test (search-for)
"This function runs a test on
diff --git a/typescript-mode.el b/typescript-mode.el
index 380301324d..3d6022dce2 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -55,6 +55,7 @@
(require 'compile)
(require 'cc-mode)
(require 'font-lock)
+ (require 'rx)
(require 'newcomment))
(eval-when-compile
@@ -1777,6 +1778,24 @@ and searches for the next token to be highlighted."
("\\.\\(prototype\\)\\_>"
(1 font-lock-constant-face))
+ (,(rx symbol-start "class" (+ space) (group (+ (or (syntax word) (syntax
symbol)))))
+ (1 font-lock-type-face))
+
+ (,(rx symbol-start "extends" (+ space) (group (+ (or (syntax word) (syntax
symbol)))))
+ (1 font-lock-type-face))
+
+ (,(rx symbol-start "implements" (+ space) (group (+ (or (syntax word)
(syntax symbol)))))
+ (1 font-lock-type-face))
+
+ (,(rx symbol-start "interface" (+ space) (group (+ (or (syntax word)
(syntax symbol)))))
+ (1 font-lock-type-face))
+
+ (,(rx symbol-start "type" (+ space) (group (+ (or (syntax word) (syntax
symbol)))))
+ (1 font-lock-type-face))
+
+ (,(rx symbol-start "enum" (+ space) (group (+ (or (syntax word) (syntax
symbol)))))
+ (1 font-lock-type-face))
+
;; Highlights class being declared, in parts
(typescript--class-decl-matcher
,(concat "\\(" typescript--name-re "\\)\\(?:\\.\\|.*$\\)")
- [nongnu] elpa/typescript-mode c5e7788ce9 044/222: Merge pull request #28 from ananthakumaran/testing, (continued)
- [nongnu] elpa/typescript-mode c5e7788ce9 044/222: Merge pull request #28 from ananthakumaran/testing, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 99c2b74ac3 059/222: Make current-column function internal., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 89d22c4e18 051/222: Don't interpret forward slash in list as operator., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 393ac6db0f 081/222: add tests for regexp font locking, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 361564c4a9 057/222: typescript-current-column: Dont cause side-effects., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d155a4b623 063/222: Revert indent of complex parameters., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e0b4a6cb31 055/222: Merge pull request #36 from lddubeau/feature/improved-tslint-regex, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bce2e73cf2 107/222: Remove unused dependencies, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7172a23d86 072/222: Add a custom predicate for flyspell-prog-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d8501770f6 103/222: Fix indentation of multiple curly braces in sequence., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a09e9c78f9 108/222: Highlight class names.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 7c6fd0f4a8 115/222: Document how to handle ANSI codes in error messages., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 9796425fdb 113/222: Add support for new type "unknown"., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 39b7ba9e54 117/222: Distinguish type arguments from lesser/greater than. (Fixes #81), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 30f8b8feb4 122/222: Merge pull request #87 from Ailrun/add-jsdoc-tags, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 29282a32b7 124/222: add never type, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8910e12525 129/222: Add autoload cookie with safe-local-var for typescript-indent-level, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode fbaad515c9 132/222: Merge pull request #89 from Ailrun/update-jsdoc-tests, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 32146510b8 147/222: Pin our dist to Trusty., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 706f938aef 155/222: force generic regex to include symbol before it (#119), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e38492f1cd 179/222: Extend Type-name to support namespace-prefixes., ELPA Syncer, 2022/02/06