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

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

[nongnu] elpa/d-mode aaa704a 216/346: Fix coverage issues in d-forward-t


From: ELPA Syncer
Subject: [nongnu] elpa/d-mode aaa704a 216/346: Fix coverage issues in d-forward-type
Date: Sun, 29 Aug 2021 11:00:34 -0400 (EDT)

branch: elpa/d-mode
commit aaa704a9d392db339fb48175490a55004333fb6f
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>

    Fix coverage issues in d-forward-type
    
    Remove code not useful for d-mode and add tests to increase coverage.
---
 d-mode.el          | 112 ++++-------------------------------------------------
 tests/fonts.d      |   4 ++
 tests/fonts.d.html |   4 ++
 3 files changed, 15 insertions(+), 105 deletions(-)

diff --git a/d-mode.el b/d-mode.el
index b93040f..f42fa5b 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:  201909082054
+;; Version:  201909082055
 ;; Keywords:  D programming language emacs cc-mode
 ;; Package-Requires: ((emacs "25.1"))
 
@@ -1222,34 +1222,11 @@ Key bindings:
                 (or c-promote-possible-types (eq res t)))
        (c-record-type-id (cons (match-beginning 1) (match-end 1))))
 
-      (if (and c-opt-type-component-key
-              (save-match-data
-                (looking-at c-opt-type-component-key)))
-         ;; There might be more keywords for the type.
-         (let (safe-pos)
-           (c-forward-keyword-clause 1)
-           (while (progn
-                    (setq safe-pos (point))
-                    (looking-at c-opt-type-component-key))
-             (when (and c-record-type-identifiers
-                        (looking-at c-primitive-type-key))
-               (c-record-type-id (cons (match-beginning 1)
-                                       (match-end 1))))
-             (c-forward-keyword-clause 1))
-           (if (looking-at c-primitive-type-key)
-               (progn
-                 (when c-record-type-identifiers
-                   (c-record-type-id (cons (match-beginning 1)
-                                           (match-end 1))))
-                 (c-forward-keyword-clause 1)
-                 (setq res t))
-             (goto-char safe-pos)
-             (setq res 'prefix)))
-       (unless (save-match-data (c-forward-keyword-clause 1))
-         (if pos
-             (goto-char pos)
-           (goto-char (match-end 1))
-           (c-forward-syntactic-ws)))))
+      (unless (save-match-data (c-forward-keyword-clause 1))
+        (if pos
+            (goto-char pos)
+          (goto-char (match-end 1))
+          (c-forward-syntactic-ws))))
 
      (name-res
       (cond ((eq name-res t)
@@ -1268,35 +1245,14 @@ Key bindings:
                             'found
                           ;; It's an identifier that might be a type.
                           'maybe))))
-           ((eq name-res 'template)
-            ;; A template is sometimes a type.
-            (goto-char id-end)
-            (c-forward-syntactic-ws)
-            (setq res
-                  (if (eq (char-after) ?\()
-                      (if (c-check-type id-start id-end)
-                          ;; It's an identifier that has been used as
-                          ;; a type somewhere else.
-                          'found
-                        ;; It's an identifier that might be a type.
-                        'maybe)
-                    t)))
            (t
             ;; Otherwise it's an operator identifier, which is not a type.
             (goto-char start)
             (setq res nil)))))
 
     (when res
-      ;; Skip trailing type modifiers.  If any are found we know it's
-      ;; a type.
-      (when c-opt-type-modifier-key
-       (while (looking-at c-opt-type-modifier-key) ; e.g. "const", "volatile"
-         (goto-char (match-end 1))
-         (c-forward-syntactic-ws)
-         (setq res t)))
-
       ;; D: Skip over template parameters, if any
-      (when (looking-at "!")
+      (when (looking-at "!")            ; TODO: maybe use 
c-opt-type-concat-key instead
        (forward-char)
        (c-forward-syntactic-ws)
        (c-forward-sexp)
@@ -1311,60 +1267,6 @@ Key bindings:
          (goto-char (match-end 1))
          (c-forward-syntactic-ws)))
 
-      (when c-opt-type-concat-key      ; Only/mainly for pike.
-       ;; Look for a trailing operator that concatenates the type
-       ;; with a following one, and if so step past that one through
-       ;; a recursive call.  Note that we don't record concatenated
-       ;; types in `c-found-types' - it's the component types that
-       ;; are recorded when appropriate.
-       (setq pos (point))
-       (let* ((c-promote-possible-types (or (memq res '(t known))
-                                            c-promote-possible-types))
-              ;; If we can't promote then set `c-record-found-types' so that
-              ;; we can merge in the types from the second part afterwards if
-              ;; it turns out to be a known type there.
-              (c-record-found-types (and c-record-type-identifiers
-                                         (not c-promote-possible-types)))
-              subres)
-         (if (and (looking-at c-opt-type-concat-key)
-
-                  (progn
-                    (goto-char (match-end 1))
-                    (c-forward-syntactic-ws)
-                    (setq subres (c-forward-type))))
-
-             (progn
-               ;; If either operand certainly is a type then both are, but we
-               ;; don't let the existence of the operator itself promote two
-               ;; uncertain types to a certain one.
-               (cond ((eq res t))
-                     ((eq subres t)
-                      (unless (eq name-res 'template)
-                        (c-add-type id-start id-end))
-                      (when (and c-record-type-identifiers id-range)
-                        (c-record-type-id id-range))
-                      (setq res t))
-                     ((eq res 'known))
-                     ((eq subres 'known)
-                      (setq res 'known))
-                     ((eq res 'found))
-                     ((eq subres 'found)
-                      (setq res 'found))
-                     (t
-                      (setq res 'maybe)))
-
-               (when (and (eq res t)
-                          (consp c-record-found-types))
-                 ;; Merge in the ranges of any types found by the second
-                 ;; `c-forward-type'.
-                 (setq c-record-type-identifiers
-                       ;; `nconc' doesn't mind that the tail of
-                       ;; `c-record-found-types' is t.
-                       (nconc c-record-found-types
-                              c-record-type-identifiers))))
-
-           (goto-char pos))))
-
       (when (and c-record-found-types (memq res '(known found)) id-range)
        (setq c-record-found-types
              (cons id-range c-record-found-types))))
diff --git a/tests/fonts.d b/tests/fonts.d
index a9b6ee8..2495554 100644
--- a/tests/fonts.d
+++ b/tests/fonts.d
@@ -10,4 +10,8 @@ void main()
        aa[s].length;
 
        run(a ~ b);
+
+       assert(to!string(d) == to!string(double.max));
+
+       private void resetFile(string name, scope const(char)[] stdioOpenmode, 
bool isPopened) @trusted {}
 }
diff --git a/tests/fonts.d.html b/tests/fonts.d.html
index 27a9b4d..1d45b19 100644
--- a/tests/fonts.d.html
+++ b/tests/fonts.d.html
@@ -10,4 +10,8 @@
        aa[s].length;
 
        run(a ~ b);
+
+       <span class="keyword">assert</span>(to<span 
class="negation-char">!</span><span class="type">string</span>(d) == to<span 
class="negation-char">!</span><span class="type">string</span>(<span 
class="type">double</span>.max));
+
+       <span class="keyword">private</span> <span class="type">void</span> 
<span class="function-name">resetFile</span>(<span class="type">string</span> 
<span class="variable-name">name</span>, <span class="keyword">scope 
const</span>(<span class="type">char</span>)[] <span 
class="variable-name">stdioOpenmode</span>, <span class="type">bool</span> 
<span class="variable-name">isPopened</span>) <span 
class="c-annotation-face">@trusted</span> {}
 }



reply via email to

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