[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> {}
}
- [nongnu] elpa/d-mode 51b1af1 203/346: Fix K&R region detection and body-less function declarations, (continued)
- [nongnu] elpa/d-mode 51b1af1 203/346: Fix K&R region detection and body-less function declarations, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b5fb492 204/346: Fix fontification of manifest (enum) constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e52434e 218/346: d-mode-test.el: Save actual result to file in case of mismatch, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 609816b 219/346: tests: Move d-forward-type tests to new test file, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 4d9f9ce 211/346: Drop support for Emacs 24, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f2b4aec 205/346: Fix fontification of "a in b" expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f69e94e 207/346: Change test suite enumeration and activation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b0a59de 214/346: Fix mis-parsing of concatenating two variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 445c696 210/346: Implement a more complete description for D type syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode ed0de34 222/346: Refactor "this" (constructor) handling, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode aaa704a 216/346: Fix coverage issues in d-forward-type,
ELPA Syncer <=
- [nongnu] elpa/d-mode 572d707 221/346: Improve comprehension of constness and storage classes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 64afe5f 206/346: .travis.yml: Test against more Emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 02733b0 223/346: Remove some redundant progns, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c9febb3 299/346: d-mode-test: Always ignore .res files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2d4bc7d 318/346: Update comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 46a57f4 310/346: Fontify the special words inside version/debug/extern/pragma/__traits/scope, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 805eeba 078/346: Add links to build and coverage status to README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8076559 081/346: Replace obsolete defadvice by the new advice-add., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode ee38763 083/346: Use the new advising mechanism on new emacs versions., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5c06e99 087/346: add d-exceptions compilation error regexp, ELPA Syncer, 2021/08/29