[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 0f41709e15 074/222: Fontify @type properly
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 0f41709e15 074/222: Fontify @type properly and allow jsdoc one-liners. |
Date: |
Sun, 6 Feb 2022 16:59:19 -0500 (EST) |
branch: elpa/typescript-mode
commit 0f41709e1525403767bd4889cb913900c68448dd
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Fontify @type properly and allow jsdoc one-liners.
@type was improperly classified as a tag that takes a value rather
than a type.
Moreover, the regexes for jsdoc fontification did not allow one-liners
like /** @... */. This is fixed.
---
typescript-mode-tests.el | 20 ++++++++++++++++++++
typescript-mode.el | 23 +++++++++++++++++------
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index 9a4725afc5..9c57a9a098 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -236,6 +236,26 @@ fontified as documentation."
(should (eq (text-property-not-all loc (point-max) 'face
font-lock-string-face)
(1- (point-max)))))))
+(ert-deftest font-lock/immediate-doc ()
+ "Tests that it is not necessary to have the documentation tag on a
+new line after the start of '/**'."
+ (font-lock-test
+ ;; We have 4 comments here because we need to cover the multiple
+ ;; regexes that deal with the different types of jsdoc tags.
+ "/** @type {foo} */\n
+/** @alias bar */\n
+/** @author me */\n
+/** @param meow */"
+ '((1 . font-lock-comment-delimiter-face)
+ ("@type" . typescript-jsdoc-tag)
+ ("{foo}" . typescript-jsdoc-type)
+ ("@alias" . typescript-jsdoc-tag)
+ ("bar" . typescript-jsdoc-value)
+ ("@author" . typescript-jsdoc-tag)
+ ("me" . font-lock-comment-face)
+ ("@param" . typescript-jsdoc-tag)
+ ("meow" . typescript-jsdoc-value))))
+
(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 ed49358fe8..a2150a7a4c 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -414,6 +414,9 @@ Match group 1 is the name of the macro.")
:paren-depth most-negative-fixnum
:type 'toplevel))
+;; When we say "jsdoc" here, we mean "jsdoc 3". There exist multiple dialects
of
+;; "jsdoc documentation".
+
;; Note that all typedoc/jsdoc regexp by themselves would match occurrences
that appear outside
;; documentation comments. The logic that uses these regexps must guard
against it.
(defconst typescript-typedoc-link-tag-regexp
@@ -424,9 +427,14 @@ Match group 1 is the name of the macro.")
"\\(`+\\).*?\\1"
"Matches a typedoc keyword markup.")
+(defconst typescript-jsdoc-before-tag-regexp
+ "\\(?:^\\s-*\\*+\\|/\\*\\*\\)\\s-*"
+ "Matches everything we allow before the @ of a jsdoc tag.")
+
;; This was taken from js2-mode.
(defconst typescript-jsdoc-param-tag-regexp
- (concat "\\(?:^\\s-*\\*+\\|/\\*\\*\\)\\s-*\\(@"
+ (concat typescript-jsdoc-before-tag-regexp
+ "\\(@"
"\\(?:param\\|arg\\(?:ument\\)?\\|prop\\(?:erty\\)?\\)"
"\\)"
"\\s-*\\({[^}]+}\\)?" ; optional type
@@ -436,7 +444,8 @@ Match group 1 is the name of the macro.")
;; This was taken from js2-mode.
(defconst typescript-jsdoc-typed-tag-regexp
- (concat "^\\s-*\\*+\\s-*\\(@\\(?:"
+ (concat typescript-jsdoc-before-tag-regexp
+ "\\(@\\(?:"
(regexp-opt
'("enum"
"extends"
@@ -449,13 +458,15 @@ Match group 1 is the name of the macro.")
"return"
"returns"
"throw"
- "throws"))
+ "throws"
+ "type"))
"\\)\\)\\s-*\\({[^}]+}\\)?")
"Matches jsdoc tags with optional type.")
;; This was taken from js2-mode.
(defconst typescript-jsdoc-arg-tag-regexp
- (concat "^\\s-*\\*+\\s-*\\(@\\(?:"
+ (concat typescript-jsdoc-before-tag-regexp
+ "\\(@\\(?:"
(regexp-opt
'("alias"
"augments"
@@ -480,14 +491,14 @@ Match group 1 is the name of the macro.")
"suppress"
"this"
"throws"
- "type"
"version"))
"\\)\\)\\s-+\\([^ \t]+\\)")
"Matches jsdoc tags with a single argument.")
;; This was taken from js2-mode.
(defconst typescript-jsdoc-empty-tag-regexp
- (concat "^\\s-*\\*+\\s-*\\(@\\(?:"
+ (concat typescript-jsdoc-before-tag-regexp
+ "\\(@\\(?:"
(regexp-opt
'("addon"
"author"
- [nongnu] elpa/typescript-mode e38492f1cd 179/222: Extend Type-name to support namespace-prefixes., (continued)
- [nongnu] elpa/typescript-mode e38492f1cd 179/222: Extend Type-name to support namespace-prefixes., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7040961735 166/222: Highlight type-names in type-casts too., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode de1a696c3c 174/222: Ignore errors from backward-list, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a7cd7a92a5 167/222: fix(font-lock): prefer fontifying constants over keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1767de1095 180/222: Merge pull request #129 from emacs-typescript/feature/types-in-declarations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 0d5c941c4c 195/222: * typescript-mode.el: Use EOS instead of EOL for auto mode regexp., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7d80174b23 216/222: Skip past ? and ! in typescript--compute-member-expression-indent, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 6918f3f6d7 212/222: Merge pull request #154 from emacs-typescript/feature/build-tasks, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 13e6da6c57 219/222: Merge pull request #157 from rsimoes/patch-1, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a6e0eac105 029/222: Fix wrong cursor position in `typescript-indent-line`, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 0f41709e15 074/222: Fontify @type properly and allow jsdoc one-liners.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 90d9758cfb 035/222: Revert "Fix wrong cursor position in `typescript-indent-line`", ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1cea84486f 064/222: Merge pull request #35 from lddubeau/feature/indent-return-annotations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 9ad892fb22 061/222: Add keyword 'object', ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e3d2fee6de 004/222: unnecessary for single package file, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7e8b9641ae 096/222: Mark typescript indent variables as safe for file local customizations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 813cf4fef3 069/222: Fix endless loop (hang) in indentation-code., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode cebfe5952b 114/222: Rename the regexp matching pretty error messages., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5d5c611e2d 119/222: Add tags in js2-mode, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e608305ade 137/222: checkdoc fixes, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 85504ce34b 138/222: Update build-badge URL., ELPA Syncer, 2022/02/06