[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode f8c37b9 260/346: Implement parsing module names in
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode f8c37b9 260/346: Implement parsing module names in import and module declarations |
Date: |
Sun, 29 Aug 2021 11:00:42 -0400 (EDT) |
branch: elpa/d-mode
commit f8c37b938a507498f0d05245fddc5bbe29e14e7d
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Implement parsing module names in import and module declarations
Fully fixes issue #54.
---
d-mode.el | 43 ++++++++++++++++++++++++++++++++++++++++++-
tests/I0054.d | 6 ++++--
tests/I0054.d.html | 14 ++++++++------
3 files changed, 54 insertions(+), 9 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index e5d6932..b3d503d 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -7,7 +7,7 @@
;; Maintainer: Russel Winder <russel@winder.org.uk>
;; Vladimir Panteleev <vladimir@thecybershadow.net>
;; Created: March 2007
-;; Version: 201909120240
+;; Version: 201909120344
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -467,6 +467,17 @@ Each list item should be a regexp matching a single
identifier."
:type '(repeat regexp)
:group 'd-mode)
+(c-lang-defconst c-basic-matchers-after
+ d (append
+ ;; D module and import statements
+ (list (c-make-font-lock-BO-decl-search-function
+ (c-make-keywords-re t (c-lang-const c-ref-list-kwds))
+ '((c-fontify-types-and-refs ()
+ (d-forward-module-clause)
+ (if (> (point) limit) (goto-char limit))))))
+ ;; cc-mode defaults
+ (c-lang-const c-basic-matchers-after)))
+
(defconst d-font-lock-keywords-1 (c-lang-const c-matchers-1 d)
"Minimal highlighting for D mode.")
@@ -1593,6 +1604,36 @@ Key bindings:
(advice-add 'c-update-brace-stack :around #'d-around--c-update-brace-stack)
;;----------------------------------------------------------------------------
+;; Support for fontifying module name(s) after a module or import keyword.
+
+(defun d-forward-module-clause ()
+ "Fontify the module name(s) after a module or import keyword."
+ (let (safe-pos pos)
+ (goto-char (match-end 1))
+ (while
+ (progn
+ (c-forward-syntactic-ws)
+ (setq safe-pos (point))
+ (cond
+ ((looking-at c-identifier-start)
+ ;; identifier
+ (setq c-last-identifier-range nil)
+ (forward-char)
+ (when (c-end-of-current-token)
+ (when c-record-type-identifiers
+ (c-record-ref-id (cons safe-pos (point))))
+ t))
+ ;; . or , or = (keep fontifying)
+ ((memq (char-after) '(?. ?, ?=))
+ (forward-char)
+ t)
+ ;; ; or : or anything else weird
+ (t
+ nil))))
+ (goto-char safe-pos)
+ t))
+
+;;----------------------------------------------------------------------------
;;
;; Support for "Adjusting Alignment Rules for UCFS-Chains in D",
;; cf.
https://stackoverflow.com/questions/25797945/adjusting-alignment-rules-for-ucfs-chains-in-d
diff --git a/tests/I0054.d b/tests/I0054.d
index f146247..acca87a 100644
--- a/tests/I0054.d
+++ b/tests/I0054.d
@@ -4,8 +4,6 @@ module aaa;
import bbb;
-// FIXME:
-
module aaa.bbb.ccc;
import aaa.bbb;
@@ -14,3 +12,7 @@ import aaa.bbb.ccc;
import Aaa.Bbb.ccc;
import Aaa.Bbb.Ccc;
import aaa.bbb.Ccc;
+
+import ddd = aaa.bbb.ccc, vvv = xxx.yyy.zzz;
+import aaa.bbb.ccc : x, y, z;
+import aaa.bbb.ccc : i = x, j = y, k = z;
diff --git a/tests/I0054.d.html b/tests/I0054.d.html
index 33b7df8..22dd3e2 100644
--- a/tests/I0054.d.html
+++ b/tests/I0054.d.html
@@ -4,13 +4,15 @@
<span class="keyword">import</span> <span class="constant">bbb</span>;
-<span class="comment-delimiter">// </span><span class="comment">FIXME:
-</span>
-<span class="keyword">module</span> aaa.bbb.<span class="constant">ccc</span>;
+<span class="keyword">module</span> <span class="constant">aaa</span>.<span
class="constant">bbb</span>.<span class="constant">ccc</span>;
-<span class="keyword">import</span> aaa.<span class="constant">bbb</span>;
+<span class="keyword">import</span> <span class="constant">aaa</span>.<span
class="constant">bbb</span>;
<span class="keyword">import</span> <span class="constant">aaa</span>.<span
class="constant">Bbb</span>;
-<span class="keyword">import</span> aaa.bbb.<span class="constant">ccc</span>;
-<span class="keyword">import</span> <span
class="constant">Aaa</span>.Bbb.<span class="constant">ccc</span>;
+<span class="keyword">import</span> <span class="constant">aaa</span>.<span
class="constant">bbb</span>.<span class="constant">ccc</span>;
+<span class="keyword">import</span> <span class="constant">Aaa</span>.<span
class="constant">Bbb</span>.<span class="constant">ccc</span>;
<span class="keyword">import</span> <span class="constant">Aaa</span>.<span
class="constant">Bbb</span>.<span class="constant">Ccc</span>;
<span class="keyword">import</span> <span class="constant">aaa</span>.<span
class="constant">bbb</span>.<span class="constant">Ccc</span>;
+
+<span class="keyword">import</span> <span class="constant">ddd</span> = <span
class="constant">aaa</span>.<span class="constant">bbb</span>.<span
class="constant">ccc</span>, <span class="constant">vvv</span> = <span
class="constant">xxx</span>.<span class="constant">yyy</span>.<span
class="constant">zzz</span>;
+<span class="keyword">import</span> <span class="constant">aaa</span>.<span
class="constant">bbb</span>.<span class="constant">ccc</span> : x, y, z;
+<span class="keyword">import</span> <span class="constant">aaa</span>.<span
class="constant">bbb</span>.<span class="constant">ccc</span> : i = x, j = y, k
= z;
- [nongnu] elpa/d-mode 9ad04a1 213/346: Fix parsing/fontification of some expressions with periods, (continued)
- [nongnu] elpa/d-mode 9ad04a1 213/346: Fix parsing/fontification of some expressions with periods, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5146f2d 215/346: Clear some cc-mode constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3f669a1 231/346: Replace regex-based imenu implementation with cc-mode-based, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode db2c33f 225/346: Fix parsing of D lambda literals' parameter lists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1598b12 248/346: Switch to GPL v3 (or later), ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 24fffad 242/346: Fix parsing of declarations after "static else", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a8aad35 241/346: Fix imenu false positive with "static if", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 6a19457 244/346: Fix function calls being mis-parsed as declarations after static else, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3077252 238/346: Correctness fix in d-forward-type, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1e5c7c3 227/346: Fix parsing of declarations following protection group, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f8c37b9 260/346: Implement parsing module names in import and module declarations,
ELPA Syncer <=
- [nongnu] elpa/d-mode 3c7db4a 255/346: Fix imenu context with multiple nesting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3ed3b7b 257/346: Simplify imenu testing code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f1d37dd 263/346: Fix byte-compiled version, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 060d1f3 249/346: Fix parsing of version(...) and other non-scope blocks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2529eb2 259/346: Add a TODO, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8d30f6b 246/346: Add back the old imenu implementation for Emacs 25, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 7d39bdf 269/346: Add missing "package" keyword to c-modifier-kwds, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode ed4428c 272/346: Fix fontification of "invariant", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 300708d 268/346: Fix imenu for template members, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 685a8cc 271/346: Expand "is" rule for other infix keyword variants and negation, ELPA Syncer, 2021/08/29