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

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

[nongnu] elpa/dart-mode eea1000 093/192: Highlight hover dartdoc


From: ELPA Syncer
Subject: [nongnu] elpa/dart-mode eea1000 093/192: Highlight hover dartdoc
Date: Sun, 29 Aug 2021 11:01:57 -0400 (EDT)

branch: elpa/dart-mode
commit eea1000bc414bd95e0004fb9d6124857bdef2e38
Author: Natalie Weizenbaum <nex342@gmail.com>
Commit: Natalie Weizenbaum <nex342@gmail.com>

    Highlight hover dartdoc
---
 dart-mode.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/dart-mode.el b/dart-mode.el
index 0e4e70f..6de744e 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -1026,7 +1026,7 @@ reported to CALLBACK."
                  (when dartdoc) (insert ?\n))
                (when dartdoc
                  (when (or element-description parameter) (insert ?\n))
-                 (insert dartdoc))
+                 (insert (dart--highlight-dartdoc dartdoc)))
                (message "%s" (buffer-string))))))))))
 
 (defconst dart--highlight-keyword-re
@@ -1088,6 +1088,22 @@ reported to CALLBACK."
      (and (looking-at (concat "\\(" dart--identifier-re "\\|[<>]\\)*"))
           (eq (char-after (match-end 0)) ?\()))))
 
+(defun dart--highlight-dartdoc (dartdoc)
+  "Returns a higlighted copy of DARTDOC."
+  (with-temp-buffer
+    (insert dartdoc)
+
+    ;; Cut off long dartdocs so that the full signature is always visible.
+    (goto-line 11)
+    (delete-region (- (point) 1) (point-max))
+
+    (goto-char (point-min))
+
+    (while (re-search-forward "\\[.*?\\]" nil t)
+      (put-text-property (match-beginning 0) (match-end 0)
+                         'face 'font-lock-reference-face))
+
+    (buffer-string)))
 
 ;;; Formatting
 



reply via email to

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