[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode eea3ccf 170/495: move some coverage code into own
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode eea3ccf 170/495: move some coverage code into own functions |
Date: |
Sat, 7 Aug 2021 09:05:06 -0400 (EDT) |
branch: elpa/go-mode
commit eea3ccf652c878819210bab817dcfea83a43bb71
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
move some coverage code into own functions
---
go-mode.el | 63 +++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 27 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index b5ebc6f..ac1beae 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1022,6 +1022,39 @@ current coverage buffer or by prompting for it."
go--coverage-origin-buffer
(current-buffer)))
+(defun go--coverage-make-overlay (range divisor)
+ "Create a coverage overlay for a range of coverd/uncovered code."
+ (let* ((count (go--covered-count range))
+ (norm (cond
+ ((= count 0)
+ -0.1)
+ ((= max-count 1)
+ 0.8)
+ (t
+ (/ (log count) divisor))))
+ (n (1+ (floor (* norm 9))))
+ (face (concat "go-coverage-" (number-to-string n)))
+ (ov (make-overlay
+ (go--line-column-to-point
+ (go--covered-start-line range)
+ (go--covered-start-column range))
+ (go--line-column-to-point
+ (go--covered-end-line range)
+ (go--covered-end-column range)))))
+
+ (overlay-put ov 'face face)
+ (overlay-put ov 'help-echo (format "Count: %d" count))))
+
+(defun go--coverage-clear-overlays ()
+ "Remove existing overlays and put a single untracked overlay
+over the entire buffer."
+ (remove-overlays)
+ (overlay-put
+ (make-overlay
+ (point-min)
+ (point-max))
+ 'face 'go-coverage-untracked))
+
(defun go-coverage (&optional coverage-file)
"Open a clone of the current buffer and overlay it with
coverage information gathered via go test -coverprofile=COVERAGE-FILE.
@@ -1076,34 +1109,10 @@ for."
(set (make-local-variable 'go--coverage-current-file-name) coverage-file)
(save-excursion
- (remove-overlays)
- (overlay-put
- (make-overlay
- (point-min)
- (point-max))
- 'face 'go-coverage-untracked)
-
+ (go--coverage-clear-overlays)
(dolist (range ranges)
- (let* ((count (go--covered-count range))
- (norm (cond
- ((= count 0)
- -0.1)
- ((= max-count 1)
- 0.8)
- (t
- (/ (log count) divisor))))
- (n (1+ (floor (* norm 9))))
- (face (concat "go-coverage-" (number-to-string n)))
- (ov (make-overlay
- (go--line-column-to-point
- (go--covered-start-line range)
- (go--covered-start-column range))
- (go--line-column-to-point
- (go--covered-end-line range)
- (go--covered-end-column range)))))
-
- (overlay-put ov 'face face)
- (overlay-put ov 'help-echo (format "Count: %d" count)))))
+ (go--coverage-make-overlay range divisor)))
+
(if (not (eq cur-buffer (current-buffer)))
(display-buffer (current-buffer) 'display-buffer-reuse-window)))))
- [nongnu] elpa/go-mode b97cfea 133/495: godef-jump: use push-mark., (continued)
- [nongnu] elpa/go-mode b97cfea 133/495: godef-jump: use push-mark., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a18b3f3 134/495: style change, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 55295da 128/495: formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 50412f7 136/495: add gitignore, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ec73086 157/495: remove unused code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5fd1c63 156/495: document go-goto-opening-parenthesis, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f4d2977 158/495: add go-coverage to display coverage information, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a5d5039 161/495: use go--goto-line where applicable, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7ef7e56 163/495: correct docstrings of go-coverage-covered and go-coverage-uncovered, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 042f08c 169/495: if go-coverage is called in a coverage buffer, update it by using stored variables, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode eea3ccf 170/495: move some coverage code into own functions,
ELPA Syncer <=
- [nongnu] elpa/go-mode fdb2132 179/495: no free variables, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9617f0c 176/495: move actual parsing of coverage file into own function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1949b57 184/495: match unused imports where path and package name differ, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ff30ae1 190/495: use (function) for function symbols, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 50fb3b2 192/495: allow users to customize the gofmt command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 49c885d 188/495: (foo)(bar) is not a function call when there's a letter directly preceding it, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 83c4e32 185/495: fix typo, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b4cbae5 193/495: minor cleanups, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4a96be2 186/495: handle empty "import ()" in go-goto-imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4055561 191/495: Don't break on emacsen that don't have declare-function macro, ELPA Syncer, 2021/08/07