[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a104d62 21/38: [feat] add support for single-line jsdoc hi
From: |
Dmitry Gutov |
Subject: |
[elpa] master a104d62 21/38: [feat] add support for single-line jsdoc highlighting |
Date: |
Wed, 28 Feb 2018 20:12:11 -0500 (EST) |
branch: master
commit a104d62e52d58f6d1afc6c36a416a377dd67f210
Author: felipe <address@hidden>
Commit: felipe <address@hidden>
[feat] add support for single-line jsdoc highlighting
---
js2-mode.el | 6 ++++--
tests/jsdoc.el | 40 ++++++++++++++++++++++++++++++++++++----
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index cdcf9e1..5b8f502 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -7051,8 +7051,10 @@ of a simple name. Called before EXPR has a parent node."
(save-excursion
(dolist (node comments)
(when (eq (js2-comment-node-format node) 'jsdoc)
- (setq beg (js2-node-abs-pos node)
- end (+ beg (js2-node-len node)))
+ ;; Slice off the leading /* and trailing */ in case there
+ ;; are tags on the first line
+ (setq beg (+ 2 (js2-node-abs-pos node))
+ end (+ beg -4 (js2-node-len node)))
(save-restriction
(narrow-to-region beg end)
(dolist (re (list js2-jsdoc-param-tag-regexp
diff --git a/tests/jsdoc.el b/tests/jsdoc.el
index cf499ed..5b5af6e 100644
--- a/tests/jsdoc.el
+++ b/tests/jsdoc.el
@@ -49,7 +49,7 @@ BEG and END are the current buffer boundaries to use."
,fontification))))))
(js2-jsdoc-deftest param
- "/**\n * @prop {string} p - The property\n */"
+ "/**\n * @prop {string} p - The property\n */\n"
'((1 8 font-lock-doc-face)
(8 13 js2-jsdoc-tag)
(13 15 font-lock-doc-face)
@@ -59,7 +59,7 @@ BEG and END are the current buffer boundaries to use."
(24 43 font-lock-doc-face)))
(js2-jsdoc-deftest typed
- "/**\n * @implements {Interface}\n */"
+ "/**\n * @implements {Interface}\n */\n"
'((1 8 font-lock-doc-face)
(8 19 js2-jsdoc-tag)
(19 21 font-lock-doc-face)
@@ -67,7 +67,7 @@ BEG and END are the current buffer boundaries to use."
(30 35 font-lock-doc-face)))
(js2-jsdoc-deftest arg
- "/**\n * @name TheName \n */"
+ "/**\n * @name TheName \n */\n"
'((1 8 font-lock-doc-face)
(8 13 js2-jsdoc-tag)
(13 14 font-lock-doc-face)
@@ -75,7 +75,39 @@ BEG and END are the current buffer boundaries to use."
(21 26 font-lock-doc-face)))
(js2-jsdoc-deftest empty
- "/**\n * @class \n */"
+ "/**\n * @class \n */\n"
'((1 8 font-lock-doc-face)
(8 14 js2-jsdoc-tag)
(14 19 font-lock-doc-face)))
+
+(js2-jsdoc-deftest param-same-line
+ "/** @prop {string} p - The property */\n"
+ '((1 5 font-lock-doc-face)
+ (5 10 js2-jsdoc-tag)
+ (10 12 font-lock-doc-face)
+ (12 18 js2-jsdoc-type)
+ (18 20 font-lock-doc-face)
+ (20 21 js2-jsdoc-value)
+ (21 39 font-lock-doc-face)))
+
+(js2-jsdoc-deftest typed-same-line
+ "/** @implements {Interface} */\n"
+ '((1 5 font-lock-doc-face)
+ (5 16 js2-jsdoc-tag)
+ (16 18 font-lock-doc-face)
+ (18 27 js2-jsdoc-type)
+ (27 31 font-lock-doc-face)))
+
+(js2-jsdoc-deftest arg-same-line
+ "/** @name TheName */\n"
+ '((1 5 font-lock-doc-face)
+ (5 10 js2-jsdoc-tag)
+ (10 11 font-lock-doc-face)
+ (11 18 js2-jsdoc-value)
+ (18 21 font-lock-doc-face)))
+
+(js2-jsdoc-deftest empty-same-line
+ "/** @class */\n"
+ '((1 5 font-lock-doc-face)
+ (5 11 js2-jsdoc-tag)
+ (11 14 font-lock-doc-face)))
- [elpa] master a27c9cb 17/38: Fix length of shorthand object property nodes (e.g. `{foo, bar}`), (continued)
- [elpa] master a27c9cb 17/38: Fix length of shorthand object property nodes (e.g. `{foo, bar}`), Dmitry Gutov, 2018/02/28
- [elpa] master 29d295a 31/38: Merge pull request #476 from lelit/avoid-dynbind, Dmitry Gutov, 2018/02/28
- [elpa] master a495394 34/38: Do not overwrite POS, Dmitry Gutov, 2018/02/28
- [elpa] master 4e032e6 24/38: Merge pull request #467 from felipeochoa/jsdoc-single-line, Dmitry Gutov, 2018/02/28
- [elpa] master 33c7169 32/38: Port over fix for https://debbugs.gnu.org/23391, Dmitry Gutov, 2018/02/28
- [elpa] master 38e4257 37/38: Release new version, Dmitry Gutov, 2018/02/28
- [elpa] master 8488723 29/38: Merge pull request #466 from mishoo/master, Dmitry Gutov, 2018/02/28
- [elpa] master dfaa145 12/38: Add separate object property access face., Dmitry Gutov, 2018/02/28
- [elpa] master 700c024 23/38: Merge pull request #468 from felipeochoa/jsdoc-type, Dmitry Gutov, 2018/02/28
- [elpa] master 5a99c23 20/38: Add tests for jsdoc highlighting, Dmitry Gutov, 2018/02/28
- [elpa] master a104d62 21/38: [feat] add support for single-line jsdoc highlighting,
Dmitry Gutov <=
- [elpa] master 40885b6 36/38: Clarify where to report indentation bugs [ci skip], Dmitry Gutov, 2018/02/28
- [elpa] master a015ec7 33/38: Switch to lexical binding, Dmitry Gutov, 2018/02/28
- [elpa] master d72ed20 35/38: Fix the breakage, Dmitry Gutov, 2018/02/28
- [elpa] master 8d846b0 14/38: Set the correct node pos for unary nodes, Dmitry Gutov, 2018/02/28
- [elpa] master 9088d60 18/38: Drop (constructor nil) on structs where a constructor is defined, Dmitry Gutov, 2018/02/28
- [elpa] master a6c39c2 38/38: Merge commit '38e425785d5ea4600c3642f6500062ecedf694a4' from js2-mode, Dmitry Gutov, 2018/02/28